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
ef119187
Unverified
Commit
ef119187
authored
Oct 13, 2020
by
Greg Spencer
Committed by
GitHub
Oct 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert some widgets tests to NNBD (#67782)
Migrating some more widget tests to NNBD.
parent
085f1daa
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
263 additions
and
295 deletions
+263
-295
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+202
-205
ensure_visible_test.dart
packages/flutter/test/widgets/ensure_visible_test.dart
+0
-2
error_widget_builder_test.dart
packages/flutter/test/widgets/error_widget_builder_test.dart
+0
-2
fade_in_image_test.dart
packages/flutter/test/widgets/fade_in_image_test.dart
+45
-47
fade_transition_test.dart
packages/flutter/test/widgets/fade_transition_test.dart
+2
-4
fitted_box_test.dart
packages/flutter/test/widgets/fitted_box_test.dart
+3
-6
flex_test.dart
packages/flutter/test/widgets/flex_test.dart
+0
-14
flow_test.dart
packages/flutter/test/widgets/flow_test.dart
+7
-9
focus_manager_test.dart
packages/flutter/test/widgets/focus_manager_test.dart
+4
-6
No files found.
packages/flutter/test/widgets/editable_text_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
...
@@ -24,7 +22,7 @@ class _MatchesMethodCall extends Matcher {
...
@@ -24,7 +22,7 @@ class _MatchesMethodCall extends Matcher {
const
_MatchesMethodCall
(
this
.
name
,
{
this
.
arguments
});
const
_MatchesMethodCall
(
this
.
name
,
{
this
.
arguments
});
final
String
name
;
final
String
name
;
final
Matcher
arguments
;
final
Matcher
?
arguments
;
@override
@override
bool
matches
(
dynamic
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
{
bool
matches
(
dynamic
item
,
Map
<
dynamic
,
dynamic
>
matchState
)
{
...
@@ -42,7 +40,7 @@ class _MatchesMethodCall extends Matcher {
...
@@ -42,7 +40,7 @@ class _MatchesMethodCall extends Matcher {
}
}
}
}
TextEditingController
controller
;
late
TextEditingController
controller
;
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Node'
);
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Node'
);
final
FocusScopeNode
focusScopeNode
=
FocusScopeNode
(
debugLabel:
'EditableText Scope Node'
);
final
FocusScopeNode
focusScopeNode
=
FocusScopeNode
(
debugLabel:
'EditableText Scope Node'
);
const
TextStyle
textStyle
=
TextStyle
();
const
TextStyle
textStyle
=
TextStyle
();
...
@@ -62,7 +60,7 @@ class MockClipboard {
...
@@ -62,7 +60,7 @@ class MockClipboard {
case
'Clipboard.getData'
:
case
'Clipboard.getData'
:
return
_clipboardData
;
return
_clipboardData
;
case
'Clipboard.setData'
:
case
'Clipboard.setData'
:
_clipboardData
=
methodCall
.
arguments
;
_clipboardData
=
methodCall
.
arguments
as
Object
;
break
;
break
;
}
}
}
}
...
@@ -83,7 +81,6 @@ void main() {
...
@@ -83,7 +81,6 @@ void main() {
tearDown
(()
{
tearDown
(()
{
controller
.
dispose
();
controller
.
dispose
();
controller
=
null
;
});
});
// Tests that the desired keyboard action button is requested.
// Tests that the desired keyboard action button is requested.
...
@@ -92,9 +89,9 @@ void main() {
...
@@ -92,9 +89,9 @@ void main() {
// requests [serializedActionName] when attaching to the platform's input
// requests [serializedActionName] when attaching to the platform's input
// system.
// system.
Future
<
void
>
_desiredKeyboardActionIsRequested
({
Future
<
void
>
_desiredKeyboardActionIsRequested
({
WidgetTester
tester
,
required
WidgetTester
tester
,
TextInputAction
action
,
TextInputAction
?
action
,
String
serializedActionName
,
String
serializedActionName
=
''
,
})
async
{
})
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MediaQuery
(
MediaQuery
(
...
@@ -121,8 +118,8 @@ void main() {
...
@@ -121,8 +118,8 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
serializedActionName
));
equals
(
serializedActionName
));
}
}
...
@@ -182,10 +179,10 @@ void main() {
...
@@ -182,10 +179,10 @@ void main() {
final
EditableText
editableText
=
final
EditableText
editableText
=
tester
.
firstWidget
(
find
.
byType
(
EditableText
));
tester
.
firstWidget
(
find
.
byType
(
EditableText
));
expect
(
editableText
.
maxLines
,
equals
(
1
));
expect
(
editableText
.
maxLines
,
equals
(
1
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.text'
));
equals
(
'TextInputType.text'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.done'
));
equals
(
'TextInputAction.done'
));
});
});
...
@@ -321,9 +318,9 @@ void main() {
...
@@ -321,9 +318,9 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
// On web, we don't infer the keyboard type as "name". We only infer
// On web, we don't infer the keyboard type as "name". We only infer
// on iOS and macOS.
// on iOS and macOS.
kIsWeb
?
equals
(
'TextInputType.address'
)
:
equals
(
'TextInputType.name'
),
kIsWeb
?
equals
(
'TextInputType.address'
)
:
equals
(
'TextInputType.name'
),
...
@@ -357,8 +354,8 @@ void main() {
...
@@ -357,8 +354,8 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
equals
(
'TextInputType.address'
));
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.address'
));
});
});
testWidgets
(
'inferred keyboard types can be overridden: ios'
,
testWidgets
(
'inferred keyboard types can be overridden: ios'
,
...
@@ -389,8 +386,8 @@ void main() {
...
@@ -389,8 +386,8 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
equals
(
'TextInputType.text'
));
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.text'
));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
testWidgets
(
'inferred keyboard types can be overridden: non-ios'
,
testWidgets
(
'inferred keyboard types can be overridden: non-ios'
,
...
@@ -421,8 +418,8 @@ void main() {
...
@@ -421,8 +418,8 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
equals
(
'TextInputType.text'
));
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.text'
));
});
});
});
});
...
@@ -452,10 +449,10 @@ void main() {
...
@@ -452,10 +449,10 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.multiline'
));
equals
(
'TextInputType.multiline'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.newline'
));
equals
(
'TextInputAction.newline'
));
});
});
...
@@ -485,10 +482,10 @@ void main() {
...
@@ -485,10 +482,10 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.visiblePassword'
));
equals
(
'TextInputType.visiblePassword'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.done'
));
equals
(
'TextInputAction.done'
));
});
});
...
@@ -519,7 +516,7 @@ void main() {
...
@@ -519,7 +516,7 @@ void main() {
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
setClientArgs
[
'enableSuggestions'
],
enableSuggestions
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'enableSuggestions'
],
enableSuggestions
);
});
});
group
(
'smartDashesType and smartQuotesType'
,
()
{
group
(
'smartDashesType and smartQuotesType'
,
()
{
...
@@ -552,8 +549,8 @@ void main() {
...
@@ -552,8 +549,8 @@ void main() {
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
setClientArgs
[
'smartDashesType'
],
smartDashesType
.
index
.
toString
());
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'smartDashesType'
],
smartDashesType
.
index
.
toString
());
expect
(
tester
.
testTextInput
.
setClientArgs
[
'smartQuotesType'
],
smartQuotesType
.
index
.
toString
());
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'smartQuotesType'
],
smartQuotesType
.
index
.
toString
());
});
});
testWidgets
(
'default to true when obscureText is false'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'default to true when obscureText is false'
,
(
WidgetTester
tester
)
async
{
...
@@ -582,8 +579,8 @@ void main() {
...
@@ -582,8 +579,8 @@ void main() {
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
setClientArgs
[
'smartDashesType'
],
'1'
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'smartDashesType'
],
'1'
);
expect
(
tester
.
testTextInput
.
setClientArgs
[
'smartQuotesType'
],
'1'
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'smartQuotesType'
],
'1'
);
});
});
testWidgets
(
'default to false when obscureText is true'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'default to false when obscureText is true'
,
(
WidgetTester
tester
)
async
{
...
@@ -612,8 +609,8 @@ void main() {
...
@@ -612,8 +609,8 @@ void main() {
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
setClientArgs
[
'smartDashesType'
],
'0'
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'smartDashesType'
],
'0'
);
expect
(
tester
.
testTextInput
.
setClientArgs
[
'smartQuotesType'
],
'0'
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'smartQuotesType'
],
'0'
);
});
});
});
});
...
@@ -786,10 +783,10 @@ void main() {
...
@@ -786,10 +783,10 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.multiline'
));
equals
(
'TextInputType.multiline'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.newline'
));
equals
(
'TextInputAction.newline'
));
});
});
...
@@ -820,10 +817,10 @@ void main() {
...
@@ -820,10 +817,10 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.text'
));
equals
(
'TextInputType.text'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.done'
));
equals
(
'TextInputAction.done'
));
});
});
...
@@ -854,10 +851,10 @@ void main() {
...
@@ -854,10 +851,10 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.phone'
));
equals
(
'TextInputType.phone'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.done'
));
equals
(
'TextInputAction.done'
));
});
});
...
@@ -887,10 +884,10 @@ void main() {
...
@@ -887,10 +884,10 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.multiline'
));
equals
(
'TextInputType.multiline'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.newline'
));
equals
(
'TextInputAction.newline'
));
});
});
...
@@ -920,10 +917,10 @@ void main() {
...
@@ -920,10 +917,10 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputType'
][
'name'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputType'
][
'name'
],
equals
(
'TextInputType.text'
));
equals
(
'TextInputType.text'
));
expect
(
tester
.
testTextInput
.
setClientArgs
[
'inputAction'
],
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'inputAction'
],
equals
(
'TextInputAction.done'
));
equals
(
'TextInputAction.done'
));
});
});
...
@@ -956,7 +953,7 @@ void main() {
...
@@ -956,7 +953,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
tester
.
testTextInput
.
log
.
clear
();
tester
.
testTextInput
.
log
.
clear
();
...
@@ -1000,7 +997,7 @@ void main() {
...
@@ -1000,7 +997,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test3'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test3'
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
tester
.
testTextInput
.
log
.
clear
();
tester
.
testTextInput
.
log
.
clear
();
...
@@ -1018,7 +1015,7 @@ void main() {
...
@@ -1018,7 +1015,7 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
showKeyboard
(
find
.
byType
(
EditableText
));
await
tester
.
pump
();
await
tester
.
pump
();
controller
.
text
=
'test2'
;
controller
.
text
=
'test2'
;
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test2'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test2'
));
// Widget regained the focus.
// Widget regained the focus.
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
});
});
...
@@ -1071,7 +1068,7 @@ void main() {
...
@@ -1071,7 +1068,7 @@ void main() {
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byWidget
(
testNameField
));
tester
.
state
<
EditableTextState
>(
find
.
byWidget
(
testNameField
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
...
@@ -1093,7 +1090,7 @@ void main() {
...
@@ -1093,7 +1090,7 @@ void main() {
await
tester
.
showKeyboard
(
find
.
byWidget
(
testPhoneField
));
await
tester
.
showKeyboard
(
find
.
byWidget
(
testPhoneField
));
controller
.
text
=
'650123123'
;
controller
.
text
=
'650123123'
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'650123123'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'650123123'
));
// Widget regained the focus.
// Widget regained the focus.
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
});
});
...
@@ -1364,13 +1361,13 @@ void main() {
...
@@ -1364,13 +1361,13 @@ void main() {
// On the web, a regular connection to the platform should've been made
// On the web, a regular connection to the platform should've been made
// with the `readOnly` flag set to true.
// with the `readOnly` flag set to true.
expect
(
tester
.
testTextInput
.
hasAnyClients
,
isTrue
);
expect
(
tester
.
testTextInput
.
hasAnyClients
,
isTrue
);
expect
(
tester
.
testTextInput
.
setClientArgs
[
'readOnly'
],
isTrue
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'readOnly'
],
isTrue
);
expect
(
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
tester
.
testTextInput
.
editingState
!
[
'text'
],
'Lorem ipsum dolor sit amet'
,
'Lorem ipsum dolor sit amet'
,
);
);
expect
(
tester
.
testTextInput
.
editingState
[
'selectionBase'
],
0
);
expect
(
tester
.
testTextInput
.
editingState
!
[
'selectionBase'
],
0
);
expect
(
tester
.
testTextInput
.
editingState
[
'selectionExtent'
],
5
);
expect
(
tester
.
testTextInput
.
editingState
!
[
'selectionExtent'
],
5
);
}
else
{
}
else
{
// On non-web platforms, a read-only field doesn't need a connection with
// On non-web platforms, a read-only field doesn't need a connection with
// the platform.
// the platform.
...
@@ -1421,7 +1418,7 @@ void main() {
...
@@ -1421,7 +1418,7 @@ void main() {
});
});
testWidgets
(
'Read-only fields do not format text'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Read-only fields do not format text'
,
(
WidgetTester
tester
)
async
{
SelectionChangedCause
selectionCause
;
late
SelectionChangedCause
selectionCause
;
final
TextEditingController
controller
=
final
TextEditingController
controller
=
TextEditingController
(
text:
'Lorem ipsum dolor sit amet'
);
TextEditingController
(
text:
'Lorem ipsum dolor sit amet'
);
...
@@ -1436,8 +1433,8 @@ void main() {
...
@@ -1436,8 +1433,8 @@ void main() {
style:
textStyle
,
style:
textStyle
,
cursorColor:
cursorColor
,
cursorColor:
cursorColor
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
onSelectionChanged:
(
TextSelection
selection
,
SelectionChangedCause
cause
)
{
onSelectionChanged:
(
TextSelection
selection
,
SelectionChangedCause
?
cause
)
{
selectionCause
=
cause
;
selectionCause
=
cause
!
;
},
},
),
),
),
),
...
@@ -1462,7 +1459,7 @@ void main() {
...
@@ -1462,7 +1459,7 @@ void main() {
testWidgets
(
'Sends "updateConfig" when read-only flag is flipped'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Sends "updateConfig" when read-only flag is flipped'
,
(
WidgetTester
tester
)
async
{
bool
readOnly
=
true
;
bool
readOnly
=
true
;
StateSetter
setState
;
late
StateSetter
setState
;
final
TextEditingController
controller
=
TextEditingController
(
text:
'Lorem ipsum dolor sit amet'
);
final
TextEditingController
controller
=
TextEditingController
(
text:
'Lorem ipsum dolor sit amet'
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -1488,24 +1485,24 @@ void main() {
...
@@ -1488,24 +1485,24 @@ void main() {
expect
(
tester
.
testTextInput
.
hasAnyClients
,
kIsWeb
?
isTrue
:
isFalse
);
expect
(
tester
.
testTextInput
.
hasAnyClients
,
kIsWeb
?
isTrue
:
isFalse
);
if
(
kIsWeb
)
{
if
(
kIsWeb
)
{
expect
(
tester
.
testTextInput
.
setClientArgs
[
'readOnly'
],
isTrue
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'readOnly'
],
isTrue
);
}
}
setState
(()
{
readOnly
=
false
;
});
setState
(()
{
readOnly
=
false
;
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
tester
.
testTextInput
.
hasAnyClients
,
isTrue
);
expect
(
tester
.
testTextInput
.
hasAnyClients
,
isTrue
);
expect
(
tester
.
testTextInput
.
setClientArgs
[
'readOnly'
],
isFalse
);
expect
(
tester
.
testTextInput
.
setClientArgs
!
[
'readOnly'
],
isFalse
);
});
});
testWidgets
(
'Fires onChanged when text changes via TextSelectionOverlay'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Fires onChanged when text changes via TextSelectionOverlay'
,
(
WidgetTester
tester
)
async
{
String
changedValue
;
late
String
changedValue
;
final
Widget
widget
=
MaterialApp
(
final
Widget
widget
=
MaterialApp
(
home:
EditableText
(
home:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
...
@@ -1559,12 +1556,12 @@ void main() {
...
@@ -1559,12 +1556,12 @@ void main() {
TextInputAction
.
previous
:
true
,
TextInputAction
.
previous
:
true
,
};
};
final
TextInputAction
action
=
focusVariants
.
currentValue
;
final
TextInputAction
action
=
focusVariants
.
currentValue
!
;
expect
(
actionShouldLoseFocus
.
containsKey
(
action
),
isTrue
);
expect
(
actionShouldLoseFocus
.
containsKey
(
action
),
isTrue
);
Future
<
void
>
_ensureCorrectFocusHandlingForAction
(
Future
<
void
>
_ensureCorrectFocusHandlingForAction
(
TextInputAction
action
,
{
TextInputAction
action
,
{
@
required
bool
shouldLoseFocus
,
required
bool
shouldLoseFocus
,
bool
shouldFocusNext
=
false
,
bool
shouldFocusNext
=
false
,
bool
shouldFocusPrevious
=
false
,
bool
shouldFocusPrevious
=
false
,
})
async
{
})
async
{
...
@@ -1582,7 +1579,7 @@ void main() {
...
@@ -1582,7 +1579,7 @@ void main() {
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
...
@@ -1600,15 +1597,15 @@ void main() {
...
@@ -1600,15 +1597,15 @@ void main() {
await
tester
.
testTextInput
.
receiveAction
(
action
);
await
tester
.
testTextInput
.
receiveAction
(
action
);
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
Focus
.
of
(
nextKey
.
currentContext
)
.
hasFocus
,
equals
(
shouldFocusNext
));
expect
(
Focus
.
of
(
nextKey
.
currentContext
!)!
.
hasFocus
,
equals
(
shouldFocusNext
));
expect
(
Focus
.
of
(
previousKey
.
currentContext
)
.
hasFocus
,
equals
(
shouldFocusPrevious
));
expect
(
Focus
.
of
(
previousKey
.
currentContext
!)!
.
hasFocus
,
equals
(
shouldFocusPrevious
));
expect
(
focusNode
.
hasFocus
,
equals
(!
shouldLoseFocus
));
expect
(
focusNode
.
hasFocus
,
equals
(!
shouldLoseFocus
));
}
}
try
{
try
{
await
_ensureCorrectFocusHandlingForAction
(
await
_ensureCorrectFocusHandlingForAction
(
action
,
action
,
shouldLoseFocus:
actionShouldLoseFocus
[
action
],
shouldLoseFocus:
actionShouldLoseFocus
[
action
]
!
,
shouldFocusNext:
action
==
TextInputAction
.
next
,
shouldFocusNext:
action
==
TextInputAction
.
next
,
shouldFocusPrevious:
action
==
TextInputAction
.
previous
,
shouldFocusPrevious:
action
==
TextInputAction
.
previous
,
);
);
...
@@ -1626,7 +1623,7 @@ void main() {
...
@@ -1626,7 +1623,7 @@ void main() {
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
...
@@ -1663,7 +1660,7 @@ void main() {
...
@@ -1663,7 +1660,7 @@ void main() {
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
onEditingComplete:
()
{
onEditingComplete:
()
{
onEditingCompleteCalled
=
true
;
onEditingCompleteCalled
=
true
;
...
@@ -1703,7 +1700,7 @@ void main() {
...
@@ -1703,7 +1700,7 @@ void main() {
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
onEditingComplete:
()
{
onEditingComplete:
()
{
onEditingCompleteCalled
=
true
;
onEditingCompleteCalled
=
true
;
...
@@ -1743,7 +1740,7 @@ void main() {
...
@@ -1743,7 +1740,7 @@ void main() {
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
maxLines:
1
,
maxLines:
1
,
onEditingComplete:
()
{
onEditingComplete:
()
{
...
@@ -1783,7 +1780,7 @@ void main() {
...
@@ -1783,7 +1780,7 @@ void main() {
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
maxLines:
3
,
maxLines:
3
,
onEditingComplete:
()
{
onEditingComplete:
()
{
...
@@ -1818,7 +1815,7 @@ void main() {
...
@@ -1818,7 +1815,7 @@ void main() {
(
WidgetTester
tester
)
async
{
(
WidgetTester
tester
)
async
{
const
Color
rectColor
=
Color
(
0xFFFF0000
);
const
Color
rectColor
=
Color
(
0xFFFF0000
);
void
verifyAutocorrectionRectVisibility
({
bool
expectVisible
})
{
void
verifyAutocorrectionRectVisibility
({
required
bool
expectVisible
})
{
PaintPattern
evaluate
()
{
PaintPattern
evaluate
()
{
if
(
expectVisible
)
{
if
(
expectVisible
)
{
return
paints
..
something
(((
Symbol
method
,
List
<
dynamic
>
arguments
)
{
return
paints
..
something
(((
Symbol
method
,
List
<
dynamic
>
arguments
)
{
...
@@ -1850,7 +1847,7 @@ void main() {
...
@@ -1850,7 +1847,7 @@ void main() {
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
controller:
controller
,
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
autocorrect:
true
,
autocorrect:
true
,
autocorrectionTextRectColor:
rectColor
,
autocorrectionTextRectColor:
rectColor
,
...
@@ -1898,7 +1895,7 @@ void main() {
...
@@ -1898,7 +1895,7 @@ void main() {
final
TextEditingController
controller2
=
final
TextEditingController
controller2
=
TextEditingController
(
text:
'Wobble'
);
TextEditingController
(
text:
'Wobble'
);
TextEditingController
currentController
=
controller1
;
TextEditingController
currentController
=
controller1
;
StateSetter
setState
;
late
StateSetter
setState
;
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Focus Node'
);
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Focus Node'
);
Widget
builder
()
{
Widget
builder
()
{
...
@@ -1918,7 +1915,7 @@ void main() {
...
@@ -1918,7 +1915,7 @@ void main() {
focusNode:
focusNode
,
focusNode:
focusNode
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
)
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
)
.
black
.
black
.
subtitle1
,
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
...
@@ -2155,7 +2152,7 @@ void main() {
...
@@ -2155,7 +2152,7 @@ void main() {
);
);
controller
.
selection
=
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
// At end, can only go backwards.
// At end, can only go backwards.
...
@@ -2172,7 +2169,7 @@ void main() {
...
@@ -2172,7 +2169,7 @@ void main() {
);
);
controller
.
selection
=
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
-
2
);
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
-
2
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
// Somewhere in the middle, can go in both directions.
// Somewhere in the middle, can go in both directions.
...
@@ -2215,7 +2212,7 @@ void main() {
...
@@ -2215,7 +2212,7 @@ void main() {
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
controller
.
selection
=
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
EditableText
(
home:
EditableText
(
...
@@ -2239,12 +2236,12 @@ void main() {
...
@@ -2239,12 +2236,12 @@ void main() {
);
);
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
int
semanticsId
=
render
.
debugSemantics
.
id
;
final
int
semanticsId
=
render
.
debugSemantics
!
.
id
;
expect
(
controller
.
selection
.
baseOffset
,
4
);
expect
(
controller
.
selection
.
baseOffset
,
4
);
expect
(
controller
.
selection
.
extentOffset
,
4
);
expect
(
controller
.
selection
.
extentOffset
,
4
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2265,13 +2262,13 @@ void main() {
...
@@ -2265,13 +2262,13 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2291,7 +2288,7 @@ void main() {
...
@@ -2291,7 +2288,7 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorForwardByCharacter
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorForwardByCharacter
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2307,7 +2304,7 @@ void main() {
...
@@ -2307,7 +2304,7 @@ void main() {
controller
.
text
=
'test for words'
;
controller
.
text
=
'test for words'
;
controller
.
selection
=
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
EditableText
(
home:
EditableText
(
...
@@ -2331,12 +2328,12 @@ void main() {
...
@@ -2331,12 +2328,12 @@ void main() {
);
);
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
int
semanticsId
=
render
.
debugSemantics
.
id
;
final
int
semanticsId
=
render
.
debugSemantics
!
.
id
;
expect
(
controller
.
selection
.
baseOffset
,
14
);
expect
(
controller
.
selection
.
baseOffset
,
14
);
expect
(
controller
.
selection
.
extentOffset
,
14
);
expect
(
controller
.
selection
.
extentOffset
,
14
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByWord
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorBackwardByWord
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2357,14 +2354,14 @@ void main() {
...
@@ -2357,14 +2354,14 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByWord
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorBackwardByWord
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
controller
.
selection
.
baseOffset
,
5
);
expect
(
controller
.
selection
.
baseOffset
,
5
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByWord
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorBackwardByWord
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2384,14 +2381,14 @@ void main() {
...
@@ -2384,14 +2381,14 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorForwardByWord
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorForwardByWord
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
controller
.
selection
.
baseOffset
,
5
);
expect
(
controller
.
selection
.
baseOffset
,
5
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorForwardByWord
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorForwardByWord
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2408,7 +2405,7 @@ void main() {
...
@@ -2408,7 +2405,7 @@ void main() {
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
controller
.
selection
=
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
EditableText
(
home:
EditableText
(
...
@@ -2432,12 +2429,12 @@ void main() {
...
@@ -2432,12 +2429,12 @@ void main() {
);
);
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
int
semanticsId
=
render
.
debugSemantics
.
id
;
final
int
semanticsId
=
render
.
debugSemantics
!
.
id
;
expect
(
controller
.
selection
.
baseOffset
,
4
);
expect
(
controller
.
selection
.
baseOffset
,
4
);
expect
(
controller
.
selection
.
extentOffset
,
4
);
expect
(
controller
.
selection
.
extentOffset
,
4
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2458,13 +2455,13 @@ void main() {
...
@@ -2458,13 +2455,13 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
SemanticsAction
.
moveCursorBackwardByCharacter
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2484,14 +2481,14 @@ void main() {
...
@@ -2484,14 +2481,14 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorForwardByCharacter
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorForwardByCharacter
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
controller
.
selection
.
baseOffset
,
1
);
expect
(
controller
.
selection
.
baseOffset
,
1
);
expect
(
controller
.
selection
.
extentOffset
,
1
);
expect
(
controller
.
selection
.
extentOffset
,
1
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorForwardByCharacter
,
extendSelection
);
SemanticsAction
.
moveCursorForwardByCharacter
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2508,7 +2505,7 @@ void main() {
...
@@ -2508,7 +2505,7 @@ void main() {
controller
.
text
=
'test for words'
;
controller
.
text
=
'test for words'
;
controller
.
selection
=
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
EditableText
(
home:
EditableText
(
...
@@ -2532,12 +2529,12 @@ void main() {
...
@@ -2532,12 +2529,12 @@ void main() {
);
);
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
int
semanticsId
=
render
.
debugSemantics
.
id
;
final
int
semanticsId
=
render
.
debugSemantics
!
.
id
;
expect
(
controller
.
selection
.
baseOffset
,
14
);
expect
(
controller
.
selection
.
baseOffset
,
14
);
expect
(
controller
.
selection
.
extentOffset
,
14
);
expect
(
controller
.
selection
.
extentOffset
,
14
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByWord
,
extendSelection
);
SemanticsAction
.
moveCursorBackwardByWord
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2558,14 +2555,14 @@ void main() {
...
@@ -2558,14 +2555,14 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByWord
,
extendSelection
);
SemanticsAction
.
moveCursorBackwardByWord
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
controller
.
selection
.
baseOffset
,
14
);
expect
(
controller
.
selection
.
baseOffset
,
14
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorBackwardByWord
,
extendSelection
);
SemanticsAction
.
moveCursorBackwardByWord
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2585,14 +2582,14 @@ void main() {
...
@@ -2585,14 +2582,14 @@ void main() {
),
),
);
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorForwardByWord
,
doNotExtendSelection
);
SemanticsAction
.
moveCursorForwardByWord
,
doNotExtendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
controller
.
selection
.
baseOffset
,
5
);
expect
(
controller
.
selection
.
baseOffset
,
5
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
expect
(
controller
.
selection
.
extentOffset
,
5
);
tester
.
binding
.
pipelineOwner
.
semanticsOwner
.
performAction
(
semanticsId
,
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
.
performAction
(
semanticsId
,
SemanticsAction
.
moveCursorForwardByWord
,
extendSelection
);
SemanticsAction
.
moveCursorForwardByWord
,
extendSelection
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -2618,7 +2615,7 @@ void main() {
...
@@ -2618,7 +2615,7 @@ void main() {
),
),
));
));
final
String
expectedValue
=
'•'
*
controller
.
text
.
length
;
final
String
expectedValue
=
'•'
*
controller
.
text
.
length
;
expect
(
expect
(
semantics
,
semantics
,
...
@@ -2722,7 +2719,7 @@ void main() {
...
@@ -2722,7 +2719,7 @@ void main() {
),
),
));
));
expect
(
findRenderEditable
(
tester
).
text
.
text
,
expectedValue
);
expect
(
findRenderEditable
(
tester
).
text
!
.
text
,
expectedValue
);
expect
(
expect
(
semantics
,
semantics
,
...
@@ -2786,7 +2783,7 @@ void main() {
...
@@ -2786,7 +2783,7 @@ void main() {
));
));
final
String
expectedValue
=
obscuringCharacter
*
originalText
.
length
;
final
String
expectedValue
=
obscuringCharacter
*
originalText
.
length
;
expect
(
findRenderEditable
(
tester
).
text
.
text
,
expectedValue
);
expect
(
findRenderEditable
(
tester
).
text
!
.
text
,
expectedValue
);
});
});
group
(
'a11y copy/cut/paste'
,
()
{
group
(
'a11y copy/cut/paste'
,
()
{
...
@@ -2803,12 +2800,12 @@ void main() {
...
@@ -2803,12 +2800,12 @@ void main() {
));
));
}
}
MockTextSelectionControls
controls
;
late
MockTextSelectionControls
controls
;
setUp
(()
{
setUp
(()
{
controller
.
text
=
'test'
;
controller
.
text
=
'test'
;
controller
.
selection
=
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
controls
=
MockTextSelectionControls
();
controls
=
MockTextSelectionControls
();
});
});
...
@@ -2915,7 +2912,7 @@ void main() {
...
@@ -2915,7 +2912,7 @@ void main() {
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
tap
(
find
.
byType
(
EditableText
));
await
tester
.
pump
();
await
tester
.
pump
();
final
SemanticsOwner
owner
=
tester
.
binding
.
pipelineOwner
.
semanticsOwner
;
final
SemanticsOwner
owner
=
tester
.
binding
.
pipelineOwner
.
semanticsOwner
!
;
const
int
expectedNodeId
=
5
;
const
int
expectedNodeId
=
5
;
expect
(
expect
(
...
@@ -2992,7 +2989,7 @@ void main() {
...
@@ -2992,7 +2989,7 @@ void main() {
// Simulate selection change via tap to show handles.
// Simulate selection change via tap to show handles.
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
final
RenderEditable
render
=
tester
.
allRenderObjects
.
whereType
<
RenderEditable
>().
first
;
expect
(
render
.
text
.
style
.
fontStyle
,
FontStyle
.
italic
);
expect
(
render
.
text
!.
style
!
.
fontStyle
,
FontStyle
.
italic
);
});
});
testWidgets
(
'Formatters are skipped if text has not changed'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Formatters are skipped if text has not changed'
,
(
WidgetTester
tester
)
async
{
...
@@ -3058,7 +3055,7 @@ void main() {
...
@@ -3058,7 +3055,7 @@ void main() {
child:
EditableText
(
child:
EditableText
(
controller:
controller
,
controller:
controller
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
),
),
...
@@ -3089,7 +3086,7 @@ void main() {
...
@@ -3089,7 +3086,7 @@ void main() {
child:
EditableText
(
child:
EditableText
(
controller:
controller
,
controller:
controller
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
),
),
...
@@ -3135,7 +3132,7 @@ void main() {
...
@@ -3135,7 +3132,7 @@ void main() {
key:
ValueKey
<
String
>(
controller1
.
text
),
key:
ValueKey
<
String
>(
controller1
.
text
),
controller:
controller1
,
controller:
controller1
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
),
),
...
@@ -3144,7 +3141,7 @@ void main() {
...
@@ -3144,7 +3141,7 @@ void main() {
key:
ValueKey
<
String
>(
controller2
.
text
),
key:
ValueKey
<
String
>(
controller2
.
text
),
controller:
controller2
,
controller:
controller2
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
minLines:
10
,
minLines:
10
,
...
@@ -3280,7 +3277,7 @@ void main() {
...
@@ -3280,7 +3277,7 @@ void main() {
testWidgets
(
'text styling info is sent on style update'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'text styling info is sent on style update'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
EditableTextState
>
editableTextKey
=
GlobalKey
<
EditableTextState
>();
final
GlobalKey
<
EditableTextState
>
editableTextKey
=
GlobalKey
<
EditableTextState
>();
StateSetter
setState
;
late
StateSetter
setState
;
const
TextStyle
textStyle1
=
TextStyle
(
const
TextStyle
textStyle1
=
TextStyle
(
fontSize:
20.0
,
fontSize:
20.0
,
fontFamily:
'RobotoMono'
,
fontFamily:
'RobotoMono'
,
...
@@ -3466,7 +3463,7 @@ void main() {
...
@@ -3466,7 +3463,7 @@ void main() {
child:
EditableText
(
child:
EditableText
(
controller:
controller
,
controller:
controller
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
keyboardAppearance:
Brightness
.
dark
,
keyboardAppearance:
Brightness
.
dark
,
...
@@ -3511,18 +3508,18 @@ void main() {
...
@@ -3511,18 +3508,18 @@ void main() {
final
RenderEditable
renderEditable
=
findRenderEditable
(
tester
);
final
RenderEditable
renderEditable
=
findRenderEditable
(
tester
);
// The actual text span is split into 3 parts with the middle part underlined.
// The actual text span is split into 3 parts with the middle part underlined.
expect
(
renderEditable
.
text
.
children
.
length
,
3
);
expect
(
renderEditable
.
text
!.
children
!
.
length
,
3
);
final
TextSpan
textSpan
=
renderEditable
.
text
.
children
[
1
]
as
TextSpan
;
final
TextSpan
textSpan
=
renderEditable
.
text
!.
children
!
[
1
]
as
TextSpan
;
expect
(
textSpan
.
text
,
'composing'
);
expect
(
textSpan
.
text
,
'composing'
);
expect
(
textSpan
.
style
.
decoration
,
TextDecoration
.
underline
);
expect
(
textSpan
.
style
!
.
decoration
,
TextDecoration
.
underline
);
focusNode
.
unfocus
();
focusNode
.
unfocus
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
renderEditable
.
text
.
children
,
isNull
);
expect
(
renderEditable
.
text
!
.
children
,
isNull
);
// Everything's just formated the same way now.
// Everything's just formated the same way now.
expect
(
renderEditable
.
text
.
text
,
'text composing text'
);
expect
(
renderEditable
.
text
!
.
text
,
'text composing text'
);
expect
(
renderEditable
.
text
.
style
.
decoration
,
isNull
);
expect
(
renderEditable
.
text
!.
style
!
.
decoration
,
isNull
);
});
});
testWidgets
(
'text selection handle visibility'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'text selection handle visibility'
,
(
WidgetTester
tester
)
async
{
...
@@ -3539,7 +3536,7 @@ void main() {
...
@@ -3539,7 +3536,7 @@ void main() {
showSelectionHandles:
true
,
showSelectionHandles:
true
,
controller:
controller
,
controller:
controller
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
...
@@ -3650,7 +3647,7 @@ void main() {
...
@@ -3650,7 +3647,7 @@ void main() {
throw
TestFailure
(
"HandlePositionInViewport can't be null."
);
throw
TestFailure
(
"HandlePositionInViewport can't be null."
);
}
}
}
}
expect
(
state
.
selectionOverlay
.
handlesAreVisible
,
isTrue
);
expect
(
state
.
selectionOverlay
!
.
handlesAreVisible
,
isTrue
);
testPosition
(
handles
[
0
].
localToGlobal
(
Offset
.
zero
).
dx
,
leftPosition
);
testPosition
(
handles
[
0
].
localToGlobal
(
Offset
.
zero
).
dx
,
leftPosition
);
testPosition
(
handles
[
1
].
localToGlobal
(
Offset
.
zero
).
dx
,
rightPosition
);
testPosition
(
handles
[
1
].
localToGlobal
(
Offset
.
zero
).
dx
,
rightPosition
);
}
}
...
@@ -3663,13 +3660,13 @@ void main() {
...
@@ -3663,13 +3660,13 @@ void main() {
// Drag the text slightly so the first word is partially visible. Only the
// Drag the text slightly so the first word is partially visible. Only the
// right handle should be visible.
// right handle should be visible.
scrollable
.
controller
.
jumpTo
(
20.0
);
scrollable
.
controller
!
.
jumpTo
(
20.0
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
within
,
true
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
within
,
true
);
// Drag the text all the way to the left so the first word is not visible at
// Drag the text all the way to the left so the first word is not visible at
// all (and the second word is fully visible). Both handles should be
// all (and the second word is fully visible). Both handles should be
// invisible now.
// invisible now.
scrollable
.
controller
.
jumpTo
(
200.0
);
scrollable
.
controller
!
.
jumpTo
(
200.0
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
leftEdge
,
false
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
leftEdge
,
false
);
// Tap to unselect.
// Tap to unselect.
...
@@ -3684,12 +3681,12 @@ void main() {
...
@@ -3684,12 +3681,12 @@ void main() {
// Drag the text slightly to the right. Only the left handle should be
// Drag the text slightly to the right. Only the left handle should be
// visible.
// visible.
scrollable
.
controller
.
jumpTo
(
150
);
scrollable
.
controller
!
.
jumpTo
(
150
);
await
verifyVisibility
(
HandlePositionInViewport
.
within
,
true
,
HandlePositionInViewport
.
rightEdge
,
false
);
await
verifyVisibility
(
HandlePositionInViewport
.
within
,
true
,
HandlePositionInViewport
.
rightEdge
,
false
);
// Drag the text all the way to the right, so the second word is not visible
// Drag the text all the way to the right, so the second word is not visible
// at all. Again, both handles should be invisible.
// at all. Again, both handles should be invisible.
scrollable
.
controller
.
jumpTo
(
0
);
scrollable
.
controller
!
.
jumpTo
(
0
);
await
verifyVisibility
(
HandlePositionInViewport
.
rightEdge
,
false
,
HandlePositionInViewport
.
rightEdge
,
false
);
await
verifyVisibility
(
HandlePositionInViewport
.
rightEdge
,
false
,
HandlePositionInViewport
.
rightEdge
,
false
);
// On web, we don't show the Flutter toolbar and instead rely on the browser
// On web, we don't show the Flutter toolbar and instead rely on the browser
...
@@ -3710,7 +3707,7 @@ void main() {
...
@@ -3710,7 +3707,7 @@ void main() {
controller:
controller
,
controller:
controller
,
showSelectionHandles:
true
,
showSelectionHandles:
true
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
...
@@ -3750,7 +3747,7 @@ void main() {
...
@@ -3750,7 +3747,7 @@ void main() {
70.0
+
kMinInteractiveDimension
,
70.0
+
kMinInteractiveDimension
,
),
),
);
);
expect
(
state
.
selectionOverlay
.
handlesAreVisible
,
isTrue
);
expect
(
state
.
selectionOverlay
!
.
handlesAreVisible
,
isTrue
);
expect
(
controller
.
selection
.
base
.
offset
,
0
);
expect
(
controller
.
selection
.
base
.
offset
,
0
);
expect
(
controller
.
selection
.
extent
.
offset
,
5
);
expect
(
controller
.
selection
.
extent
.
offset
,
5
);
...
@@ -3770,7 +3767,7 @@ void main() {
...
@@ -3770,7 +3767,7 @@ void main() {
bool
wordModifier
=
false
,
bool
wordModifier
=
false
,
bool
lineModifier
=
false
,
bool
lineModifier
=
false
,
bool
shortcutModifier
=
false
,
bool
shortcutModifier
=
false
,
String
platform
,
required
String
platform
,
})
async
{
})
async
{
if
(
shift
)
{
if
(
shift
)
{
await
tester
.
sendKeyDownEvent
(
LogicalKeyboardKey
.
shiftLeft
,
platform:
platform
);
await
tester
.
sendKeyDownEvent
(
LogicalKeyboardKey
.
shiftLeft
,
platform:
platform
);
...
@@ -3817,15 +3814,15 @@ void main() {
...
@@ -3817,15 +3814,15 @@ void main() {
}
}
}
}
Future
<
void
>
testTextEditing
(
WidgetTester
tester
,
{
String
platform
})
async
{
Future
<
void
>
testTextEditing
(
WidgetTester
tester
,
{
required
String
platform
})
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
);
controller
.
selection
=
const
TextSelection
(
controller
.
selection
=
const
TextSelection
(
baseOffset:
0
,
baseOffset:
0
,
extentOffset:
0
,
extentOffset:
0
,
affinity:
TextAffinity
.
upstream
,
affinity:
TextAffinity
.
upstream
,
);
);
TextSelection
selection
;
late
TextSelection
selection
;
SelectionChangedCause
cause
;
late
SelectionChangedCause
cause
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Align
(
home:
Align
(
alignment:
Alignment
.
topLeft
,
alignment:
Alignment
.
topLeft
,
...
@@ -3837,15 +3834,15 @@ void main() {
...
@@ -3837,15 +3834,15 @@ void main() {
showSelectionHandles:
true
,
showSelectionHandles:
true
,
autofocus:
true
,
autofocus:
true
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
textAlign:
TextAlign
.
right
,
textAlign:
TextAlign
.
right
,
onSelectionChanged:
(
TextSelection
newSelection
,
SelectionChangedCause
newCause
)
{
onSelectionChanged:
(
TextSelection
newSelection
,
SelectionChangedCause
?
newCause
)
{
selection
=
newSelection
;
selection
=
newSelection
;
cause
=
newCause
;
cause
=
newCause
!
;
},
},
),
),
),
),
...
@@ -4275,7 +4272,7 @@ void main() {
...
@@ -4275,7 +4272,7 @@ void main() {
reason:
'on
$platform
'
,
reason:
'on
$platform
'
,
);
);
expect
(
expect
(
(
await
Clipboard
.
getData
(
Clipboard
.
kTextPlain
)).
text
,
(
await
Clipboard
.
getData
(
Clipboard
.
kTextPlain
))
!
.
text
,
equals
(
'is the'
),
equals
(
'is the'
),
reason:
'on
$platform
'
,
reason:
'on
$platform
'
,
);
);
...
@@ -4326,7 +4323,7 @@ void main() {
...
@@ -4326,7 +4323,7 @@ void main() {
reason:
'on
$platform
'
,
reason:
'on
$platform
'
,
);
);
expect
(
controller
.
text
,
equals
(
testText
),
reason:
'on
$platform
'
);
expect
(
controller
.
text
,
equals
(
testText
),
reason:
'on
$platform
'
);
expect
((
await
Clipboard
.
getData
(
Clipboard
.
kTextPlain
)).
text
,
equals
(
testText
));
expect
((
await
Clipboard
.
getData
(
Clipboard
.
kTextPlain
))
!
.
text
,
equals
(
testText
));
// Delete
// Delete
await
sendKeys
(
await
sendKeys
(
...
@@ -4386,7 +4383,7 @@ void main() {
...
@@ -4386,7 +4383,7 @@ void main() {
showSelectionHandles:
true
,
showSelectionHandles:
true
,
controller:
controller
,
controller:
controller
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
iOS
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
iOS
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
selectionControls:
cupertinoTextSelectionControls
,
selectionControls:
cupertinoTextSelectionControls
,
...
@@ -4495,7 +4492,7 @@ void main() {
...
@@ -4495,7 +4492,7 @@ void main() {
throw
TestFailure
(
"HandlePositionInViewport can't be null."
);
throw
TestFailure
(
"HandlePositionInViewport can't be null."
);
}
}
}
}
expect
(
state
.
selectionOverlay
.
handlesAreVisible
,
isTrue
);
expect
(
state
.
selectionOverlay
!
.
handlesAreVisible
,
isTrue
);
testPosition
(
handles
[
0
].
localToGlobal
(
Offset
.
zero
).
dx
,
leftPosition
);
testPosition
(
handles
[
0
].
localToGlobal
(
Offset
.
zero
).
dx
,
leftPosition
);
testPosition
(
handles
[
1
].
localToGlobal
(
Offset
.
zero
).
dx
,
rightPosition
);
testPosition
(
handles
[
1
].
localToGlobal
(
Offset
.
zero
).
dx
,
rightPosition
);
}
}
...
@@ -4508,13 +4505,13 @@ void main() {
...
@@ -4508,13 +4505,13 @@ void main() {
// Drag the text slightly so the first word is partially visible. Only the
// Drag the text slightly so the first word is partially visible. Only the
// right handle should be visible.
// right handle should be visible.
scrollable
.
controller
.
jumpTo
(
20.0
);
scrollable
.
controller
!
.
jumpTo
(
20.0
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
within
,
true
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
within
,
true
);
// Drag the text all the way to the left so the first word is not visible at
// Drag the text all the way to the left so the first word is not visible at
// all (and the second word is fully visible). Both handles should be
// all (and the second word is fully visible). Both handles should be
// invisible now.
// invisible now.
scrollable
.
controller
.
jumpTo
(
200.0
);
scrollable
.
controller
!
.
jumpTo
(
200.0
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
leftEdge
,
false
);
await
verifyVisibility
(
HandlePositionInViewport
.
leftEdge
,
false
,
HandlePositionInViewport
.
leftEdge
,
false
);
// Tap to unselect.
// Tap to unselect.
...
@@ -4529,12 +4526,12 @@ void main() {
...
@@ -4529,12 +4526,12 @@ void main() {
// Drag the text slightly to the right. Only the left handle should be
// Drag the text slightly to the right. Only the left handle should be
// visible.
// visible.
scrollable
.
controller
.
jumpTo
(
150
);
scrollable
.
controller
!
.
jumpTo
(
150
);
await
verifyVisibility
(
HandlePositionInViewport
.
within
,
true
,
HandlePositionInViewport
.
rightEdge
,
false
);
await
verifyVisibility
(
HandlePositionInViewport
.
within
,
true
,
HandlePositionInViewport
.
rightEdge
,
false
);
// Drag the text all the way to the right, so the second word is not visible
// Drag the text all the way to the right, so the second word is not visible
// at all. Again, both handles should be invisible.
// at all. Again, both handles should be invisible.
scrollable
.
controller
.
jumpTo
(
0
);
scrollable
.
controller
!
.
jumpTo
(
0
);
await
verifyVisibility
(
HandlePositionInViewport
.
rightEdge
,
false
,
HandlePositionInViewport
.
rightEdge
,
false
);
await
verifyVisibility
(
HandlePositionInViewport
.
rightEdge
,
false
,
HandlePositionInViewport
.
rightEdge
,
false
);
// On web, we don't show the Flutter toolbar and instead rely on the browser
// On web, we don't show the Flutter toolbar and instead rely on the browser
...
@@ -4556,7 +4553,7 @@ void main() {
...
@@ -4556,7 +4553,7 @@ void main() {
maxLines:
2
,
maxLines:
2
,
controller:
controller
,
controller:
controller
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
...
@@ -4571,24 +4568,24 @@ void main() {
...
@@ -4571,24 +4568,24 @@ void main() {
final
RenderEditable
renderEditable
=
state
.
renderEditable
;
final
RenderEditable
renderEditable
=
state
.
renderEditable
;
final
Scrollable
scrollable
=
tester
.
widget
<
Scrollable
>(
find
.
byType
(
Scrollable
));
final
Scrollable
scrollable
=
tester
.
widget
<
Scrollable
>(
find
.
byType
(
Scrollable
));
expect
(
scrollable
.
controller
.
position
.
viewportDimension
,
equals
(
28
));
expect
(
scrollable
.
controller
!
.
position
.
viewportDimension
,
equals
(
28
));
expect
(
scrollable
.
controller
.
position
.
pixels
,
equals
(
0
));
expect
(
scrollable
.
controller
!
.
position
.
pixels
,
equals
(
0
));
expect
(
renderEditable
.
maxScrollExtent
,
equals
(
14
));
expect
(
renderEditable
.
maxScrollExtent
,
equals
(
14
));
scrollable
.
controller
.
jumpTo
(
20.0
);
scrollable
.
controller
!
.
jumpTo
(
20.0
);
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
scrollable
.
controller
.
position
.
pixels
,
equals
(
20
));
expect
(
scrollable
.
controller
!
.
position
.
pixels
,
equals
(
20
));
state
.
bringIntoView
(
const
TextPosition
(
offset:
0
));
state
.
bringIntoView
(
const
TextPosition
(
offset:
0
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
scrollable
.
controller
.
position
.
pixels
,
equals
(
0
));
expect
(
scrollable
.
controller
!
.
position
.
pixels
,
equals
(
0
));
state
.
bringIntoView
(
const
TextPosition
(
offset:
13
));
state
.
bringIntoView
(
const
TextPosition
(
offset:
13
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
scrollable
.
controller
.
position
.
pixels
,
equals
(
14
));
expect
(
scrollable
.
controller
!
.
position
.
pixels
,
equals
(
14
));
expect
(
scrollable
.
controller
.
position
.
pixels
,
equals
(
renderEditable
.
maxScrollExtent
));
expect
(
scrollable
.
controller
!
.
position
.
pixels
,
equals
(
renderEditable
.
maxScrollExtent
));
});
});
testWidgets
(
'bringIntoView brings the caret into view when in a viewport'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'bringIntoView brings the caret into view when in a viewport'
,
(
WidgetTester
tester
)
async
{
...
@@ -4637,7 +4634,7 @@ void main() {
...
@@ -4637,7 +4634,7 @@ void main() {
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
*
20
);
final
TextEditingController
controller
=
TextEditingController
(
text:
testText
*
20
);
final
ScrollController
scrollController
=
ScrollController
();
final
ScrollController
scrollController
=
ScrollController
();
Future
<
void
>
buildWithPhysics
({
ScrollPhysics
physics
})
async
{
Future
<
void
>
buildWithPhysics
({
ScrollPhysics
?
physics
})
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Align
(
home:
Align
(
alignment:
Alignment
.
topLeft
,
alignment:
Alignment
.
topLeft
,
...
@@ -4746,7 +4743,7 @@ void main() {
...
@@ -4746,7 +4743,7 @@ void main() {
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
);
);
...
@@ -4789,7 +4786,7 @@ void main() {
...
@@ -4789,7 +4786,7 @@ void main() {
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
);
);
...
@@ -4821,7 +4818,7 @@ void main() {
...
@@ -4821,7 +4818,7 @@ void main() {
expect
(
m
.
method
,
logOrder
[
index
]);
expect
(
m
.
method
,
logOrder
[
index
]);
index
++;
index
++;
}
}
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
'flutter is the best!'
);
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
'flutter is the best!'
);
});
});
testWidgets
(
'setEditingState is called when text changes on controller'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'setEditingState is called when text changes on controller'
,
(
WidgetTester
tester
)
async
{
...
@@ -4835,7 +4832,7 @@ void main() {
...
@@ -4835,7 +4832,7 @@ void main() {
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
);
);
...
@@ -4869,7 +4866,7 @@ void main() {
...
@@ -4869,7 +4866,7 @@ void main() {
tester
.
testTextInput
.
log
.
map
((
MethodCall
m
)
=>
m
.
method
),
tester
.
testTextInput
.
log
.
map
((
MethodCall
m
)
=>
m
.
method
),
logOrder
,
logOrder
,
);
);
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
'flutter is the best!...'
);
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
'flutter is the best!...'
);
});
});
testWidgets
(
'Synchronous test of local and remote editing values'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Synchronous test of local and remote editing values'
,
(
WidgetTester
tester
)
async
{
...
@@ -4885,7 +4882,7 @@ void main() {
...
@@ -4885,7 +4882,7 @@ void main() {
return
newValue
;
return
newValue
;
});
});
final
TextEditingController
controller
=
TextEditingController
();
final
TextEditingController
controller
=
TextEditingController
();
StateSetter
setState
;
late
StateSetter
setState
;
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Focus Node'
);
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'EditableText Focus Node'
);
Widget
builder
()
{
Widget
builder
()
{
...
@@ -5174,7 +5171,7 @@ void main() {
...
@@ -5174,7 +5171,7 @@ void main() {
showSelectionHandles:
true
,
showSelectionHandles:
true
,
autofocus:
true
,
autofocus:
true
,
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
...
@@ -5221,7 +5218,7 @@ void main() {
...
@@ -5221,7 +5218,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
''
));
state
.
updateEditingValue
(
const
TextEditingValue
(
text:
''
));
...
@@ -5294,7 +5291,7 @@ void main() {
...
@@ -5294,7 +5291,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
// We no longer perform full repeat filtering in framework, it is now left
// We no longer perform full repeat filtering in framework, it is now left
...
@@ -5373,7 +5370,7 @@ void main() {
...
@@ -5373,7 +5370,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
'test'
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
'test'
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
formatter
.
formatCallCount
,
0
);
expect
(
formatter
.
formatCallCount
,
0
);
...
@@ -5414,7 +5411,7 @@ void main() {
...
@@ -5414,7 +5411,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
// Simple mixed directional input.
// Simple mixed directional input.
...
@@ -5469,7 +5466,7 @@ void main() {
...
@@ -5469,7 +5466,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
// Does not overwrite existing RLM or LRM characters
// Does not overwrite existing RLM or LRM characters
...
@@ -5517,7 +5514,7 @@ void main() {
...
@@ -5517,7 +5514,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
// Can be passed through formatter repeatedly without leaking/growing.
// Can be passed through formatter repeatedly without leaking/growing.
...
@@ -5559,7 +5556,7 @@ void main() {
...
@@ -5559,7 +5556,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
// Doesn't eat emojis
// Doesn't eat emojis
...
@@ -5599,7 +5596,7 @@ void main() {
...
@@ -5599,7 +5596,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
// Doesn't eat emojis
// Doesn't eat emojis
...
@@ -5639,7 +5636,7 @@ void main() {
...
@@ -5639,7 +5636,7 @@ void main() {
final
EditableTextState
state
=
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
expect
(
tester
.
testTextInput
.
editingState
[
'text'
],
equals
(
''
));
expect
(
tester
.
testTextInput
.
editingState
!
[
'text'
],
equals
(
''
));
expect
(
state
.
wantKeepAlive
,
true
);
expect
(
state
.
wantKeepAlive
,
true
);
// Simulate deleting only the trailing RTL mark.
// Simulate deleting only the trailing RTL mark.
...
@@ -5679,7 +5676,7 @@ void main() {
...
@@ -5679,7 +5676,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
// Test default cursor
// Test default cursor
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -5704,17 +5701,17 @@ void main() {
...
@@ -5704,17 +5701,17 @@ void main() {
),
),
);
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
});
});
testWidgets
(
'Can access characters on editing string'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Can access characters on editing string'
,
(
WidgetTester
tester
)
async
{
int
charactersLength
;
late
int
charactersLength
;
final
Widget
widget
=
MaterialApp
(
final
Widget
widget
=
MaterialApp
(
home:
EditableText
(
home:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
...
@@ -6065,10 +6062,10 @@ void main() {
...
@@ -6065,10 +6062,10 @@ void main() {
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
selectionControls:
materialTextSelectionControls
,
selectionControls:
materialTextSelectionControls
,
onSelectionChanged:
(
TextSelection
selection
,
SelectionChangedCause
cause
)
{
onSelectionChanged:
(
TextSelection
selection
,
SelectionChangedCause
?
cause
)
{
throw
FlutterError
(
errorText
);
throw
FlutterError
(
errorText
);
},
},
),
),
...
@@ -6092,7 +6089,7 @@ void main() {
...
@@ -6092,7 +6089,7 @@ void main() {
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
onChanged:
(
String
text
)
{
onChanged:
(
String
text
)
{
throw
FlutterError
(
errorText
);
throw
FlutterError
(
errorText
);
...
@@ -6118,7 +6115,7 @@ void main() {
...
@@ -6118,7 +6115,7 @@ void main() {
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
onEditingComplete:
()
{
onEditingComplete:
()
{
throw
FlutterError
(
errorText
);
throw
FlutterError
(
errorText
);
...
@@ -6149,7 +6146,7 @@ void main() {
...
@@ -6149,7 +6146,7 @@ void main() {
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
cursorColor:
Colors
.
red
,
cursorColor:
Colors
.
red
,
backgroundCursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
blue
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
.
copyWith
(
fontFamily:
'Roboto'
),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
.
copyWith
(
fontFamily:
'Roboto'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
onSubmitted:
(
String
text
)
{
onSubmitted:
(
String
text
)
{
throw
FlutterError
(
errorText
);
throw
FlutterError
(
errorText
);
...
@@ -6176,8 +6173,8 @@ class MockTextFormatter extends TextInputFormatter {
...
@@ -6176,8 +6173,8 @@ class MockTextFormatter extends TextInputFormatter {
int
formatCallCount
;
int
formatCallCount
;
List
<
String
>
log
;
List
<
String
>
log
;
TextEditingValue
lastOldValue
;
late
TextEditingValue
lastOldValue
;
TextEditingValue
lastNewValue
;
late
TextEditingValue
lastNewValue
;
@override
@override
TextEditingValue
formatEditUpdate
(
TextEditingValue
formatEditUpdate
(
...
@@ -6242,7 +6239,7 @@ class MockTextSelectionControls extends Fake implements TextSelectionControls {
...
@@ -6242,7 +6239,7 @@ class MockTextSelectionControls extends Fake implements TextSelectionControls {
int
copyCount
=
0
;
int
copyCount
=
0
;
@override
@override
void
handleCopy
(
TextSelectionDelegate
delegate
,
ClipboardStatusNotifier
clipboardStatus
)
{
void
handleCopy
(
TextSelectionDelegate
delegate
,
ClipboardStatusNotifier
?
clipboardStatus
)
{
copyCount
+=
1
;
copyCount
+=
1
;
}
}
...
@@ -6274,11 +6271,11 @@ class MockTextSelectionControls extends Fake implements TextSelectionControls {
...
@@ -6274,11 +6271,11 @@ class MockTextSelectionControls extends Fake implements TextSelectionControls {
class
CustomStyleEditableText
extends
EditableText
{
class
CustomStyleEditableText
extends
EditableText
{
CustomStyleEditableText
({
CustomStyleEditableText
({
Key
key
,
Key
?
key
,
TextEditingController
controller
,
required
TextEditingController
controller
,
Color
cursorColor
,
required
Color
cursorColor
,
FocusNode
focusNode
,
required
FocusNode
focusNode
,
TextStyle
style
,
required
TextStyle
style
,
})
:
super
(
})
:
super
(
key:
key
,
key:
key
,
controller:
controller
,
controller:
controller
,
...
@@ -6304,9 +6301,9 @@ class CustomStyleEditableTextState extends EditableTextState {
...
@@ -6304,9 +6301,9 @@ class CustomStyleEditableTextState extends EditableTextState {
class
TransformedEditableText
extends
StatefulWidget
{
class
TransformedEditableText
extends
StatefulWidget
{
const
TransformedEditableText
({
const
TransformedEditableText
({
Key
key
,
Key
?
key
,
this
.
offset
,
required
this
.
offset
,
this
.
transformButtonKey
,
required
this
.
transformButtonKey
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
Offset
offset
;
final
Offset
offset
;
...
@@ -6336,7 +6333,7 @@ class _TransformedEditableTextState extends State<TransformedEditableText> {
...
@@ -6336,7 +6333,7 @@ class _TransformedEditableTextState extends State<TransformedEditableText> {
child:
EditableText
(
child:
EditableText
(
controller:
TextEditingController
(),
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
focusNode:
FocusNode
(),
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
,
style:
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
subtitle1
!
,
cursorColor:
Colors
.
blue
,
cursorColor:
Colors
.
blue
,
backgroundCursorColor:
Colors
.
grey
,
backgroundCursorColor:
Colors
.
grey
,
),
),
...
@@ -6358,19 +6355,19 @@ class _TransformedEditableTextState extends State<TransformedEditableText> {
...
@@ -6358,19 +6355,19 @@ class _TransformedEditableTextState extends State<TransformedEditableText> {
}
}
class
NoImplicitScrollPhysics
extends
AlwaysScrollableScrollPhysics
{
class
NoImplicitScrollPhysics
extends
AlwaysScrollableScrollPhysics
{
const
NoImplicitScrollPhysics
({
ScrollPhysics
parent
})
:
super
(
parent:
parent
);
const
NoImplicitScrollPhysics
({
ScrollPhysics
?
parent
})
:
super
(
parent:
parent
);
@override
@override
bool
get
allowImplicitScrolling
=>
false
;
bool
get
allowImplicitScrolling
=>
false
;
@override
@override
NoImplicitScrollPhysics
applyTo
(
ScrollPhysics
ancestor
)
{
NoImplicitScrollPhysics
applyTo
(
ScrollPhysics
?
ancestor
)
{
return
NoImplicitScrollPhysics
(
parent:
buildParent
(
ancestor
));
return
NoImplicitScrollPhysics
(
parent:
buildParent
(
ancestor
)
!
);
}
}
}
}
class
SkipPainting
extends
SingleChildRenderObjectWidget
{
class
SkipPainting
extends
SingleChildRenderObjectWidget
{
const
SkipPainting
({
Key
key
,
Widget
child
}):
super
(
key:
key
,
child:
child
);
const
SkipPainting
({
Key
?
key
,
required
Widget
child
}):
super
(
key:
key
,
child:
child
);
@override
@override
SkipPaintingRenderObject
createRenderObject
(
BuildContext
context
)
=>
SkipPaintingRenderObject
();
SkipPaintingRenderObject
createRenderObject
(
BuildContext
context
)
=>
SkipPaintingRenderObject
();
...
...
packages/flutter/test/widgets/ensure_visible_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter/test/widgets/error_widget_builder_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/fade_in_image_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
as
ui
;
...
@@ -22,21 +20,21 @@ class FadeInImageParts {
...
@@ -22,21 +20,21 @@ class FadeInImageParts {
assert
(
target
!=
null
);
assert
(
target
!=
null
);
final
ComponentElement
fadeInImageElement
;
final
ComponentElement
fadeInImageElement
;
final
FadeInImageElements
placeholder
;
final
FadeInImageElements
?
placeholder
;
final
FadeInImageElements
target
;
final
FadeInImageElements
target
;
State
get
state
{
State
?
get
state
{
StatefulElement
animatedFadeOutFadeInElement
;
StatefulElement
?
animatedFadeOutFadeInElement
;
fadeInImageElement
.
visitChildren
((
Element
child
)
{
fadeInImageElement
.
visitChildren
((
Element
child
)
{
expect
(
animatedFadeOutFadeInElement
,
isNull
);
expect
(
animatedFadeOutFadeInElement
,
isNull
);
animatedFadeOutFadeInElement
=
child
as
StatefulElement
;
animatedFadeOutFadeInElement
=
child
as
StatefulElement
;
});
});
expect
(
animatedFadeOutFadeInElement
,
isNotNull
);
expect
(
animatedFadeOutFadeInElement
,
isNotNull
);
return
animatedFadeOutFadeInElement
.
state
;
return
animatedFadeOutFadeInElement
!
.
state
;
}
}
Element
get
semanticsElement
{
Element
?
get
semanticsElement
{
Element
result
;
Element
?
result
;
fadeInImageElement
.
visitChildren
((
Element
child
)
{
fadeInImageElement
.
visitChildren
((
Element
child
)
{
if
(
child
.
widget
is
Semantics
)
if
(
child
.
widget
is
Semantics
)
result
=
child
;
result
=
child
;
...
@@ -49,39 +47,39 @@ class FadeInImageElements {
...
@@ -49,39 +47,39 @@ class FadeInImageElements {
const
FadeInImageElements
(
this
.
rawImageElement
,
this
.
fadeTransitionElement
);
const
FadeInImageElements
(
this
.
rawImageElement
,
this
.
fadeTransitionElement
);
final
Element
rawImageElement
;
final
Element
rawImageElement
;
final
Element
fadeTransitionElement
;
final
Element
?
fadeTransitionElement
;
RawImage
get
rawImage
=>
rawImageElement
.
widget
as
RawImage
;
RawImage
get
rawImage
=>
rawImageElement
.
widget
as
RawImage
;
FadeTransition
get
fadeTransition
=>
fadeTransitionElement
?.
widget
as
FadeTransition
;
FadeTransition
?
get
fadeTransition
=>
fadeTransitionElement
?.
widget
as
FadeTransition
?
;
double
get
opacity
=>
fadeTransition
==
null
?
1
:
fadeTransition
.
opacity
.
value
;
double
get
opacity
=>
fadeTransition
==
null
?
1
:
fadeTransition
!
.
opacity
.
value
;
}
}
class
LoadTestImageProvider
extends
ImageProvider
<
dynamic
>
{
class
LoadTestImageProvider
extends
ImageProvider
<
Object
>
{
LoadTestImageProvider
(
this
.
provider
);
LoadTestImageProvider
(
this
.
provider
);
final
ImageProvider
provider
;
final
ImageProvider
provider
;
ImageStreamCompleter
testLoad
(
dynamic
key
,
DecoderCallback
decode
)
{
ImageStreamCompleter
testLoad
(
Object
key
,
DecoderCallback
decode
)
{
return
provider
.
load
(
key
,
decode
);
return
provider
.
load
(
key
,
decode
);
}
}
@override
@override
Future
<
dynamic
>
obtainKey
(
ImageConfiguration
configuration
)
{
Future
<
Object
>
obtainKey
(
ImageConfiguration
configuration
)
{
return
null
;
throw
UnimplementedError
()
;
}
}
@override
@override
ImageStreamCompleter
load
(
dynamic
key
,
DecoderCallback
decode
)
{
ImageStreamCompleter
load
(
Object
key
,
DecoderCallback
decode
)
{
return
null
;
throw
UnimplementedError
()
;
}
}
}
}
FadeInImageParts
findFadeInImage
(
WidgetTester
tester
)
{
FadeInImageParts
findFadeInImage
(
WidgetTester
tester
)
{
final
List
<
FadeInImageElements
>
elements
=
<
FadeInImageElements
>[];
final
List
<
FadeInImageElements
>
elements
=
<
FadeInImageElements
>[];
final
Iterable
<
Element
>
rawImageElements
=
tester
.
elementList
(
find
.
byType
(
RawImage
));
final
Iterable
<
Element
>
rawImageElements
=
tester
.
elementList
(
find
.
byType
(
RawImage
));
ComponentElement
fadeInImageElement
;
ComponentElement
?
fadeInImageElement
;
for
(
final
Element
rawImageElement
in
rawImageElements
)
{
for
(
final
Element
rawImageElement
in
rawImageElements
)
{
Element
fadeTransitionElement
;
Element
?
fadeTransitionElement
;
rawImageElement
.
visitAncestorElements
((
Element
ancestor
)
{
rawImageElement
.
visitAncestorElements
((
Element
ancestor
)
{
if
(
ancestor
.
widget
is
FadeTransition
)
{
if
(
ancestor
.
widget
is
FadeTransition
)
{
fadeTransitionElement
=
ancestor
;
fadeTransitionElement
=
ancestor
;
...
@@ -99,10 +97,10 @@ FadeInImageParts findFadeInImage(WidgetTester tester) {
...
@@ -99,10 +97,10 @@ FadeInImageParts findFadeInImage(WidgetTester tester) {
elements
.
add
(
FadeInImageElements
(
rawImageElement
,
fadeTransitionElement
));
elements
.
add
(
FadeInImageElements
(
rawImageElement
,
fadeTransitionElement
));
}
}
if
(
elements
.
length
==
2
)
{
if
(
elements
.
length
==
2
)
{
return
FadeInImageParts
(
fadeInImageElement
,
elements
.
last
,
elements
.
first
);
return
FadeInImageParts
(
fadeInImageElement
!
,
elements
.
last
,
elements
.
first
);
}
else
{
}
else
{
expect
(
elements
,
hasLength
(
1
));
expect
(
elements
,
hasLength
(
1
));
return
FadeInImageParts
(
fadeInImageElement
,
null
,
elements
.
first
);
return
FadeInImageParts
(
fadeInImageElement
!
,
null
,
elements
.
first
);
}
}
}
}
...
@@ -127,30 +125,30 @@ Future<void> main() async {
...
@@ -127,30 +125,30 @@ Future<void> main() async {
excludeFromSemantics:
true
,
excludeFromSemantics:
true
,
));
));
expect
(
findFadeInImage
(
tester
).
placeholder
.
rawImage
.
image
,
null
);
expect
(
findFadeInImage
(
tester
).
placeholder
!
.
rawImage
.
image
,
null
);
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
,
null
);
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
,
null
);
placeholderProvider
.
complete
();
placeholderProvider
.
complete
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
findFadeInImage
(
tester
).
placeholder
.
rawImage
.
image
.
isCloneOf
(
placeholderImage
),
true
);
expect
(
findFadeInImage
(
tester
).
placeholder
!.
rawImage
.
image
!
.
isCloneOf
(
placeholderImage
),
true
);
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
,
null
);
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
,
null
);
imageProvider
.
complete
();
imageProvider
.
complete
();
await
tester
.
pump
();
await
tester
.
pump
();
for
(
int
i
=
0
;
i
<
5
;
i
+=
1
)
{
for
(
int
i
=
0
;
i
<
5
;
i
+=
1
)
{
final
FadeInImageParts
parts
=
findFadeInImage
(
tester
);
final
FadeInImageParts
parts
=
findFadeInImage
(
tester
);
expect
(
parts
.
placeholder
.
rawImage
.
image
.
isCloneOf
(
placeholderImage
),
true
);
expect
(
parts
.
placeholder
!.
rawImage
.
image
!
.
isCloneOf
(
placeholderImage
),
true
);
expect
(
parts
.
target
.
rawImage
.
image
.
isCloneOf
(
targetImage
),
true
);
expect
(
parts
.
target
.
rawImage
.
image
!
.
isCloneOf
(
targetImage
),
true
);
expect
(
parts
.
placeholder
.
opacity
,
moreOrLessEquals
(
1
-
i
/
5
));
expect
(
parts
.
placeholder
!
.
opacity
,
moreOrLessEquals
(
1
-
i
/
5
));
expect
(
parts
.
target
.
opacity
,
0
);
expect
(
parts
.
target
.
opacity
,
0
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
}
}
for
(
int
i
=
0
;
i
<
5
;
i
+=
1
)
{
for
(
int
i
=
0
;
i
<
5
;
i
+=
1
)
{
final
FadeInImageParts
parts
=
findFadeInImage
(
tester
);
final
FadeInImageParts
parts
=
findFadeInImage
(
tester
);
expect
(
parts
.
placeholder
.
rawImage
.
image
.
isCloneOf
(
placeholderImage
),
true
);
expect
(
parts
.
placeholder
!.
rawImage
.
image
!
.
isCloneOf
(
placeholderImage
),
true
);
expect
(
parts
.
target
.
rawImage
.
image
.
isCloneOf
(
targetImage
),
true
);
expect
(
parts
.
target
.
rawImage
.
image
!
.
isCloneOf
(
targetImage
),
true
);
expect
(
parts
.
placeholder
.
opacity
,
0
);
expect
(
parts
.
placeholder
!
.
opacity
,
0
);
expect
(
parts
.
target
.
opacity
,
moreOrLessEquals
(
i
/
5
));
expect
(
parts
.
target
.
opacity
,
moreOrLessEquals
(
i
/
5
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
}
}
...
@@ -159,7 +157,7 @@ Future<void> main() async {
...
@@ -159,7 +157,7 @@ Future<void> main() async {
placeholder:
placeholderProvider
,
placeholder:
placeholderProvider
,
image:
imageProvider
,
image:
imageProvider
,
));
));
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
.
isCloneOf
(
targetImage
),
true
);
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
!
.
isCloneOf
(
targetImage
),
true
);
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
1
);
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
1
);
});
});
...
@@ -174,7 +172,7 @@ Future<void> main() async {
...
@@ -174,7 +172,7 @@ Future<void> main() async {
image:
imageProvider
,
image:
imageProvider
,
));
));
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
.
isCloneOf
(
targetImage
),
true
);
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
!
.
isCloneOf
(
targetImage
),
true
);
expect
(
findFadeInImage
(
tester
).
placeholder
,
isNull
);
expect
(
findFadeInImage
(
tester
).
placeholder
,
isNull
);
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
1
);
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
1
);
});
});
...
@@ -192,10 +190,10 @@ Future<void> main() async {
...
@@ -192,10 +190,10 @@ Future<void> main() async {
excludeFromSemantics:
true
,
excludeFromSemantics:
true
,
));
));
final
State
state
=
findFadeInImage
(
tester
).
state
;
final
State
?
state
=
findFadeInImage
(
tester
).
state
;
placeholderProvider
.
complete
();
placeholderProvider
.
complete
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
findFadeInImage
(
tester
).
placeholder
.
rawImage
.
image
.
isCloneOf
(
placeholderImage
),
true
);
expect
(
findFadeInImage
(
tester
).
placeholder
!.
rawImage
.
image
!
.
isCloneOf
(
placeholderImage
),
true
);
await
tester
.
pumpWidget
(
FadeInImage
(
await
tester
.
pumpWidget
(
FadeInImage
(
placeholder:
secondPlaceholderProvider
,
placeholder:
secondPlaceholderProvider
,
...
@@ -207,7 +205,7 @@ Future<void> main() async {
...
@@ -207,7 +205,7 @@ Future<void> main() async {
secondPlaceholderProvider
.
complete
();
secondPlaceholderProvider
.
complete
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
findFadeInImage
(
tester
).
placeholder
.
rawImage
.
image
.
isCloneOf
(
replacementImage
),
true
);
expect
(
findFadeInImage
(
tester
).
placeholder
!.
rawImage
.
image
!
.
isCloneOf
(
replacementImage
),
true
);
expect
(
findFadeInImage
(
tester
).
state
,
same
(
state
));
expect
(
findFadeInImage
(
tester
).
state
,
same
(
state
));
});
});
...
@@ -246,7 +244,7 @@ Future<void> main() async {
...
@@ -246,7 +244,7 @@ Future<void> main() async {
excludeFromSemantics:
true
,
excludeFromSemantics:
true
,
));
));
final
State
state
=
findFadeInImage
(
tester
).
state
;
final
State
?
state
=
findFadeInImage
(
tester
).
state
;
placeholderProvider
.
complete
();
placeholderProvider
.
complete
();
imageProvider
.
complete
();
imageProvider
.
complete
();
await
tester
.
pump
();
await
tester
.
pump
();
...
@@ -263,15 +261,15 @@ Future<void> main() async {
...
@@ -263,15 +261,15 @@ Future<void> main() async {
secondImageProvider
.
complete
();
secondImageProvider
.
complete
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
.
isCloneOf
(
replacementImage
),
true
);
expect
(
findFadeInImage
(
tester
).
target
.
rawImage
.
image
!
.
isCloneOf
(
replacementImage
),
true
);
expect
(
findFadeInImage
(
tester
).
state
,
same
(
state
));
expect
(
findFadeInImage
(
tester
).
state
,
same
(
state
));
expect
(
findFadeInImage
(
tester
).
placeholder
.
opacity
,
moreOrLessEquals
(
1
));
expect
(
findFadeInImage
(
tester
).
placeholder
!
.
opacity
,
moreOrLessEquals
(
1
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
0
));
await
tester
.
pump
(
animationDuration
);
await
tester
.
pump
(
animationDuration
);
expect
(
findFadeInImage
(
tester
).
placeholder
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
placeholder
!
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
0
));
await
tester
.
pump
(
animationDuration
);
await
tester
.
pump
(
animationDuration
);
expect
(
findFadeInImage
(
tester
).
placeholder
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
placeholder
!
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
1
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
1
));
});
});
...
@@ -287,7 +285,7 @@ Future<void> main() async {
...
@@ -287,7 +285,7 @@ Future<void> main() async {
excludeFromSemantics:
true
,
excludeFromSemantics:
true
,
));
));
final
State
state
=
findFadeInImage
(
tester
).
state
;
final
State
?
state
=
findFadeInImage
(
tester
).
state
;
placeholderProvider
.
complete
();
placeholderProvider
.
complete
();
imageProvider
.
complete
();
imageProvider
.
complete
();
await
tester
.
pump
();
await
tester
.
pump
();
...
@@ -302,10 +300,10 @@ Future<void> main() async {
...
@@ -302,10 +300,10 @@ Future<void> main() async {
));
));
expect
(
findFadeInImage
(
tester
).
state
,
same
(
state
));
expect
(
findFadeInImage
(
tester
).
state
,
same
(
state
));
expect
(
findFadeInImage
(
tester
).
placeholder
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
placeholder
!
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
0
));
await
tester
.
pump
(
animationDuration
);
await
tester
.
pump
(
animationDuration
);
expect
(
findFadeInImage
(
tester
).
placeholder
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
placeholder
!
.
opacity
,
moreOrLessEquals
(
0
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
1
));
expect
(
findFadeInImage
(
tester
).
target
.
opacity
,
moreOrLessEquals
(
1
));
});
});
...
@@ -323,12 +321,12 @@ Future<void> main() async {
...
@@ -323,12 +321,12 @@ Future<void> main() async {
);
);
bool
called
=
false
;
bool
called
=
false
;
final
DecoderCallback
decode
=
(
Uint8List
bytes
,
{
int
cacheWidth
,
int
cacheHeight
,
bool
allowUpscaling
})
{
final
DecoderCallback
decode
=
(
Uint8List
bytes
,
{
int
?
cacheWidth
,
int
?
cacheHeight
,
bool
allowUpscaling
=
false
})
{
expect
(
cacheWidth
,
20
);
expect
(
cacheWidth
,
20
);
expect
(
cacheHeight
,
30
);
expect
(
cacheHeight
,
30
);
expect
(
allowUpscaling
,
false
);
expect
(
allowUpscaling
,
false
);
called
=
true
;
called
=
true
;
return
PaintingBinding
.
instance
.
instantiateImageCodec
(
bytes
,
cacheWidth:
cacheWidth
,
cacheHeight:
cacheHeight
,
allowUpscaling:
allowUpscaling
);
return
PaintingBinding
.
instance
!
.
instantiateImageCodec
(
bytes
,
cacheWidth:
cacheWidth
,
cacheHeight:
cacheHeight
,
allowUpscaling:
allowUpscaling
);
};
};
final
ImageProvider
resizeImage
=
image
.
placeholder
;
final
ImageProvider
resizeImage
=
image
.
placeholder
;
expect
(
image
.
placeholder
,
isA
<
ResizeImage
>());
expect
(
image
.
placeholder
,
isA
<
ResizeImage
>());
...
@@ -346,12 +344,12 @@ Future<void> main() async {
...
@@ -346,12 +344,12 @@ Future<void> main() async {
);
);
bool
called
=
false
;
bool
called
=
false
;
final
DecoderCallback
decode
=
(
Uint8List
bytes
,
{
int
cacheWidth
,
int
cacheHeight
,
bool
allowUpscaling
})
{
final
DecoderCallback
decode
=
(
Uint8List
bytes
,
{
int
?
cacheWidth
,
int
?
cacheHeight
,
bool
allowUpscaling
=
false
})
{
expect
(
cacheWidth
,
null
);
expect
(
cacheWidth
,
null
);
expect
(
cacheHeight
,
null
);
expect
(
cacheHeight
,
null
);
expect
(
allowUpscaling
,
null
);
expect
(
allowUpscaling
,
false
);
called
=
true
;
called
=
true
;
return
PaintingBinding
.
instance
.
instantiateImageCodec
(
bytes
,
cacheWidth:
cacheWidth
,
cacheHeight:
cacheHeight
);
return
PaintingBinding
.
instance
!
.
instantiateImageCodec
(
bytes
,
cacheWidth:
cacheWidth
,
cacheHeight:
cacheHeight
);
};
};
// image.placeholder should be an instance of MemoryImage instead of ResizeImage
// image.placeholder should be an instance of MemoryImage instead of ResizeImage
final
ImageProvider
memoryImage
=
image
.
placeholder
;
final
ImageProvider
memoryImage
=
image
.
placeholder
;
...
...
packages/flutter/test/widgets/fade_transition_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -12,8 +10,8 @@ void main() {
...
@@ -12,8 +10,8 @@ void main() {
testWidgets
(
'FadeTransition'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'FadeTransition'
,
(
WidgetTester
tester
)
async
{
final
DebugPrintCallback
oldPrint
=
debugPrint
;
final
DebugPrintCallback
oldPrint
=
debugPrint
;
final
List
<
String
>
log
=
<
String
>[];
final
List
<
String
>
log
=
<
String
>[];
debugPrint
=
(
String
message
,
{
int
wrapWidth
})
{
debugPrint
=
(
String
?
message
,
{
int
?
wrapWidth
})
{
log
.
add
(
message
);
log
.
add
(
message
!
);
};
};
debugPrintBuildScope
=
true
;
debugPrintBuildScope
=
true
;
final
AnimationController
controller
=
AnimationController
(
final
AnimationController
controller
=
AnimationController
(
...
...
packages/flutter/test/widgets/fitted_box_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -595,12 +593,11 @@ void main() {
...
@@ -595,12 +593,11 @@ void main() {
List
<
Type
>
getLayers
()
{
List
<
Type
>
getLayers
()
{
final
List
<
Type
>
layers
=
<
Type
>[];
final
List
<
Type
>
layers
=
<
Type
>[];
Layer
layer
=
RendererBinding
.
instance
.
renderView
.
debugLayer
;
Layer
?
container
=
RendererBinding
.
instance
!.
renderView
.
debugLayer
;
while
(
layer
is
ContainerLayer
)
{
while
(
container
is
ContainerLayer
)
{
final
ContainerLayer
container
=
layer
as
ContainerLayer
;
layers
.
add
(
container
.
runtimeType
);
layers
.
add
(
container
.
runtimeType
);
expect
(
container
.
firstChild
,
same
(
container
.
lastChild
));
expect
(
container
.
firstChild
,
same
(
container
.
lastChild
));
lay
er
=
container
.
firstChild
;
contain
er
=
container
.
firstChild
;
}
}
return
layers
;
return
layers
;
}
}
packages/flutter/test/widgets/flex_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -63,18 +61,6 @@ void main() {
...
@@ -63,18 +61,6 @@ void main() {
expect
(
box
.
size
.
width
,
100.0
);
expect
(
box
.
size
.
width
,
100.0
);
});
});
testWidgets
(
'Can pass null for flex'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Row
(
textDirection:
TextDirection
.
ltr
,
children:
const
<
Widget
>[
Expanded
(
flex:
null
,
child:
Text
(
'one'
,
textDirection:
TextDirection
.
ltr
)),
Flexible
(
flex:
null
,
child:
Text
(
'two'
,
textDirection:
TextDirection
.
ltr
)),
],
),
);
});
testWidgets
(
"Doesn't overflow because of floating point accumulated error"
,
(
WidgetTester
tester
)
async
{
testWidgets
(
"Doesn't overflow because of floating point accumulated error"
,
(
WidgetTester
tester
)
async
{
// both of these cases have failed in the past due to floating point issues
// both of these cases have failed in the past due to floating point issues
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/widgets/flow_test.dart
View file @
ef119187
...
@@ -2,14 +2,12 @@
...
@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
class
TestFlowDelegate
extends
FlowDelegate
{
class
TestFlowDelegate
extends
FlowDelegate
{
TestFlowDelegate
({
this
.
startOffset
})
:
super
(
repaint:
startOffset
);
TestFlowDelegate
({
required
this
.
startOffset
})
:
super
(
repaint:
startOffset
);
final
Animation
<
double
>
startOffset
;
final
Animation
<
double
>
startOffset
;
...
@@ -23,7 +21,7 @@ class TestFlowDelegate extends FlowDelegate {
...
@@ -23,7 +21,7 @@ class TestFlowDelegate extends FlowDelegate {
double
dy
=
startOffset
.
value
;
double
dy
=
startOffset
.
value
;
for
(
int
i
=
0
;
i
<
context
.
childCount
;
++
i
)
{
for
(
int
i
=
0
;
i
<
context
.
childCount
;
++
i
)
{
context
.
paintChild
(
i
,
transform:
Matrix4
.
translationValues
(
0.0
,
dy
,
0.0
));
context
.
paintChild
(
i
,
transform:
Matrix4
.
translationValues
(
0.0
,
dy
,
0.0
));
dy
+=
0.75
*
context
.
getChildSize
(
i
).
height
;
dy
+=
0.75
*
context
.
getChildSize
(
i
)
!
.
height
;
}
}
}
}
...
@@ -149,13 +147,13 @@ void main() {
...
@@ -149,13 +147,13 @@ void main() {
],
],
),
),
);
);
ContainerLayer
layer
=
RendererBinding
.
instance
.
renderView
.
debugLayer
;
ContainerLayer
?
layer
=
RendererBinding
.
instance
!
.
renderView
.
debugLayer
;
while
(
layer
!=
null
&&
layer
is
!
OpacityLayer
)
while
(
layer
!=
null
&&
layer
is
!
OpacityLayer
)
layer
=
layer
.
firstChild
as
ContainerLayer
;
layer
=
layer
.
firstChild
as
ContainerLayer
?
;
expect
(
layer
,
isA
<
OpacityLayer
>());
expect
(
layer
,
isA
<
OpacityLayer
>());
final
OpacityLayer
opacityLayer
=
layer
as
OpacityLayer
;
final
OpacityLayer
?
opacityLayer
=
layer
as
OpacityLayer
?
;
expect
(
opacityLayer
.
alpha
,
equals
(
opacity
*
255
));
expect
(
opacityLayer
!
.
alpha
,
equals
(
opacity
*
255
));
expect
(
layer
.
firstChild
,
isA
<
TransformLayer
>());
expect
(
layer
!
.
firstChild
,
isA
<
TransformLayer
>());
});
});
testWidgets
(
'Flow can set and update clipBehavior'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Flow can set and update clipBehavior'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/widgets/focus_manager_test.dart
View file @
ef119187
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -18,7 +16,7 @@ void main() {
...
@@ -18,7 +16,7 @@ void main() {
final
GlobalKey
widgetKey
=
GlobalKey
();
final
GlobalKey
widgetKey
=
GlobalKey
();
Future
<
BuildContext
>
setupWidget
(
WidgetTester
tester
)
async
{
Future
<
BuildContext
>
setupWidget
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Container
(
key:
widgetKey
));
await
tester
.
pumpWidget
(
Container
(
key:
widgetKey
));
return
widgetKey
.
currentContext
;
return
widgetKey
.
currentContext
!
;
}
}
group
(
FocusNode
,
()
{
group
(
FocusNode
,
()
{
...
@@ -931,7 +929,7 @@ void main() {
...
@@ -931,7 +929,7 @@ void main() {
},
variant:
TargetPlatformVariant
.
all
());
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'Mouse events change initial focus highlight mode on mobile.'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Mouse events change initial focus highlight mode on mobile.'
,
(
WidgetTester
tester
)
async
{
expect
(
FocusManager
.
instance
.
highlightMode
,
equals
(
FocusHighlightMode
.
touch
));
expect
(
FocusManager
.
instance
.
highlightMode
,
equals
(
FocusHighlightMode
.
touch
));
RendererBinding
.
instance
.
initMouseTracker
();
// Clear out the mouse state.
RendererBinding
.
instance
!
.
initMouseTracker
();
// Clear out the mouse state.
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
0
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
0
);
addTearDown
(
gesture
.
removePointer
);
addTearDown
(
gesture
.
removePointer
);
await
gesture
.
moveTo
(
Offset
.
zero
);
await
gesture
.
moveTo
(
Offset
.
zero
);
...
@@ -939,7 +937,7 @@ void main() {
...
@@ -939,7 +937,7 @@ void main() {
},
variant:
TargetPlatformVariant
.
mobile
());
},
variant:
TargetPlatformVariant
.
mobile
());
testWidgets
(
'Mouse events change initial focus highlight mode on desktop.'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Mouse events change initial focus highlight mode on desktop.'
,
(
WidgetTester
tester
)
async
{
expect
(
FocusManager
.
instance
.
highlightMode
,
equals
(
FocusHighlightMode
.
traditional
));
expect
(
FocusManager
.
instance
.
highlightMode
,
equals
(
FocusHighlightMode
.
traditional
));
RendererBinding
.
instance
.
initMouseTracker
();
// Clear out the mouse state.
RendererBinding
.
instance
!
.
initMouseTracker
();
// Clear out the mouse state.
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
0
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
0
);
addTearDown
(
gesture
.
removePointer
);
addTearDown
(
gesture
.
removePointer
);
await
gesture
.
moveTo
(
Offset
.
zero
);
await
gesture
.
moveTo
(
Offset
.
zero
);
...
@@ -952,7 +950,7 @@ void main() {
...
@@ -952,7 +950,7 @@ void main() {
testWidgets
(
'Events change focus highlight mode.'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Events change focus highlight mode.'
,
(
WidgetTester
tester
)
async
{
await
setupWidget
(
tester
);
await
setupWidget
(
tester
);
int
callCount
=
0
;
int
callCount
=
0
;
FocusHighlightMode
lastMode
;
FocusHighlightMode
?
lastMode
;
void
handleModeChange
(
FocusHighlightMode
mode
)
{
void
handleModeChange
(
FocusHighlightMode
mode
)
{
lastMode
=
mode
;
lastMode
=
mode
;
callCount
++;
callCount
++;
...
...
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