From 4ebe18c83df275e07270bfd16f00a2828d4383a7 Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Tue, 14 Jul 2020 19:34:02 -0400 Subject: [PATCH 01/11] add extra info report --- packages/e2e/lib/common.dart | 38 ++++++++++++++++++++++++++++-------- packages/e2e/lib/e2e.dart | 18 +++++++++++++++-- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/packages/e2e/lib/common.dart b/packages/e2e/lib/common.dart index 39efcc867704..559cc50af971 100644 --- a/packages/e2e/lib/common.dart +++ b/packages/e2e/lib/common.dart @@ -11,13 +11,20 @@ class Response { final bool _allTestsPassed; + /// The extra information to be added along side the test result. + /// + /// Specially `'result'` and `'failureDetails'` keys are occupied, and will + /// be ignored. + Map extraInfo; + /// Constructor to use for positive response. - Response.allTestsPassed() + Response.allTestsPassed([this.extraInfo]) : this._allTestsPassed = true, this._failureDetails = null; /// Constructor for failure response. - Response.someTestsFailed(this._failureDetails) : this._allTestsPassed = false; + Response.someTestsFailed(this._failureDetails, [this.extraInfo]) + : this._allTestsPassed = false; /// Whether the test ran successfully or not. bool get allTestsPassed => _allTestsPassed; @@ -30,19 +37,34 @@ class Response { List get failureDetails => _failureDetails; /// Serializes this message to a JSON map. - String toJson() => json.encode({ - 'result': allTestsPassed.toString(), - 'failureDetails': _failureDetailsAsString(), + String toJson() { + Map result = {}; + result['result'] = allTestsPassed.toString(); + result['failureDetails'] = _failureDetailsAsString(); + if (extraInfo != null) { + extraInfo.forEach((String key, dynamic value) { + if (key != 'result' && key != 'failureDetails') { + result[key] = value; + } }); + } + return json.encode(result); + } /// Deserializes the result from JSON. static Response fromJson(String source) { Map responseJson = json.decode(source); - if (responseJson['result'] == 'true') { - return Response.allTestsPassed(); + String result = responseJson['result'] as String; + responseJson.remove('result'); + dynamic detail = responseJson['failureDetails']; + responseJson.remove('failureDetails'); + if (result == 'true') { + return Response.allTestsPassed(responseJson); } else { return Response.someTestsFailed( - _failureDetailsFromJson(responseJson['failureDetails'])); + _failureDetailsFromJson(detail), + responseJson, + ); } } diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index ec1615e904b4..082c31da74ee 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -78,6 +78,20 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { static Map _results = {}; + Map _reports; + /// Add fields to the reported result. + /// + /// The values in `report` should be json-serializable objects. + /// + /// For keys in `report` that's previously added, it will over write the + /// original values. + void addReportResult(Map report) { + _reports ??= {}; + report.forEach((String key, dynamic value) { + _reports[key] = value; + }); + } + // Emulates the Flutter driver extension, returning 'pass' or 'fail'. @override void initServiceExtensions() { @@ -90,8 +104,8 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { final bool allTestsPassed = await _allTestsPassed.future; response = { 'message': allTestsPassed - ? Response.allTestsPassed().toJson() - : Response.someTestsFailed(_failureMethodsDetails).toJson(), + ? Response.allTestsPassed(_reports).toJson() + : Response.someTestsFailed(_failureMethodsDetails, _reports).toJson(), }; break; case 'get_health': From 317eef1dcd61a83baf65446e77f1c67cd8b780cf Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Tue, 14 Jul 2020 19:36:38 -0400 Subject: [PATCH 02/11] update version --- packages/e2e/CHANGELOG.md | 4 ++++ packages/e2e/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/e2e/CHANGELOG.md b/packages/e2e/CHANGELOG.md index ad2f8d3e24f0..e97210eb6a65 100644 --- a/packages/e2e/CHANGELOG.md +++ b/packages/e2e/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.1 + +* Added `extraInfo` in the reported json. + ## 0.6.0 * **Breaking change** `E2EPlugin` exports a `Future` for `testResults`. diff --git a/packages/e2e/pubspec.yaml b/packages/e2e/pubspec.yaml index 25eeb3ce1374..c489b4cb92bb 100644 --- a/packages/e2e/pubspec.yaml +++ b/packages/e2e/pubspec.yaml @@ -1,6 +1,6 @@ name: e2e description: Runs tests that use the flutter_test API as integration tests. -version: 0.6.0 +version: 0.6.1 homepage: https://github.com/flutter/plugins/tree/master/packages/e2e environment: From 182f6ad073b9d678349b21613f26409916a8dd7f Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Tue, 14 Jul 2020 21:06:26 -0400 Subject: [PATCH 03/11] formatting --- packages/e2e/lib/common.dart | 10 +++++----- packages/e2e/lib/e2e.dart | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/e2e/lib/common.dart b/packages/e2e/lib/common.dart index 559cc50af971..3079aa86b920 100644 --- a/packages/e2e/lib/common.dart +++ b/packages/e2e/lib/common.dart @@ -24,7 +24,7 @@ class Response { /// Constructor for failure response. Response.someTestsFailed(this._failureDetails, [this.extraInfo]) - : this._allTestsPassed = false; + : this._allTestsPassed = false; /// Whether the test ran successfully or not. bool get allTestsPassed => _allTestsPassed; @@ -38,7 +38,7 @@ class Response { /// Serializes this message to a JSON map. String toJson() { - Map result = {}; + final Map result = {}; result['result'] = allTestsPassed.toString(); result['failureDetails'] = _failureDetailsAsString(); if (extraInfo != null) { @@ -53,10 +53,10 @@ class Response { /// Deserializes the result from JSON. static Response fromJson(String source) { - Map responseJson = json.decode(source); - String result = responseJson['result'] as String; + final Map responseJson = json.decode(source); + final String result = responseJson['result'] as String; responseJson.remove('result'); - dynamic detail = responseJson['failureDetails']; + final dynamic detail = responseJson['failureDetails']; responseJson.remove('failureDetails'); if (result == 'true') { return Response.allTestsPassed(responseJson); diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index 082c31da74ee..c76f1c8762f6 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -79,6 +79,7 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { static Map _results = {}; Map _reports; + /// Add fields to the reported result. /// /// The values in `report` should be json-serializable objects. @@ -105,7 +106,8 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { response = { 'message': allTestsPassed ? Response.allTestsPassed(_reports).toJson() - : Response.someTestsFailed(_failureMethodsDetails, _reports).toJson(), + : Response.someTestsFailed(_failureMethodsDetails, _reports) + .toJson(), }; break; case 'get_health': From 5e3d1a7372d727dd3774d88023cbe91cdecab5a7 Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 14:37:27 -0400 Subject: [PATCH 04/11] Modify according to dnfield@ --- packages/e2e/lib/common.dart | 8 ++++---- packages/e2e/lib/e2e.dart | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/e2e/lib/common.dart b/packages/e2e/lib/common.dart index 3079aa86b920..974350b5d7e2 100644 --- a/packages/e2e/lib/common.dart +++ b/packages/e2e/lib/common.dart @@ -18,12 +18,12 @@ class Response { Map extraInfo; /// Constructor to use for positive response. - Response.allTestsPassed([this.extraInfo]) + Response.allTestsPassed({this.extraInfo}) : this._allTestsPassed = true, this._failureDetails = null; /// Constructor for failure response. - Response.someTestsFailed(this._failureDetails, [this.extraInfo]) + Response.someTestsFailed(this._failureDetails, {this.extraInfo}) : this._allTestsPassed = false; /// Whether the test ran successfully or not. @@ -59,11 +59,11 @@ class Response { final dynamic detail = responseJson['failureDetails']; responseJson.remove('failureDetails'); if (result == 'true') { - return Response.allTestsPassed(responseJson); + return Response.allTestsPassed(extraInfo: responseJson); } else { return Response.someTestsFailed( _failureDetailsFromJson(detail), - responseJson, + extraInfo: responseJson, ); } } diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index c76f1c8762f6..788487cafa50 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -105,9 +105,11 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { final bool allTestsPassed = await _allTestsPassed.future; response = { 'message': allTestsPassed - ? Response.allTestsPassed(_reports).toJson() - : Response.someTestsFailed(_failureMethodsDetails, _reports) - .toJson(), + ? Response.allTestsPassed(extraInfo: _reports).toJson() + : Response.someTestsFailed( + _failureMethodsDetails, + extraInfo: _reports, + ).toJson(), }; break; case 'get_health': From 9d31c559589aff27e34d0aec681d3c1ab3af89dc Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 14:51:52 -0400 Subject: [PATCH 05/11] extraInfo -> data --- packages/e2e/CHANGELOG.md | 2 +- packages/e2e/lib/common.dart | 31 +++++++++---------------------- packages/e2e/lib/e2e.dart | 18 +++++++++--------- packages/e2e/pubspec.yaml | 2 +- 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/packages/e2e/CHANGELOG.md b/packages/e2e/CHANGELOG.md index e97210eb6a65..255d7ce08c2d 100644 --- a/packages/e2e/CHANGELOG.md +++ b/packages/e2e/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.6.1 -* Added `extraInfo` in the reported json. +* Added `data` in the reported json. ## 0.6.0 diff --git a/packages/e2e/lib/common.dart b/packages/e2e/lib/common.dart index 974350b5d7e2..61d3806812e7 100644 --- a/packages/e2e/lib/common.dart +++ b/packages/e2e/lib/common.dart @@ -12,18 +12,15 @@ class Response { final bool _allTestsPassed; /// The extra information to be added along side the test result. - /// - /// Specially `'result'` and `'failureDetails'` keys are occupied, and will - /// be ignored. - Map extraInfo; + Map data; /// Constructor to use for positive response. - Response.allTestsPassed({this.extraInfo}) + Response.allTestsPassed({this.data}) : this._allTestsPassed = true, this._failureDetails = null; /// Constructor for failure response. - Response.someTestsFailed(this._failureDetails, {this.extraInfo}) + Response.someTestsFailed(this._failureDetails, {this.data}) : this._allTestsPassed = false; /// Whether the test ran successfully or not. @@ -37,33 +34,23 @@ class Response { List get failureDetails => _failureDetails; /// Serializes this message to a JSON map. - String toJson() { - final Map result = {}; - result['result'] = allTestsPassed.toString(); - result['failureDetails'] = _failureDetailsAsString(); - if (extraInfo != null) { - extraInfo.forEach((String key, dynamic value) { - if (key != 'result' && key != 'failureDetails') { - result[key] = value; - } + String toJson() => json.encode({ + 'result': allTestsPassed.toString(), + 'failureDetails': _failureDetailsAsString(), + if (data != null) 'data': data }); - } - return json.encode(result); - } /// Deserializes the result from JSON. static Response fromJson(String source) { final Map responseJson = json.decode(source); final String result = responseJson['result'] as String; - responseJson.remove('result'); final dynamic detail = responseJson['failureDetails']; - responseJson.remove('failureDetails'); if (result == 'true') { - return Response.allTestsPassed(extraInfo: responseJson); + return Response.allTestsPassed(data: responseJson['data']); } else { return Response.someTestsFailed( _failureDetailsFromJson(detail), - extraInfo: responseJson, + data: responseJson['data'], ); } } diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index 788487cafa50..7867e50c378e 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -78,18 +78,18 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { static Map _results = {}; - Map _reports; + Map _data; /// Add fields to the reported result. /// - /// The values in `report` should be json-serializable objects. + /// The values in `data` should be json-serializable objects. /// - /// For keys in `report` that's previously added, it will over write the + /// For keys in `data` that's previously added, it will over write the /// original values. - void addReportResult(Map report) { - _reports ??= {}; - report.forEach((String key, dynamic value) { - _reports[key] = value; + void addData(Map data) { + _data ??= {}; + data.forEach((String key, dynamic value) { + _data[key] = value; }); } @@ -105,10 +105,10 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { final bool allTestsPassed = await _allTestsPassed.future; response = { 'message': allTestsPassed - ? Response.allTestsPassed(extraInfo: _reports).toJson() + ? Response.allTestsPassed(data: _data).toJson() : Response.someTestsFailed( _failureMethodsDetails, - extraInfo: _reports, + data: _data, ).toJson(), }; break; diff --git a/packages/e2e/pubspec.yaml b/packages/e2e/pubspec.yaml index c489b4cb92bb..70e57d0cb4f7 100644 --- a/packages/e2e/pubspec.yaml +++ b/packages/e2e/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.6.1 homepage: https://github.com/flutter/plugins/tree/master/packages/e2e environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.2.2 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" dependencies: From f9eb6db62d983d2bc8612b99b43516876fee5547 Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 16:26:06 -0400 Subject: [PATCH 06/11] add unit test to e2e --- packages/e2e/lib/e2e.dart | 55 ++++++++++--------- packages/e2e/test/binding_test.dart | 41 ++++++++++++++ .../e2e/test/response_serialization_test.dart | 47 ++++++++++++++++ 3 files changed, 117 insertions(+), 26 deletions(-) create mode 100644 packages/e2e/test/binding_test.dart create mode 100644 packages/e2e/test/response_serialization_test.dart diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index 7867e50c378e..7398b17f6e1d 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -93,36 +93,39 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { }); } + /// the callback function to response the driver side input. + @visibleForTesting + Future> callback(Map params) async { + final String command = params['command']; + Map response; + switch (command) { + case 'request_data': + final bool allTestsPassed = await _allTestsPassed.future; + response = { + 'message': allTestsPassed + ? Response.allTestsPassed(data: _data).toJson() + : Response.someTestsFailed( + _failureMethodsDetails, + data: _data, + ).toJson(), + }; + break; + case 'get_health': + response = {'status': 'ok'}; + break; + default: + throw UnimplementedError('$command is not implemented'); + } + return { + 'isError': false, + 'response': response, + }; + } + // Emulates the Flutter driver extension, returning 'pass' or 'fail'. @override void initServiceExtensions() { super.initServiceExtensions(); - Future> callback(Map params) async { - final String command = params['command']; - Map response; - switch (command) { - case 'request_data': - final bool allTestsPassed = await _allTestsPassed.future; - response = { - 'message': allTestsPassed - ? Response.allTestsPassed(data: _data).toJson() - : Response.someTestsFailed( - _failureMethodsDetails, - data: _data, - ).toJson(), - }; - break; - case 'get_health': - response = {'status': 'ok'}; - break; - default: - throw UnimplementedError('$command is not implemented'); - } - return { - 'isError': false, - 'response': response, - }; - } if (kIsWeb) { registerWebServiceExtension(callback); diff --git a/packages/e2e/test/binding_test.dart b/packages/e2e/test/binding_test.dart new file mode 100644 index 000000000000..2b5b72753333 --- /dev/null +++ b/packages/e2e/test/binding_test.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; + +import 'package:e2e/e2e.dart'; +import 'package:e2e/common.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() async { + Future> request; + + group('Test E2E binding', () { + final WidgetsBinding binding = E2EWidgetsFlutterBinding.ensureInitialized(); + assert(binding is E2EWidgetsFlutterBinding); + final E2EWidgetsFlutterBinding e2ebinding = + binding as E2EWidgetsFlutterBinding; + + setUp(() { + request = e2ebinding.callback({ + 'command': 'request_data', + }); + }); + + testWidgets('Run E2E app', (WidgetTester tester) async { + runApp(MaterialApp( + home: Text('Test'), + )); + expect(tester.binding, e2ebinding); + e2ebinding.addData({'answer': 42}); + }); + }); + + tearDownAll(() async { + // This part is outside the group so that `request` has been compeleted as + // part of the `tearDownAll` registerred in the group during + // `E2EWidgetsFlutterBinding` initialization. + final Map response = + (await request)['response'] as Map; + final String message = response['message'] as String; + Response result = Response.fromJson(message); + assert(result.data['answer'] == 42); + }); +} diff --git a/packages/e2e/test/response_serialization_test.dart b/packages/e2e/test/response_serialization_test.dart new file mode 100644 index 000000000000..4d823e2ebf10 --- /dev/null +++ b/packages/e2e/test/response_serialization_test.dart @@ -0,0 +1,47 @@ +import 'package:flutter_test/flutter_test.dart'; + +import 'package:e2e/common.dart'; + +void main() { + test('Serialize and deserialize Failure', () { + Failure fail = Failure('what a name', 'no detail'); + Failure restored = Failure.fromJsonString(fail.toString()); + expect(restored.methodName, fail.methodName); + expect(restored.details, fail.details); + }); + + test('Serialize and deserialize Response', () { + Response response, restored; + String jsonString; + + response = Response.allTestsPassed(); + jsonString = response.toJson(); + expect(jsonString, '{"result":"true","failureDetails":[]}'); + restored = Response.fromJson(jsonString); + expect(restored.allTestsPassed, response.allTestsPassed); + expect(restored.data, null); + expect(restored.formattedFailureDetails, ''); + + final Failure fail = Failure('what a name', 'no detail'); + final Failure fail2 = Failure('what a name2', 'no detail2'); + response = Response.someTestsFailed([fail, fail2]); + jsonString = response.toJson(); + restored = Response.fromJson(jsonString); + expect(restored.allTestsPassed, response.allTestsPassed); + expect(restored.data, null); + expect(restored.formattedFailureDetails, response.formattedFailureDetails); + + Map data = {'aaa': 'bbb'}; + response = Response.allTestsPassed(data: data); + jsonString = response.toJson(); + restored = Response.fromJson(jsonString); + expect(restored.data.keys, ['aaa']); + expect(restored.data.values, ['bbb']); + + response = Response.someTestsFailed([fail, fail2], data: data); + jsonString = response.toJson(); + restored = Response.fromJson(jsonString); + expect(restored.data.keys, ['aaa']); + expect(restored.data.values, ['bbb']); + }); +} From 1178ede379f7c2b3f8d8a8f9418b38cb625df230 Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 17:08:23 -0400 Subject: [PATCH 07/11] addData -> addReportData --- packages/e2e/lib/e2e.dart | 4 ++-- packages/e2e/test/binding_test.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index 7398b17f6e1d..3bb7e428cb3e 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -80,13 +80,13 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { Map _data; - /// Add fields to the reported result. + /// Add data to the reported result. /// /// The values in `data` should be json-serializable objects. /// /// For keys in `data` that's previously added, it will over write the /// original values. - void addData(Map data) { + void addReportData(Map data) { _data ??= {}; data.forEach((String key, dynamic value) { _data[key] = value; diff --git a/packages/e2e/test/binding_test.dart b/packages/e2e/test/binding_test.dart index 2b5b72753333..2417bd2f2233 100644 --- a/packages/e2e/test/binding_test.dart +++ b/packages/e2e/test/binding_test.dart @@ -24,7 +24,7 @@ void main() async { home: Text('Test'), )); expect(tester.binding, e2ebinding); - e2ebinding.addData({'answer': 42}); + e2ebinding.addReportData({'answer': 42}); }); }); From 6efbb3d47dcbf3a57d5fc8e283d391a4695758bb Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 18:12:13 -0400 Subject: [PATCH 08/11] expose report data --- packages/e2e/lib/e2e.dart | 22 ++++++++-------------- packages/e2e/test/binding_test.dart | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index 3bb7e428cb3e..e89b7b9793c6 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:convert'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -78,20 +79,13 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { static Map _results = {}; - Map _data; - - /// Add data to the reported result. + /// The extra data for the reported result. /// - /// The values in `data` should be json-serializable objects. + /// The values in `reportData` should be json-serializable objects or `null`. + /// If it's `null`, no extra data is attached to the result. /// - /// For keys in `data` that's previously added, it will over write the - /// original values. - void addReportData(Map data) { - _data ??= {}; - data.forEach((String key, dynamic value) { - _data[key] = value; - }); - } + /// The default value is `null`. + Map reportData; /// the callback function to response the driver side input. @visibleForTesting @@ -103,10 +97,10 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { final bool allTestsPassed = await _allTestsPassed.future; response = { 'message': allTestsPassed - ? Response.allTestsPassed(data: _data).toJson() + ? Response.allTestsPassed(data: reportData).toJson() : Response.someTestsFailed( _failureMethodsDetails, - data: _data, + data: reportData, ).toJson(), }; break; diff --git a/packages/e2e/test/binding_test.dart b/packages/e2e/test/binding_test.dart index 2417bd2f2233..8c97e161b0fe 100644 --- a/packages/e2e/test/binding_test.dart +++ b/packages/e2e/test/binding_test.dart @@ -24,7 +24,7 @@ void main() async { home: Text('Test'), )); expect(tester.binding, e2ebinding); - e2ebinding.addReportData({'answer': 42}); + e2ebinding.reportData = {'answer': 42}; }); }); From dddc34be87e0225ed118d3e428f985830d6ec4f9 Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 19:14:09 -0400 Subject: [PATCH 09/11] modify according to dnfield@ --- packages/e2e/lib/e2e.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index e89b7b9793c6..a6f2f8e2dc2d 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -81,7 +81,7 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding { /// The extra data for the reported result. /// - /// The values in `reportData` should be json-serializable objects or `null`. + /// The values in `reportData` must be json-serializable objects or `null`. /// If it's `null`, no extra data is attached to the result. /// /// The default value is `null`. From 4071a29cd4567900a556baed8c18a7f2a9fcf15b Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 19:49:27 -0400 Subject: [PATCH 10/11] modify according to liyuqian@ --- packages/e2e/lib/common.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/e2e/lib/common.dart b/packages/e2e/lib/common.dart index 61d3806812e7..4325b6555ba8 100644 --- a/packages/e2e/lib/common.dart +++ b/packages/e2e/lib/common.dart @@ -43,13 +43,11 @@ class Response { /// Deserializes the result from JSON. static Response fromJson(String source) { final Map responseJson = json.decode(source); - final String result = responseJson['result'] as String; - final dynamic detail = responseJson['failureDetails']; - if (result == 'true') { + if (responseJson['result'] as String == 'true') { return Response.allTestsPassed(data: responseJson['data']); } else { return Response.someTestsFailed( - _failureDetailsFromJson(detail), + _failureDetailsFromJson(responseJson['failureDetails']), data: responseJson['data'], ); } From 910070c8caf37d1264fb110def056b4b06fa3c64 Mon Sep 17 00:00:00 2001 From: "Ming Lyu (CareF)" Date: Wed, 15 Jul 2020 22:12:56 -0400 Subject: [PATCH 11/11] formatting --- packages/e2e/lib/e2e.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/e2e/lib/e2e.dart b/packages/e2e/lib/e2e.dart index a6f2f8e2dc2d..a9bf83041e40 100644 --- a/packages/e2e/lib/e2e.dart +++ b/packages/e2e/lib/e2e.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:convert'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart';