Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit e9bf7bb

Browse files
committed
extraInfo -> data
1 parent 5e3d1a7 commit e9bf7bb

File tree

4 files changed

+20
-31
lines changed

4 files changed

+20
-31
lines changed

packages/e2e/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 0.6.1
22

3-
* Added `extraInfo` in the reported json.
3+
* Added `data` in the reported json.
44

55
## 0.6.0
66

packages/e2e/lib/common.dart

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ class Response {
1212
final bool _allTestsPassed;
1313

1414
/// The extra information to be added along side the test result.
15-
///
16-
/// Specially `'result'` and `'failureDetails'` keys are occupied, and will
17-
/// be ignored.
18-
Map<String, dynamic> extraInfo;
15+
Map<String, dynamic> data;
1916

2017
/// Constructor to use for positive response.
21-
Response.allTestsPassed({this.extraInfo})
18+
Response.allTestsPassed({this.data})
2219
: this._allTestsPassed = true,
2320
this._failureDetails = null;
2421

2522
/// Constructor for failure response.
26-
Response.someTestsFailed(this._failureDetails, {this.extraInfo})
23+
Response.someTestsFailed(this._failureDetails, {this.data})
2724
: this._allTestsPassed = false;
2825

2926
/// Whether the test ran successfully or not.
@@ -37,19 +34,11 @@ class Response {
3734
List<Failure> get failureDetails => _failureDetails;
3835

3936
/// Serializes this message to a JSON map.
40-
String toJson() {
41-
final Map<String, dynamic> result = <String, dynamic>{};
42-
result['result'] = allTestsPassed.toString();
43-
result['failureDetails'] = _failureDetailsAsString();
44-
if (extraInfo != null) {
45-
extraInfo.forEach((String key, dynamic value) {
46-
if (key != 'result' && key != 'failureDetails') {
47-
result[key] = value;
48-
}
37+
String toJson() => json.encode(<String, dynamic>{
38+
'result': allTestsPassed.toString(),
39+
'failureDetails': _failureDetailsAsString(),
40+
if (data != null) 'data': data
4941
});
50-
}
51-
return json.encode(result);
52-
}
5342

5443
/// Deserializes the result from JSON.
5544
static Response fromJson(String source) {
@@ -59,11 +48,11 @@ class Response {
5948
final dynamic detail = responseJson['failureDetails'];
6049
responseJson.remove('failureDetails');
6150
if (result == 'true') {
62-
return Response.allTestsPassed(extraInfo: responseJson);
51+
return Response.allTestsPassed(data: responseJson);
6352
} else {
6453
return Response.someTestsFailed(
6554
_failureDetailsFromJson(detail),
66-
extraInfo: responseJson,
55+
data: responseJson,
6756
);
6857
}
6958
}

packages/e2e/lib/e2e.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding {
7878

7979
static Map<String, String> _results = <String, String>{};
8080

81-
Map<String, dynamic> _reports;
81+
Map<String, dynamic> _data;
8282

8383
/// Add fields to the reported result.
8484
///
85-
/// The values in `report` should be json-serializable objects.
85+
/// The values in `data` should be json-serializable objects.
8686
///
87-
/// For keys in `report` that's previously added, it will over write the
87+
/// For keys in `data` that's previously added, it will over write the
8888
/// original values.
89-
void addReportResult(Map<String, dynamic> report) {
90-
_reports ??= <String, dynamic>{};
91-
report.forEach((String key, dynamic value) {
92-
_reports[key] = value;
89+
void addData(Map<String, dynamic> data) {
90+
_data ??= <String, dynamic>{};
91+
data.forEach((String key, dynamic value) {
92+
_data[key] = value;
9393
});
9494
}
9595

@@ -105,10 +105,10 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding {
105105
final bool allTestsPassed = await _allTestsPassed.future;
106106
response = <String, String>{
107107
'message': allTestsPassed
108-
? Response.allTestsPassed(extraInfo: _reports).toJson()
108+
? Response.allTestsPassed(data: _data).toJson()
109109
: Response.someTestsFailed(
110110
_failureMethodsDetails,
111-
extraInfo: _reports,
111+
data: _data,
112112
).toJson(),
113113
};
114114
break;

packages/e2e/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 0.6.1
44
homepage: https://github.com/flutter/plugins/tree/master/packages/e2e
55

66
environment:
7-
sdk: ">=2.1.0 <3.0.0"
7+
sdk: ">=2.2.2 <3.0.0"
88
flutter: ">=1.12.13+hotfix.5 <2.0.0"
99

1010
dependencies:

0 commit comments

Comments
 (0)