forked from flutter/devtools
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include static DevTools extensions in the Flutter sidebar (flutter#7604)
- Loading branch information
1 parent
564ee86
commit e15c472
Showing
5 changed files
with
275 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
117 changes: 117 additions & 0 deletions
117
packages/devtools_app/test/standalone_ui/vs_code/devtools_test.dart
This file contains 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,117 @@ | ||
// Copyright 2024 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:devtools_app/devtools_app.dart'; | ||
import 'package:devtools_app/src/standalone_ui/api/impl/vs_code_api.dart'; | ||
import 'package:devtools_app/src/standalone_ui/vs_code/devtools.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'; | ||
|
||
void main() { | ||
const windowSize = Size(2000.0, 2000.0); | ||
|
||
late MockVsCodeApi mockVsCodeApi; | ||
|
||
setUpAll(() { | ||
// Set test mode so that the debug list of extensions will be used. | ||
setTestMode(); | ||
}); | ||
|
||
setUp(() { | ||
mockVsCodeApi = MockVsCodeApi(); | ||
when(mockVsCodeApi.capabilities).thenReturn( | ||
VsCodeCapabilitiesImpl({ | ||
'executeCommand': true, | ||
'selectDevice': true, | ||
'openDevToolsPage': true, | ||
'openDevToolsExternally': true, | ||
'hotReload': true, | ||
'hotRestart': true, | ||
}), | ||
); | ||
setGlobal(IdeTheme, IdeTheme()); | ||
setGlobal(PreferencesController, PreferencesController()); | ||
}); | ||
|
||
Future<void> pumpDevToolsSidebarOptions( | ||
WidgetTester tester, { | ||
bool hasDebugSessions = false, | ||
}) async { | ||
await tester.pumpWidget( | ||
wrap( | ||
DevToolsSidebarOptions( | ||
api: mockVsCodeApi, | ||
hasDebugSessions: hasDebugSessions, | ||
), | ||
), | ||
); | ||
// Additional pump to allow for initializing the extensions service. | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
group('$DevToolsSidebarOptions', () { | ||
testWidgetsWithWindowSize( | ||
'includes static DevTools screens', | ||
windowSize, | ||
(tester) async { | ||
await pumpDevToolsSidebarOptions(tester); | ||
expect(find.text('DevTools'), findsOneWidget); | ||
expect(find.text(ScreenMetaData.appSize.title!), findsOneWidget); | ||
expect(find.text(ScreenMetaData.deepLinks.title!), findsOneWidget); | ||
expect(find.text('Open in Browser'), findsOneWidget); | ||
expect( | ||
find.text( | ||
'Begin a debug session to use tools that require a running ' | ||
'application.', | ||
), | ||
findsOneWidget, | ||
); | ||
}, | ||
); | ||
|
||
testWidgetsWithWindowSize( | ||
'includes DevTools extensions', | ||
windowSize, | ||
(tester) async { | ||
await pumpDevToolsSidebarOptions(tester); | ||
expect(find.text('DevTools Extensions'), findsOneWidget); | ||
expect(find.text('bar'), findsOneWidget); | ||
expect( | ||
find.text( | ||
'Begin a debug session to use extensions that require a running ' | ||
'application.', | ||
), | ||
findsOneWidget, | ||
); | ||
}, | ||
); | ||
|
||
testWidgetsWithWindowSize( | ||
'changes runtime tool instructions with non-empty debug sessions', | ||
windowSize, | ||
(tester) async { | ||
await pumpDevToolsSidebarOptions(tester, hasDebugSessions: true); | ||
expect( | ||
find.text( | ||
'Open the tools menu for a debug session to access tools that ' | ||
'require a running application.', | ||
), | ||
findsOneWidget, | ||
); | ||
expect( | ||
find.text( | ||
'Open the tools menu for a debug session to access extensions that ' | ||
'require a running application.', | ||
), | ||
findsOneWidget, | ||
); | ||
}, | ||
); | ||
}); | ||
} |