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