Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,9 @@ class _ServiceExtensionCheckboxState extends State<ServiceExtensionCheckbox>
void _onMainIsolateChanged() => _initExtensionState();

void _initExtensionState() {
if (serviceConnection.serviceManager.serviceExtensionManager
.isServiceExtensionAvailable(widget.serviceExtension.extension)) {
final state = serviceConnection.serviceManager.serviceExtensionManager
.getServiceExtensionState(widget.serviceExtension.extension);
_setValueFromState(state.value);
}
final state = serviceConnection.serviceManager.serviceExtensionManager
.getServiceExtensionState(widget.serviceExtension.extension);
_setValueFromState(state.value);

unawaited(
serviceConnection.serviceManager.serviceExtensionManager
Expand Down
3 changes: 2 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ TODO: Remove this section if there are not any updates.

## Performance updates

TODO: Remove this section if there are not any updates.
- Fixed an issue where 'More Debug Options' showed options as unselected in
profile mode even when selected. [TODO](https://github.com/flutter/devtools/pull/TODO)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN]: The link for the pull request is a [TODO] placeholder. Please update this with the correct pull request number before merging.


## CPU profiler updates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,61 @@ void main() {
expect(toggle.value, false, reason: 'The extension is disabled.');
});
});

group('ServiceExtensionCheckbox', () {
testWidgets('shows value state even when unavailable', (WidgetTester tester) async {
final ext = extensions.disableClipLayers;
final customFake = _UnavailableServiceExtensionManager();
customFake.makeUnavailable(ext.extension);

// Override the serviceExtensionManager on mockServiceManager
when(mockServiceManager.serviceExtensionManager).thenReturn(customFake);

// Set state to enabled: false (which means clips not disabled -> checked true)
await customFake.setServiceExtensionState(
ext.extension,
enabled: false,
value: false,
);

final checkbox = ServiceExtensionCheckbox(serviceExtension: ext);
await tester.pumpWidget(
wrap(Scaffold(body: Center(child: checkbox))),
);
await tester.pumpAndSettle();

final checkboxFinder = find.byType(Checkbox);
expect(checkboxFinder, findsOneWidget);

final checkboxWidget = tester.widget<Checkbox>(checkboxFinder);
expect(checkboxWidget.value, isTrue);
expect(checkboxWidget.onChanged, isNull);
});
});
}

base class _UnavailableServiceExtensionManager extends FakeServiceExtensionManager {
final _unavailableExtensions = <String>{};

void makeUnavailable(String name) {
_unavailableExtensions.add(name);
}

@override
Future<bool> waitForServiceExtensionAvailable(String name) {
if (_unavailableExtensions.contains(name)) {
return Future.value(false);
}
return super.waitForServiceExtensionAvailable(name);
}

@override
bool isServiceExtensionAvailable(String name) {
if (_unavailableExtensions.contains(name)) {
return false;
}
return super.isServiceExtensionAvailable(name);
}
}

void registerServiceExtension(
Expand Down
Loading