Search in sources :

Example 1 with ShadowAccessibilityManager

use of org.robolectric.shadows.ShadowAccessibilityManager in project android_packages_apps_Settings by omnirom.

the class AccessibilitySlicePreferenceControllerTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    final ContentResolver contentResolver = mContext.getContentResolver();
    Settings.Secure.putInt(contentResolver, Settings.Secure.ACCESSIBILITY_ENABLED, 1);
    Settings.Secure.putString(contentResolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, SERVICE_NAME);
    // Register the fake a11y Service
    ShadowAccessibilityManager shadowAccessibilityManager = Shadow.extract(RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
    shadowAccessibilityManager.setInstalledAccessibilityServiceList(getFakeServiceList());
    mController = new AccessibilitySlicePreferenceController(mContext, SERVICE_NAME);
}
Also used : ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) ContentResolver(android.content.ContentResolver) Before(org.junit.Before)

Example 2 with ShadowAccessibilityManager

use of org.robolectric.shadows.ShadowAccessibilityManager in project android_packages_apps_Settings by omnirom.

the class SettingsSliceProviderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    // Register the fake a11y Service
    ShadowAccessibilityManager shadowAccessibilityManager = Shadow.extract(RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
    shadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
    mProvider = spy(new SettingsSliceProvider());
    ShadowStrictMode.reset();
    mProvider.mSliceWeakDataCache = new HashMap<>();
    mProvider.mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(mContext);
    when(mProvider.getContext()).thenReturn(mContext);
    SlicesDatabaseHelper.getInstance(mContext).setIndexedState();
    doReturn(mManager).when(mContext).getSystemService(SliceManager.class);
    when(mManager.getPinnedSlices()).thenReturn(Collections.emptyList());
    mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
    SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
}
Also used : ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) Before(org.junit.Before)

Example 3 with ShadowAccessibilityManager

use of org.robolectric.shadows.ShadowAccessibilityManager in project android_packages_apps_Settings by omnirom.

the class SlicesDatabaseAccessorTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    ShadowUserManager.getShadow().setIsAdminUser(true);
    mAccessor = spy(new SlicesDatabaseAccessor(mContext));
    SlicesDatabaseHelper.getInstance(mContext).setIndexedState();
    // Register the fake a11y Service
    ShadowAccessibilityManager shadowAccessibilityManager = Shadow.extract(RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
    shadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
}
Also used : ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) Before(org.junit.Before)

Example 4 with ShadowAccessibilityManager

use of org.robolectric.shadows.ShadowAccessibilityManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PermissionBarChartPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = RuntimeEnvironment.application;
    final UserManager userManager = context.getSystemService(UserManager.class);
    final ShadowUserManager shadowUserManager = Shadow.extract(userManager);
    final ShadowAccessibilityManager accessibilityManager = Shadow.extract(AccessibilityManager.getInstance(context));
    accessibilityManager.setEnabledAccessibilityServiceList(new ArrayList<>());
    shadowUserManager.addProfile(new UserInfo(123, null, 0));
    when(FakeFeatureFactory.setupForTest().securityFeatureProvider.getLockPatternUtils(any(Context.class))).thenReturn(mLockPatternUtils);
    mController = spy(new PermissionBarChartPreferenceController(context, "test_key"));
    mFragment = spy(FragmentController.of(new PrivacyDashboardFragment()).create().start().get());
    mController.setFragment(mFragment);
    mPreference = spy(new BarChartPreference(context));
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn((BarChartPreference) mPreference);
}
Also used : Context(android.content.Context) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) BarChartPreference(com.android.settingslib.widget.BarChartPreference) UserManager(android.os.UserManager) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) UserInfo(android.content.pm.UserInfo) Before(org.junit.Before)

Example 5 with ShadowAccessibilityManager

use of org.robolectric.shadows.ShadowAccessibilityManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccessibilitySlicePreferenceControllerTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    final ContentResolver contentResolver = mContext.getContentResolver();
    Settings.Secure.putInt(contentResolver, Settings.Secure.ACCESSIBILITY_ENABLED, 1);
    Settings.Secure.putString(contentResolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, SERVICE_NAME);
    // Register the fake a11y Service
    ShadowAccessibilityManager shadowAccessibilityManager = Shadow.extract(RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
    shadowAccessibilityManager.setInstalledAccessibilityServiceList(getFakeServiceList());
    mController = new AccessibilitySlicePreferenceController(mContext, SERVICE_NAME);
}
Also used : ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) ShadowAccessibilityManager(org.robolectric.shadows.ShadowAccessibilityManager) AccessibilityManager(android.view.accessibility.AccessibilityManager) ContentResolver(android.content.ContentResolver) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)7 ShadowAccessibilityManager (org.robolectric.shadows.ShadowAccessibilityManager)7 AccessibilityManager (android.view.accessibility.AccessibilityManager)6 ContentResolver (android.content.ContentResolver)2 Context (android.content.Context)1 UserInfo (android.content.pm.UserInfo)1 UserManager (android.os.UserManager)1 ShadowUserManager (com.android.settings.testutils.shadow.ShadowUserManager)1 BarChartPreference (com.android.settingslib.widget.BarChartPreference)1