Skip to content

Commit

Permalink
fix(gnome-a11y): check access to all a11y settings
Browse files Browse the repository at this point in the history
  • Loading branch information
d-loose committed Feb 28, 2024
1 parent 8a569d2 commit ca4bee4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,16 @@ class GnomeAccessibilityService implements AccessibilityService {
}

@override
Future<bool> isSupported() =>
_a11yInterfaceSettings.list().then((_) => true, onError: (_) => false);
Future<bool> isSupported() => Future.wait(
[
_a11yInterfaceSettings,
_applicationSettings,
_interfaceSettings,
_keyboardSettings,
_wmSettings,
].map((settings) => settings.list()),
eagerError: true,
).then((_) => true, onError: (_) => false);

@override
Future<bool> getHighContrast() => _tryGet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,26 @@ void main() {
expect(await service.getDesktopZoom(), isTrue);
});
});

group('isSupported', () {
test('all interfaces available', () async {
when(a11yInterfaceSettings.list()).thenAnswer((_) async => []);
when(applicationSettings.list()).thenAnswer((_) async => []);
when(interfaceSettings.list()).thenAnswer((_) async => []);
when(keyboardSettings.list()).thenAnswer((_) async => []);
when(wmSettings.list()).thenAnswer((_) async => []);

expect(await service.isSupported(), isTrue);
});

test('some interfaces unavailable', () async {
when(a11yInterfaceSettings.list()).thenAnswer((_) async => []);
when(applicationSettings.list()).thenThrow(Exception());
when(interfaceSettings.list()).thenAnswer((_) async => []);
when(keyboardSettings.list()).thenAnswer((_) async => []);
when(wmSettings.list()).thenThrow(Exception());

expect(await service.isSupported(), isFalse);
});
});
}

0 comments on commit ca4bee4

Please sign in to comment.