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
c1c5b492
Unverified
Commit
c1c5b492
authored
Apr 02, 2021
by
LongCatIsLooong
Committed by
GitHub
Apr 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland 79654 (#79656)
parent
8859f7a7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
19 deletions
+64
-19
constants.dart
...on_tests/android_semantics_testing/lib/src/constants.dart
+2
-2
main_test.dart
...ests/android_semantics_testing/test_driver/main_test.dart
+2
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+33
-15
test_text_input.dart
packages/flutter_test/lib/src/test_text_input.dart
+4
-0
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+5
-2
test_text_input_test.dart
packages/flutter_test/test/test_text_input_test.dart
+18
-0
No files found.
dev/integration_tests/android_semantics_testing/lib/src/constants.dart
View file @
c1c5b492
...
...
@@ -144,7 +144,7 @@ class AndroidSemanticsAction {
case
_kNextAtMovementGranularityIndex:
return
'AndroidSemanticsAction.nextAtMovementGranularity'
;
case
_kPreviousAtMovementGranularityIndex:
return
'AndroidSemanticsAction.
next
AtMovementGranularity'
;
return
'AndroidSemanticsAction.
previous
AtMovementGranularity'
;
case
_kNextHtmlElementIndex:
return
'AndroidSemanticsAction.nextHtmlElement'
;
case
_kPreviousHtmlElementIndex:
...
...
@@ -182,7 +182,7 @@ class AndroidSemanticsAction {
_kAccessibilityFocusIndex:
accessibilityFocus
,
_kClearAccessibilityFocusIndex:
clearAccessibilityFocus
,
_kNextAtMovementGranularityIndex:
nextAtMovementGranularity
,
_kPreviousAtMovementGranularityIndex:
next
AtMovementGranularity
,
_kPreviousAtMovementGranularityIndex:
previous
AtMovementGranularity
,
_kNextHtmlElementIndex:
nextHtmlElement
,
_kPreviousHtmlElementIndex:
previousHtmlElement
,
_kScrollForwardIndex:
scrollForward
,
...
...
dev/integration_tests/android_semantics_testing/test_driver/main_test.dart
View file @
c1c5b492
...
...
@@ -157,6 +157,7 @@ void main() {
AndroidSemanticsAction
.
copy
,
AndroidSemanticsAction
.
setSelection
,
AndroidSemanticsAction
.
setText
,
AndroidSemanticsAction
.
previousAtMovementGranularity
,
],
),
);
...
...
@@ -224,6 +225,7 @@ void main() {
AndroidSemanticsAction
.
copy
,
AndroidSemanticsAction
.
setSelection
,
AndroidSemanticsAction
.
setText
,
AndroidSemanticsAction
.
previousAtMovementGranularity
,
],
),
);
...
...
packages/flutter/test/material/text_field_test.dart
View file @
c1c5b492
...
...
@@ -848,18 +848,24 @@ void main() {
);
testWidgets
(
'cursor layout has correct width'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
.
fromValue
(
const
TextEditingValue
(
selection:
TextSelection
.
collapsed
(
offset:
0
)),
);
final
FocusNode
focusNode
=
FocusNode
();
EditableText
.
debugDeterministicCursor
=
true
;
await
tester
.
pumpWidget
(
overlay
(
child:
const
RepaintBoundary
(
child:
RepaintBoundary
(
child:
TextField
(
cursorWidth:
15.0
,
controller:
controller
,
focusNode:
focusNode
,
),
),
)
);
await
tester
.
enterText
(
find
.
byType
(
TextField
),
' '
);
await
skipPastScrollingAnimation
(
tester
);
focusNode
.
requestFocus
(
);
await
tester
.
pump
(
);
await
expectLater
(
find
.
byType
(
TextField
),
...
...
@@ -869,19 +875,25 @@ void main() {
});
testWidgets
(
'cursor layout has correct radius'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
.
fromValue
(
const
TextEditingValue
(
selection:
TextSelection
.
collapsed
(
offset:
0
)),
);
final
FocusNode
focusNode
=
FocusNode
();
EditableText
.
debugDeterministicCursor
=
true
;
await
tester
.
pumpWidget
(
overlay
(
child:
const
RepaintBoundary
(
child:
RepaintBoundary
(
child:
TextField
(
cursorWidth:
15.0
,
cursorRadius:
Radius
.
circular
(
3.0
),
cursorRadius:
const
Radius
.
circular
(
3.0
),
controller:
controller
,
focusNode:
focusNode
,
),
),
)
);
await
tester
.
enterText
(
find
.
byType
(
TextField
),
' '
);
await
skipPastScrollingAnimation
(
tester
);
focusNode
.
requestFocus
(
);
await
tester
.
pump
(
);
await
expectLater
(
find
.
byType
(
TextField
),
...
...
@@ -891,19 +903,25 @@ void main() {
});
testWidgets
(
'cursor layout has correct height'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
.
fromValue
(
const
TextEditingValue
(
selection:
TextSelection
.
collapsed
(
offset:
0
)),
);
final
FocusNode
focusNode
=
FocusNode
();
EditableText
.
debugDeterministicCursor
=
true
;
await
tester
.
pumpWidget
(
overlay
(
child:
const
RepaintBoundary
(
child:
RepaintBoundary
(
child:
TextField
(
cursorWidth:
15.0
,
cursorHeight:
30.0
,
controller:
controller
,
focusNode:
focusNode
,
),
),
)
);
await
tester
.
enterText
(
find
.
byType
(
TextField
),
' '
);
await
skipPastScrollingAnimation
(
tester
);
focusNode
.
requestFocus
(
);
await
tester
.
pump
(
);
await
expectLater
(
find
.
byType
(
TextField
),
...
...
@@ -1115,8 +1133,8 @@ void main() {
await
tester
.
tapAt
(
ePos
);
await
tester
.
pump
();
expect
(
controller
.
selection
.
baseOffset
,
-
1
);
expect
(
controller
.
selection
.
extentOffset
,
-
1
);
expect
(
controller
.
selection
.
baseOffset
,
testValue
.
length
);
expect
(
controller
.
selection
.
isCollapsed
,
isTrue
);
});
testWidgets
(
'Can long press to select'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -1584,8 +1602,7 @@ void main() {
await
tester
.
pump
();
expect
(
controller
.
selection
.
isCollapsed
,
true
);
expect
(
controller
.
selection
.
baseOffset
,
-
1
);
expect
(
controller
.
selection
.
extentOffset
,
-
1
);
expect
(
controller
.
selection
.
baseOffset
,
testValue
.
length
);
});
testWidgets
(
'Can select text by dragging with a mouse'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -5218,7 +5235,8 @@ void main() {
const
String
testValue
=
'x'
;
await
tester
.
enterText
(
find
.
byType
(
TextField
),
testValue
);
await
skipPastScrollingAnimation
(
tester
);
expect
(
controller
.
selection
.
baseOffset
,
-
1
);
expect
(
controller
.
selection
.
isCollapsed
,
true
);
expect
(
controller
.
selection
.
baseOffset
,
testValue
.
length
);
// Tap the selection handle to bring up the "paste / select all" menu.
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
0
));
...
...
packages/flutter_test/lib/src/test_text_input.dart
View file @
c1c5b492
...
...
@@ -166,10 +166,14 @@ class TestTextInput {
}
/// Simulates the user typing the given text.
///
/// Calling this method replaces the content of the connected input field with
/// `text`, and places the caret at the end of the text.
void
enterText
(
String
text
)
{
assert
(
isRegistered
);
updateEditingValue
(
TextEditingValue
(
text:
text
,
selection:
TextSelection
.
collapsed
(
offset:
text
.
length
),
));
}
...
...
packages/flutter_test/lib/src/widget_tester.dart
View file @
c1c5b492
...
...
@@ -1040,13 +1040,16 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
});
}
/// Give the text input widget specified by [finder] the focus and
///
enter [text] as if it
been provided by the onscreen keyboard.
/// Give the text input widget specified by [finder] the focus and
replace its
///
content with [text], as if it had
been provided by the onscreen keyboard.
///
/// The widget specified by [finder] must be an [EditableText] or have
/// an [EditableText] descendant. For example `find.byType(TextField)`
/// or `find.byType(TextFormField)`, or `find.byType(EditableText)`.
///
/// When the returned future completes, the text input widget's text will be
/// exactly `text`, and the caret will be placed at the end of `text`.
///
/// To just give [finder] the focus without entering any text,
/// see [showKeyboard].
Future
<
void
>
enterText
(
Finder
finder
,
String
text
)
async
{
...
...
packages/flutter_test/test/test_text_input_test.dart
View file @
c1c5b492
...
...
@@ -7,6 +7,24 @@ import 'package:flutter/services.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'enterText works'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Material
(
child:
TextField
(),
),
),
);
final
EditableTextState
state
=
tester
.
state
(
find
.
byType
(
EditableText
));
expect
(
state
.
textEditingValue
.
text
,
''
);
await
tester
.
enterText
(
find
.
byType
(
EditableText
),
'let there be text'
);
expect
(
state
.
textEditingValue
.
text
,
'let there be text'
);
expect
(
state
.
textEditingValue
.
selection
.
isCollapsed
,
isTrue
);
expect
(
state
.
textEditingValue
.
selection
.
baseOffset
,
17
);
});
testWidgets
(
'receiveAction() forwards exception when exception occurs during action processing'
,
(
WidgetTester
tester
)
async
{
// Setup a widget that can receive focus so that we can open the keyboard.
const
Widget
widget
=
MaterialApp
(
...
...
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