AccessibilityServices { public boolean isSpokenFeedbackEnabled() { List<AccessibilityServiceInfo> enabledServices = getEnabledServicesFor(AccessibilityServiceInfo.FEEDBACK_SPOKEN); return !enabledServices.isEmpty(); } AccessibilityServices(AccessibilityManager accessibilityManager, CaptionManager captionManager); static AccessibilityServices newInstance(Context context); boolean isSpokenFeedbackEnabled(); boolean isClosedCaptioningEnabled(); boolean isSwitchAccessEnabled();  }
@Test public void givenEnabledServicesListForSpokenFeedbackIsNotEmpty_thenReportsSpokenFeedbackIsEnabled() { AccessibilityServiceInfo anyServiceInfo = accessibilityServiceInfoWithId("any"); given(accessibilityManager.getEnabledAccessibilityServiceList(FEEDBACK_SPOKEN)) .willReturn(Collections.singletonList(anyServiceInfo)); boolean spokenFeedbackEnabled = accessibilityServices.isSpokenFeedbackEnabled(); assertThat(spokenFeedbackEnabled).isTrue(); }
@Test public void givenEnabledServicesListForSpokenFeedbackIsEmpty_thenReportsSpokenFeedbackIsDisabled() { given(accessibilityManager.getEnabledAccessibilityServiceList(FEEDBACK_SPOKEN)) .willReturn(Collections.emptyList()); boolean spokenFeedbackEnabled = accessibilityServices.isSpokenFeedbackEnabled(); assertThat(spokenFeedbackEnabled).isFalse(); }