Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
49825559
Unverified
Commit
49825559
authored
Oct 13, 2020
by
xubaolin
Committed by
GitHub
Oct 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more unit test cases for EditableText widget (#66889)
parent
37ebe3d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+83
-0
No files found.
packages/flutter/test/widgets/editable_text_test.dart
View file @
49825559
...
...
@@ -5076,6 +5076,89 @@ void main() {
)));
});
testWidgets
(
'Repeatedly receiving [TextEditingValue] will not trigger a keyboard request'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/66036
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
SystemChannels
.
textInput
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
log
.
add
(
methodCall
);
});
final
TextEditingController
controller
=
TextEditingController
();
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Focus Node'
);
Widget
builder
()
{
return
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setter
)
{
return
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
Material
(
child:
EditableText
(
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
red
,
keyboardType:
TextInputType
.
multiline
,
onChanged:
(
String
value
)
{
},
),
),
),
),
),
);
},
);
}
await
tester
.
pumpWidget
(
builder
());
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
pump
();
// The keyboard is shown after tap the EditableText.
expect
(
focusNode
.
hasFocus
,
true
);
log
.
clear
();
final
EditableTextState
state
=
tester
.
firstState
(
find
.
byType
(
EditableText
));
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
'a'
,
));
await
tester
.
pump
();
// Nothing called when only the remote changes.
expect
(
log
.
length
,
0
);
// Hide the keyboard.
focusNode
.
unfocus
();
await
tester
.
pump
();
expect
(
log
.
length
,
2
);
MethodCall
methodCall
=
log
[
0
];
// Close the InputConnection.
expect
(
methodCall
,
isMethodCall
(
'TextInput.clearClient'
,
arguments:
null
),);
methodCall
=
log
[
1
];
expect
(
methodCall
,
isMethodCall
(
'TextInput.hide'
,
arguments:
null
),);
// The keyboard loses focus.
expect
(
focusNode
.
hasFocus
,
false
);
log
.
clear
();
// Send repeat value from the engine.
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
'a'
,
));
await
tester
.
pump
();
// Nothing called when only the remote changes.
expect
(
log
.
length
,
0
);
// The keyboard is not be requested after a repeat value from the engine.
expect
(
focusNode
.
hasFocus
,
false
);
});
testWidgets
(
'autofocus:true on first frame does not throw'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
controller
.
selection
=
const
TextSelection
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment