Skip to content

Inspector integration tests are resilient to Flutter framework changes #9321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flutter-candidate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2b6b9d12589875842e64f4b78fd0f11337755aaa
c2ea27002b9c4ab1aff1db6eb1960e4299aca369
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ import '../../test_infra/matchers/matchers.dart';
const inspectorChangeSettleTime = Duration(seconds: 2);

void main() {
const windowSize = Size(2600.0, 1200.0);
// We need to use real async in this test so we need to use this binding.
initializeLiveTestWidgetsFlutterBindingWithAssets();
const windowSize = Size(2600.0, 1200.0);

final env = FlutterTestEnvironment(
const FlutterRunConfiguration(withDebugger: true),
);
late FlutterTestEnvironment env;

env.afterEverySetup = () async {
Future<void> resetInspectorSelection() async {
final service = serviceConnection.inspectorService;
if (env.reuseTestEnvironment) {
// Ensure the previous test did not set the selection on the device.
Expand All @@ -37,19 +35,26 @@ void main() {
isAlive: null,
);
}
};
}

setUp(() async {
await env.setupEnvironment();
// Ensure the legacy inspector is enabled:
preferences.inspector.setLegacyInspectorEnabled(true);
});
group('screenshot tests', () {
setUpAll(() {
env = FlutterTestEnvironment(
const FlutterRunConfiguration(withDebugger: true),
);
env.afterEverySetup = resetInspectorSelection;
});

tearDownAll(() async {
await env.tearDownEnvironment(force: true);
});
setUp(() async {
await env.setupEnvironment();
// Ensure the legacy inspector is enabled:
preferences.inspector.setLegacyInspectorEnabled(true);
});

tearDownAll(() async {
await env.tearDownEnvironment(force: true);
});

group('screenshot tests', () {
testWidgetsWithWindowSize('navigation', windowSize, (
WidgetTester tester,
) async {
Expand Down Expand Up @@ -99,6 +104,9 @@ void main() {
matchesDevToolsGolden(
'../../test_infra/goldens/integration_inspector_select_center_details_tree.png',
),
// Implementation widgets from Flutter framework are not guaranteed to
// be stable.
skip: 'https://github.com/flutter/flutter/issues/172037',
Comment on lines +107 to +109

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what you guys were hoping to test with these goldens and if it can be achieved with widget tests instead?

Taking a look at a golden image here (https://github.com/flutter/devtools/blob/master/packages/devtools_app/test/test_infra/goldens/integration_inspector_select_center_details_tree.png) it looks pretty UI-light, which is generally better for golden testing, but still I usually avoid golden testing if possible due to unintended breakages like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the golden tests are mostly to make sure that we don't accidentally introduce some UI change that we wouldn't have thought to test in our widget tests. Since this specific view will be going away, I'm not too concerned about not having comprehensive test coverage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the V2 view, I think the fact that we have golden tests for the panel (just without implementation widgets enabled) should catch the vast majority of UI regressions.

);

// Select the RichText row.
Expand All @@ -109,6 +117,9 @@ void main() {
matchesDevToolsGolden(
'../../test_infra/goldens/integration_inspector_richtext_selected.png',
),
// Implementation widgets from Flutter framework are not guaranteed to
// be stable.
skip: 'https://github.com/flutter/flutter/issues/172037',
);

// Test hovering over the icon shown when a property has its default
Expand All @@ -131,6 +142,9 @@ void main() {
matchesDevToolsGolden(
'../../test_infra/goldens/integration_inspector_scaffold_selected.png',
),
// Implementation widgets from Flutter framework are not guaranteed to
// be stable.
skip: 'https://github.com/flutter/flutter/issues/172037',
);

// The important thing about this is that the details tree should scroll
Expand All @@ -143,6 +157,9 @@ void main() {
matchesDevToolsGolden(
'../../test_infra/goldens/integration_animated_physical_model_selected.png',
),
// Implementation widgets from Flutter framework are not guaranteed to
// be stable.
skip: 'https://github.com/flutter/flutter/issues/172037',
);

await env.tearDownEnvironment();
Expand Down Expand Up @@ -401,15 +418,25 @@ void main() {
});

group('widget errors', () {
testWidgetsWithWindowSize('show navigator and error labels', windowSize, (
WidgetTester tester,
) async {
setUpAll(() async {
env = FlutterTestEnvironment(
testAppDirectory: 'test/test_infra/fixtures/inspector_app',
const FlutterRunConfiguration(withDebugger: true),
);
await env.setupEnvironment(
config: const FlutterRunConfiguration(
withDebugger: true,
entryScript: 'lib/overflow_errors.dart',
),
);
env.afterEverySetup = resetInspectorSelection;
// Enable the legacy inspector.
preferences.inspector.setLegacyInspectorEnabled(true);
});

testWidgetsWithWindowSize('show navigator and error labels', windowSize, (
WidgetTester tester,
) async {
expect(serviceConnection.serviceManager.service, equals(env.service));
expect(serviceConnection.serviceManager.isolateManager, isNotNull);

Expand Down
Loading
Loading