com.linkedin.android.testbutler.TestButler Java Examples
The following examples show how to use
com.linkedin.android.testbutler.TestButler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonHttpVersionProviderTest.java From force-update with Apache License 2.0 | 6 votes |
@Test @SdkSuppress(minSdkVersion=19) public void loadVersionOffline() throws Exception { JsonHttpVersionProvider provider = new JsonHttpVersionProvider("https://raw.githubusercontent.com/skoumalcz/force-update/master/force-update/src/androidTest/java/net/skoumal/forceupdate/provider/JsonHttpVersionProviderTest.DefaultAttributes.json"); TestButler.setGsmState(false); TestButler.setWifiState(false); try { VersionResult result = provider.getVersionResult(); assertTrue(result.isError()); assertNotNull(result); assertNull(result.getVersion()); assertNull(result.getPayload()); assertNotNull(result.getErrorMessage()); assertNotNull(result.getErrorException()); } finally { TestButler.setGsmState(true); TestButler.setWifiState(true); Thread.sleep(1000); } }
Example #2
Source File: LocationServicesChangerTest.java From test-butler with Apache License 2.0 | 6 votes |
@Test public void enableLocationModePostAndroidQ() { assumeTrue("Only for Android Q or later", Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_OFF); assertFalse(manager.isLocationEnabled()); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY); assertTrue(manager.isLocationEnabled()); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_BATTERY_SAVING); assertTrue(manager.isLocationEnabled()); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); assertTrue(manager.isLocationEnabled()); }
Example #3
Source File: LocationServicesChangerTest.java From test-butler with Apache License 2.0 | 6 votes |
@Test public void enableGpsProviderForSensorsAndHighAccuracyOnly() { assumeTrue("Only works before Android Q", Build.VERSION.SDK_INT < Build.VERSION_CODES.Q); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_OFF); assertFalse(manager.isProviderEnabled(LocationManager.GPS_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY); assertTrue(manager.isProviderEnabled(LocationManager.GPS_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_BATTERY_SAVING); assertFalse(manager.isProviderEnabled(LocationManager.GPS_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); assertTrue(manager.isProviderEnabled(LocationManager.GPS_PROVIDER)); }
Example #4
Source File: LocationServicesChangerTest.java From test-butler with Apache License 2.0 | 6 votes |
@Test public void enableNetworkProviderOnPhysicalDevice() { assumeTrue("Only works before Android Q", Build.VERSION.SDK_INT < Build.VERSION_CODES.Q); assumeFalse("Device is an emulator", Build.FINGERPRINT.contains("generic")); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_OFF); assertFalse(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY); assertFalse(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_BATTERY_SAVING); assertTrue(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); assertTrue(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); }
Example #5
Source File: LocationServicesChangerTest.java From test-butler with Apache License 2.0 | 6 votes |
@Test public void neverEnableNetworkProviderOnEmulator() { assumeTrue("Only works before Android Q", Build.VERSION.SDK_INT < Build.VERSION_CODES.Q); assumeTrue("Device is not an emulator", Build.FINGERPRINT.contains("generic")); // the network provider doesn't work on emulators, so nothing we do should be able to turn it on // http://stackoverflow.com/questions/2424564/activating-network-location-provider-in-the-android-emulator TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_OFF); assertFalse(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY); assertFalse(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_BATTERY_SAVING); assertFalse(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); assertFalse(manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)); }
Example #6
Source File: LocationServicesChangerTest.java From test-butler with Apache License 2.0 | 6 votes |
@Test public void alwaysLeavePassiveProviderEnabled() { assumeTrue("Only works before Android Q", Build.VERSION.SDK_INT < Build.VERSION_CODES.Q); // the passive provider is always enabled, regardless of the user's location preferences TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_OFF); assertTrue(manager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_SENSORS_ONLY); assertTrue(manager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_BATTERY_SAVING); assertTrue(manager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)); TestButler.setLocationMode(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY); assertTrue(manager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)); }
Example #7
Source File: ShowImeWithHardKeyboardHelperTest.java From test-butler with Apache License 2.0 | 6 votes |
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP_MR1) @Test public void keyboardDoesShow() { TestButler.setShowImeWithHardKeyboardState(true); EditText editText = (EditText) testRule.getActivity().findViewById(R.id.editText); int before[] = new int[2]; editText.getLocationOnScreen(before); onView(withId(R.id.editText)).perform(click()); int after[] = new int[2]; editText.getLocationOnScreen(after); // Only check that the y position changed assertNotEquals(before[1], after[1]); }
Example #8
Source File: ShowImeWithHardKeyboardHelperTest.java From test-butler with Apache License 2.0 | 6 votes |
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP_MR1) @Test public void keyboardDoesNotShow() { TestButler.setShowImeWithHardKeyboardState(false); EditText editText = (EditText) testRule.getActivity().findViewById(R.id.editText); int before[] = new int[2]; editText.getLocationOnScreen(before); onView(withId(R.id.editText)).perform(click()); int after[] = new int[2]; editText.getLocationOnScreen(after); // Check that the position has not changed at all assertEquals(before[0], after[0]); assertEquals(before[1], after[1]); }
Example #9
Source File: CarretoVersionProviderTest.java From force-update with Apache License 2.0 | 6 votes |
@Test @SdkSuppress(minSdkVersion=19) public void loadVersionOffline() throws Exception { CarretoGooglePlayVersionProvider provider = new CarretoGooglePlayVersionProvider("com.vocabularyminer.android"); TestButler.setGsmState(false); TestButler.setWifiState(false); try { VersionResult result = provider.getVersionResult(); assertTrue(result.isError()); assertNotNull(result); assertNull(result.getVersion()); assertNotNull(result.getErrorMessage()); assertNotNull(result.getErrorException()); } finally { TestButler.setGsmState(true); TestButler.setWifiState(true); Thread.sleep(1000); } }
Example #10
Source File: PermissionGranterTest.java From test-butler with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void failWhenTryingToGrantPermissionNotInManifest() { Context context = ApplicationProvider.getApplicationContext(); String permission = Manifest.permission.ADD_VOICEMAIL; TestButler.grantPermission(context, permission); }
Example #11
Source File: AlwaysFinishActivitiesChangerTest.java From test-butler with Apache License 2.0 | 5 votes |
@Test public void changeAlwaysFinishActivitiesSetting() { TestButler.setAlwaysFinishActivities(true); assertTrue(getAlwaysFinishActivitiesState(contentResolver)); TestButler.setAlwaysFinishActivities(false); assertFalse(getAlwaysFinishActivitiesState(contentResolver)); }
Example #12
Source File: AccessibilityEnablerTest.java From test-butler with Apache License 2.0 | 5 votes |
@Test public void startAndStopAccessibility() { TestButler.setAccessibilityServiceState(true); assertTrue(isButlerAccessibilityServiceEnabled()); TestButler.setAccessibilityServiceState(false); assertFalse(isButlerAccessibilityServiceEnabled()); }
Example #13
Source File: ImmersiveModeConfirmationDisablerTest.java From test-butler with Apache License 2.0 | 5 votes |
@Test public void immersiveModeConfirmationDoesNotShow() { TestButler.setImmersiveModeConfirmation(false); onView(withId(R.id.button_switch_to_immersive_mode)).perform(click()); onView(withId(R.id.button_call_butler)).perform(click()); onView(withId(R.id.text_butler_response)).check(matches(isDisplayed())); }
Example #14
Source File: PermissionGranterTest.java From test-butler with Apache License 2.0 | 5 votes |
/** * This is not a great test...it will only pass once, unless you revoke the permission externally between test runs */ @Test @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void successfullyGrantPermission() { Context context = ApplicationProvider.getApplicationContext(); String permission = Manifest.permission.WRITE_EXTERNAL_STORAGE; long result = ContextCompat.checkSelfPermission(context, permission); assertEquals(PackageManager.PERMISSION_DENIED, result); TestButler.grantPermission(context, permission); long newResult = ContextCompat.checkSelfPermission(context, permission); assertEquals(PackageManager.PERMISSION_GRANTED, newResult); }
Example #15
Source File: PermissionGranterTest.java From test-butler with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void failWhenTryingToGrantNonDangerousPermission() { Context context = ApplicationProvider.getApplicationContext(); String permission = Manifest.permission.ACCESS_WIFI_STATE; TestButler.grantPermission(context, permission); }
Example #16
Source File: GsmEnablerTest.java From test-butler with Apache License 2.0 | 5 votes |
private boolean enableDataTransfer() { //Action TestButler.setGsmState(true); //Check return Waiter.wait(RETRY_COUNT, new Waiter.DelayDependOnCount.SimpleLinearDelay(PAUSE), new Waiter.Predicate() { @Override public boolean compute(int tryCount) { NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); } }); }
Example #17
Source File: GsmEnablerTest.java From test-butler with Apache License 2.0 | 5 votes |
private boolean disableDataTransfer() { //Action TestButler.setGsmState(false); //Check return Waiter.wait(RETRY_COUNT, new Waiter.DelayDependOnCount.SimpleLinearDelay(PAUSE), new Waiter.Predicate() { @Override public boolean compute(int tryCount) { NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo == null || !activeNetworkInfo.isConnected(); } }); }
Example #18
Source File: MyAndroidJUnitRunner.java From force-update with Apache License 2.0 | 4 votes |
@Override public void finish(int resultCode, Bundle results) { TestButler.teardown(InstrumentationRegistry.getTargetContext()); super.finish(resultCode, results); }
Example #19
Source File: MyAndroidJUnitRunner.java From force-update with Apache License 2.0 | 4 votes |
@Override public void onStart() { TestButler.setup(InstrumentationRegistry.getTargetContext()); super.onStart(); }
Example #20
Source File: DemoTestRunner.java From test-butler with Apache License 2.0 | 4 votes |
@Override public void onStart() { TestButler.setup(getTargetContext()); super.onStart(); }
Example #21
Source File: DemoTestRunner.java From test-butler with Apache License 2.0 | 4 votes |
@Override public void finish(int resultCode, Bundle results) { TestButler.teardown(getTargetContext()); super.finish(resultCode, results); }
Example #22
Source File: AnimationDisablerTest.java From test-butler with Apache License 2.0 | 4 votes |
@Test public void disableAnimations() throws Exception { TestButler.verifyAnimationsDisabled(ApplicationProvider.getApplicationContext()); }
Example #23
Source File: TestButlerRunner.java From android-material-stepper with Apache License 2.0 | 4 votes |
@Override public void onStart() { TestButler.setup(InstrumentationRegistry.getTargetContext()); super.onStart(); }
Example #24
Source File: TestButlerRunner.java From android-material-stepper with Apache License 2.0 | 4 votes |
@Override public void finish(int resultCode, Bundle results) { TestButler.teardown(InstrumentationRegistry.getTargetContext()); super.finish(resultCode, results); }