android.test.suitebuilder.annotation.SmallTest Java Examples
The following examples show how to use
android.test.suitebuilder.annotation.SmallTest.
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: FragmentRunTest.java From Chronos with MIT License | 6 votes |
@SmallTest public void testNormalRunRotateTagged() { final SimpleMockActivity activity = new SimpleMockActivity(); final SimpleMockFragment fragment = new SimpleMockFragment(); activity.addFragment(fragment); activity.start(); final int firstRunId = fragment.runSimpleTagged(INPUT); activity.stop(); activity.start(); final int secondRunId = fragment.runSimpleTagged(INPUT); assertTrue(firstRunId == secondRunId); sleep(); assertTrue(fragment.getResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, fragment.getResult())); assertNull(fragment.getError()); }
Example #2
Source File: ActivityRunTest.java From Chronos with MIT License | 6 votes |
@SmallTest public void testNormalRunTaggedSequential() { final SimpleMockActivity activity = new SimpleMockActivity(); activity.start(); final int firstRunId = activity.runSimpleTagged(INPUT); sleep(); assertTrue(activity.getResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, activity.getResult())); assertNull(activity.getError()); final int secondRunId = activity.runSimpleTagged(INPUT); assertTrue(firstRunId != secondRunId); sleep(); assertTrue(activity.getResultObtained() == 2); assertTrue(SimpleOperation.isTransform(INPUT, activity.getResult())); assertNull(activity.getError()); }
Example #3
Source File: FragmentRunTest.java From Chronos with MIT License | 6 votes |
@SmallTest public void testRelaunchCancelledTaggedRunByTag() { final SimpleMockActivity activity = new SimpleMockActivity(); final SimpleMockFragment fragment = new SimpleMockFragment(); activity.addFragment(fragment); activity.start(); final int firstRunId = fragment.runSimpleTagged(INPUT); final boolean cancelResult = fragment.cancelTagged(); assertTrue(cancelResult); final int secondRunId = fragment.runSimpleTagged(INPUT); assertTrue(firstRunId != secondRunId); sleep(); assertTrue(fragment.getResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, fragment.getResult())); assertNull(fragment.getError()); }
Example #4
Source File: ChangesListenersTestCase.java From StoreBox with Apache License 2.0 | 6 votes |
@UiThreadTest @SmallTest public void testIntChanged() { final AtomicInteger value = new AtomicInteger(-1); final OnPreferenceValueChangedListener<Integer> listener = new OnPreferenceValueChangedListener<Integer>() { @Override public void onChanged(Integer newValue) { value.set(newValue); } }; uut.registerIntChangeListener(listener); uut.setInt(1); assertEquals(1, value.get()); }
Example #5
Source File: TimeBasedCacheTest.java From rxsnappy with Apache License 2.0 | 6 votes |
@SmallTest public void testDataCacheIsValid() throws SnappydbException { String key = "asd"; DummyData dummyData = DataGenerator.generateNewDummyData(); rxSnappyClient.setObject(key, dummyData) .toBlocking().first(); try { Thread.sleep(2500L); } catch (InterruptedException e) { } DummyData actual = rxSnappyClient.getObject(key, 5000L, DummyData.class) .toBlocking().first(); assertEquals(dummyData, actual); }
Example #6
Source File: FragmentRunTest.java From Chronos with MIT License | 6 votes |
@SmallTest public void testNormalRunTaggedSequential() { final SimpleMockActivity activity = new SimpleMockActivity(); final SimpleMockFragment fragment = new SimpleMockFragment(); activity.addFragment(fragment); activity.start(); final int firstRunId = fragment.runSimpleTagged(INPUT); sleep(); assertTrue(fragment.getResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, fragment.getResult())); assertNull(fragment.getError()); final int secondRunId = fragment.runSimpleTagged(INPUT); assertTrue(firstRunId != secondRunId); sleep(); assertTrue(fragment.getResultObtained() == 2); assertTrue(SimpleOperation.isTransform(INPUT, fragment.getResult())); assertNull(fragment.getError()); }
Example #7
Source File: ChangesListenersTestCase.java From StoreBox with Apache License 2.0 | 6 votes |
@UiThreadTest @SmallTest public void testCustomClassChangedNull() { final AtomicReference<CustomClass> value = new AtomicReference<>(); final OnPreferenceValueChangedListener<CustomClass> listener = new OnPreferenceValueChangedListener<CustomClass>() { @Override public void onChanged(CustomClass newValue) { value.set(newValue); } }; uut.setCustomClass(new CustomClass("a", "b")); uut.registerCustomClassChangeListener(listener); uut.setCustomClass(null); assertNull(value.get()); }
Example #8
Source File: BarberTest.java From barber with Apache License 2.0 | 6 votes |
@SmallTest public void testColorStateList() { int defaultColor = res.getColor(android.R.color.holo_blue_bright); int pressedColor = res.getColor(android.R.color.holo_blue_dark); int[] pressedState = {android.R.attr.state_pressed}; int[] defaultState = {}; assertNotNull(testView.testColorStateList); assertTrue(testView.testColorStateList.isStateful()); assertEquals(pressedColor, testView.testColorStateList.getColorForState(pressedState, defaultColor)); assertEquals(defaultColor, testView.testColorStateList.getColorForState(defaultState, defaultColor)); assertNotNull(defaultsTestView.testColorStateList); assertTrue(defaultsTestView.testColorStateList.isStateful()); assertEquals(pressedColor, defaultsTestView.testColorStateList.getColorForState(pressedState, defaultColor)); assertEquals(defaultColor, defaultsTestView.testColorStateList.getColorForState(defaultState, defaultColor)); }
Example #9
Source File: ApplicationTest.java From StepSensor with MIT License | 5 votes |
/** * Test the zeroSteps setting on first activation and on the manager's method */ @SmallTest public void testSetZeroSteps() { //Reset everything String STEPS_PREFERENCE_KEY = "STEPS_PREFERENCE_KEY"; String ZERO_STEPS_PREFERENCE_KEY = "ZERO_STEPS_PREFERENCE_KEY"; SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(solo.getCurrentActivity()); sharedPreferences.edit().remove(STEPS_PREFERENCE_KEY) .remove(ZERO_STEPS_PREFERENCE_KEY) .remove(SensorStepServiceManager.STEP_COUNTER_ACTIVATED_PREFERENCE_KEY) .apply(); //Set zero steps on first call final SensorStepServiceImpl sensorStepService = new SensorStepServiceImpl(solo.getCurrentActivity()); SensorStepServiceManagerImpl.startAutoUpdate(solo.getCurrentActivity()); assertTrue(solo.waitForCondition(new Condition() { @Override public boolean isSatisfied() { return sensorStepService.getZeroSteps() != 0; } }, 60000)); //Set zero steps on method called sensorStepService.storeRawSteps(sensorStepService.getZeroSteps() + 5); solo.clickOnText("zero"); assertTrue(solo.waitForCondition(new Condition() { @Override public boolean isSatisfied() { return sensorStepService.getZeroSteps() == sensorStepService.getRawSteps(); } }, 30000)); }
Example #10
Source File: SaveModeTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SmallTest public void testCommit() { final SaveModeCommitInterface uut = StoreBox.create( getActivity(), SaveModeCommitInterface.class); uut.setValue("value"); verify(editor).commit(); verify(editor, never()).apply(); }
Example #11
Source File: ActivityRunTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testCancelWrongId() { final SimpleMockActivity activity = new SimpleMockActivity(); activity.start(); final int runId = activity.runSimple(INPUT); final int wrongId = -1 * runId; final boolean cancelResult = activity.cancel(wrongId); assertFalse(cancelResult); sleep(); assertTrue(activity.gotResult()); }
Example #12
Source File: BroadcastRunTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testNormalRunFromActivityRotate() { final SimpleMockActivity firstActivity = new SimpleMockActivity(); final SimpleMockFragment fragment = new SimpleMockFragment(); firstActivity.addFragment(fragment); final SimpleMockActivity secondActivity = new SimpleMockActivity(); firstActivity.start(); secondActivity.start(); secondActivity.runBroadcast(INPUT); firstActivity.stop(); sleep(); assertTrue(secondActivity.getResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, secondActivity.getResult())); assertNull(secondActivity.getError()); assertFalse(secondActivity.gotBroadcastResult()); assertFalse(firstActivity.gotResult()); assertFalse(firstActivity.gotBroadcastResult()); assertFalse(fragment.gotResult()); assertFalse(fragment.gotBroadcastResult()); firstActivity.start(); assertFalse(firstActivity.gotResult()); assertTrue(firstActivity.getBroadcastResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, firstActivity.getBroadcastResult())); assertNull(firstActivity.getBroadcastError()); assertFalse(fragment.gotResult()); assertTrue(fragment.getBroadcastResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, fragment.getBroadcastResult())); assertNull(fragment.getBroadcastError()); }
Example #13
Source File: PreferencesTypeAndModeTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @SmallTest public void testModeMultiProcess() { final AtomicInteger count = new AtomicInteger(1); setActivityContext(new InjectedContext( getInstrumentation(), null, Context.MODE_MULTI_PROCESS, count)); startActivity(); StoreBox.create(getActivity(), PreferencesModeMultiProcessInterface.class); assertEquals(0, count.get()); }
Example #14
Source File: PreferencesTypeAndModeTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @SmallTest public void testModeWorldReadable() { final AtomicInteger count = new AtomicInteger(1); setActivityContext(new InjectedContext( getInstrumentation(), null, Context.MODE_WORLD_READABLE, count)); startActivity(); StoreBox.create(getActivity(), PreferencesModeWorldReadableInterface.class); assertEquals(0, count.get()); }
Example #15
Source File: ActivityRunTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testCancelAfterRun() { final SimpleMockActivity activity = new SimpleMockActivity(); activity.start(); final int runId = activity.runSimple(INPUT); sleep(); final boolean cancelResult = activity.cancel(runId); assertFalse(cancelResult); assertTrue(activity.gotResult()); }
Example #16
Source File: FragmentRunTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testCancelRunTaggedById() { final SimpleMockActivity activity = new SimpleMockActivity(); final SimpleMockFragment fragment = new SimpleMockFragment(); activity.addFragment(fragment); activity.start(); final int runId = fragment.runSimpleTagged(INPUT); final boolean cancelResult = fragment.cancel(runId); assertTrue(cancelResult); sleep(); assertFalse(fragment.gotResult()); }
Example #17
Source File: PreferencesTypeAndModeTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SmallTest public void testTypeDefaultShared() { final AtomicInteger count = new AtomicInteger(1); setActivityContext(new InjectedContext( getInstrumentation(), getInstrumentation().getTargetContext().getPackageName() + "_preferences", null, count)); startActivity(); StoreBox.create(getActivity(), PreferencesTypeDefaultSharedInterface.class); assertEquals(0, count.get()); }
Example #18
Source File: SaveModeTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SmallTest public void testCommitUsingMethodPrecedence() { final SaveModeCommitInterface uut = StoreBox.create( getActivity(), SaveModeCommitInterface.class); uut.setValueWithMethodAnnotation("value"); verify(editor).apply(); verify(editor, never()).commit(); }
Example #19
Source File: SetupTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testActivityFragmentLifecycleNormal() { final MockActivity activity = new SimpleMockActivity(); final MockFragment firstFragment = new SimpleMockFragment(); final MockFragment secondFragment = new SimpleMockFragment(); activity.addFragment(firstFragment); activity.addFragment(secondFragment); activity.start(); activity.stop(); activity.start(); activity.stop(); activity.start(); }
Example #20
Source File: SetupTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testActivityFragmentLifecycleInvalid2() { final MockActivity activity = new SimpleMockActivity(); final MockFragment fragment = new SimpleMockFragment(); activity.addFragment(fragment); IllegalStateException exception = null; try { activity.start(); activity.start(); } catch (IllegalStateException e) { exception = e; } Assert.assertNotNull(exception); }
Example #21
Source File: CustomTypesTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SmallTest public void testDateNull() { uut.setDate(new Date()); uut.setDate(null); assertNull(uut.getDate()); }
Example #22
Source File: QuoteOfTheDayMockAdapterTest.java From android-retrofit-test-examples with MIT License | 5 votes |
@SmallTest public void testRandomQuoteRetrieval() throws Exception { BehaviorDelegate<QuoteOfTheDayRestService> delegate = mockRetrofit.create(QuoteOfTheDayRestService.class); QuoteOfTheDayRestService mockQodService = new MockQuoteOfTheDayService(delegate); //Actual Test Call<QuoteOfTheDayResponse> quote = mockQodService.getQuoteOfTheDay(); Response<QuoteOfTheDayResponse> quoteOfTheDayResponse = quote.execute(); //Asserting response Assert.assertTrue(quoteOfTheDayResponse.isSuccessful()); Assert.assertEquals("Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.", quoteOfTheDayResponse.body().getContents().getQuotes().get(0).getQuote()); }
Example #23
Source File: FragmentRunTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testErrorRunRotate() { final SimpleMockActivity activity = new SimpleMockActivity(); final SimpleMockFragment fragment = new SimpleMockFragment(); activity.addFragment(fragment); activity.start(); fragment.runErrorSimple(); activity.stop(); sleep(); activity.start(); assertTrue(fragment.getResultObtained() == 1); assertNotNull(SimpleErrorOperation.isExpectedException(fragment.getError())); assertNull(fragment.getResult()); }
Example #24
Source File: ValueTypesTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SmallTest public void testLong() { assertEquals(0L, uut.getLong()); uut.setLong(1L); assertEquals(1L, uut.getLong()); }
Example #25
Source File: ActivityRunTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testRunningStateRotate() { final SimpleMockActivity activity = new SimpleMockActivity(); activity.start(); final int runId = activity.runSimple(INPUT); activity.stop(); sleep(SHORT_WAIT); activity.start(); assertTrue(activity.isRunning(runId)); activity.stop(); sleep(); activity.start(); assertFalse(activity.isRunning(runId)); }
Example #26
Source File: SetupTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testActivityLifecycleInvalid1() { final MockActivity activity = new SimpleMockActivity(); IllegalStateException exception = null; try { activity.stop(); } catch (IllegalStateException e) { exception = e; } Assert.assertNotNull(exception); }
Example #27
Source File: InitializationTest.java From rxsnappy with Apache License 2.0 | 5 votes |
@SmallTest public void testClientCreateWithoutInit() { boolean exceptionThrown = false; try { RxSnappyClient rxSnappyClient = new RxSnappyClient(); } catch (RxSnappyException rxSnappyException) { exceptionThrown = true; } assertEquals(true, exceptionThrown); }
Example #28
Source File: ValueTypesTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SmallTest public void testStringSetNull() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { uut.setStringSet(new HashSet<>(Collections.singletonList("one"))); uut.setStringSet(null); assertEquals(null, uut.getStringSet()); } else { // testStringSet() covers this scenario } }
Example #29
Source File: CustomTypesTestCase.java From StoreBox with Apache License 2.0 | 5 votes |
@SmallTest public void testUri() { final Uri value = Uri.parse("http://www.google.com"); uut.setUri(value); assertEquals(value, uut.getUri()); assertEquals(value, uut.getUri(Uri.EMPTY)); }
Example #30
Source File: ActivityRunTest.java From Chronos with MIT License | 5 votes |
@SmallTest public void testRelaunchCancelledTaggedRunByTag() { final SimpleMockActivity activity = new SimpleMockActivity(); activity.start(); final int firstRunId = activity.runSimpleTagged(INPUT); final boolean cancelResult = activity.cancelTagged(); assertTrue(cancelResult); final int secondRunId = activity.runSimpleTagged(INPUT); assertTrue(firstRunId != secondRunId); sleep(); assertTrue(activity.getResultObtained() == 1); assertTrue(SimpleOperation.isTransform(INPUT, activity.getResult())); assertNull(activity.getError()); }