Skip to content

Commit d1f73f0

Browse files
authored
Merge branch 'master' into 2.44.1
2 parents 798a83f + f4fbff8 commit d1f73f0

191 files changed

Lines changed: 3985 additions & 1469 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yaml

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

55
name: devtools
66

.github/workflows/flutter-prep.yaml

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

55
name: Flutter SDK prep
66

analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ linter:
6767
- cancel_subscriptions
6868
# - cascade_invocations # not yet tested
6969
# - close_sinks # https://github.com/flutter/flutter/issues/5789
70-
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
70+
- comment_references
7171
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
7272
- control_flow_in_finally
7373
- directives_ordering

flutter-candidate.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9ffdd3a0ecfa94b94a2fa856fc94e4fcbb2f50c6
1+
f0992e09655aca7ed2a162042e6ba874f1280dc2

packages/devtools_app/benchmark/devtools_benchmarks_test.dart

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ void _verifyScoresAgainstThresholds(
124124
}) {
125125
final identifier = '${devToolsBenchmark.id}.${useWasm ? 'wasm' : 'js'}';
126126
stdout.writeln('Verifying $identifier scores against expected thresholds.');
127+
final benchmarkThresholds = _benchmarkThresholds(useWasm);
127128
expect(
128-
_benchmarkThresholds.containsKey(devToolsBenchmark),
129+
benchmarkThresholds.containsKey(devToolsBenchmark),
129130
isTrue,
130131
reason: 'Missing expected thresholds for ${devToolsBenchmark.id}.',
131132
);
132-
final expectedThresholds = _benchmarkThresholds[devToolsBenchmark]!;
133+
final expectedThresholds = benchmarkThresholds[devToolsBenchmark]!;
133134

134135
final scoresAsMap = Map.fromEntries([
135136
for (final score in scores) MapEntry(score.metric, score),
@@ -171,8 +172,13 @@ void _verifyScoresAgainstThresholds(
171172
}
172173

173174
const _frameTimeFor60FPSInMicros = 16666.6;
175+
const _frameTimeFor30FPSInMicros = 33333.3;
174176

175-
final _benchmarkThresholds = {
177+
/// Creates the expected [DevToolsBenchmark]s for the specified compiler.
178+
///
179+
/// Note that some of the wasm benchmarks use a 30fps frame budget instead of
180+
/// the 60fps frame budget due to https://issues.chromium.org/issues/396208308.
181+
Map<DevToolsBenchmark, Map<String, num>> _benchmarkThresholds(bool isWasm) => {
176182
// Note that some of these benchmarks exceed the 60fps frame budget,
177183
// especially the p90 benchmarks.
178184
//
@@ -204,29 +210,33 @@ final _benchmarkThresholds = {
204210
DevToolsBenchmark.offlineCpuProfilerScreen: {
205211
..._valuesForMetric(
206212
BenchmarkMetric.flutterFrameTotalTime,
207-
avg: _frameTimeFor60FPSInMicros * 2,
208-
p50: _frameTimeFor60FPSInMicros,
213+
avg:
214+
(isWasm ? _frameTimeFor30FPSInMicros : _frameTimeFor60FPSInMicros) *
215+
2,
216+
p50: isWasm ? _frameTimeFor30FPSInMicros * 2 : _frameTimeFor60FPSInMicros,
209217
p90: _frameTimeFor60FPSInMicros * 6,
210218
),
211219
..._valuesForMetric(
212220
BenchmarkMetric.flutterFrameBuildTime,
213221
avg: _frameTimeFor60FPSInMicros * 2,
214222
p50: _frameTimeFor60FPSInMicros,
215-
p90: _frameTimeFor60FPSInMicros,
223+
p90: isWasm ? _frameTimeFor30FPSInMicros : _frameTimeFor60FPSInMicros,
216224
),
217225
..._valuesForMetric(
218226
BenchmarkMetric.flutterFrameRasterTime,
219-
avg: _frameTimeFor60FPSInMicros * 2,
220-
p50: _frameTimeFor60FPSInMicros,
221-
p90: _frameTimeFor60FPSInMicros,
227+
avg:
228+
(isWasm ? _frameTimeFor30FPSInMicros : _frameTimeFor60FPSInMicros) *
229+
2,
230+
p50: isWasm ? _frameTimeFor30FPSInMicros * 2 : _frameTimeFor60FPSInMicros,
231+
p90: isWasm ? _frameTimeFor30FPSInMicros * 3 : _frameTimeFor60FPSInMicros,
222232
),
223233
},
224234
DevToolsBenchmark.offlinePerformanceScreen: {
225235
..._valuesForMetric(
226236
BenchmarkMetric.flutterFrameTotalTime,
227237
avg: _frameTimeFor60FPSInMicros,
228238
p50: _frameTimeFor60FPSInMicros,
229-
p90: _frameTimeFor60FPSInMicros,
239+
p90: _frameTimeFor30FPSInMicros,
230240
),
231241
..._valuesForMetric(
232242
BenchmarkMetric.flutterFrameBuildTime,

packages/devtools_app/benchmark/scripts/utils.dart

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

55
import 'dart:io';
66

packages/devtools_app/integration_test/README.md

Lines changed: 65 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,101 @@ found in the LICENSE file or at https://developers.google.com/open-source/licens
77

88
## Set up ChromeDriver (one time only)
99

10-
1. Follow the instructions [here](https://flutter.dev/to/integration-test-on-web) to download ChromeDriver.
10+
1. Follow the instructions
11+
[here](https://flutter.dev/to/integration-test-on-web) to download
12+
ChromeDriver.
1113

12-
2. Add `chromedriver` to your PATH by modifying your `.bash_profile` or `.zshrc`:
14+
2. Add `chromedriver` to your PATH by modifying your `.bash_profile` or
15+
`.zshrc`:
1316

14-
```
15-
export PATH=${PATH}:/Users/me/folder_containing_chromedriver/
16-
```
17+
```
18+
export PATH=${PATH}:/Users/me/folder_containing_chromedriver/
19+
```
1720

1821
3. Verify you can start `chromedriver`:
1922

20-
```
21-
chromedriver --port=4444
22-
```
23+
```
24+
chromedriver --port=4444
25+
```
2326

24-
If you get the error "'chromedriver' cannot be opened because it is from an unidentified developer.", run the following command with your path to the `chromedriver` executable:
27+
If you get the error "'chromedriver' cannot be opened because it is from an
28+
unidentified developer." on MacOS, run the following command with your path
29+
to the `chromedriver` executable:
2530

26-
```
27-
xattr -d com.apple.quarantine ~/path/to/chromedriver
28-
```
31+
```
32+
xattr -d com.apple.quarantine ~/path/to/chromedriver
33+
```
2934

3035
### Updating ChromeDriver
3136

32-
If you update your Chrome version (or it updates automatically), you may need to update your `chromedriver`
33-
executable as well. To do this, delete your existing `chromedriver` executable (you can find this by
34-
running `which chromedriver`). Then, download the proper `chromedriver` zip file from
35-
[here](https://googlechromelabs.github.io/chrome-for-testing/#stable) based on your platform. Copy the
36-
link for your platform, open in a new tab, and then the zip file will be downloaded. Unzip the
37-
folder, and move the executable to the same location that you just deleted the previous executable from.
37+
If you update your Chrome version (or it updates automatically), you may need to
38+
update your `chromedriver` executable as well. To do this, delete your existing
39+
`chromedriver` executable (you can find this by running `which chromedriver`).
40+
Then, download the proper `chromedriver` zip file from
41+
[here](https://googlechromelabs.github.io/chrome-for-testing/#stable) based on
42+
your platform. Copy the link for your platform, open in a new tab, and then the
43+
zip file will be downloaded. Unzip the folder, and move the executable to the
44+
same location that you just deleted the previous executable from.
45+
46+
If you are on MacOS, you will likely need to run this command again on the new
47+
executable:
3848

39-
If you are on Mac, you will likely need to run this command again on the new executable:
4049
```
4150
xattr -d com.apple.quarantine ~/path/to/chromedriver
4251
```
4352

4453
## Running a test
4554

4655
* To run all integration tets: `dart run integration_test/run_tests.dart`
47-
* To run a single integration test: `dart run integration_test/run_tests.dart --target=integration_test/test/my_test.dart`
56+
* To run a single integration test:
57+
`dart run integration_test/run_tests.dart --target=integration_test/test/my_test.dart`
4858

4959
### Special flags:
5060

51-
* `--test-app-uri`: to speed up local development, you can pass in a vm service uri from a Dart or Flutter
52-
app running on your local machine. This saves the cost of spinning up a new test app for each test run. To
53-
do this, pass the vm service uri using the `--test-app-uri=some-uri` run flag.
54-
* `--headless`: this will run the integration test on the 'web-server' device instead of the 'chrome' device, meaning you will not be able to see the integration test run in Chrome when running locally.
55-
* `--update-goldens`: behaves like the `--update-goldens` flag for Flutter unit tests,
56-
updating the golden images to the results produced by the test run.
57-
58-
The following flags are available, but should not be used manually. To run a test with offline data
59-
or with experiments enabled, place the test in the proper directory, and the `run_tests.dart` script
60-
will propagate the proper flag values automatically (see [instructions below](#where-to-add-an-integration-test))
61+
* `--test-app-uri`: to speed up local development, you can pass in a VM service
62+
URI from a Dart or Flutter app running on your local machine. This saves the
63+
cost of spinning up a new test app for each test run. To do this, pass the VM
64+
service URI using the `--test-app-uri=some-uri` run flag.
65+
* `--headless`: this will run the integration test on the 'web-server' device
66+
instead of the 'chrome' device, meaning you will not be able to see the
67+
integration test run in Chrome when running locally.
68+
* `--update-goldens`: behaves like the `--update-goldens` flag for Flutter unit
69+
tests, updating the golden images to the results produced by the test run.
70+
71+
The following flags are available, but should not be used manually. To run a
72+
test with offline data or with experiments enabled, place the test in the proper
73+
directory, and the `run_tests.dart` script will propagate the proper flag values
74+
automatically (see [instructions below](#where-to-add-an-integration-test)).
6175

6276
# Where to add an integration test
6377

64-
Where you should place your integration test will depend on the answers to the following questions:
65-
1. Does your test require DevTools to be connected to a live test application? This is a
66-
["live connection"](#live-connection-integration-tests) integration test.
78+
Where you should place your integration test will depend on the answers to the
79+
following questions:
80+
81+
1. Does your test require DevTools to be connected to a live test application?
82+
This is a ["live connection"](#live-connection-integration-tests) integration
83+
test.
6784
2. Does your test need to use offline (and stable) test data? This is an
68-
["offline"](#offline-integration-tests) integration test.
85+
["offline"](#offline-integration-tests) integration test.
6986

7087
## "live connection" integration tests
7188

72-
Tests under `integration_test/test/live_connection` will run DevTools and connect it to a live Dart or Flutter
73-
application.
89+
Tests under `integration_test/test/live_connection` will run DevTools and
90+
connect it to a live Dart or Flutter application.
7491

7592
## "offline" integration tests
7693

77-
Tests under `integration_test/test/offline` will run DevTools without connecting it to a live application.
78-
Integration tests in this directory will load offline data for testing. This is useful
79-
for testing features that will not have stable data from a live application. For example,
80-
the Performance screen timeline data will never be stable with a live applicaiton, so
81-
loading offline data allows for screenshot testing without flakiness.
94+
Tests under `integration_test/test/offline` will run DevTools without connecting
95+
it to a live application. Integration tests in this directory will load offline
96+
data for testing. This is useful for testing features that will not have stable
97+
data from a live application. For example, the Performance screen timeline data
98+
will never be stable with a live applicaiton, so loading offline data allows for
99+
screenshot testing without flakiness.
82100

83101
# In-file test arguments
84102

85-
Some test arguments are set in the test file directly as specifically formatted comments.
103+
Some test arguments are set in the test file directly as specifically formatted
104+
comments.
86105

87106
For example:
88107
```dart
@@ -91,5 +110,7 @@ For example:
91110
// test-argument:experimentsOn=true
92111
```
93112

94-
For a list of such arguments, see [_in_file_args.dart](test_infra/run/_in_file_args.dart). For an example of
95-
usage, see [eval_and_browse_test.dart](test/live_connection/eval_and_browse_test.dart).
113+
For a list of such arguments, see
114+
[_in_file_args.dart](test_infra/run/_in_file_args.dart). For an example of
115+
usage, see
116+
[eval_and_browse_test.dart](test/live_connection/eval_and_browse_test.dart).
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Copyright 2025 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
4+
5+
// Do not delete these arguments. They are parsed by test runner.
6+
// test-argument:appPath="test/test_infra/fixtures/networking_app/bin/main.dart"
7+
8+
import 'package:devtools_app/devtools_app.dart';
9+
import 'package:devtools_app/src/shared/table/table.dart' show DevToolsTable;
10+
import 'package:devtools_test/helpers.dart';
11+
import 'package:devtools_test/integration_test.dart';
12+
import 'package:flutter_test/flutter_test.dart';
13+
import 'package:http/http.dart' as http;
14+
import 'package:integration_test/integration_test.dart';
15+
16+
// To run:
17+
// dart run integration_test/run_tests.dart --target=integration_test/test/live_connection/network_screen_test.dart --test-app-device=cli
18+
19+
void main() {
20+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
21+
22+
late TestApp testApp;
23+
24+
setUpAll(() {
25+
testApp = TestApp.fromEnvironment();
26+
expect(testApp.vmServiceUri, isNotNull);
27+
});
28+
29+
tearDown(() async {
30+
await resetHistory();
31+
await http.get(Uri.parse('http://localhost:${testApp.controlPort}/exit/'));
32+
});
33+
34+
testWidgets('nnn', (tester) async {
35+
await pumpAndConnectDevTools(tester, testApp);
36+
await _prepareNetworkScreen(tester);
37+
38+
final helper = _NetworkScreenHelper(tester, testApp.controlPort!);
39+
40+
// Instruct the app to make a GET request via the dart:io HttpClient.
41+
await helper.triggerRequest('get/');
42+
_expectInRequestTable('GET');
43+
await helper.clear();
44+
45+
// Instruct the app to make a POST request via the dart:io HttpClient.
46+
await helper.triggerRequest('post/');
47+
_expectInRequestTable('POST');
48+
await helper.clear();
49+
50+
// Instruct the app to make a PUT request via the dart:io HttpClient.
51+
await helper.triggerRequest('put/');
52+
_expectInRequestTable('PUT');
53+
await helper.clear();
54+
55+
// Instruct the app to make a DELETE request via the dart:io HttpClient.
56+
await helper.triggerRequest('delete/');
57+
_expectInRequestTable('DELETE');
58+
await helper.clear();
59+
60+
// Instruct the app to make a GET request via the 'http' package.
61+
await helper.triggerRequest('packageHttp/get/');
62+
_expectInRequestTable('GET');
63+
await helper.clear();
64+
65+
// Instruct the app to make a POST request via the 'http' package.
66+
await helper.triggerRequest('packageHttp/post/');
67+
_expectInRequestTable('POST');
68+
await helper.clear();
69+
70+
// Instruct the app to make a GET request via Dio.
71+
await helper.triggerRequest('dio/get/');
72+
_expectInRequestTable('GET');
73+
await helper.clear();
74+
75+
// Instruct the app to make a POST request via Dio.
76+
await helper.triggerRequest('dio/post/');
77+
_expectInRequestTable('POST');
78+
});
79+
}
80+
81+
final class _NetworkScreenHelper {
82+
_NetworkScreenHelper(this._tester, this._controlPort);
83+
84+
final WidgetTester _tester;
85+
86+
final int _controlPort;
87+
88+
Future<void> clear() async {
89+
// Press the 'Clear' button between tests.
90+
await _tester.tap(find.text('Clear'));
91+
await _tester.pump(safePumpDuration);
92+
expect(
93+
screenControllers.lookup<NetworkController>().requests.value,
94+
isEmpty,
95+
);
96+
}
97+
98+
Future<void> triggerRequest(String path) async {
99+
await http.get(Uri.parse('http://localhost:$_controlPort/$path'));
100+
await Future.delayed(const Duration(milliseconds: 200));
101+
await _tester.pump(safePumpDuration);
102+
}
103+
}
104+
105+
void _expectInRequestTable(String text) {
106+
expect(
107+
find.descendant(
108+
of: find.byType(DevToolsTable<NetworkRequest>),
109+
matching: find.text(text),
110+
),
111+
findsOneWidget,
112+
);
113+
}
114+
115+
/// Prepares the UI of the network screen for an integration test.
116+
Future<void> _prepareNetworkScreen(WidgetTester tester) async {
117+
await switchToScreen(
118+
tester,
119+
tabIcon: ScreenMetaData.network.icon,
120+
tabIconAsset: ScreenMetaData.network.iconAsset,
121+
screenId: ScreenMetaData.network.id,
122+
);
123+
}

0 commit comments

Comments
 (0)