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
fc1b3043
Unverified
Commit
fc1b3043
authored
Sep 11, 2018
by
Jonah Williams
Committed by
GitHub
Sep 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add text field to semantics integration test (#21665)
parent
fa0a857d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
183 additions
and
5 deletions
+183
-5
main.dart
...integration_tests/android_semantics_testing/lib/main.dart
+18
-5
text_field_constants.dart
...semantics_testing/lib/src/tests/text_field_constants.dart
+12
-0
text_field_page.dart
...roid_semantics_testing/lib/src/tests/text_field_page.dart
+45
-0
test_constants.dart
...n_tests/android_semantics_testing/lib/test_constants.dart
+1
-0
main_test.dart
...ests/android_semantics_testing/test_driver/main_test.dart
+107
-0
No files found.
dev/integration_tests/android_semantics_testing/lib/main.dart
View file @
fc1b3043
...
@@ -6,12 +6,15 @@ import 'dart:async';
...
@@ -6,12 +6,15 @@ import 'dart:async';
import
'dart:convert'
;
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_driver/driver_extension.dart'
;
import
'package:flutter_driver/driver_extension.dart'
;
import
'src/tests/controls_page.dart'
;
import
'src/tests/controls_page.dart'
;
import
'src/tests/text_field_page.dart'
;
void
main
(
)
{
void
main
(
)
{
timeDilation
=
0.05
;
// remove animations.
enableFlutterDriverExtension
(
handler:
dataHandler
);
enableFlutterDriverExtension
(
handler:
dataHandler
);
runApp
(
const
TestApp
());
runApp
(
const
TestApp
());
}
}
...
@@ -20,17 +23,26 @@ const MethodChannel kSemanticsChannel = MethodChannel('semantics');
...
@@ -20,17 +23,26 @@ const MethodChannel kSemanticsChannel = MethodChannel('semantics');
Future
<
String
>
dataHandler
(
String
message
)
async
{
Future
<
String
>
dataHandler
(
String
message
)
async
{
if
(
message
.
contains
(
'getSemanticsNode'
))
{
if
(
message
.
contains
(
'getSemanticsNode'
))
{
final
Completer
<
String
>
completer
=
new
Completer
<
String
>();
final
int
id
=
int
.
tryParse
(
message
.
split
(
'#'
)[
1
])
??
0
;
final
int
id
=
int
.
tryParse
(
message
.
split
(
'#'
)[
1
])
??
0
;
Future
<
void
>
completeSemantics
([
Object
_
])
async
{
final
dynamic
result
=
await
kSemanticsChannel
.
invokeMethod
(
'getSemanticsNode'
,
<
String
,
dynamic
>{
final
dynamic
result
=
await
kSemanticsChannel
.
invokeMethod
(
'getSemanticsNode'
,
<
String
,
dynamic
>{
'id'
:
id
,
'id'
:
id
,
});
});
return
json
.
encode
(
result
);
completer
.
complete
(
json
.
encode
(
result
));
}
if
(
SchedulerBinding
.
instance
.
hasScheduledFrame
)
SchedulerBinding
.
instance
.
addPostFrameCallback
(
completeSemantics
);
else
completeSemantics
();
return
completer
.
future
;
}
}
throw
new
UnimplementedError
();
throw
new
UnimplementedError
();
}
}
const
List
<
String
>
routes
=
<
String
>[
const
List
<
String
>
routes
=
<
String
>[
selectionControlsRoute
,
selectionControlsRoute
,
textFieldRoute
,
];
];
class
TestApp
extends
StatelessWidget
{
class
TestApp
extends
StatelessWidget
{
...
@@ -41,11 +53,12 @@ class TestApp extends StatelessWidget {
...
@@ -41,11 +53,12 @@ class TestApp extends StatelessWidget {
return
new
MaterialApp
(
return
new
MaterialApp
(
routes:
<
String
,
WidgetBuilder
>{
routes:
<
String
,
WidgetBuilder
>{
selectionControlsRoute:
(
BuildContext
context
)
=>
new
SelectionControlsPage
(),
selectionControlsRoute:
(
BuildContext
context
)
=>
new
SelectionControlsPage
(),
textFieldRoute:
(
BuildContext
context
)
=>
new
TextFieldPage
(),
},
},
home:
new
Builder
(
home:
new
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
new
Scaffold
(
return
new
Scaffold
(
body:
new
Column
(
body:
new
ListView
(
children:
routes
.
map
((
String
value
)
{
children:
routes
.
map
((
String
value
)
{
return
new
MaterialButton
(
return
new
MaterialButton
(
child:
new
Text
(
value
),
child:
new
Text
(
value
),
...
...
dev/integration_tests/android_semantics_testing/lib/src/tests/text_field_constants.dart
0 → 100644
View file @
fc1b3043
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// The name of the route containing the text field tests.
const
String
textFieldRoute
=
'textField'
;
/// The string supplied to the [ValueKey] for the normal text field.
const
String
normalTextFieldKeyValue
=
'textFieldNormal'
;
/// The string supplied to the [ValueKey] for the password text field.
const
String
passwordTextFieldKeyValue
=
'passwordField'
;
dev/integration_tests/android_semantics_testing/lib/src/tests/text_field_page.dart
0 → 100644
View file @
fc1b3043
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'text_field_constants.dart'
;
export
'text_field_constants.dart'
;
/// A page with a normal text field and a password field.
class
TextFieldPage
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
=>
new
_TextFieldPageState
();
}
class
_TextFieldPageState
extends
State
<
TextFieldPage
>
{
final
TextEditingController
_normalController
=
new
TextEditingController
();
final
TextEditingController
_passwordController
=
new
TextEditingController
();
final
Key
normalTextFieldKey
=
const
ValueKey
<
String
>(
normalTextFieldKeyValue
);
final
Key
passwordTextFieldKey
=
const
ValueKey
<
String
>(
passwordTextFieldKeyValue
);
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scaffold
(
appBar:
new
AppBar
(
leading:
const
BackButton
(
key:
ValueKey
<
String
>(
'back'
))),
body:
new
Material
(
child:
new
Column
(
children:
<
Widget
>[
new
TextField
(
key:
normalTextFieldKey
,
controller:
_normalController
,
autofocus:
false
,
),
const
Spacer
(),
new
TextField
(
key:
passwordTextFieldKey
,
controller:
_passwordController
,
obscureText:
true
,
autofocus:
false
,
),
],
),
));
}
}
dev/integration_tests/android_semantics_testing/lib/test_constants.dart
View file @
fc1b3043
...
@@ -3,3 +3,4 @@
...
@@ -3,3 +3,4 @@
// found in the LICENSE file.
// found in the LICENSE file.
export
'src/tests/controls_constants.dart'
;
export
'src/tests/controls_constants.dart'
;
export
'src/tests/text_field_constants.dart'
;
dev/integration_tests/android_semantics_testing/test_driver/main_test.dart
View file @
fc1b3043
...
@@ -47,6 +47,113 @@ void main() {
...
@@ -47,6 +47,113 @@ void main() {
await
run
.
exitCode
;
await
run
.
exitCode
;
driver
?.
close
();
driver
?.
close
();
});
});
group
(
'TextField'
,
()
{
setUpAll
(()
async
{
await
driver
.
tap
(
find
.
text
(
textFieldRoute
));
});
test
(
'TextField has correct Android semantics'
,
()
async
{
final
SerializableFinder
normalTextField
=
find
.
byValueKey
(
normalTextFieldKeyValue
);
expect
(
await
getSemantics
(
normalTextField
),
hasAndroidSemantics
(
className:
AndroidClassName
.
editText
,
isEditable:
true
,
isFocusable:
true
,
isFocused:
false
,
isPassword:
false
,
actions:
<
AndroidSemanticsAction
>[
AndroidSemanticsAction
.
click
,
AndroidSemanticsAction
.
accessibilityFocus
,
],
));
await
driver
.
tap
(
normalTextField
);
expect
(
await
getSemantics
(
normalTextField
),
hasAndroidSemantics
(
className:
AndroidClassName
.
editText
,
isFocusable:
true
,
isFocused:
true
,
isEditable:
true
,
isPassword:
false
,
actions:
<
AndroidSemanticsAction
>[
AndroidSemanticsAction
.
click
,
AndroidSemanticsAction
.
accessibilityFocus
,
AndroidSemanticsAction
.
setSelection
,
AndroidSemanticsAction
.
copy
,
],
));
await
driver
.
enterText
(
'hello world'
);
expect
(
await
getSemantics
(
normalTextField
),
hasAndroidSemantics
(
text:
'hello world'
,
className:
AndroidClassName
.
editText
,
isFocusable:
true
,
isFocused:
true
,
isEditable:
true
,
isPassword:
false
,
actions:
<
AndroidSemanticsAction
>[
AndroidSemanticsAction
.
click
,
AndroidSemanticsAction
.
accessibilityFocus
,
AndroidSemanticsAction
.
setSelection
,
AndroidSemanticsAction
.
copy
,
],
));
});
test
(
'password TextField has correct Android semantics'
,
()
async
{
final
SerializableFinder
passwordTextField
=
find
.
byValueKey
(
passwordTextFieldKeyValue
);
expect
(
await
getSemantics
(
passwordTextField
),
hasAndroidSemantics
(
className:
AndroidClassName
.
editText
,
isEditable:
true
,
isFocusable:
true
,
isFocused:
false
,
isPassword:
true
,
actions:
<
AndroidSemanticsAction
>[
AndroidSemanticsAction
.
click
,
AndroidSemanticsAction
.
accessibilityFocus
,
],
));
await
driver
.
tap
(
passwordTextField
);
expect
(
await
getSemantics
(
passwordTextField
),
hasAndroidSemantics
(
className:
AndroidClassName
.
editText
,
isFocusable:
true
,
isFocused:
true
,
isEditable:
true
,
isPassword:
true
,
actions:
<
AndroidSemanticsAction
>[
AndroidSemanticsAction
.
click
,
AndroidSemanticsAction
.
accessibilityFocus
,
AndroidSemanticsAction
.
setSelection
,
AndroidSemanticsAction
.
copy
,
],
));
await
driver
.
enterText
(
'hello world'
);
expect
(
await
getSemantics
(
passwordTextField
),
hasAndroidSemantics
(
text:
'
\
u{2022}'
*
(
'hello world'
.
length
),
className:
AndroidClassName
.
editText
,
isFocusable:
true
,
isFocused:
true
,
isEditable:
true
,
isPassword:
true
,
actions:
<
AndroidSemanticsAction
>[
AndroidSemanticsAction
.
click
,
AndroidSemanticsAction
.
accessibilityFocus
,
AndroidSemanticsAction
.
setSelection
,
AndroidSemanticsAction
.
copy
,
],
));
});
tearDownAll
(()
async
{
await
driver
.
tap
(
find
.
byValueKey
(
'back'
));
});
});
group
(
'SelectionControls'
,
()
{
group
(
'SelectionControls'
,
()
{
setUpAll
(()
async
{
setUpAll
(()
async
{
await
driver
.
tap
(
find
.
text
(
selectionControlsRoute
));
await
driver
.
tap
(
find
.
text
(
selectionControlsRoute
));
...
...
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