diff --git a/packages/flutter_driver/lib/src/driver/timeline.dart b/packages/flutter_driver/lib/src/driver/timeline.dart index dc7ddc57802..fdc85a84a5c 100644 --- a/packages/flutter_driver/lib/src/driver/timeline.dart +++ b/packages/flutter_driver/lib/src/driver/timeline.dart @@ -122,12 +122,13 @@ class TimelineEvent { } List _parseEvents(Map json) { - final List> jsonEvents = json['traceEvents']; + final List jsonEvents = json['traceEvents']; if (jsonEvents == null) return null; - return jsonEvents + // TODO(vegorov) use instance method version of castFrom when it is available. + return Iterable.castFrom>(jsonEvents) .map((Map eventJson) => new TimelineEvent(eventJson)) .toList(); } diff --git a/packages/flutter_driver/lib/src/extension/extension.dart b/packages/flutter_driver/lib/src/extension/extension.dart index 95ab580abaf..18c7631c704 100644 --- a/packages/flutter_driver/lib/src/extension/extension.dart +++ b/packages/flutter_driver/lib/src/extension/extension.dart @@ -125,10 +125,10 @@ class FlutterDriverExtension { }); _finders.addAll({ - 'ByText': _createByTextFinder, - 'ByTooltipMessage': _createByTooltipMessageFinder, - 'ByValueKey': _createByValueKeyFinder, - 'ByType': _createByTypeFinder, + 'ByText': (SerializableFinder finder) => _createByTextFinder(finder), + 'ByTooltipMessage': (SerializableFinder finder) => _createByTooltipMessageFinder(finder), + 'ByValueKey': (SerializableFinder finder) => _createByValueKeyFinder(finder), + 'ByType': (SerializableFinder finder) => _createByTypeFinder(finder), }); } diff --git a/packages/flutter_driver/test/flutter_driver_test.dart b/packages/flutter_driver/test/flutter_driver_test.dart index 1ba4ac464e4..1a9228625a8 100644 --- a/packages/flutter_driver/test/flutter_driver_test.dart +++ b/packages/flutter_driver/test/flutter_driver_test.dart @@ -40,7 +40,7 @@ void main() { when(mockClient.getVM()).thenReturn(mockVM); when(mockVM.isolates).thenReturn([mockIsolate]); when(mockIsolate.loadRunnable()).thenReturn(mockIsolate); - when(mockIsolate.invokeExtension(any, any)).thenAnswer( + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer( (Invocation invocation) => makeMockResponse({'status': 'ok'})); vmServiceConnectFunction = (String url) { return new Future.value( @@ -124,7 +124,7 @@ void main() { }); test('checks the health of the driver extension', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer( + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer( (Invocation invocation) => makeMockResponse({'status': 'ok'})); final Health result = await driver.checkHealth(); expect(result.status, HealthStatus.ok); @@ -142,7 +142,7 @@ void main() { }); test('finds by ValueKey', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer((Invocation i) { expect(i.positionalArguments[1], { 'command': 'tap', 'timeout': _kSerializedTestTimeout, @@ -162,7 +162,7 @@ void main() { }); test('sends the tap command', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer((Invocation i) { expect(i.positionalArguments[1], { 'command': 'tap', 'timeout': _kSerializedTestTimeout, @@ -181,7 +181,7 @@ void main() { }); test('sends the getText command', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer((Invocation i) { expect(i.positionalArguments[1], { 'command': 'get_text', 'timeout': _kSerializedTestTimeout, @@ -204,7 +204,7 @@ void main() { }); test('sends the waitFor command', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer((Invocation i) { expect(i.positionalArguments[1], { 'command': 'waitFor', 'finderType': 'ByTooltipMessage', @@ -219,7 +219,7 @@ void main() { group('waitUntilNoTransientCallbacks', () { test('sends the waitUntilNoTransientCallbacks command', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer((Invocation i) { expect(i.positionalArguments[1], { 'command': 'waitUntilNoTransientCallbacks', 'timeout': _kSerializedTestTimeout, @@ -356,7 +356,7 @@ void main() { group('sendCommand error conditions', () { test('local timeout', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer((Invocation i) { // completer never competed to trigger timeout return new Completer>().future; }); @@ -370,7 +370,7 @@ void main() { }); test('remote error', () async { - when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { + when(mockIsolate.invokeExtension(typed(any), typed(any))).thenAnswer((Invocation i) { return makeMockResponse({ 'message': 'This is a failure' }, isError: true);