Skip to content

Commit 08e070f

Browse files
committed
Update copyright year to 2026 and refactor timestamp values in network tests for clarity. Adjusted start times in various test cases and improved code readability in the HotRestartNetworkVmService class.
1 parent 7d34604 commit 08e070f

5 files changed

Lines changed: 58 additions & 56 deletions

File tree

packages/devtools_app/test/screens/network/network_clear_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors
1+
// Copyright 2026 The Flutter Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

@@ -121,7 +121,7 @@ void main() {
121121
controller
122122
.networkService
123123
.lastHttpDataRefreshTimePerIsolate[isolateId] =
124-
DateTime.now().microsecondsSinceEpoch;
124+
500_000;
125125

126126
await controller.clear();
127127

@@ -144,7 +144,7 @@ void main() {
144144
createTestHttpRequest(
145145
id: 'stale-request',
146146
method: 'GET',
147-
startTime: 1500000,
147+
startTime: 1_500_000,
148148
),
149149
],
150150
);
@@ -179,7 +179,7 @@ void main() {
179179
createTestHttpRequest(
180180
id: 'after-clear-and-restart',
181181
method: 'PUT',
182-
startTime: 9000000,
182+
startTime: 9_000_000,
183183
),
184184
);
185185
await controller.networkService.refreshNetworkData();
@@ -211,7 +211,7 @@ void main() {
211211
createTestHttpRequest(
212212
id: 'after-restart',
213213
method: 'POST',
214-
startTime: 8000000,
214+
startTime: 8_000_000,
215215
),
216216
);
217217
await controller.networkService.refreshNetworkData();
@@ -225,7 +225,7 @@ void main() {
225225
createTestHttpRequest(
226226
id: 'after-restart-and-clear',
227227
method: 'DELETE',
228-
startTime: 10000000,
228+
startTime: 10_000_000,
229229
),
230230
);
231231
await controller.networkService.refreshNetworkData();
@@ -295,7 +295,7 @@ void main() {
295295
createTestHttpRequest(
296296
id: 'after-multi-clear',
297297
method: 'PATCH',
298-
startTime: 3000000,
298+
startTime: 3_000_000,
299299
),
300300
);
301301
await controller.networkService.refreshNetworkData();

packages/devtools_app/test/screens/network/network_hot_restart_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors
1+
// Copyright 2026 The Flutter Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

@@ -83,7 +83,7 @@ void main() {
8383
createTestHttpRequest(
8484
id: 'post-restart',
8585
method: 'POST',
86-
startTime: 8000000,
86+
startTime: 8_000_000,
8787
),
8888
]);
8989

@@ -187,7 +187,7 @@ void main() {
187187
createTestHttpRequest(
188188
id: 'new-isolate-request',
189189
method: 'PUT',
190-
startTime: 9000000,
190+
startTime: 9_000_000,
191191
),
192192
]);
193193

@@ -224,15 +224,15 @@ void main() {
224224
controller
225225
.networkService
226226
.lastHttpDataRefreshTimePerIsolate[preRestartIsolateId] =
227-
DateTime.now().microsecondsSinceEpoch;
227+
12_000_000;
228228

229229
final postRestartIsolateId = vmService.simulateHotRestart();
230230
notifyMainIsolateChanged(fakeServiceConnection, postRestartIsolateId);
231231
vmService.setHttpProfile(postRestartIsolateId, [
232232
createTestHttpRequest(
233233
id: 'after-stale-isolate',
234234
method: 'DELETE',
235-
startTime: 10000000,
235+
startTime: 10_000_000,
236236
),
237237
]);
238238
await pumpEventQueue();
@@ -266,7 +266,7 @@ void main() {
266266
createTestHttpRequest(
267267
id: 'new-request',
268268
method: 'POST',
269-
startTime: 11000000,
269+
startTime: 11_000_000,
270270
),
271271
]);
272272
await pumpEventQueue();

packages/devtools_app/test/screens/network/utils/hot_restart_network_vm_service.dart

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors
1+
// Copyright 2026 The Flutter Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

@@ -40,11 +40,24 @@ class HotRestartNetworkVmService extends FakeVmServiceWrapper {
4040
static final _testVmFlagManager = VmFlagManager();
4141

4242
String _currentIsolateId = 'isolates/1';
43-
int _timelineMicros = 1000000;
4443

44+
/// A monotonic microsecond counter simulating the VM timeline clock.
45+
int _timelineMicros = 1_000_000;
46+
47+
/// A map of isolate ID to the list of mock HTTP requests recorded on that
48+
/// isolate.
4549
final _httpProfiles = <String, List<HttpProfileRequest>>{};
50+
51+
/// A map of isolate ID to the list of mock socket statistics recorded on that
52+
/// isolate.
4653
final _socketProfiles = <String, List<SocketStatistic>>{};
54+
55+
/// A map tracking whether HTTP timeline logging is enabled (true/false) per
56+
/// isolate ID.
4757
final _httpLoggingEnabled = <String, bool>{};
58+
59+
/// A map tracking whether socket profiling is enabled (true/false) per isolate
60+
/// ID.
4861
final _socketProfilingEnabled = <String, bool>{};
4962

5063
/// The isolate ID currently returned by [forEachIsolate].
@@ -79,28 +92,27 @@ class HotRestartNetworkVmService extends FakeVmServiceWrapper {
7992
_currentIsolateId = nextId;
8093
_httpLoggingEnabled[nextId] = false;
8194
_socketProfilingEnabled[nextId] = false;
82-
_timelineMicros += 5000000;
95+
// Advance past pre-restart request timestamps so refresh logic treats them
96+
// as stale on the new isolate.
97+
_timelineMicros += 5_000_000;
8398
return nextId;
8499
}
85100

86101
/// Appends [request] to the HTTP profile for [isolateId].
87102
void appendHttpRequest(String isolateId, HttpProfileRequest request) {
88-
_httpProfiles[isolateId] = [
89-
...(_httpProfiles[isolateId] ?? const []),
90-
request,
91-
];
103+
_httpProfiles[isolateId] = [...?_httpProfiles[isolateId], request];
92104
}
93105

94106
@override
95-
Future<Success> clearHttpProfileWrapper(String isolateId) {
107+
Future<Success> clearHttpProfileWrapper(String isolateId) async {
96108
_httpProfiles[isolateId] = [];
97-
return Future.value(Success());
109+
return Success();
98110
}
99111

100112
@override
101-
Future<Success> clearSocketProfileWrapper(String isolateId) {
113+
Future<Success> clearSocketProfileWrapper(String isolateId) async {
102114
_socketProfiles[isolateId] = [];
103-
return Future.value(Success());
115+
return Success();
104116
}
105117

106118
@override
@@ -111,45 +123,39 @@ class HotRestartNetworkVmService extends FakeVmServiceWrapper {
111123
Future<HttpTimelineLoggingState> httpEnableTimelineLoggingWrapper(
112124
String isolateId, [
113125
bool? enabled,
114-
]) {
126+
]) async {
115127
if (enabled != null) {
116128
_httpLoggingEnabled[isolateId] = enabled;
117-
return Future.value(HttpTimelineLoggingState(enabled: enabled));
129+
return HttpTimelineLoggingState(enabled: enabled);
118130
}
119-
return Future.value(
120-
HttpTimelineLoggingState(
121-
enabled: _httpLoggingEnabled[isolateId] ?? false,
122-
),
131+
return HttpTimelineLoggingState(
132+
enabled: _httpLoggingEnabled[isolateId] ?? false,
123133
);
124134
}
125135

126136
@override
127137
Future<SocketProfilingState> socketProfilingEnabledWrapper(
128138
String isolateId, [
129139
bool? enabled,
130-
]) {
140+
]) async {
131141
if (enabled != null) {
132142
_socketProfilingEnabled[isolateId] = enabled;
133-
return Future.value(SocketProfilingState(enabled: enabled));
143+
return SocketProfilingState(enabled: enabled);
134144
}
135-
return Future.value(
136-
SocketProfilingState(
137-
enabled: _socketProfilingEnabled[isolateId] ?? false,
138-
),
145+
return SocketProfilingState(
146+
enabled: _socketProfilingEnabled[isolateId] ?? false,
139147
);
140148
}
141149

142150
@override
143151
Future<HttpProfile> getHttpProfileWrapper(
144152
String isolateId, {
145153
DateTime? updatedSince,
146-
}) {
154+
}) async {
147155
if (!(_httpLoggingEnabled[isolateId] ?? false)) {
148-
return Future.value(
149-
HttpProfile(
150-
requests: [],
151-
timestamp: DateTime.fromMicrosecondsSinceEpoch(_timelineMicros),
152-
),
156+
return HttpProfile(
157+
requests: [],
158+
timestamp: DateTime.fromMicrosecondsSinceEpoch(_timelineMicros),
153159
);
154160
}
155161

@@ -165,25 +171,21 @@ class HotRestartNetworkVmService extends FakeVmServiceWrapper {
165171
)
166172
.toList();
167173
}
168-
return Future.value(
169-
HttpProfile(
170-
requests: requests,
171-
timestamp: DateTime.fromMicrosecondsSinceEpoch(_timelineMicros),
172-
),
174+
return HttpProfile(
175+
requests: requests,
176+
timestamp: DateTime.fromMicrosecondsSinceEpoch(_timelineMicros),
173177
);
174178
}
175179

176180
@override
177-
Future<SocketProfile> getSocketProfileWrapper(String isolateId) {
181+
Future<SocketProfile> getSocketProfileWrapper(String isolateId) async {
178182
if (!(_socketProfilingEnabled[isolateId] ?? false)) {
179-
return Future.value(SocketProfile(sockets: []));
183+
return SocketProfile(sockets: []);
180184
}
181-
return Future.value(
182-
SocketProfile(sockets: _socketProfiles[isolateId] ?? const []),
183-
);
185+
return SocketProfile(sockets: _socketProfiles[isolateId] ?? const []);
184186
}
185187

186188
@override
187-
Future<Timestamp> getVMTimelineMicros() =>
188-
Future.value(Timestamp(timestamp: _timelineMicros));
189+
Future<Timestamp> getVMTimelineMicros() async =>
190+
Timestamp(timestamp: _timelineMicros);
189191
}

packages/devtools_app/test/screens/network/utils/network_lifecycle_test_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The Flutter Authors
1+
// Copyright 2026 The Flutter Authors
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

packages/devtools_app/test/screens/network/utils/network_test_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import '../../../test_infra/test_data/network.dart';
1010
HttpProfileRequest createTestHttpRequest({
1111
required String id,
1212
required String method,
13-
int startTime = 2000000,
13+
int startTime = 2_000_000,
1414
String uri = 'https://example.com/test',
1515
}) {
1616
final endTime = startTime + 1000;

0 commit comments

Comments
 (0)