diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 125a7ca0e6b..5386271c604 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -74,7 +74,7 @@ jobs: wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list sudo apt-get update - sudo apt-get install dcm=1.38.1-1 # To avoid errors add `-1` (build number) to the version + sudo apt-get install dcm=1.38.3-1 # To avoid errors add `-1` (build number) to the version sudo chmod +x /usr/bin/dcm echo "$(dcm --version)" - name: Setup Dart SDK diff --git a/analysis_options.yaml b/analysis_options.yaml index e5b9fd19a59..7438d8d372a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -174,8 +174,8 @@ dart_code_metrics: - lib/src/screens/inspector/**_controller.dart - lib/src/shared/diagnostics/inspector_service.dart - lib/src/shared/diagnostics/diagnostics_node.dart - - - test/** + # This fixture has unused code for testing the debugger. + - test/test_infra/fixtures/flutter_app/** rules: # - arguments-ordering Too strict # - avoid-banned-imports # TODO(polina-c): add configuration diff --git a/flutter-candidate.txt b/flutter-candidate.txt index 5900694a6d8..f094eb2ae96 100644 --- a/flutter-candidate.txt +++ b/flutter-candidate.txt @@ -1 +1 @@ -ad80825c24d770a19e33f67800fc0338a3b89ec7 +0f0246377b1c9d8bc365a439c520a7de6c3f590b diff --git a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart index a41441fcf36..b9e158009c5 100644 --- a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart +++ b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart @@ -48,13 +48,10 @@ class PerformanceController extends DevToolsScreenController @override final screenId = ScreenMetaData.performance.id; - // ignore: dispose-class-fields, false positive. See `applyToFeatureControllers` in the dispose() method. late final FlutterFramesController flutterFramesController; - // ignore: dispose-class-fields, false positive. See `applyToFeatureControllers` in the dispose() method. late final TimelineEventsController timelineEventsController; - // ignore: dispose-class-fields, false positive. See `applyToFeatureControllers` in the dispose() method. late final RebuildStatsController rebuildStatsController; // ignore: dispose-class-fields, false positive. See `applyToFeatureControllers` in the dispose() method. diff --git a/packages/devtools_app/test/screens/cpu_profiler/cpu_profile_benchmark_test.dart b/packages/devtools_app/test/screens/cpu_profiler/cpu_profile_benchmark_test.dart index 59ed603ebe7..b4e7d430269 100644 --- a/packages/devtools_app/test/screens/cpu_profiler/cpu_profile_benchmark_test.dart +++ b/packages/devtools_app/test/screens/cpu_profiler/cpu_profile_benchmark_test.dart @@ -35,7 +35,7 @@ void main() { final score = await benchmark.measure(); expect( score, - lessThan(110000), + lessThan(120000), reason: 'Exceeded benchmark for run $i: $score', ); } diff --git a/packages/devtools_app/test/screens/inspector/inspector_integration_test.dart b/packages/devtools_app/test/screens/inspector/inspector_integration_test.dart index 65ab143f45e..970108a134b 100644 --- a/packages/devtools_app/test/screens/inspector/inspector_integration_test.dart +++ b/packages/devtools_app/test/screens/inspector/inspector_integration_test.dart @@ -31,14 +31,39 @@ import '../../test_infra/matchers/matchers.dart'; // reduced to under 1 second without introducing flakes. const inspectorChangeSettleTime = Duration(seconds: 2); +void _copyDirectorySync(Directory source, Directory destination) { + if (!destination.existsSync()) { + destination.createSync(recursive: true); + } + for (final entity in source.listSync()) { + final newPath = p.join(destination.path, p.basename(entity.path)); + if (entity is Directory) { + _copyDirectorySync(entity, Directory(newPath)); + } else if (entity is File) { + entity.copySync(newPath); + } + } +} + void main() { // We need to use real async in this test so we need to use this binding. initializeLiveTestWidgetsFlutterBindingWithAssets(); const windowSize = Size(2600.0, 1200.0); + // We copy the fixture app to a temporary directory because the + // auto-refresh tests modify lib/main.dart in-place. If this used the shared + // 'inspector_app' fixture, it could cause flaky test failures in other tests + // (like inspector_service_test.dart) that run in parallel. + final tempAppDir = + 'test/test_infra/fixtures/inspector_app_temp_${DateTime.now().millisecondsSinceEpoch}'; + _copyDirectorySync( + Directory('test/test_infra/fixtures/inspector_app'), + Directory(tempAppDir), + ); + final env = FlutterTestEnvironment( const FlutterRunConfiguration(withDebugger: true), - testAppDirectory: 'test/test_infra/fixtures/inspector_app', + testAppDirectory: tempAppDir, ); env.afterEverySetup = () async { @@ -67,6 +92,10 @@ void main() { tearDownAll(() { env.finalTeardown(); + final dir = Directory(tempAppDir); + if (dir.existsSync()) { + dir.deleteSync(recursive: true); + } }); group('screenshot tests', () { @@ -653,17 +682,6 @@ void verifyPropertyIsVisible({ expect(propertyNameCenter.dy, equals(propertyValueCenter.dy)); } -bool areHorizontallyAligned( - Finder widgetAFinder, - Finder widgetBFinder, { - required WidgetTester tester, -}) { - final widgetACenter = tester.getCenter(widgetAFinder); - final widgetBCenter = tester.getCenter(widgetBFinder); - - return widgetACenter.dy == widgetBCenter.dy; -} - bool _treeRowsAreInOrder({ required List treeRowDescriptions, required int startingAtIndex, diff --git a/packages/devtools_app/test/screens/memory/framework/memory_service_test.dart b/packages/devtools_app/test/screens/memory/framework/memory_service_test.dart deleted file mode 100644 index 650f13afef1..00000000000 --- a/packages/devtools_app/test/screens/memory/framework/memory_service_test.dart +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2019 The Flutter Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. - -import 'package:devtools_app/src/screens/memory/framework/memory_controller.dart'; -import 'package:devtools_app/src/screens/memory/shared/primitives/memory_timeline.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import '../../../test_infra/flutter_test_driver.dart' - show FlutterRunConfiguration; -import '../../../test_infra/flutter_test_environment.dart'; - -late MemoryController memoryController; - -// Track number of onMemory events received. -int memoryTrackersReceived = 0; - -int previousTimestamp = 0; - -bool firstSample = true; - -void main() { - // TODO(https://github.com/flutter/devtools/issues/2053): rewrite. - // ignore: dead_code - if (false) { - final env = FlutterTestEnvironment( - const FlutterRunConfiguration(withDebugger: true), - ); - - env.afterNewSetup = () { - memoryController = MemoryController(); - }; - } -} - -void validateHeapInfo(MemoryTimeline timeline) { - for (final sample in timeline.data) { - expect(sample.timestamp, greaterThan(0)); - expect(sample.timestamp, greaterThan(previousTimestamp)); - - expect(sample.used, greaterThan(0)); - expect(sample.used, lessThan(sample.capacity)); - - expect(sample.external, greaterThan(0)); - expect(sample.external, lessThan(sample.capacity)); - - // TODO(terry): Bug - VM's first HeapSample returns a null for the rss value. - // Subsequent samples the rss values are valid integers. This is - // a VM regression https://github.com/dart-lang/sdk/issues/40766. - // When fixed, remove below test rss != null and firstSample global. - if (firstSample) { - expect(sample.rss, greaterThan(0)); - expect(sample.rss, greaterThan(sample.capacity)); - firstSample = false; - } - - expect(sample.capacity, greaterThan(0)); - expect(sample.capacity, greaterThan(sample.used + sample.external)); - - previousTimestamp = sample.timestamp; - } - - timeline.data.clear(); - - memoryTrackersReceived++; -} diff --git a/packages/devtools_app/test/shared/primitives/utils_test.dart b/packages/devtools_app/test/shared/primitives/utils_test.dart index 941165d0443..f71c0cae441 100644 --- a/packages/devtools_app/test/shared/primitives/utils_test.dart +++ b/packages/devtools_app/test/shared/primitives/utils_test.dart @@ -704,135 +704,3 @@ class _SubtractionResult { @override String toString() => '$from - $subtract'; } - -// This was generated from a canvas with font size 14.0. -const asciiMeasurements = [ - 0, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 0, - 3.8896484375, - 3.8896484375, - 3.8896484375, - 3.8896484375, - 3.8896484375, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 4.6619873046875, - 0, - 4.6619873046875, - 4.6619873046875, - 3.8896484375, - 3.8896484375, - 4.9697265625, - 7.7861328125, - 7.7861328125, - 12.4482421875, - 9.337890625, - 2.6728515625, - 4.662109375, - 4.662109375, - 5.4482421875, - 8.17578125, - 3.8896484375, - 4.662109375, - 3.8896484375, - 3.8896484375, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 3.8896484375, - 3.8896484375, - 8.17578125, - 8.17578125, - 8.17578125, - 7.7861328125, - 14.2119140625, - 9.337890625, - 9.337890625, - 10.1103515625, - 10.1103515625, - 9.337890625, - 8.5517578125, - 10.8896484375, - 10.1103515625, - 3.8896484375, - 7, - 9.337890625, - 7.7861328125, - 11.662109375, - 10.1103515625, - 10.8896484375, - 9.337890625, - 10.8896484375, - 10.1103515625, - 9.337890625, - 8.5517578125, - 10.1103515625, - 9.337890625, - 13.2138671875, - 9.337890625, - 9.337890625, - 8.5517578125, - 3.8896484375, - 3.8896484375, - 3.8896484375, - 6.5693359375, - 7.7861328125, - 4.662109375, - 7.7861328125, - 7.7861328125, - 7, - 7.7861328125, - 7.7861328125, - 3.8896484375, - 7.7861328125, - 7.7861328125, - 3.1103515625, - 3.1103515625, - 7, - 3.1103515625, - 11.662109375, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 7.7861328125, - 4.662109375, - 7, - 3.8896484375, - 7.7861328125, - 7, - 10.1103515625, - 7, - 7, - 7, - 4.67578125, - 3.63671875, - 4.67578125, - 8.17578125, - 0, -]; diff --git a/packages/devtools_app/test/test_infra/fixtures/debugging_app.dart b/packages/devtools_app/test/test_infra/fixtures/debugging_app.dart deleted file mode 100644 index bb732d9187d..00000000000 --- a/packages/devtools_app/test/test_infra/fixtures/debugging_app.dart +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2019 The Flutter Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. - -// ignore_for_file: avoid_print - -import 'dart:async'; - -void main() { - print('starting debugging app'); - - final cat = Cat('Fluffy'); - - void run() { - Timer(const Duration(milliseconds: 100), () { - cat.performAction(); - - run(); - }); - } - - run(); -} - -class Cat { - Cat(this.name); - - final String name; - - String get type => 'cat'; - - int actionCount = 0; - - void performAction() { - String actionStr = 'catAction'; - actionStr = '$actionStr!'; - - actionCount++; // breakpoint - } -} diff --git a/packages/devtools_app/test/test_infra/fixtures/logging_app.dart b/packages/devtools_app/test/test_infra/fixtures/logging_app.dart deleted file mode 100644 index afe3700a6a2..00000000000 --- a/packages/devtools_app/test/test_infra/fixtures/logging_app.dart +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2018 The Flutter Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. - -// ignore_for_file: avoid_print - -import 'dart:async'; -import 'dart:developer'; -import 'dart:io'; - -// Allow a test driver to communicate with this app through the controller. -final controller = Controller(); - -void main() { - print('starting logging app'); - log('starting logging app'); - - // Don't exit until it's indicated we should by the controller. - Timer(const Duration(days: 1), () {}); -} - -class Controller { - int count = 0; - - void emitLog() { - count++; - - print('emitLog called'); - log('emit log $count', name: 'logging'); - } - - void shutdown() { - print('stopping app'); - log('stopping app'); - - exit(0); - } -} diff --git a/packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart b/packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart index 73d1d30a4ab..c875688e804 100644 --- a/packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart +++ b/packages/devtools_app/test/test_infra/fixtures/networking_app/bin/main.dart @@ -100,11 +100,6 @@ class _HttpClient { final _dio = Dio(); - void close() { - _client.close(force: true); - _dio.close(force: true); - } - void get() async { print('Sending GET...'); final request = await _client.getUrl(_uri); diff --git a/packages/devtools_app/test/test_infra/flutter_test_driver.dart b/packages/devtools_app/test/test_infra/flutter_test_driver.dart index 99eda70e734..5aa28a639f0 100644 --- a/packages/devtools_app/test/test_infra/flutter_test_driver.dart +++ b/packages/devtools_app/test/test_infra/flutter_test_driver.dart @@ -43,17 +43,9 @@ abstract class FlutterTestDriver { final errorBuffer = StringBuffer(); late String lastResponse; late Uri _vmServiceWsUri; - bool hasExited = false; VmServiceWrapper? vmService; - String get lastErrorInfo => errorBuffer.toString(); - - Stream get stderr => stderrController.stream; - Stream get stdout => stdoutController.stream; - - Uri get vmServiceUri => _vmServiceWsUri; - String _debugPrint(String msg) { const maxLength = 500; final truncatedMsg = msg.length > maxLength @@ -94,7 +86,6 @@ abstract class FlutterTestDriver { unawaited( proc.exitCode.then((int code) { _debugPrint('Process exited ($code)'); - hasExited = true; }), ); transformToLines( diff --git a/packages/devtools_app/test/test_infra/flutter_test_environment.dart b/packages/devtools_app/test/test_infra/flutter_test_environment.dart index 812853c2b2b..bb81e3e1c1b 100644 --- a/packages/devtools_app/test/test_infra/flutter_test_environment.dart +++ b/packages/devtools_app/test/test_infra/flutter_test_environment.dart @@ -71,11 +71,6 @@ class FlutterTestEnvironment { /// test/my_test.dart`). final String _flutterExe; - // This function will be called after we have ran the Flutter app and the - // vmService is opened. - Future Function()? _afterNewSetup; - set afterNewSetup(Future Function() f) => _afterNewSetup = f; - // This function will be called for every call to [setupEnvironment], even // when the setup is not forced or triggered by a new FlutterRunConfiguration. Future Function()? _afterEverySetup; @@ -89,12 +84,6 @@ class FlutterTestEnvironment { set beforeEveryTearDown(Future Function() f) => _beforeEveryTearDown = f; - // The function will be called before the final forced teardown at the end - // of the test suite (which will then stop the Flutter app). - Future Function()? _beforeFinalTearDown; - set beforeFinalTearDown(Future Function() f) => - _beforeFinalTearDown = f; - bool _needsSetup = true; Completer? _setupInProgress; @@ -173,8 +162,6 @@ class FlutterTestEnvironment { } finally { _setupInProgress!.complete(!_needsSetup); } - - if (_afterNewSetup != null) await _afterNewSetup!(); } if (_afterEverySetup != null) await _afterEverySetup!(); } @@ -192,8 +179,6 @@ class FlutterTestEnvironment { return; } - if (_beforeFinalTearDown != null) await _beforeFinalTearDown!(); - await serviceConnection.serviceManager.manuallyDisconnect(); await _service.allFuturesCompleted.timeout( diff --git a/packages/devtools_app/test/test_infra/matchers/matchers.dart b/packages/devtools_app/test/test_infra/matchers/matchers.dart index 6005a4540a8..e13237043ee 100644 --- a/packages/devtools_app/test/test_infra/matchers/matchers.dart +++ b/packages/devtools_app/test/test_infra/matchers/matchers.dart @@ -34,14 +34,6 @@ String treeToDebugString(RemoteDiagnosticsNode node) { return node.toDiagnosticsNode().toStringDeep(); } -String treeToDebugStringTruncated(RemoteDiagnosticsNode node, int maxLines) { - List lines = node.toDiagnosticsNode().toStringDeep().split('\n'); - if (lines.length > maxLines) { - lines = lines.take(maxLines).toList()..add('...'); - } - return lines.join('\n'); -} - /// Asserts that a [path] matches a golden file after normalizing likely hash /// codes. /// diff --git a/packages/devtools_app/test/test_infra/scenes/memory/diff_snapshot.dart b/packages/devtools_app/test/test_infra/scenes/memory/diff_snapshot.dart index aa79a9d08dc..ce34c5f5238 100644 --- a/packages/devtools_app/test/test_infra/scenes/memory/diff_snapshot.dart +++ b/packages/devtools_app/test/test_infra/scenes/memory/diff_snapshot.dart @@ -60,6 +60,4 @@ class DiffSnapshotScene extends Scene { ClassFilter(filterType: ClassFilterType.showAll, except: '', only: ''), ); } - - void tearDown() {} } diff --git a/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart b/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart index a762658e145..d2d66ef6531 100644 --- a/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart +++ b/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart @@ -35,11 +35,6 @@ class SimulatedEditor { return editor; } - void dispose() { - unawaited(_logger.close()); - unawaited(close()); - } - /// The URI of the DTD instance we are connecting/connected to. final Uri _dtdUri; @@ -49,6 +44,7 @@ class SimulatedEditor { DartToolingDaemon? _dtd; /// A controller for emitting to [log]. + // ignore: dispose-class-fields, only used in tests. final _logger = StreamController(); /// A stream of protocol traffic between the editor and DTD (or postMessage @@ -209,10 +205,6 @@ class SimulatedEditor { await _postEvent(DebugSessionStartedEvent(debugSession: debugSession)); } - void sendDebugSessionChanged(EditorDebugSession debugSession) async { - await _postEvent(DebugSessionChangedEvent(debugSession: debugSession)); - } - void sendDebugSessionStopped(EditorDebugSession debugSession) async { await _postEvent(DebugSessionStoppedEvent(debugSessionId: debugSession.id)); } diff --git a/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_sidebar.dart b/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_sidebar.dart index 57cbd4fa9e4..bdf95127c43 100644 --- a/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_sidebar.dart +++ b/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_sidebar.dart @@ -9,7 +9,6 @@ import 'package:devtools_app/src/standalone_ui/standalone_screen.dart'; import 'package:devtools_app_shared/service.dart'; import 'package:devtools_app_shared/ui.dart'; import 'package:devtools_app_shared/utils.dart'; -import 'package:dtd/dtd.dart'; import 'package:flutter/material.dart'; import 'package:stager/stager.dart'; @@ -24,7 +23,6 @@ import 'shared/utils.dart'; /// flutter run -t test/test_infra/scenes/standalone_ui/editor_sidebar.stager_app.g.dart -d chrome class EditorSidebarScene extends Scene { late Stream clientLog; - late DartToolingDaemon clientDtd; late SimulatedEditor editor; @override diff --git a/packages/devtools_app/test/test_infra/scenes/standalone_ui/shared/utils.dart b/packages/devtools_app/test/test_infra/scenes/standalone_ui/shared/utils.dart index 0156a7f2603..bfda887b284 100644 --- a/packages/devtools_app/test/test_infra/scenes/standalone_ui/shared/utils.dart +++ b/packages/devtools_app/test/test_infra/scenes/standalone_ui/shared/utils.dart @@ -9,10 +9,6 @@ import 'package:dtd/dtd.dart'; import 'package:stream_channel/stream_channel.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; -/// A record of a [StreamChannel] and a [Stream] of logs of protocol traffic -/// in both directions across it. -typedef LoggedChannel = ({StreamChannel channel, Stream log}); - /// Connects to the websocket at [wsUri] and returns a [StreamSink]. /// /// All traffic is logged into [sink]. diff --git a/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart b/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart index 1f8ebc5272f..beaf9c50d45 100644 --- a/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart +++ b/packages/devtools_app/test/test_infra/test_data/deep_link/fake_responses.dart @@ -429,18 +429,6 @@ const iosValidationResponseWithError = ''' } '''; -const androidDeepLinkWithPathErrors = '''{ - "host": "example.com", - "path": "/path", - "intentFilterCheck": { - "hasBrowsableCategory": false, - "hasActionView": true, - "hasDefaultCategory": true, - "hasAutoVerify": true - } - } -'''; - const defaultDomain = 'example.com'; String androidDeepLinkJson( diff --git a/packages/devtools_app/test/test_infra/test_data/memory/heap/heap_data.dart b/packages/devtools_app/test/test_infra/test_data/memory/heap/heap_data.dart index 867dff6eae7..be031245f44 100644 --- a/packages/devtools_app/test/test_infra/test_data/memory/heap/heap_data.dart +++ b/packages/devtools_app/test/test_infra/test_data/memory/heap/heap_data.dart @@ -32,15 +32,6 @@ class GoldenHeapTest extends HeapTest { } } -class MockedHeapTest extends HeapTest { - MockedHeapTest({required super.appClassName}); - - @override - Future loadHeap() { - throw UnimplementedError(); - } -} - /// Provides test snapshots from pre-saved goldens. class HeapGraphLoaderGoldens implements HeapGraphLoader { int _nextIndex = 0; diff --git a/packages/devtools_app/test/test_infra/test_data/performance/sample_performance_data.dart b/packages/devtools_app/test/test_infra/test_data/performance/sample_performance_data.dart index 8a9362ca124..e453bb56b31 100644 --- a/packages/devtools_app/test/test_infra/test_data/performance/sample_performance_data.dart +++ b/packages/devtools_app/test/test_infra/test_data/performance/sample_performance_data.dart @@ -140,32 +140,6 @@ extension FlutterFrame2 on Never { ..setEventFlow(uiEvent) ..setEventFlow(rasterEvent); - static const uiEventAsString = - ''' Animator::BeginFrame [713834379092 μs - 713834379102 μs] -'''; - - static const rasterEventAsString = - ''' Rasterizer::DoDraw [713836088591 μs - 713836108931 μs] - Rasterizer::DrawToSurfaces [713836088592 μs - 713836108917 μs] - GPUSurfaceMetalImpeller::AcquireFrame [713836088607 μs - 713836093553 μs] - SurfaceMTL::WrapCurrentMetalLayerDrawable [713836088654 μs - 713836093545 μs] - WaitForNextDrawable [713836088655 μs - 713836093541 μs] - CompositorContext::ScopedFrame::Raster [713836093557 μs - 713836093615 μs] - LayerTree::Preroll [713836093580 μs - 713836093597 μs] - IOSExternalViewEmbedder::PostPrerollAction [713836093598 μs - 713836093598 μs] - LayerTree::Paint [713836093599 μs - 713836093615 μs] - SurfaceFrame::Submit [713836093616 μs - 713836108864 μs] - SurfaceFrame::BuildDisplayList [713836093616 μs - 713836093621 μs] - DisplayListDispatcher::EndRecordingAsPicture [713836094185 μs - 713836094188 μs] - Renderer::Render [713836094188 μs - 713836108846 μs] - EntityPass::OnRender [713836094556 μs - 713836108700 μs] - CreateGlyphAtlas [713836099800 μs - 713836108025 μs] - CanAppendToExistingAtlas [713836099807 μs - 713836099810 μs] - OptimumAtlasSizeForFontGlyphPairs [713836099811 μs - 713836099835 μs] - CreateAtlasBitmap [713836099845 μs - 713836103975 μs] - UploadGlyphTextureAtlas [713836103979 μs - 713836108020 μs] -'''; - static final uiEvent = animatorBeginFrameEvent; static final animatorBeginFrameEvent = testTimelineEvent( name: 'Animator::BeginFrame', @@ -385,40 +359,6 @@ extension FlutterFrame4 on Never { 'vsyncOverhead': 12625, }; - static const uiEventAsString = - ''' Animator::BeginFrame [713836200161 μs - 713836206957 μs] - LAYOUT (root) [713836202351 μs - 713836202383 μs] - LAYOUT [713836202373 μs - 713836202380 μs] - UPDATING COMPOSITING BITS (root) [713836202387 μs - 713836202402 μs] - UPDATING COMPOSITING BITS [713836202397 μs - 713836202400 μs] - PAINT (root) [713836202408 μs - 713836202429 μs] - PAINT [713836202422 μs - 713836202427 μs] - COMPOSITING [713836202440 μs - 713836206727 μs] - Animator::Render [713836206671 μs - 713836206714 μs] - SEMANTICS (root) [713836206752 μs - 713836206828 μs] - SEMANTICS [713836206785 μs - 713836206825 μs] - FINALIZE TREE [713836206834 μs - 713836206878 μs] - POST_FRAME [713836206903 μs - 713836206925 μs] -'''; - - static const rasterEventAsString = - ''' Rasterizer::DoDraw [713836206748 μs - 713836211160 μs] - Rasterizer::DrawToSurfaces [713836206750 μs - 713836211143 μs] - GPUSurfaceMetalImpeller::AcquireFrame [713836206755 μs - 713836210203 μs] - SurfaceMTL::WrapCurrentMetalLayerDrawable [713836206763 μs - 713836210196 μs] - WaitForNextDrawable [713836206764 μs - 713836210193 μs] - CompositorContext::ScopedFrame::Raster [713836210206 μs - 713836210251 μs] - LayerTree::Preroll [713836210219 μs - 713836210225 μs] - IOSExternalViewEmbedder::PostPrerollAction [713836210226 μs - 713836210226 μs] - LayerTree::Paint [713836210240 μs - 713836210250 μs] - SurfaceFrame::Submit [713836210251 μs - 713836211118 μs] - SurfaceFrame::BuildDisplayList [713836210251 μs - 713836210254 μs] - DisplayListDispatcher::EndRecordingAsPicture [713836210613 μs - 713836210616 μs] - Renderer::Render [713836210616 μs - 713836211105 μs] - EntityPass::OnRender [713836210642 μs - 713836211061 μs] - CreateGlyphAtlas [713836210893 μs - 713836210899 μs] -'''; - static final uiEvent = animatorBeginFrameEvent ..addAllChildren([ layoutRootEvent..addChild(layoutEvent), @@ -943,40 +883,6 @@ extension FlutterFrame6 on Never { 'vsyncOverhead': 1108, }; - static const uiEventAsString = - ''' Animator::BeginFrame [713836329948 μs - 713836331003 μs] - LAYOUT (root) [713836330239 μs - 713836330280 μs] - LAYOUT [713836330262 μs - 713836330277 μs] - UPDATING COMPOSITING BITS (root) [713836330284 μs - 713836330307 μs] - UPDATING COMPOSITING BITS [713836330302 μs - 713836330306 μs] - PAINT (root) [713836330324 μs - 713836330348 μs] - PAINT [713836330337 μs - 713836330346 μs] - COMPOSITING [713836330357 μs - 713836330723 μs] - Animator::Render [713836330691 μs - 713836330716 μs] - SEMANTICS (root) [713836330738 μs - 713836330844 μs] - SEMANTICS [713836330783 μs - 713836330842 μs] - FINALIZE TREE [713836330848 μs - 713836330920 μs] - POST_FRAME [713836330964 μs - 713836330989 μs] -'''; - - static const rasterEventAsString = - ''' Rasterizer::DoDraw [713836330790 μs - 713836331692 μs] - Rasterizer::DrawToSurfaces [713836330791 μs - 713836331684 μs] - GPUSurfaceMetalImpeller::AcquireFrame [713836330801 μs - 713836330844 μs] - SurfaceMTL::WrapCurrentMetalLayerDrawable [713836330814 μs - 713836330839 μs] - WaitForNextDrawable [713836330817 μs - 713836330836 μs] - CompositorContext::ScopedFrame::Raster [713836330846 μs - 713836330888 μs] - LayerTree::Preroll [713836330862 μs - 713836330870 μs] - IOSExternalViewEmbedder::PostPrerollAction [713836330870 μs - 713836330870 μs] - LayerTree::Paint [713836330870 μs - 713836330888 μs] - SurfaceFrame::Submit [713836330888 μs - 713836331669 μs] - SurfaceFrame::BuildDisplayList [713836330889 μs - 713836330894 μs] - DisplayListDispatcher::EndRecordingAsPicture [713836331274 μs - 713836331276 μs] - Renderer::Render [713836331277 μs - 713836331661 μs] - EntityPass::OnRender [713836331302 μs - 713836331633 μs] - CreateGlyphAtlas [713836331499 μs - 713836331505 μs] -'''; - static final uiEvent = animatorBeginFrameEvent ..addAllChildren([ layoutRootEvent..addChild(layoutEvent), diff --git a/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart b/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart index 4242f4ee753..509a0b3de83 100644 --- a/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart +++ b/packages/devtools_app/test/test_infra/utils/deep_links_utils.dart @@ -56,7 +56,6 @@ class TestDeepLinksController extends DeepLinksController { List fakeAndroidDeepLinks = []; bool hasAndroidDomainErrors = false; - bool hasAndroidPathErrors = false; String iosValidationResponse = ''; List fakeIosDomains = []; diff --git a/packages/devtools_app/test/test_infra/utils/extent_delegate_utils.dart b/packages/devtools_app/test/test_infra/utils/extent_delegate_utils.dart index 6893cf1909f..e3ef8c0f765 100644 --- a/packages/devtools_app/test/test_infra/utils/extent_delegate_utils.dart +++ b/packages/devtools_app/test/test_infra/utils/extent_delegate_utils.dart @@ -16,6 +16,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { }); late RenderSliverExtentDelegateBoxAdaptor _renderObject; + // ignore: unused-code, used in asserts. bool _renderObjectInitialized = false; List children; diff --git a/packages/devtools_app/test/test_infra/utils/rendering_tester.dart b/packages/devtools_app/test/test_infra/utils/rendering_tester.dart index 5b054988ed0..b74d9fcaad3 100644 --- a/packages/devtools_app/test/test_infra/utils/rendering_tester.dart +++ b/packages/devtools_app/test/test_infra/utils/rendering_tester.dart @@ -34,8 +34,7 @@ class TestRenderingFlutterBinding extends BindingBase /// /// If [onErrors] is not null, it is called if [FlutterError] caught any errors /// while drawing the frame. If [onErrors] is null and [FlutterError] caught at least - /// one error, this function fails the test. A test may override [onErrors] and - /// inspect errors using [takeFlutterErrorDetails]. + /// one error, this function fails the test. /// /// Errors caught between frames will cause the test to fail unless /// [FlutterError.onError] has been overridden. @@ -119,83 +118,11 @@ class TestRenderingFlutterBinding extends BindingBase /// A function called after drawing a frame if [FlutterError] caught any errors. /// /// This function is expected to inspect these errors and decide whether they - /// are expected or not. Use [takeFlutterErrorDetails] to take one error at a - /// time, or [takeAllFlutterErrorDetails] to iterate over all errors. + /// are expected or not. VoidCallback? onErrors; - /// Returns the error least recently caught by [FlutterError] and removes it - /// from the list of captured errors. - /// - /// Returns null if no errors were captures, or if the list was exhausted by - /// calling this method repeatedly. - FlutterErrorDetails? takeFlutterErrorDetails() { - if (_errors.isEmpty) { - return null; - } - return _errors.removeAt(0); - } - - /// Returns all error details caught by [FlutterError] from least recently caught to - /// most recently caught, and removes them from the list of captured errors. - /// - /// The returned iterable takes errors lazily. If, for example, you iterate over 2 - /// errors, but there are 5 errors total, this binding will still fail the test. - /// Tests are expected to take and inspect all errors. - Iterable takeAllFlutterErrorDetails() sync* { - // sync* and yield are used for lazy evaluation. Otherwise, the list would be - // drained eagerly and allow a test pass with unexpected errors. - while (_errors.isNotEmpty) { - yield _errors.removeAt(0); - } - } - - /// Returns all exceptions caught by [FlutterError] from least recently caught to - /// most recently caught, and removes them from the list of captured errors. - /// - /// The returned iterable takes errors lazily. If, for example, you iterate over 2 - /// errors, but there are 5 errors total, this binding will still fail the test. - /// Tests are expected to take and inspect all errors. - Iterable takeAllFlutterExceptions() sync* { - // sync* and yield are used for lazy evaluation. Otherwise, the list would be - // drained eagerly and allow a test pass with unexpected errors. - while (_errors.isNotEmpty) { - yield _errors.removeAt(0).exception; - } - } - EnginePhase phase = EnginePhase.composite; - /// Pumps a frame and runs its entire life cycle. - /// - /// This method runs all of the [SchedulerPhase]s in a frame, this is useful - /// to test [SchedulerPhase.postFrameCallbacks]. - void pumpCompleteFrame() { - final FlutterExceptionHandler? oldErrorHandler = FlutterError.onError; - FlutterError.onError = _errors.add; - try { - TestRenderingFlutterBinding.instance.handleBeginFrame(null); - TestRenderingFlutterBinding.instance.handleDrawFrame(); - } finally { - FlutterError.onError = oldErrorHandler; - if (_errors.isNotEmpty) { - if (onErrors != null) { - onErrors!(); - if (_errors.isNotEmpty) { - _errors.forEach(FlutterError.dumpErrorToConsole); - fail( - 'There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.', - ); - } - } else { - _errors.forEach(FlutterError.dumpErrorToConsole); - fail( - 'Caught error while rendering frame. See preceding logs for details.', - ); - } - } - } - } - @override void drawFrame() { assert( @@ -315,20 +242,6 @@ void pumpFrame({ TestRenderingFlutterBinding.instance.drawFrame(); } -class TestCallbackPainter extends CustomPainter { - const TestCallbackPainter({required this.onPaint}); - - final VoidCallback onPaint; - - @override - void paint(Canvas canvas, Size size) { - onPaint(); - } - - @override - bool shouldRepaint(TestCallbackPainter oldPainter) => true; -} - class RenderSizedBox extends RenderBox { RenderSizedBox(this._size); @@ -368,70 +281,3 @@ class RenderSizedBox extends RenderBox { @override bool hitTestSelf(Offset position) => true; } - -class TestClipPaintingContext extends PaintingContext { - TestClipPaintingContext() : super(ContainerLayer(), Rect.zero); - - @override - ClipRectLayer? pushClipRect( - bool needsCompositing, - Offset offset, - Rect clipRect, - PaintingContextCallback painter, { - Clip clipBehavior = Clip.hardEdge, - ClipRectLayer? oldLayer, - }) { - this.clipBehavior = clipBehavior; - return null; - } - - Clip clipBehavior = Clip.none; -} - -class TestPushLayerPaintingContext extends PaintingContext { - TestPushLayerPaintingContext() : super(ContainerLayer(), Rect.zero); - - final pushedLayers = []; - - @override - void pushLayer( - ContainerLayer childLayer, - PaintingContextCallback painter, - Offset offset, { - Rect? childPaintBounds, - }) { - pushedLayers.add(childLayer); - super.pushLayer( - childLayer, - painter, - offset, - childPaintBounds: childPaintBounds, - ); - } -} - -// Absorbs errors that don't have "overflowed" in their error details. -void absorbOverflowedErrors() { - final errorDetails = TestRenderingFlutterBinding.instance - .takeAllFlutterErrorDetails(); - final filtered = errorDetails.where((FlutterErrorDetails details) { - return !details.toString().contains('overflowed'); - }); - if (filtered.isNotEmpty) { - filtered.forEach(FlutterError.reportError); - } -} - -// Reports any FlutterErrors. -void expectNoFlutterErrors() { - final errorDetails = TestRenderingFlutterBinding.instance - .takeAllFlutterErrorDetails(); - errorDetails.forEach(FlutterError.reportError); -} - -RenderConstrainedBox get box200x200 => RenderConstrainedBox( - additionalConstraints: const BoxConstraints.tightFor( - height: 200.0, - width: 200.0, - ), -); diff --git a/packages/devtools_shared/lib/src/server/file_system.dart b/packages/devtools_shared/lib/src/server/file_system.dart index 450790b47fd..63918084354 100644 --- a/packages/devtools_shared/lib/src/server/file_system.dart +++ b/packages/devtools_shared/lib/src/server/file_system.dart @@ -12,7 +12,7 @@ import 'package:path/path.dart' as path; import 'devtools_store.dart'; /// The real, local file system, which can be avoided in tests. -const FileSystem fileSystem = LocalFileSystem(); +const fileSystem = LocalFileSystem(); extension FileSystemExtension on FileSystem { static String get _userHomeDir { diff --git a/packages/devtools_shared/test/server/general_api_test.dart b/packages/devtools_shared/test/server/general_api_test.dart index c2bb0002803..8fc848dd404 100644 --- a/packages/devtools_shared/test/server/general_api_test.dart +++ b/packages/devtools_shared/test/server/general_api_test.dart @@ -157,8 +157,6 @@ void main() { setUp(() async { app = TestDartApp(); vmServiceUriString = await app!.start(); - // Await a short delay to give the VM a chance to initialize. - await delay(duration: const Duration(milliseconds: 2500)); expect(vmServiceUriString, isNotEmpty); }); @@ -171,13 +169,21 @@ void main() { test('succeeds for a connect event', () async { final vmServiceUri = normalizeVmServiceUri(vmServiceUriString!); expect(vmServiceUri, isNotNull); - final response = - await server.VmServiceHandler.detectRootPackageForVmService( - vmServiceUriAsString: vmServiceUriString!, - vmServiceUri: vmServiceUri!, - connected: true, - dtd: testDtdConnection!, - ); + late server.DetectRootPackageResponse response; + await runWithRetry( + callback: () async { + response = + await server.VmServiceHandler.detectRootPackageForVmService( + vmServiceUriAsString: vmServiceUriString!, + vmServiceUri: vmServiceUri!, + connected: true, + dtd: testDtdConnection!, + ); + if (!response.success) throw Exception('VM not ready'); + }, + maxRetries: 20, + retryDelay: const Duration(milliseconds: 500), + ); expect(response.success, true); expect(response.message, isNull); expect(response.uri, isNotNull); @@ -200,13 +206,21 @@ void main() { () async { final vmServiceUri = normalizeVmServiceUri(vmServiceUriString!); expect(vmServiceUri, isNotNull); - final response = - await server.VmServiceHandler.detectRootPackageForVmService( - vmServiceUriAsString: vmServiceUriString!, - vmServiceUri: vmServiceUri!, - connected: true, - dtd: testDtdConnection!, - ); + late server.DetectRootPackageResponse response; + await runWithRetry( + callback: () async { + response = + await server.VmServiceHandler.detectRootPackageForVmService( + vmServiceUriAsString: vmServiceUriString!, + vmServiceUri: vmServiceUri!, + connected: true, + dtd: testDtdConnection!, + ); + if (!response.success) throw Exception('VM not ready'); + }, + maxRetries: 20, + retryDelay: const Duration(milliseconds: 500), + ); expect(response.success, true); expect(response.message, isNull); expect(response.uri, isNotNull); @@ -215,7 +229,7 @@ void main() { final disconnectResponse = await server.VmServiceHandler.detectRootPackageForVmService( vmServiceUriAsString: vmServiceUriString!, - vmServiceUri: vmServiceUri, + vmServiceUri: vmServiceUri!, connected: false, dtd: testDtdConnection!, ); diff --git a/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart b/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart index 0df17c7f325..c687bb6d4cb 100644 --- a/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart +++ b/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart @@ -128,25 +128,27 @@ class FakeVmServiceWrapper extends Fake implements VmServiceWrapper { } @override - Future lookupPackageUris( - String isolateId, - List uris, - ) => Future.syncValue(UriList( - uris: _resolvedUriMap != null - ? (uris.map((e) => _resolvedUriMap[e]).toList()) - : null - )); + Future lookupPackageUris(String isolateId, List uris) => + Future.syncValue( + UriList( + uris: _resolvedUriMap != null + ? (uris.map((e) => _resolvedUriMap[e]).toList()) + : null, + ), + ); @override Future lookupResolvedPackageUris( String isolateId, List uris, { bool? local, - }) => Future.syncValue(UriList( - uris: _reverseResolvedUriMap != null - ? (uris.map((e) => _reverseResolvedUriMap[e]).toList()) - : null, - )); + }) => Future.syncValue( + UriList( + uris: _reverseResolvedUriMap != null + ? (uris.map((e) => _reverseResolvedUriMap[e]).toList()) + : null, + ), + ); @override String get wsUri => 'ws://127.0.0.1:56137/ISsyt6ki0no=/ws'; diff --git a/tool/cpu_sample_intervals.dart b/tool/cpu_sample_intervals.dart index f6b2f07b556..10d50bcbc2f 100644 --- a/tool/cpu_sample_intervals.dart +++ b/tool/cpu_sample_intervals.dart @@ -26,10 +26,10 @@ void main(List arguments) async { final List deltas = []; for (int i = 0; i < cpuSampleTraceEvents.length - 1; i++) { - final Map current = - (cpuSampleTraceEvents[i] as Map).cast(); - final Map next = - (cpuSampleTraceEvents[i + 1] as Map).cast(); + final Map current = (cpuSampleTraceEvents[i] as Map) + .cast(); + final Map next = (cpuSampleTraceEvents[i + 1] as Map) + .cast(); deltas.add((next['ts'] as int) - (current['ts'] as int)); } print(deltas); diff --git a/tool/json_to_map.dart b/tool/json_to_map.dart index dffb32204c0..d3b134174b4 100644 --- a/tool/json_to_map.dart +++ b/tool/json_to_map.dart @@ -30,8 +30,9 @@ void main(List args) { } final jsonFileName = jsonFilePath.split('/').last; - final fileNameWithoutExtension = (jsonFileName.split('.') - ..removeLast()).join('.'); + final fileNameWithoutExtension = (jsonFileName.split( + '.', + )..removeLast()).join('.'); final jsonFileDirectoryPath = Uri.parse( (jsonFilePath.split('/')..removeLast()).join('/'), ); @@ -45,10 +46,9 @@ void main(List args) { // String interpolation. jsonFormattedString = jsonFormattedString.replaceAll('\$', '\\\$'); - final dartFile = - File('$jsonFileDirectoryPath/$fileNameWithoutExtension.dart') - ..createSync() - ..writeAsStringSync(''' + final dartFile = File('$jsonFileDirectoryPath/$fileNameWithoutExtension.dart') + ..createSync() + ..writeAsStringSync(''' // Copyright 2023 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.