-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Create Hot Restart over websocket test #173852
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
Open
jyameo
wants to merge
4
commits into
flutter:master
Choose a base branch
from
jyameo:hot-restart-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+288
−122
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/flutter_tools/test/integration.shard/hot_restart_websocket_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@Tags(<String>['flutter-test-driver']) | ||
library; | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:file/file.dart'; | ||
|
||
import '../src/common.dart'; | ||
import 'test_data/hot_reload_project.dart'; | ||
import 'test_data/websocket_dwds_test_common.dart'; | ||
import 'test_driver.dart'; | ||
import 'test_utils.dart'; | ||
import 'transition_test_utils.dart'; | ||
|
||
void main() { | ||
testAll(); | ||
} | ||
|
||
void testAll({List<String> additionalCommandArgs = const <String>[]}) { | ||
group('WebSocket DWDS connection for hot restart' | ||
'${additionalCommandArgs.isEmpty ? '' : ' with args: $additionalCommandArgs'}', () { | ||
// Test configuration constants | ||
const hotRestartTimeout = Duration(seconds: 15); | ||
|
||
late Directory tempDir; | ||
final project = HotReloadProject(); | ||
late FlutterRunTestDriver flutter; | ||
|
||
setUp(() async { | ||
tempDir = createResolvedTempDirectorySync('hot_restart_websocket_test.'); | ||
await project.setUpIn(tempDir); | ||
flutter = FlutterRunTestDriver(tempDir); | ||
}); | ||
|
||
tearDown(() async { | ||
await flutter.stop(); | ||
tryToDelete(tempDir); | ||
}); | ||
|
||
testWithoutContext( | ||
'hot restart with headless Chrome WebSocket connection', | ||
() async { | ||
debugPrint('Starting WebSocket DWDS test with headless Chrome for hot restart...'); | ||
|
||
// Set up WebSocket connection | ||
final WebSocketDwdsTestSetup setup = await WebSocketDwdsTestUtils.setupWebSocketConnection( | ||
flutter, | ||
additionalCommandArgs: additionalCommandArgs, | ||
); | ||
|
||
try { | ||
// Test hot restart functionality | ||
debugPrint('Step 6: Testing hot restart with WebSocket connection...'); | ||
await flutter.hotRestart().timeout( | ||
hotRestartTimeout, | ||
onTimeout: () { | ||
throw Exception('Hot restart timed out'); | ||
}, | ||
); | ||
|
||
// Give some time for logs to capture | ||
await Future<void>.delayed(const Duration(seconds: 2)); | ||
|
||
final output = setup.stdout.toString(); | ||
expect( | ||
output, | ||
contains('Restarted application'), | ||
reason: 'Hot restart should complete successfully', | ||
); | ||
debugPrint('✓ Hot restart completed successfully with WebSocket connection'); | ||
|
||
// Verify the correct infrastructure was used | ||
WebSocketDwdsTestUtils.verifyWebSocketInfrastructure(output); | ||
|
||
debugPrint('✓ WebSocket DWDS test completed successfully'); | ||
debugPrint('✓ Verified: web-server device + DWDS + WebSocket connection + hot restart'); | ||
} finally { | ||
await cleanupWebSocketTestResources(setup.chromeProcess, setup.subscription); | ||
} | ||
}, | ||
skip: !platform.isMacOS, // Skip on non-macOS platforms where Chrome paths may differ | ||
); | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having step numbers here requires keeping all these files in sync. If the common file changes then we would have to update this one too. I think for the actual testing we can omit the step numbers.