Skip to content

Commit 47f3877

Browse files
committed
tweak test data timestamps to avoid rounding errors
1 parent d1acbf2 commit 47f3877

File tree

2 files changed

+34
-36
lines changed

2 files changed

+34
-36
lines changed

packages/devtools_app/test/network_model_test.dart

+14-16
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ void main() {
5858
});
5959

6060
test('duration returns correct value', () {
61-
expect(httpGetEvent.duration.inMicroseconds, equals(424865));
62-
expect(httpPutEvent.duration.inMicroseconds, equals(443000));
63-
expect(httpGetEventWithError.duration.inMicroseconds, equals(10000));
61+
expect(httpGetEvent.duration.inMicroseconds, equals(900000));
62+
expect(httpPutEvent.duration.inMicroseconds, equals(900000));
63+
expect(httpGetEventWithError.duration.inMicroseconds, equals(100000));
6464
expect(httpInvalidEvent.duration, isNull);
6565
expect(httpInProgressEvent.duration, isNull);
6666

@@ -70,22 +70,20 @@ void main() {
7070

7171
test('startTimestamp returns correct value', () {
7272
// Test these values in UTC to avoid timezone differences with the bots.
73-
expect(
74-
formatDateTime(httpGetEvent.startTimestamp.toUtc()),
75-
equals('8:51:10.643 AM'),
76-
);
73+
expect(formatDateTime(httpGetEvent.startTimestamp.toUtc()),
74+
equals('8:51:09.000 AM'));
7775
expect(
7876
formatDateTime(httpPutEvent.startTimestamp.toUtc()),
79-
equals('8:51:10.309 AM'),
77+
equals('8:51:11.000 AM'),
8078
);
8179
expect(
8280
formatDateTime(httpGetEventWithError.startTimestamp.toUtc()),
83-
equals('8:51:11.215 AM'),
81+
equals('8:51:13.000 AM'),
8482
);
8583
expect(httpInvalidEvent.startTimestamp, isNull);
8684
expect(
8785
formatDateTime(httpInProgressEvent.startTimestamp.toUtc()),
88-
equals('8:51:10.643 AM'),
86+
equals('8:51:17.000 AM'),
8987
);
9088

9189
expect(
@@ -102,15 +100,15 @@ void main() {
102100
// Test these values in UTC to avoid timezone differences with the bots.
103101
expect(
104102
formatDateTime(httpGetEvent.endTimestamp.toUtc()),
105-
equals('8:51:11.068 AM'),
103+
equals('8:51:09.900 AM'),
106104
);
107105
expect(
108106
formatDateTime(httpPutEvent.endTimestamp.toUtc()),
109-
equals('8:51:10.752 AM'),
107+
equals('8:51:11.900 AM'),
110108
);
111109
expect(
112110
formatDateTime(httpGetEventWithError.endTimestamp.toUtc()),
113-
equals('8:51:11.225 AM'),
111+
equals('8:51:13.100 AM'),
114112
);
115113
expect(httpInvalidEvent.endTimestamp, isNull);
116114
expect(httpInProgressEvent.endTimestamp, isNull);
@@ -143,9 +141,9 @@ void main() {
143141
});
144142

145143
test('durationDisplay returns correct value', () {
146-
expect(httpGetEvent.durationDisplay, equals('Duration: 424.9 ms'));
147-
expect(httpPutEvent.durationDisplay, equals('Duration: 443.0 ms'));
148-
expect(httpGetEventWithError.durationDisplay, 'Duration: 10.0 ms');
144+
expect(httpGetEvent.durationDisplay, equals('Duration: 900.0 ms'));
145+
expect(httpPutEvent.durationDisplay, equals('Duration: 900.0 ms'));
146+
expect(httpGetEventWithError.durationDisplay, 'Duration: 100.0 ms');
149147
expect(httpInvalidEvent.durationDisplay, equals('Duration: Pending'));
150148
expect(httpInProgressEvent.durationDisplay, equals('Duration: Pending'));
151149
expect(testSocket1.durationDisplay, equals('Duration: 1000.0 ms'));

packages/devtools_app/test/support/network_test_data.dart

+20-20
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import 'package:devtools_app/src/http/http_request_data.dart';
66
import 'package:devtools_app/src/network/network_model.dart';
77
import 'package:vm_service/vm_service.dart';
88

9-
const _getStartTime = 231935321629;
9+
const _getStartTime = 231935000000;
1010
final httpGetEvent = HttpRequestData.fromTimeline(
11-
_getStartTime - 10, // - 10 is arbitrary.
11+
_getStartTime - 1000000, // - 1000000 is arbitrary.
1212
httpGetEventTrace,
1313
);
1414
final httpGetEventTrace = [
@@ -32,7 +32,7 @@ final httpGetEventTrace = [
3232
'cat': 'Dart',
3333
'tid': 52414,
3434
'pid': 52406,
35-
'ts': 231935321740,
35+
'ts': 231935100000,
3636
'ph': 'n',
3737
'id': '1d',
3838
'args': {'isolateId': 'isolates/3907117677703047'}
@@ -42,7 +42,7 @@ final httpGetEventTrace = [
4242
'cat': 'Dart',
4343
'tid': 52414,
4444
'pid': 52406,
45-
'ts': 231935321786,
45+
'ts': 231935200000,
4646
'ph': 'n',
4747
'id': '1d',
4848
'args': {'isolateId': 'isolates/3907117677703047'}
@@ -52,7 +52,7 @@ final httpGetEventTrace = [
5252
'cat': 'Dart',
5353
'tid': 52414,
5454
'pid': 52406,
55-
'ts': 231935746112,
55+
'ts': 231935400000,
5656
'ph': 'n',
5757
'id': '1d',
5858
'args': {'isolateId': 'isolates/3907117677703047'}
@@ -62,7 +62,7 @@ final httpGetEventTrace = [
6262
'cat': 'Dart',
6363
'tid': 52414,
6464
'pid': 52406,
65-
'ts': 231935746494,
65+
'ts': 231935900000,
6666
'ph': 'e',
6767
'id': '1d',
6868
'args': {
@@ -97,9 +97,9 @@ final httpGetEventTrace = [
9797
},
9898
];
9999

100-
const _putStartTime = 231935155000;
100+
const _putStartTime = 231936000000;
101101
final httpPutEvent = HttpRequestData.fromTimeline(
102-
_putStartTime - 10, // - 10 is arbitrary.
102+
_putStartTime - 1000000, // - 1000000 is arbitrary.
103103
httpPutEventTrace,
104104
);
105105
final httpPutEventTrace = [
@@ -123,7 +123,7 @@ final httpPutEventTrace = [
123123
'cat': 'Dart',
124124
'tid': 52414,
125125
'pid': 52406,
126-
'ts': 231935155100,
126+
'ts': 231936300000,
127127
'ph': 'n',
128128
'id': '17',
129129
'args': {'isolateId': 'isolates/3907117677703047'}
@@ -133,7 +133,7 @@ final httpPutEventTrace = [
133133
'cat': 'Dart',
134134
'tid': 52414,
135135
'pid': 52406,
136-
'ts': 231935155200,
136+
'ts': 231936600000,
137137
'ph': 'n',
138138
'id': '17',
139139
'args': {'isolateId': 'isolates/3907117677703047'}
@@ -143,7 +143,7 @@ final httpPutEventTrace = [
143143
'cat': 'Dart',
144144
'tid': 52414,
145145
'pid': 52406,
146-
'ts': 231935597000,
146+
'ts': 231936800000,
147147
'ph': 'n',
148148
'id': '17',
149149
'args': {'isolateId': 'isolates/3907117677703047'}
@@ -153,7 +153,7 @@ final httpPutEventTrace = [
153153
'cat': 'Dart',
154154
'tid': 52414,
155155
'pid': 52406,
156-
'ts': 231935598000,
156+
'ts': 231936900000,
157157
'ph': 'e',
158158
'id': '17',
159159
'args': {
@@ -189,9 +189,9 @@ final httpPutEventTrace = [
189189
},
190190
];
191191

192-
const _getWithErrorStartTime = 231935607670;
192+
const _getWithErrorStartTime = 231937000000;
193193
final httpGetEventWithError = HttpRequestData.fromTimeline(
194-
_getWithErrorStartTime - 10, // - 10 is arbitrary.
194+
_getWithErrorStartTime - 1000000, // - 1000000 is arbitrary.
195195
httpGetEventWithErrorTrace,
196196
);
197197
final httpGetEventWithErrorTrace = [
@@ -217,7 +217,7 @@ final httpGetEventWithErrorTrace = [
217217
'cat': 'Dart',
218218
'tid': 21767,
219219
'pid': 81479,
220-
'ts': 231935617670,
220+
'ts': 231937100000,
221221
'ph': 'e',
222222
'id': 238,
223223
'args': {
@@ -231,9 +231,9 @@ final httpGetEventWithErrorTrace = [
231231
},
232232
];
233233

234-
const _invalidStartTime = 231935607670;
234+
const _invalidStartTime = 231938000000;
235235
final httpInvalidEvent = HttpRequestData.fromTimeline(
236-
_invalidStartTime - 10, // - 10 is arbitrary.
236+
_invalidStartTime - 1000000, // - 1000000 is arbitrary.
237237
httpInvalidEventTrace,
238238
);
239239
final httpInvalidEventTrace = [
@@ -242,7 +242,7 @@ final httpInvalidEventTrace = [
242242
'cat': 'Dart',
243243
'tid': 52414,
244244
'pid': 52406,
245-
'ts': 231935597670,
245+
'ts': 231938100000,
246246
'ph': 'e',
247247
'id': '17',
248248
'args': {
@@ -278,9 +278,9 @@ final httpInvalidEventTrace = [
278278
},
279279
];
280280

281-
const _inProgressStartTime = 231935321629;
281+
const _inProgressStartTime = 231939000000;
282282
final httpInProgressEvent = HttpRequestData.fromTimeline(
283-
_inProgressStartTime - 10, // - 10 is arbitrary.
283+
_inProgressStartTime - 1000000, // - 1000000 is arbitrary.
284284
httpInProgressEventTrace,
285285
);
286286
final httpInProgressEventTrace = [

0 commit comments

Comments
 (0)