-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add development flag for debugging devtools extensions without a serv…
…er connection (#6367)
- Loading branch information
1 parent
d50d223
commit 3de0cf5
Showing
6 changed files
with
97 additions
and
75 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
65 changes: 65 additions & 0 deletions
65
packages/devtools_app/lib/src/shared/development_helpers.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,65 @@ | ||
// Copyright 2023 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_shared/devtools_extensions.dart'; | ||
|
||
/// Whether to build DevTools for conveniently debugging DevTools extensions. | ||
/// | ||
/// Turning this flag to [true] allows for debugging the extensions framework | ||
/// without a server connection. | ||
/// | ||
/// This flag should never be checked in with a value of true - this is covered | ||
/// by a test. | ||
const debugDevToolsExtensions = false; | ||
|
||
List<DevToolsExtensionConfig> debugHandleRefreshAvailableExtensions( | ||
String rootPath, | ||
) { | ||
return debugExtensions; | ||
} | ||
|
||
ExtensionEnabledState debugHandleExtensionEnabledState({ | ||
required String rootPath, | ||
required String extensionName, | ||
bool? enable, | ||
}) { | ||
if (enable != null) { | ||
stubExtensionEnabledStates[extensionName] = | ||
enable ? ExtensionEnabledState.enabled : ExtensionEnabledState.disabled; | ||
} | ||
return stubExtensionEnabledStates.putIfAbsent( | ||
extensionName, | ||
() => ExtensionEnabledState.none, | ||
); | ||
} | ||
|
||
/// Stubbed activation states so we can develop DevTools extensions without a | ||
/// server connection. | ||
final stubExtensionEnabledStates = <String, ExtensionEnabledState>{}; | ||
|
||
/// Stubbed extensions so we can develop DevTools Extensions without a server | ||
/// connection. | ||
final List<DevToolsExtensionConfig> debugExtensions = [ | ||
DevToolsExtensionConfig.parse({ | ||
DevToolsExtensionConfig.nameKey: 'foo', | ||
DevToolsExtensionConfig.issueTrackerKey: 'www.google.com', | ||
DevToolsExtensionConfig.versionKey: '1.0.0', | ||
DevToolsExtensionConfig.pathKey: '/path/to/foo', | ||
}), | ||
DevToolsExtensionConfig.parse({ | ||
DevToolsExtensionConfig.nameKey: 'bar', | ||
DevToolsExtensionConfig.issueTrackerKey: 'www.google.com', | ||
DevToolsExtensionConfig.versionKey: '2.0.0', | ||
DevToolsExtensionConfig.materialIconCodePointKey: 0xe638, | ||
DevToolsExtensionConfig.pathKey: '/path/to/bar', | ||
}), | ||
DevToolsExtensionConfig.parse({ | ||
DevToolsExtensionConfig.nameKey: 'provider', | ||
DevToolsExtensionConfig.issueTrackerKey: | ||
'https://github.com/rrousselGit/provider/issues', | ||
DevToolsExtensionConfig.versionKey: '3.0.0', | ||
DevToolsExtensionConfig.materialIconCodePointKey: 0xe50a, | ||
DevToolsExtensionConfig.pathKey: '/path/to/provider', | ||
}), | ||
]; |
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
12 changes: 12 additions & 0 deletions
12
packages/devtools_app/test/shared/development_helpers_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,12 @@ | ||
// Copyright 2023 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/src/shared/development_helpers.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
test('debug flags are false', () { | ||
expect(debugDevToolsExtensions, isFalse); | ||
}); | ||
} |