-
Notifications
You must be signed in to change notification settings - Fork 399
Support brightness override in a11y page #9898
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 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
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
118 changes: 118 additions & 0 deletions
118
packages/devtools_app/test/screens/accessibility/accessibility_controller_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,118 @@ | ||
| // Copyright 2026 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. | ||
|
|
||
| @TestOn('vm') | ||
| library; | ||
|
|
||
| import 'package:devtools_app/devtools_app.dart'; | ||
| import 'package:devtools_app_shared/utils.dart'; | ||
| import 'package:devtools_test/devtools_test.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:mockito/mockito.dart'; | ||
|
|
||
| void main() { | ||
| group('AccessibilityController', () { | ||
| late AccessibilityController controller; | ||
|
|
||
| setUp(() { | ||
| final fakeServiceConnection = FakeServiceConnectionManager(); | ||
| when( | ||
| fakeServiceConnection.serviceManager.connectedApp!.isFlutterWebAppNow, | ||
| ).thenReturn(false); | ||
| when( | ||
| fakeServiceConnection.serviceManager.connectedApp!.isProfileBuildNow, | ||
| ).thenReturn(false); | ||
|
|
||
| setGlobal(NotificationService, NotificationService()); | ||
| setGlobal( | ||
| DevToolsEnvironmentParameters, | ||
| ExternalDevToolsEnvironmentParameters(), | ||
| ); | ||
| setGlobal(PreferencesController, PreferencesController()); | ||
| setGlobal(ServiceConnectionManager, fakeServiceConnection); | ||
|
|
||
| controller = AccessibilityController()..init(); | ||
| }); | ||
|
|
||
| test('initial state', () { | ||
| expect(controller.brightness.value, BrightnessOverride.system); | ||
| }); | ||
|
|
||
| test( | ||
| 'service extension state change updates controller brightness state', | ||
| () { | ||
| final fakeServiceExtensionManager = | ||
| serviceConnection.serviceManager.serviceExtensionManager | ||
| as FakeServiceExtensionManager; | ||
|
|
||
| expect(controller.brightness.value, BrightnessOverride.system); | ||
|
|
||
| // Simulate service extension state change from device to dark mode | ||
| fakeServiceExtensionManager.fakeServiceExtensionStateChanged( | ||
| brightnessMode.extension, | ||
| 'Brightness.dark', | ||
| ); | ||
| expect(controller.brightness.value, BrightnessOverride.dark); | ||
|
|
||
| // Simulate service extension state change from device to light mode | ||
| fakeServiceExtensionManager.fakeServiceExtensionStateChanged( | ||
| brightnessMode.extension, | ||
| 'Brightness.light', | ||
| ); | ||
| expect(controller.brightness.value, BrightnessOverride.light); | ||
|
|
||
| // Simulate service extension state change from device to system | ||
| fakeServiceExtensionManager.fakeServiceExtensionStateChanged( | ||
| brightnessMode.extension, | ||
| 'system', | ||
| ); | ||
| expect(controller.brightness.value, BrightnessOverride.system); | ||
| }, | ||
| ); | ||
|
|
||
| test( | ||
| 'setting controller brightness updates service extension state', | ||
| () async { | ||
| final fakeServiceExtensionManager = | ||
| serviceConnection.serviceManager.serviceExtensionManager | ||
| as FakeServiceExtensionManager; | ||
|
|
||
| // Initial state | ||
| expect(controller.brightness.value, BrightnessOverride.system); | ||
|
|
||
| // Set to dark mode | ||
| controller.brightness.value = BrightnessOverride.dark; | ||
|
|
||
| // Wait for async operations to complete | ||
| await Future<void>.delayed(Duration.zero); | ||
|
|
||
| final darkState = fakeServiceExtensionManager | ||
| .getServiceExtensionState(brightnessMode.extension) | ||
| .value; | ||
| expect(darkState.value, equals('Brightness.dark')); | ||
| expect(darkState.enabled, isTrue); | ||
|
|
||
| // Set to light mode | ||
| controller.brightness.value = BrightnessOverride.light; | ||
| await Future<void>.delayed(Duration.zero); | ||
|
|
||
| final lightState = fakeServiceExtensionManager | ||
| .getServiceExtensionState(brightnessMode.extension) | ||
| .value; | ||
| expect(lightState.value, equals('Brightness.light')); | ||
| expect(lightState.enabled, isTrue); | ||
|
|
||
| // Set to system | ||
| controller.brightness.value = BrightnessOverride.system; | ||
| await Future<void>.delayed(Duration.zero); | ||
|
|
||
| final systemState = fakeServiceExtensionManager | ||
| .getServiceExtensionState(brightnessMode.extension) | ||
| .value; | ||
| expect(systemState.value, equals('system')); | ||
| expect(systemState.enabled, isFalse); | ||
| }, | ||
| ); | ||
| }); | ||
| } |
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
32 changes: 32 additions & 0 deletions
32
packages/devtools_app_shared/test/service/service_extensions_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,32 @@ | ||
| // Copyright 2026 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. | ||
|
|
||
| import 'package:devtools_app_shared/service_extensions.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| void main() { | ||
| group('ServiceExtensions', () { | ||
| test('brightnessMode is properly configured', () { | ||
| expect( | ||
| brightnessMode.extension, | ||
| equals('ext.flutter.brightnessOverride'), | ||
| ); | ||
| expect( | ||
| brightnessMode.values, | ||
| equals(['system', 'Brightness.light', 'Brightness.dark']), | ||
| ); | ||
| expect( | ||
| serviceExtensionsAllowlist[brightnessMode.extension], | ||
| equals(brightnessMode), | ||
| ); | ||
| }); | ||
|
|
||
| test('brightnessMode is in unsafe before first frame set', () { | ||
| expect( | ||
| isUnsafeBeforeFirstFlutterFrame('ext.flutter.brightnessOverride'), | ||
| isTrue, | ||
| ); | ||
| }); | ||
| }); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.