Prepare DevTools tests for running in the Flutter customer test registry (#6505)
diff --git a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart index e8c5b86..8c47c6a 100644 --- a/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart +++ b/packages/devtools_app/lib/src/screens/deep_link_validation/deep_links_model.dart
@@ -33,8 +33,8 @@ @override bool matchesSearchToken(RegExp regExpSearch) { - return (domain.caseInsensitiveContains(regExpSearch) == true) || - (path.caseInsensitiveContains(regExpSearch) == true); + return domain.caseInsensitiveContains(regExpSearch) || + path.caseInsensitiveContains(regExpSearch); } @override
diff --git a/packages/devtools_app/pubspec.yaml b/packages/devtools_app/pubspec.yaml index e4eec89..c4174eb 100644 --- a/packages/devtools_app/pubspec.yaml +++ b/packages/devtools_app/pubspec.yaml
@@ -76,7 +76,7 @@ fake_async: ^1.3.1 flutter_driver: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.3 flutter_test: sdk: flutter integration_test:
diff --git a/packages/devtools_app/test/cpu_profiler/cpu_profile_model_test.dart b/packages/devtools_app/test/cpu_profiler/cpu_profile_model_test.dart index 2697b93..8af25d7 100644 --- a/packages/devtools_app/test/cpu_profiler/cpu_profile_model_test.dart +++ b/packages/devtools_app/test/cpu_profiler/cpu_profile_model_test.dart
@@ -28,17 +28,20 @@ ); }); - test('empty frame regression test', () { - final cpuProfileEmptyData = - CpuProfileData.parse(cpuProfileResponseEmptyJson); - expect( - cpuProfileEmptyData.profileMetaData.time!.end!.inMilliseconds, - 47377796, - ); - final filtered = - CpuProfileData.filterFrom(cpuProfileEmptyData, (_) => true); - expect(filtered.profileMetaData.time!.end!.inMilliseconds, 0); - }); + test( + 'empty frame regression test', + () { + final cpuProfileEmptyData = + CpuProfileData.parse(cpuProfileResponseEmptyJson); + expect( + cpuProfileEmptyData.profileMetaData.time!.end!.inMilliseconds, + 47377796, + ); + final filtered = + CpuProfileData.filterFrom(cpuProfileEmptyData, (_) => true); + expect(filtered.profileMetaData.time!.end!.inMilliseconds, 0); + }, + ); test('init from parse', () { expect( @@ -112,30 +115,39 @@ expect(cpuProfileData.toJson, equals(goldenCpuProfileDataJson)); }); - test('converts golden samples to golden cpu profile data', () async { - final generatedCpuProfileData = - await CpuProfileData.generateFromCpuSamples( - isolateId: goldenSamplesIsolate, - cpuSamples: CpuSamples.parse(goldenCpuSamplesJson)!, - ); + test( + 'converts golden samples to golden cpu profile data', + () async { + final generatedCpuProfileData = + await CpuProfileData.generateFromCpuSamples( + isolateId: goldenSamplesIsolate, + cpuSamples: CpuSamples.parse(goldenCpuSamplesJson)!, + ); - expect(generatedCpuProfileData.toJson, equals(goldenCpuProfileDataJson)); - }); + expect( + generatedCpuProfileData.toJson, + equals(goldenCpuProfileDataJson), + ); + }, + ); - test('to json defaults packageUri to resolvedUrl', () { - const id = '140357727781376-12'; - final profileData = Map<String, dynamic>.from(goldenCpuProfileDataJson); - profileData['stackFrames'] = Map<String, Map<String, String?>>.from( - {id: goldenCpuProfileStackFrames[id]}, - ); - profileData['stackFrames'][id] - .remove(CpuProfileData.resolvedPackageUriKey); + test( + 'to json defaults packageUri to resolvedUrl', + () { + const id = '140357727781376-12'; + final profileData = Map<String, dynamic>.from(goldenCpuProfileDataJson); + profileData['stackFrames'] = Map<String, Map<String, String?>>.from( + {id: goldenCpuProfileStackFrames[id]}, + ); + profileData['stackFrames'][id] + .remove(CpuProfileData.resolvedPackageUriKey); - final parsedProfileData = CpuProfileData.parse(profileData); + final parsedProfileData = CpuProfileData.parse(profileData); - final jsonPackageUri = parsedProfileData.stackFrames[id]!.packageUri; - expect(jsonPackageUri, goldenCpuProfileStackFrames[id]!['resolvedUrl']); - }); + final jsonPackageUri = parsedProfileData.stackFrames[id]!.packageUri; + expect(jsonPackageUri, goldenCpuProfileStackFrames[id]!['resolvedUrl']); + }, + ); test('generateFromCpuSamples handles duplicate resolvedUrls', () async { const resolvedUrl = 'the/resolved/Url';
diff --git a/packages/devtools_app_shared/pubspec.yaml b/packages/devtools_app_shared/pubspec.yaml index e696168..e2d9f6b 100644 --- a/packages/devtools_app_shared/pubspec.yaml +++ b/packages/devtools_app_shared/pubspec.yaml
@@ -18,10 +18,10 @@ vm_service: ^11.10.0 dev_dependencies: - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.3 flutter_test: sdk: flutter - lints: ^2.0.0 + lints: ^2.1.1 test: ^1.21.0 flutter:
diff --git a/packages/devtools_extensions/example/app_that_uses_foo/pubspec.yaml b/packages/devtools_extensions/example/app_that_uses_foo/pubspec.yaml index f888c1b..dd0bb54 100644 --- a/packages/devtools_extensions/example/app_that_uses_foo/pubspec.yaml +++ b/packages/devtools_extensions/example/app_that_uses_foo/pubspec.yaml
@@ -17,7 +17,7 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.3 flutter: uses-material-design: true
diff --git a/packages/devtools_extensions/example/foo/packages/foo/pubspec.yaml b/packages/devtools_extensions/example/foo/packages/foo/pubspec.yaml index 3207f78..e968c33 100644 --- a/packages/devtools_extensions/example/foo/packages/foo/pubspec.yaml +++ b/packages/devtools_extensions/example/foo/packages/foo/pubspec.yaml
@@ -13,4 +13,4 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.3
diff --git a/packages/devtools_extensions/lib/src/template/extension_manager.dart b/packages/devtools_extensions/lib/src/template/extension_manager.dart index f4e22d9..3f22110 100644 --- a/packages/devtools_extensions/lib/src/template/extension_manager.dart +++ b/packages/devtools_extensions/lib/src/template/extension_manager.dart
@@ -210,7 +210,7 @@ }); } - void showNotification(String message) async { + void showNotification(String message) { postMessageToDevTools( ShowNotificationExtensionEvent(message: message), ); @@ -222,7 +222,7 @@ required String message, required String extensionName, bool ignoreIfAlreadyDismissed = true, - }) async { + }) { postMessageToDevTools( ShowBannerMessageExtensionEvent( id: key,
diff --git a/packages/devtools_extensions/pubspec.yaml b/packages/devtools_extensions/pubspec.yaml index 095d0ec..f8e2116 100644 --- a/packages/devtools_extensions/pubspec.yaml +++ b/packages/devtools_extensions/pubspec.yaml
@@ -25,7 +25,7 @@ dev_dependencies: flutter_driver: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.3 flutter_test: sdk: flutter flutter_web_plugins:
diff --git a/packages/devtools_extensions/test/api_test.dart b/packages/devtools_extensions/test/api_test.dart index 152f361..16996f8 100644 --- a/packages/devtools_extensions/test/api_test.dart +++ b/packages/devtools_extensions/test/api_test.dart
@@ -260,7 +260,7 @@ expect(showBannerMessageEvent.extensionName, 'blah'); expect(showBannerMessageEvent.ignoreIfAlreadyDismissed, false); }); - test('throws for unexpected values', () async { + test('throws for unexpected values', () { final event1 = DevToolsExtensionEvent.parse({ 'type': 'showBannerMessage', 'data': {
diff --git a/packages/devtools_test/lib/src/wrappers.dart b/packages/devtools_test/lib/src/wrappers.dart index 4f66d6a..4814998 100644 --- a/packages/devtools_test/lib/src/wrappers.dart +++ b/packages/devtools_test/lib/src/wrappers.dart
@@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:meta/meta.dart'; import 'package:provider/provider.dart'; /// The RouterDelegate must use the same NavigatorKey when building in order @@ -169,6 +170,7 @@ } /// Runs a test with the size of the app window under test to [windowSize]. +@isTest void testWidgetsWithWindowSize( String name, Size windowSize,
diff --git a/packages/devtools_test/pubspec.yaml b/packages/devtools_test/pubspec.yaml index 28541e5..7fe14f8 100644 --- a/packages/devtools_test/pubspec.yaml +++ b/packages/devtools_test/pubspec.yaml
@@ -26,6 +26,7 @@ sdk: flutter flutter_test: sdk: flutter + meta: ^1.9.1 mockito: ^5.4.1 path: ^1.8.0 provider: ^6.0.2
diff --git a/packages/pubspec.yaml b/packages/pubspec.yaml index 6029551..19b21de 100644 --- a/packages/pubspec.yaml +++ b/packages/pubspec.yaml
@@ -6,4 +6,4 @@ sdk: '>=3.0.0 <4.0.0' dev_dependencies: - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.3
diff --git a/tool/flutter_customer_tests/analyze.sh b/tool/flutter_customer_tests/analyze.sh new file mode 100755 index 0000000..e7025cb --- /dev/null +++ b/tool/flutter_customer_tests/analyze.sh
@@ -0,0 +1,14 @@ +#!/bin/bash -e +# Script to analyze the devtools repo for the flutter/tests registry +# https://github.com/flutter/tests +# This is executed as a pre-submit check for every PR in flutter/flutter + +# At this point we can expect that mocks have already been generated +# from the setup steps in +# https://github.com/flutter/tests/blob/main/registry/flutter_devtools.test + +cd tool +flutter pub get +dart bin/devtools_tool.dart pub-get +dart bin/devtools_tool.dart analyze +cd ..
diff --git a/tool/flutter_customer_tests/test.sh b/tool/flutter_customer_tests/test.sh new file mode 100755 index 0000000..4df6f0a --- /dev/null +++ b/tool/flutter_customer_tests/test.sh
@@ -0,0 +1,16 @@ +# Script to execute smoke tests for the flutter/tests registry +# https://github.com/flutter/tests +# This is executed as a pre-submit check for every PR in flutter/flutter + +# At this point we can expect that mocks have already been generated +# from the setup steps in +# https://github.com/flutter/tests/blob/main/registry/flutter_devtools.test + +# Test all tests in devtools_app_shared +cd packages/devtools_app_shared +flutter pub get +flutter test test/ + +cd ../devtools_app +flutter pub get +flutter test test/
diff --git a/tool/flutter_tests.sh b/tool/flutter_tests.sh deleted file mode 100755 index 60b231c..0000000 --- a/tool/flutter_tests.sh +++ /dev/null
@@ -1,15 +0,0 @@ -# Script to execute smoke tests for the flutter/tests registry -# https://github.com/flutter/tests -# This is executed as a pre-submit check for every PR in flutter/flutter - -# Generate mocks for tests -# flutter/tests does not allow output from execution. -./tool/generate_code.sh >> output.txt - -# Test devtools_shared -cd packages/devtools_shared -flutter test test/ - -# Test devtools_app -cd ../devtools_app -flutter test test/
diff --git a/tool/lib/model.dart b/tool/lib/model.dart index fc58dc5..a7cee17 100644 --- a/tool/lib/model.dart +++ b/tool/lib/model.dart
@@ -28,7 +28,6 @@ final result = <Package>[]; final repoDir = Directory(repoPath); - // For the first level of packages, ignore any directory named 'flutter'. for (FileSystemEntity entity in repoDir.listSync()) { final name = path.basename(entity.path); if (entity is Directory && !name.startsWith('.')) { @@ -61,7 +60,10 @@ // directory. if (dir.path.contains('flutter-sdk/')) return; - if (_fileExists(dir, 'pubspec.yaml')) { + // Do not include the top level devtools/packages directory in the results + // even though it has a pubspec.yaml file. + if (_fileExists(dir, 'pubspec.yaml') && + !dir.path.endsWith('/devtools/packages')) { result.add(Package._(this, dir.path)); }