/
model.g.dart
706 lines (579 loc) · 18.5 KB
/
model.g.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
// Model generated by generator/generate.dart
import 'dart:convert' show json;
abstract class Event {
/// The type of the event.
///
/// This is always one of the subclass types listed below.
abstract final String type;
/// The time (in milliseconds) that has elapsed since the test runner started.
abstract final int time;
}
class StartEvent extends Event {
@override
final String type = 'start';
/// The version of the JSON reporter protocol being used.
///
/// This is a semantic version, but it reflects only the version of the
/// protocol—it's not identical to the version of the test runner itself.
final String protocolVersion;
/// The version of the test runner being used.
///
/// This is null if for some reason the version couldn't be loaded.
final String? runnerVersion;
/// The pid of the VM process running the tests.
final int pid;
@override
final int time;
StartEvent(
{required this.protocolVersion,
this.runnerVersion,
required this.pid,
required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is StartEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
protocolVersion == other.protocolVersion &&
runnerVersion == other.runnerVersion &&
pid == other.pid &&
time == other.time;
@override
int get hashCode =>
type.hashCode ^
protocolVersion.hashCode ^
(runnerVersion?.hashCode ?? 0) ^
pid.hashCode ^
time.hashCode;
@override
String toString() =>
'StartEvent{type: $type, protocolVersion: $protocolVersion, runnerVersion: $runnerVersion, pid: $pid, time: $time}';
}
class AllSuitesEvent extends Event {
@override
final String type = 'allSuites';
/// The total number of suites that will be loaded.
final int count;
@override
final int time;
AllSuitesEvent({required this.count, required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is AllSuitesEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
count == other.count &&
time == other.time;
@override
int get hashCode => type.hashCode ^ count.hashCode ^ time.hashCode;
@override
String toString() =>
'AllSuitesEvent{type: $type, count: $count, time: $time}';
}
class SuiteEvent extends Event {
@override
final String type = 'suite';
/// Metadata about the suite.
final Suite suite;
@override
final int time;
SuiteEvent({required this.suite, required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is SuiteEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
suite == other.suite &&
time == other.time;
@override
int get hashCode => type.hashCode ^ suite.hashCode ^ time.hashCode;
@override
String toString() => 'SuiteEvent{type: $type, suite: $suite, time: $time}';
}
class DebugEvent extends Event {
@override
final String type = 'debug';
/// The suite for which debug information is reported.
final int suiteID;
/// The HTTP URL for the Dart Observatory, or `null` if the Observatory isn't
/// available for this suite.
final String? observatory;
/// The HTTP URL for the remote debugger for this suite's host page, or `null`
/// if no remote debugger is available for this suite.
final String? remoteDebugger;
@override
final int time;
DebugEvent(
{required this.suiteID,
this.observatory,
this.remoteDebugger,
required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is DebugEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
suiteID == other.suiteID &&
observatory == other.observatory &&
remoteDebugger == other.remoteDebugger &&
time == other.time;
@override
int get hashCode =>
type.hashCode ^
suiteID.hashCode ^
(observatory?.hashCode ?? 0) ^
(remoteDebugger?.hashCode ?? 0) ^
time.hashCode;
@override
String toString() =>
'DebugEvent{type: $type, suiteID: $suiteID, observatory: $observatory, remoteDebugger: $remoteDebugger, time: $time}';
}
class GroupEvent extends Event {
@override
final String type = 'group';
/// Metadata about the group.
final Group group;
@override
final int time;
GroupEvent({required this.group, required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is GroupEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
group == other.group &&
time == other.time;
@override
int get hashCode => type.hashCode ^ group.hashCode ^ time.hashCode;
@override
String toString() => 'GroupEvent{type: $type, group: $group, time: $time}';
}
class TestStartEvent extends Event {
@override
final String type = 'testStart';
/// Metadata about the test that started.
final Test test;
@override
final int time;
TestStartEvent({required this.test, required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TestStartEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
test == other.test &&
time == other.time;
@override
int get hashCode => type.hashCode ^ test.hashCode ^ time.hashCode;
@override
String toString() => 'TestStartEvent{type: $type, test: $test, time: $time}';
}
class MessageEvent extends Event {
@override
final String type = 'print';
/// The ID of the test that printed a message.
final int testID;
/// The type of message being printed.
final String messageType;
/// The message that was printed.
final String message;
@override
final int time;
MessageEvent(
{required this.testID,
required this.messageType,
required this.message,
required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is MessageEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
testID == other.testID &&
messageType == other.messageType &&
message == other.message &&
time == other.time;
@override
int get hashCode =>
type.hashCode ^
testID.hashCode ^
messageType.hashCode ^
message.hashCode ^
time.hashCode;
@override
String toString() =>
'MessageEvent{type: $type, testID: $testID, messageType: $messageType, message: $message, time: $time}';
}
class ErrorEvent extends Event {
@override
final String type = 'error';
/// The ID of the test that experienced the error.
final int testID;
/// The result of calling toString() on the error object.
final String error;
/// The error's stack trace, in the stack_trace package format.
final String stackTrace;
/// Whether the error was a TestFailure.
final bool isFailure;
@override
final int time;
ErrorEvent(
{required this.testID,
required this.error,
required this.stackTrace,
required this.isFailure,
required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ErrorEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
testID == other.testID &&
error == other.error &&
stackTrace == other.stackTrace &&
isFailure == other.isFailure &&
time == other.time;
@override
int get hashCode =>
type.hashCode ^
testID.hashCode ^
error.hashCode ^
stackTrace.hashCode ^
isFailure.hashCode ^
time.hashCode;
@override
String toString() =>
'ErrorEvent{type: $type, testID: $testID, error: $error, stackTrace: $stackTrace, isFailure: $isFailure, time: $time}';
}
class TestDoneEvent extends Event {
@override
final String type = 'testDone';
/// The ID of the test that completed.
final int testID;
/// The result of the test.
final String result;
/// Whether the test's result should be hidden.
final bool hidden;
/// Whether the test (or some part of it) was skipped.
final bool skipped;
@override
final int time;
TestDoneEvent(
{required this.testID,
required this.result,
required this.hidden,
required this.skipped,
required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TestDoneEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
testID == other.testID &&
result == other.result &&
hidden == other.hidden &&
skipped == other.skipped &&
time == other.time;
@override
int get hashCode =>
type.hashCode ^
testID.hashCode ^
result.hashCode ^
hidden.hashCode ^
skipped.hashCode ^
time.hashCode;
@override
String toString() =>
'TestDoneEvent{type: $type, testID: $testID, result: $result, hidden: $hidden, skipped: $skipped, time: $time}';
}
class DoneEvent extends Event {
@override
final String type = 'done';
/// Whether all tests succeeded (or were skipped).
///
/// Will be `null` if the test runner was close before all tests completed
/// running.
final bool? success;
@override
final int time;
DoneEvent({this.success, required this.time});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is DoneEvent &&
runtimeType == other.runtimeType &&
type == other.type &&
success == other.success &&
time == other.time;
@override
int get hashCode => type.hashCode ^ (success?.hashCode ?? 0) ^ time.hashCode;
@override
String toString() => 'DoneEvent{type: $type, success: $success, time: $time}';
}
class Test {
/// An opaque ID for the test.
final int id;
/// The name of the test, including prefixes from any containing groups.
final String name;
/// The ID of the suite containing this test.
final int suiteID;
/// The IDs of groups containing this test, in order from outermost to
/// innermost.
final List<int> groupIDs;
/// The (1-based) line on which the test was defined, or `null`.
final int? line;
/// The (1-based) column on which the test was defined, or `null`.
final int? column;
/// The URL for the file in which the test was defined, or `null`.
final String? url;
/// The (1-based) line in the original test suite from which the test
/// originated.
///
/// Will only be present if `root_url` is different from `url`.
final int? root_line;
/// The (1-based) line on in the original test suite from which the test
/// originated.
///
/// Will only be present if `root_url` is different from `url`.
final int? root_column;
/// The URL for the original test suite in which the test was defined.
///
/// Will only be present if different from `url`.
final String? root_url;
/// This field is deprecated and should not be used.
final Metadata metadata;
Test(
{required this.id,
required this.name,
required this.suiteID,
required this.groupIDs,
this.line,
this.column,
this.url,
this.root_line,
this.root_column,
this.root_url,
required this.metadata});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Test &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
suiteID == other.suiteID &&
groupIDs == other.groupIDs &&
line == other.line &&
column == other.column &&
url == other.url &&
root_line == other.root_line &&
root_column == other.root_column &&
root_url == other.root_url &&
metadata == other.metadata;
@override
int get hashCode =>
id.hashCode ^
name.hashCode ^
suiteID.hashCode ^
groupIDs.hashCode ^
(line?.hashCode ?? 0) ^
(column?.hashCode ?? 0) ^
(url?.hashCode ?? 0) ^
(root_line?.hashCode ?? 0) ^
(root_column?.hashCode ?? 0) ^
(root_url?.hashCode ?? 0) ^
metadata.hashCode;
@override
String toString() =>
'Test{id: $id, name: $name, suiteID: $suiteID, groupIDs: $groupIDs, line: $line, column: $column, url: $url, root_line: $root_line, root_column: $root_column, root_url: $root_url, metadata: $metadata}';
}
class Suite {
/// An opaque ID for the group.
final int id;
/// The platform on which the suite is running.
final String platform;
/// The path to the suite's file, or `null` if that path is unknown.
final String? path;
Suite({required this.id, required this.platform, this.path});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Suite &&
runtimeType == other.runtimeType &&
id == other.id &&
platform == other.platform &&
path == other.path;
@override
int get hashCode => id.hashCode ^ platform.hashCode ^ (path?.hashCode ?? 0);
@override
String toString() => 'Suite{id: $id, platform: $platform, path: $path}';
}
class Group {
/// An opaque ID for the group.
final int id;
/// The name of the group, including prefixes from any containing groups.
final String name;
/// The ID of the suite containing this group.
final int suiteID;
/// The ID of the group's parent group, unless it's the root group.
final int? parentID;
/// The number of tests (recursively) within this group.
final int testCount;
/// The (1-based) line on which the group was defined, or `null`.
final int? line;
/// The (1-based) column on which the group was defined, or `null`.
final int? column;
/// The URL for the file in which the group was defined, or `null`.
final String? url;
/// This field is deprecated and should not be used.
final Metadata metadata;
Group(
{required this.id,
required this.name,
required this.suiteID,
this.parentID,
required this.testCount,
this.line,
this.column,
this.url,
required this.metadata});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Group &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
suiteID == other.suiteID &&
parentID == other.parentID &&
testCount == other.testCount &&
line == other.line &&
column == other.column &&
url == other.url &&
metadata == other.metadata;
@override
int get hashCode =>
id.hashCode ^
name.hashCode ^
suiteID.hashCode ^
(parentID?.hashCode ?? 0) ^
testCount.hashCode ^
(line?.hashCode ?? 0) ^
(column?.hashCode ?? 0) ^
(url?.hashCode ?? 0) ^
metadata.hashCode;
@override
String toString() =>
'Group{id: $id, name: $name, suiteID: $suiteID, parentID: $parentID, testCount: $testCount, line: $line, column: $column, url: $url, metadata: $metadata}';
}
class Metadata {
final bool skip;
/// The reason the tests was skipped, or `null` if it wasn't skipped.
final String? skipReason;
Metadata({required this.skip, this.skipReason});
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Metadata &&
runtimeType == other.runtimeType &&
skip == other.skip &&
skipReason == other.skipReason;
@override
int get hashCode => skip.hashCode ^ (skipReason?.hashCode ?? 0);
@override
String toString() => 'Metadata{skip: $skip, skipReason: $skipReason}';
}
Event parseJsonToEvent(String text) {
final map = json.decode(text);
switch (map['type']) {
case 'start':
return StartEvent(
protocolVersion: map['protocolVersion'],
runnerVersion: map['runnerVersion'],
pid: map['pid'],
time: map['time']);
case 'allSuites':
return AllSuitesEvent(count: map['count'], time: map['time']);
case 'suite':
final suite = map['suite'];
return SuiteEvent(
suite: Suite(
id: suite['id'],
platform: suite['platform'],
path: suite['path']),
time: map['time']);
case 'debug':
return DebugEvent(
suiteID: map['suiteID'],
observatory: map['observatory'],
remoteDebugger: map['remoteDebugger'],
time: map['time']);
case 'group':
final group = map['group'];
final metadata = group['metadata'];
return GroupEvent(
group: Group(
id: group['id'],
name: group['name'],
suiteID: group['suiteID'],
parentID: group['parentID'],
testCount: group['testCount'],
line: group['line'],
column: group['column'],
url: group['url'],
metadata: Metadata(
skip: metadata['skip'], skipReason: metadata['skipReason'])),
time: map['time']);
case 'testStart':
final test = map['test'];
final metadata = test['metadata'];
return TestStartEvent(
test: Test(
id: test['id'],
name: test['name'],
suiteID: test['suiteID'],
groupIDs: test['groupIDs'].cast<int>(),
line: test['line'],
column: test['column'],
url: test['url'],
root_line: test['root_line'],
root_column: test['root_column'],
root_url: test['root_url'],
metadata: Metadata(
skip: metadata['skip'], skipReason: metadata['skipReason'])),
time: map['time']);
case 'print':
return MessageEvent(
testID: map['testID'],
messageType: map['messageType'],
message: map['message'],
time: map['time']);
case 'error':
return ErrorEvent(
testID: map['testID'],
error: map['error'],
stackTrace: map['stackTrace'],
isFailure: map['isFailure'],
time: map['time']);
case 'testDone':
return TestDoneEvent(
testID: map['testID'],
result: map['result'],
hidden: map['hidden'],
skipped: map['skipped'],
time: map['time']);
case 'done':
return DoneEvent(success: map['success'], time: map['time']);
default:
throw Exception('Unknown Event type: $map');
}
}