-
Notifications
You must be signed in to change notification settings - Fork 382
Add Reconnect button to embedded disconnect overlay and restore VM service connection after sleep/wake #9693
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
rishika0212
wants to merge
5
commits into
flutter:master
Choose a base branch
from
rishika0212:inspector-reconnect-fix
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.
+193
−27
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
19ac712
Add reconnect option for Inspector when VM service disconnects
rishika0212 4e2c4c3
Add reconnect button to DisconnectObserver for VM service reconnection
rishika0212 ea66c0f
edited in release notes
rishika0212 8260a7c
Addressed PR review comments
rishika0212 51c7db0
Refactor disconnected overlay reconnect UI and simplify reconnect flow
rishika0212 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
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
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
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 |
|---|---|---|
|
|
@@ -4,24 +4,31 @@ | |
|
|
||
| import 'package:devtools_app/devtools_app.dart'; | ||
| import 'package:devtools_app/src/framework/observer/disconnect_observer.dart'; | ||
| import 'package:devtools_app/src/shared/primitives/query_parameters.dart'; | ||
| import 'package:devtools_app/src/shared/framework/framework_controller.dart'; | ||
| import 'package:devtools_app_shared/service.dart'; | ||
| import 'package:devtools_app_shared/shared.dart'; | ||
| import 'package:devtools_app_shared/ui.dart'; | ||
| import 'package:devtools_app_shared/utils.dart'; | ||
| import 'package:devtools_test/devtools_test.dart'; | ||
| import 'package:devtools_test/helpers.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:mockito/mockito.dart'; | ||
|
|
||
| import '../../test_infra/matchers/matchers.dart'; | ||
|
|
||
| void main() { | ||
| group('DisconnectObserver', () { | ||
| late FakeServiceConnectionManager fakeServiceConnectionManager; | ||
| late MockDTDManager mockDtdManager; | ||
|
|
||
| setUp(() { | ||
| fakeServiceConnectionManager = FakeServiceConnectionManager(); | ||
| mockDtdManager = MockDTDManager(); | ||
| when(mockDtdManager.reconnect()).thenAnswer((_) async {}); | ||
| setGlobal(ServiceConnectionManager, fakeServiceConnectionManager); | ||
| setGlobal(DTDManager, mockDtdManager); | ||
| setGlobal(FrameworkController, FrameworkController()); | ||
| setGlobal(OfflineDataController, OfflineDataController()); | ||
| setGlobal(IdeTheme, IdeTheme()); | ||
|
|
@@ -30,6 +37,7 @@ void main() { | |
| Future<void> pumpDisconnectObserver( | ||
| WidgetTester tester, { | ||
| Widget child = const Placeholder(), | ||
| DevToolsQueryParams? queryParams, | ||
| }) async { | ||
| await tester.pumpWidget( | ||
| wrap( | ||
|
|
@@ -41,6 +49,7 @@ void main() { | |
| ); | ||
| }, | ||
| ), | ||
| queryParams: queryParams, | ||
| ), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
|
|
@@ -67,8 +76,14 @@ void main() { | |
| find.byType(ConnectToNewAppButton), | ||
| showingOverlay && !isEmbedded() ? findsOneWidget : findsNothing, | ||
| ); | ||
| // The Reconnect button should be present in both embedded and | ||
| // non-embedded modes when the overlay is showing. | ||
| expect( | ||
| find.text('Run a new debug session to reconnect.'), | ||
| find.text('Reconnect'), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test that using the reconnect button restores the old VM service connection |
||
| showingOverlay ? findsOneWidget : findsNothing, | ||
| ); | ||
| expect( | ||
| find.text('Or run a new debug session to connect to it.'), | ||
| showingOverlay && isEmbedded() ? findsOneWidget : findsNothing, | ||
| ); | ||
| expect( | ||
|
|
@@ -134,6 +149,40 @@ void main() { | |
| await showOverlayAndVerifyContents(tester); | ||
| }); | ||
|
|
||
| testWidgets( | ||
| 'reconnect button restores previous VM service URI on success', | ||
| (WidgetTester tester) async { | ||
| const previousVmServiceUri = 'http://127.0.0.1:8181/'; | ||
| when(mockDtdManager.reconnect()).thenAnswer((_) async { | ||
| fakeServiceConnectionManager.serviceManager.setConnectedState(true); | ||
| }); | ||
|
|
||
| await pumpDisconnectObserver( | ||
| tester, | ||
| queryParams: DevToolsQueryParams({ | ||
| DevToolsQueryParams.vmServiceUriKey: previousVmServiceUri, | ||
| }), | ||
| ); | ||
| verifyObserverState(tester, connected: true, showingOverlay: false); | ||
|
|
||
| fakeServiceConnectionManager.serviceManager.setConnectedState(false); | ||
| await tester.pumpAndSettle(); | ||
| verifyObserverState(tester, connected: false, showingOverlay: true); | ||
|
|
||
| await tester.tap(find.text('Reconnect')); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| verify(mockDtdManager.reconnect()).called(1); | ||
| verifyObserverState(tester, connected: true, showingOverlay: false); | ||
| final context = tester.element(find.byType(DisconnectObserver)); | ||
| final routerDelegate = DevToolsRouterDelegate.of(context); | ||
| expect( | ||
| routerDelegate.currentConfiguration!.params.vmServiceUri, | ||
| previousVmServiceUri, | ||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| // Regression test for https://github.com/flutter/devtools/issues/8050. | ||
| testWidgets('hides widgets at lower z-index', ( | ||
| WidgetTester tester, | ||
|
|
||
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.
I think this method could be simplified quite a bit. I think we want to:
I think this will avoid the multiple
serviceConnection.serviceManager.connectedState.value.connectedcalls and nesting of if/else in try/catch blocks and make this code easier to understand.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.
Implemented. I simplified attemptReconnect to match the flow described.