only tap on widgets reachable by hit testing (#11767)
* only tap on widgets reachable by hit testing * use FractionalOffset * added tests * check finder finds correct widget * undo unintentional changes * address comments * style fix * add Directionality in test * fix analysis warning
This commit is contained in:
@@ -21,7 +21,14 @@ Future<TaskResult> runEndToEndTests() async {
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.ios)
|
||||
await prepareProvisioningCertificates(testDirectory.path);
|
||||
|
||||
await flutter('drive', options: <String>['--verbose', '-d', deviceId, 'lib/keyboard_resize.dart']);
|
||||
const List<String> entryPoints = const <String>[
|
||||
'lib/keyboard_resize.dart',
|
||||
'lib/driver.dart',
|
||||
];
|
||||
|
||||
for (final String entryPoint in entryPoints) {
|
||||
await flutter('drive', options: <String>['--verbose', '-d', deviceId, entryPoint]);
|
||||
}
|
||||
});
|
||||
|
||||
return new TaskResult.success(<String, dynamic>{});
|
||||
|
||||
@@ -23,6 +23,7 @@ class DriverTestApp extends StatefulWidget {
|
||||
|
||||
class DriverTestAppState extends State<DriverTestApp> {
|
||||
bool present = true;
|
||||
Letter _selectedValue = Letter.a;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -52,9 +53,41 @@ class DriverTestAppState extends State<DriverTestApp> {
|
||||
),
|
||||
],
|
||||
),
|
||||
new Row(
|
||||
children: <Widget>[
|
||||
const Expanded(
|
||||
child: const Text('hit testability'),
|
||||
),
|
||||
new DropdownButton<Letter>(
|
||||
key: const ValueKey<String>('dropdown'),
|
||||
value: _selectedValue,
|
||||
onChanged: (Letter newValue) {
|
||||
setState(() {
|
||||
_selectedValue = newValue;
|
||||
});
|
||||
},
|
||||
items: <DropdownMenuItem<Letter>>[
|
||||
const DropdownMenuItem<Letter>(
|
||||
value: Letter.a,
|
||||
child: const Text('Aaa', key: const ValueKey<String>('a')),
|
||||
),
|
||||
const DropdownMenuItem<Letter>(
|
||||
value: Letter.b,
|
||||
child: const Text('Bbb', key: const ValueKey<String>('b')),
|
||||
),
|
||||
const DropdownMenuItem<Letter>(
|
||||
value: Letter.c,
|
||||
child: const Text('Ccc', key: const ValueKey<String>('c')),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum Letter { a, b, c }
|
||||
|
||||
@@ -77,5 +77,21 @@ void main() {
|
||||
test('waitForAbsent resolves immediately when the element does not exist', () async {
|
||||
await driver.waitForAbsent(find.text('that does not exist'));
|
||||
});
|
||||
|
||||
test('uses hit test to determine tappable elements', () async {
|
||||
final SerializableFinder a = find.byValueKey('a');
|
||||
final SerializableFinder menu = find.byType('_DropdownMenu<Letter>');
|
||||
|
||||
// Dropdown is closed
|
||||
await driver.waitForAbsent(menu);
|
||||
|
||||
// Open dropdown
|
||||
await driver.tap(a);
|
||||
await driver.waitFor(menu);
|
||||
|
||||
// Close it again
|
||||
await driver.tap(a);
|
||||
await driver.waitForAbsent(menu);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user