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
93f718b3
Commit
93f718b3
authored
Dec 20, 2019
by
Dan Field
Committed by
Flutter GitHub Bot
Dec 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix requestExistingInputState response (#47472)
parent
cc1c9649
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
26 deletions
+25
-26
text_input.dart
packages/flutter/lib/src/services/text_input.dart
+6
-5
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+3
-0
text_input_test.dart
packages/flutter/test/services/text_input_test.dart
+16
-21
No files found.
packages/flutter/lib/src/services/text_input.dart
View file @
93f718b3
...
...
@@ -753,6 +753,9 @@ abstract class TextInputClient {
/// Updates the floating cursor position and state.
void
updateFloatingCursor
(
RawFloatingCursorPoint
point
);
/// The current state of the [TextEditingValue] held by this client.
TextEditingValue
get
currentTextEditingValue
;
/// Platform notified framework of closed connection.
///
/// [TextInputClient] should cleanup its connection and finalize editing.
...
...
@@ -1036,7 +1039,6 @@ class TextInput {
TextInputConnection
_currentConnection
;
TextInputConfiguration
_currentConfiguration
;
TextEditingValue
_currentTextEditingValue
;
Future
<
dynamic
>
_handleTextInputInvocation
(
MethodCall
methodCall
)
async
{
if
(
_currentConnection
==
null
)
...
...
@@ -1048,9 +1050,9 @@ class TextInput {
if
(
method
==
'TextInputClient.requestExistingInputState'
)
{
assert
(
_currentConnection
.
_client
!=
null
);
_attach
(
_currentConnection
,
_currentConfiguration
);
// This will be null if we've never had a call to [_setEditingState].
if
(
_currentTextE
ditingValue
!=
null
)
{
_setEditingState
(
_currentTextE
ditingValue
);
final
TextEditingValue
editingValue
=
_currentConnection
.
_client
.
currentTextEditingValue
;
if
(
e
ditingValue
!=
null
)
{
_setEditingState
(
e
ditingValue
);
}
return
;
}
...
...
@@ -1110,7 +1112,6 @@ class TextInput {
'TextInput.setEditingState'
,
value
.
toJSON
(),
);
_currentTextEditingValue
=
value
;
}
void
_show
()
{
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
93f718b3
...
...
@@ -1202,6 +1202,9 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
TextEditingValue
_lastKnownRemoteTextEditingValue
;
@override
TextEditingValue
get
currentTextEditingValue
=>
_value
;
@override
void
updateEditingValue
(
TextEditingValue
value
)
{
// Since we still have to support keyboard select, this is the best place
...
...
packages/flutter/test/services/text_input_test.dart
View file @
93f718b3
...
...
@@ -13,12 +13,10 @@ void main() {
group
(
'TextInput message channels'
,
()
{
FakeTextChannel
fakeTextChannel
;
FakeTextInputClient
client
;
setUp
(()
{
fakeTextChannel
=
FakeTextChannel
((
MethodCall
call
)
async
{});
TextInput
.
setChannel
(
fakeTextChannel
);
client
=
FakeTextInputClient
();
});
tearDown
(()
{
...
...
@@ -27,6 +25,7 @@ void main() {
});
test
(
'text input client handler responds to reattach with setClient'
,
()
async
{
final
FakeTextInputClient
client
=
FakeTextInputClient
(
const
TextEditingValue
(
text:
'test1'
));
TextInput
.
attach
(
client
,
client
.
configuration
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
...
...
@@ -34,39 +33,31 @@ void main() {
fakeTextChannel
.
incoming
(
const
MethodCall
(
'TextInputClient.requestExistingInputState'
,
null
));
expect
(
fakeTextChannel
.
outgoingCalls
.
length
,
2
);
expect
(
fakeTextChannel
.
outgoingCalls
.
length
,
3
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
// From original attach
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
// From requestExistingInputState
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
MethodCall
(
'TextInput.setEditingState'
,
client
.
currentTextEditingValue
.
toJSON
()),
]);
});
test
(
'text input client handler responds to reattach with setClient and text state'
,
()
async
{
final
TextInputConnection
connection
=
TextInput
.
attach
(
client
,
client
.
configuration
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
]);
const
TextEditingValue
editingState
=
TextEditingValue
(
text:
'foo'
);
connection
.
setEditingState
(
editingState
);
test
(
'text input client handler responds to reattach with setClient (null TextEditingValue)'
,
()
async
{
final
FakeTextInputClient
client
=
FakeTextInputClient
(
null
);
TextInput
.
attach
(
client
,
client
.
configuration
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
MethodCall
(
'TextInput.setEditingState'
,
editingState
.
toJSON
()),
]);
fakeTextChannel
.
incoming
(
const
MethodCall
(
'TextInputClient.requestExistingInputState'
,
null
));
expect
(
fakeTextChannel
.
outgoingCalls
.
length
,
4
);
expect
(
fakeTextChannel
.
outgoingCalls
.
length
,
2
);
fakeTextChannel
.
validateOutgoingMethodCalls
(<
MethodCall
>[
// attach
//
From original
attach
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
// set editing state 1
MethodCall
(
'TextInput.setEditingState'
,
editingState
.
toJSON
()),
// both from requestExistingInputState
// From requestExistingInputState
MethodCall
(
'TextInput.setClient'
,
<
dynamic
>[
1
,
client
.
configuration
.
toJson
()]),
MethodCall
(
'TextInput.setEditingState'
,
editingState
.
toJSON
()),
]);
});
});
...
...
@@ -153,7 +144,7 @@ void main() {
test
(
'TextInputClient onConnectionClosed method is called'
,
()
async
{
// Assemble a TextInputConnection so we can verify its change in state.
final
FakeTextInputClient
client
=
FakeTextInputClient
();
final
FakeTextInputClient
client
=
FakeTextInputClient
(
const
TextEditingValue
(
text:
'test3'
)
);
const
TextInputConfiguration
configuration
=
TextInputConfiguration
();
TextInput
.
attach
(
client
,
configuration
);
...
...
@@ -176,8 +167,13 @@ void main() {
}
class
FakeTextInputClient
implements
TextInputClient
{
FakeTextInputClient
(
this
.
currentTextEditingValue
);
String
latestMethodCall
=
''
;
@override
TextEditingValue
currentTextEditingValue
;
@override
void
performAction
(
TextInputAction
action
)
{
latestMethodCall
=
'performAction'
;
...
...
@@ -231,7 +227,6 @@ class FakeTextChannel implements MethodChannel {
@override
String
get
name
=>
'flutter/textinput'
;
@override
void
setMethodCallHandler
(
Future
<
void
>
Function
(
MethodCall
call
)
handler
)
{
incoming
=
handler
;
...
...
@@ -252,7 +247,7 @@ class FakeTextChannel implements MethodChannel {
if
(
outgoingString
!=
expectedString
)
{
print
(
'Index
$i
did not match:
\n
'
' actual:
${outgoingCalls[i]}
'
' actual:
${outgoingCalls[i]}
\n
'
' expected:
${calls[i]}
'
);
hasError
=
true
;
}
...
...
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