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
d51956a9
Unverified
Commit
d51956a9
authored
Dec 19, 2019
by
Lau Ching Jun
Committed by
GitHub
Dec 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Call setEditingState when text changes. (#47177)" (#47397)
This reverts commit
d4b49ce9
.
parent
2df96458
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
73 deletions
+8
-73
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+1
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+1
-1
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+6
-47
test_text_input.dart
packages/flutter_test/lib/src/test_text_input.dart
+0
-13
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+0
-12
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
d51956a9
...
...
@@ -1217,6 +1217,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_obscureLatestCharIndex
=
_value
.
selection
.
baseOffset
;
}
}
_lastKnownRemoteTextEditingValue
=
value
;
_formatAndSetValue
(
value
);
// To keep the cursor from blinking while typing, we want to restart the
...
...
packages/flutter/test/material/text_field_test.dart
View file @
d51956a9
...
...
@@ -2961,7 +2961,7 @@ void main() {
),
),
);
expect
(
tester
.
testTextInput
.
editingState
,
isNull
);
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
isEmpty
);
// Initial state with null controller.
await
tester
.
tap
(
find
.
byType
(
TextField
));
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
d51956a9
...
...
@@ -3928,6 +3928,10 @@ void main() {
});
testWidgets
(
'input imm channel calls are ordered correctly'
,
(
WidgetTester
tester
)
async
{
final
List
<
MethodCall
>
log
=
<
MethodCall
>[];
SystemChannels
.
textInput
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
log
.
add
(
methodCall
);
});
const
String
testText
=
'flutter is the best!'
;
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
final
EditableText
et
=
EditableText
(
...
...
@@ -3952,59 +3956,14 @@ void main() {
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
expect
(
log
.
length
,
7
);
// TextInput.show should be before TextInput.setEditingState
final
List
<
String
>
logOrder
=
<
String
>[
'TextInput.setClient'
,
'TextInput.show'
,
'TextInput.setEditableSizeAndTransform'
,
'TextInput.setStyle'
,
'TextInput.setEditingState'
,
'TextInput.setEditingState'
,
'TextInput.show'
];
expect
(
tester
.
testTextInput
.
log
.
length
,
7
);
int
index
=
0
;
for
(
MethodCall
m
in
tester
.
testTextInput
.
log
)
{
expect
(
m
.
method
,
logOrder
[
index
]);
index
++;
}
});
testWidgets
(
'setEditingState is called when text changes'
,
(
WidgetTester
tester
)
async
{
const
String
testText
=
'flutter is the best!'
;
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
final
EditableText
et
=
EditableText
(
showSelectionHandles:
true
,
maxLines:
2
,
controller:
controller
,
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
(
platform:
TargetPlatform
.
android
).
black
.
subhead
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Align
(
alignment:
Alignment
.
topLeft
,
child:
SizedBox
(
width:
100
,
child:
et
,
),
),
));
await
tester
.
enterText
(
find
.
byType
(
EditableText
),
'...'
);
final
List
<
String
>
logOrder
=
<
String
>[
'TextInput.setClient'
,
'TextInput.show'
,
'TextInput.setEditableSizeAndTransform'
,
'TextInput.setStyle'
,
'TextInput.setEditingState'
,
'TextInput.setEditingState'
,
'TextInput.show'
,
'TextInput.setEditingState'
,
];
expect
(
tester
.
testTextInput
.
log
.
length
,
logOrder
.
length
);
int
index
=
0
;
for
(
MethodCall
m
in
tester
.
testTextInput
.
log
)
{
for
(
MethodCall
m
in
log
)
{
expect
(
m
.
method
,
logOrder
[
index
]);
index
++;
}
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
'...'
);
});
}
...
...
packages/flutter_test/lib/src/test_text_input.dart
View file @
d51956a9
...
...
@@ -39,18 +39,6 @@ class TestTextInput {
/// The messenger which sends the bytes for this channel, not null.
BinaryMessenger
get
_binaryMessenger
=>
ServicesBinding
.
instance
.
defaultBinaryMessenger
;
/// Resets any internal state of this object and calls [register].
///
/// This method is invoked by the testing framework between tests. It should
/// not ordinarily be called by tests directly.
void
resetAndRegister
()
{
log
.
clear
();
editingState
=
null
;
setClientArgs
=
null
;
_client
=
0
;
_isVisible
=
false
;
register
();
}
/// Installs this object as a mock handler for [SystemChannels.textInput].
void
register
()
{
SystemChannels
.
textInput
.
setMockMethodCallHandler
(
_handleTextInputCall
);
...
...
@@ -76,7 +64,6 @@ class TestTextInput {
/// Whether this [TestTextInput] is registered with [SystemChannels.textInput].
///
/// Use [register] and [unregister] methods to control this value.
// TODO(dnfield): This is unreliable. https://github.com/flutter/flutter/issues/47180
bool
get
isRegistered
=>
_isRegistered
;
bool
_isRegistered
=
false
;
...
...
packages/flutter_test/lib/src/widget_tester.dart
View file @
d51956a9
...
...
@@ -121,7 +121,6 @@ void testWidgets(
return
binding
.
runTest
(
()
async
{
debugResetSemanticsIdCounter
();
tester
.
resetTestTextInput
();
await
callback
(
tester
);
semanticsHandle
?.
dispose
();
},
...
...
@@ -693,17 +692,6 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// like [TextField] or [TextFormField], call [enterText].
TestTextInput
get
testTextInput
=>
binding
.
testTextInput
;
/// Ensures that [testTextInput] is registered and [TestTextInput.log] is
/// reset.
///
/// This is called by the testing framework before test runs, so that if a
/// previous test has set its own handler on [SystemChannels.textInput], the
/// [testTextInput] regains control and the log is fresh for the new test.
/// It should not typically need to be called by tests.
void
resetTestTextInput
()
{
testTextInput
.
resetAndRegister
();
}
/// Give the text input widget specified by [finder] the focus, as if the
/// onscreen keyboard had appeared.
///
...
...
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