Add semantic label finders (#29342)

* Add semantic label finders
This commit is contained in:
Dan Field
2019-03-18 20:32:03 -07:00
committed by GitHub
parent 79e3bf4ad3
commit 5e27ebbe8d
6 changed files with 206 additions and 0 deletions

View File

@@ -158,6 +158,35 @@ void main() {
});
});
group('BySemanticsLabel', () {
test('finds by Semantic label using String', () async {
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
expect(i.positionalArguments[1], <String, String>{
'command': 'tap',
'timeout': _kSerializedTestTimeout,
'finderType': 'BySemanticsLabel',
'label': 'foo',
});
return makeMockResponse(<String, dynamic>{});
});
await driver.tap(find.bySemanticsLabel('foo'), timeout: _kTestTimeout);
});
test('finds by Semantic label using RegExp', () async {
when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) {
expect(i.positionalArguments[1], <String, String>{
'command': 'tap',
'timeout': _kSerializedTestTimeout,
'finderType': 'BySemanticsLabel',
'label': '^foo',
'isRegExp': 'true',
});
return makeMockResponse(<String, dynamic>{});
});
await driver.tap(find.bySemanticsLabel(RegExp('^foo')), timeout: _kTestTimeout);
});
});
group('tap', () {
test('requires a target reference', () async {
expect(driver.tap(null), throwsA(isInstanceOf<DriverError>()));