android.test.UiThreadTest Java Examples

The following examples show how to use android.test.UiThreadTest. 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: ChangesListenersTestCase.java    From StoreBox with Apache License 2.0 7 votes vote down vote up
@UiThreadTest
@SmallTest
public void testListenerGarbageCollected() throws Exception {
    final AtomicBoolean called = new AtomicBoolean();

    uut.registerIntChangeListener(new OnPreferenceValueChangedListener<Integer>() {
        @Override
        public void onChanged(Integer newValue) {
            called.set(true);
        }
    });
    // nasty, but it does force collection of soft references...
    // TODO is there a better way to do this?
    try {
        Object[] ignored = new Object[(int) Runtime.getRuntime().maxMemory()];
    } catch (OutOfMemoryError e) {
        // NOP
    }
    uut.setInt(1);

    assertFalse(called.get());
}
 
Example #2
Source File: ChangesListenersTestCase.java    From StoreBox with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
@SmallTest
public void testCustomClassUnregistered() {
    final AtomicBoolean called = new AtomicBoolean();
    final OnPreferenceValueChangedListener<CustomClass> listener =
            new OnPreferenceValueChangedListener<CustomClass>() {
                @Override
                public void onChanged(CustomClass newValue) {
                    called.set(true);
                }
            };

    uut.registerCustomClassChangeListener(listener);
    uut.unregisterCustomClassChangeListener(listener);
    uut.setCustomClass(new CustomClass("a", "b"));

    assertFalse(called.get());
}
 
Example #3
Source File: SanityTest.java    From pretty with MIT License 6 votes vote down vote up
@Test
@UiThreadTest
public void testWrapActivity() throws Exception {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.madisp.pretty", "TestActivity"));

    Activity act = instrumentation.newActivity(
            Activity.class,
            context,
            null,
            new MockApplication(),
            intent,
            new ActivityInfo(),
            "",
            null,
            null,
            null);
    Pretty.wrap(act);
}
 
Example #4
Source File: BackgroundQueuesTest.java    From tinybus with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testPostSingleEventToSingleQueue() throws Exception {
	
	final TinyBus bus = TinyBus.from(getInstrumentation().getContext());
	final CountDownLatch latch = new CountDownLatch(1);
	bus.register(new Object() {
		@Subscribe(mode = Mode.Background)
		public void onEvent(String event) {
			collectEvent(event);
			latch.countDown();
		}
	});
	
	bus.post("event a");
	latch.await(TEST_TIMEOUT, TimeUnit.SECONDS);
	
	assertEventsNumber(1);
	assertResult(0, "event a", "tinybus-worker-");
}
 
Example #5
Source File: BackgroundQueuesTest.java    From tinybus with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testPostMultipleEventsToSingleQueue() throws Exception {
	
	int numberOfEvents = 100;
	
	TinyBus bus = TinyBus.from(getInstrumentation().getContext());
	final CountDownLatch latch = new CountDownLatch(numberOfEvents);
	bus.register(new Object() {
		@Subscribe(mode = Mode.Background)
		public void onEvent(String event) {
			collectEvent(event);
			latch.countDown();
		}
	});
	
	for(int i=0; i<numberOfEvents; i++) {
		bus.post("event_" + i);
	}
	latch.await(TEST_TIMEOUT, TimeUnit.SECONDS);
	
	assertEventsNumber(numberOfEvents);
	for(int i=0; i<numberOfEvents; i++) {
		assertResult(i, "event_" + i, "tinybus-worker-0");
	}
}
 
Example #6
Source File: FragmentStackTest.java    From nucleus with MIT License 6 votes vote down vote up
@UiThreadTest
public void testBack() throws Exception {
    FragmentManager manager = activity.getSupportFragmentManager();
    FragmentStack stack = new FragmentStack(activity, manager, CONTAINER_ID);

    assertFalse(stack.back());

    stack.push(new TestFragment1());
    assertEquals(1, stack.size());
    assertFalse(stack.back());

    stack.push(new TestFragment1());
    assertEquals(2, stack.size());
    assertTrue(stack.back());

    assertEquals(1, stack.size());
}
 
Example #7
Source File: ChangesListenersTestCase.java    From StoreBox with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
@SmallTest
public void testCustomClassChanged() {
    final AtomicReference<CustomClass> value = new AtomicReference<>();
    final OnPreferenceValueChangedListener<CustomClass> listener =
            new OnPreferenceValueChangedListener<CustomClass>() {
                @Override
                public void onChanged(CustomClass newValue) {
                    value.set(newValue);
                }
            };
    
    uut.registerCustomClassChangeListener(listener);
    uut.setCustomClass(new CustomClass("a", "b"));
    
    assertEquals(new CustomClass("a", "b"), value.get());
}
 
Example #8
Source File: BackgroundProcessingTest.java    From tinybus with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testPostMainReceiveBackgroundWrongConstructor() {
	
	final CountDownLatch latch = new CountDownLatch(1);
	
	bus = new TinyBus();
	bus.register(new Object() {
		@Subscribe(mode=Mode.Background)
		public void onEvent(String event) {
			stringResult = event;
			latch.countDown();
		}
	});
	
	try {
		bus.post("event a");
		fail();
	} catch (IllegalStateException e) {
		// OK
	}
}
 
Example #9
Source File: ActivityMainTest.java    From ploggy with GNU General Public License v3.0 6 votes vote down vote up
@UiThreadTest
public void testStateSaveRestore() {
    //
    // Destroy/Create
    //

    // Check that we're starting on the first tab
    assertEquals(mActionBar.getSelectedNavigationIndex(), 0);

    // Select the second tab
    mActionBar.setSelectedNavigationItem(1);

    // Destroy the activity, which should save the state
    mActivity.finish();

    // Recreate the activity...
    mActivity = this.getActivity();

    // ...which should cause it to restore state
    assertEquals(mActionBar.getSelectedNavigationIndex(), 1);
}
 
Example #10
Source File: RequestQueueTest.java    From android-project-wo2b with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testAdd_requestProcessedInCorrectOrder() throws Exception {
    int requestsToMake = 100;

    OrderCheckingNetwork network = new OrderCheckingNetwork();
    RequestQueue queue = new RequestQueue(new NoCache(), network, 1, mDelivery);

    for (Request<?> request : makeRequests(requestsToMake)) {
        queue.add(request);
    }

    network.setExpectedRequests(requestsToMake);
    queue.start();
    network.waitUntilExpectedDone(2000); // 2 seconds
    queue.stop();
}
 
Example #11
Source File: FragmentStackTest.java    From nucleus with MIT License 6 votes vote down vote up
@UiThreadTest
public void testPushPop() throws Exception {
    FragmentManager manager = activity.getSupportFragmentManager();
    FragmentStack stack = new FragmentStack(activity, manager, CONTAINER_ID);

    TestFragment1 fragment = new TestFragment1();
    stack.push(fragment);
    assertTopFragment(manager, stack, fragment, 0);

    TestFragment2 fragment2 = new TestFragment2();
    stack.push(fragment2);
    assertFragment(manager, fragment, 0);
    assertTopFragment(manager, stack, fragment2, 1);

    assertFalse(fragment.isAdded());
    assertTrue(fragment2.isAdded());

    assertTrue(stack.pop());
    assertTopFragment(manager, stack, fragment, 0);

    assertNull(manager.findFragmentByTag("1"));

    assertFalse(stack.pop());
    assertTopFragment(manager, stack, fragment, 0);
}
 
Example #12
Source File: ChangesListenersTestCase.java    From StoreBox with Apache License 2.0 6 votes vote down vote up
@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 #13
Source File: ChangesListenersTestCase.java    From StoreBox with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
@SmallTest
public void testIntUnregistered() {
    final AtomicBoolean called = new AtomicBoolean();
    final OnPreferenceValueChangedListener<Integer> listener =
            new OnPreferenceValueChangedListener<Integer>() {
                @Override
                public void onChanged(Integer newValue) {
                    called.set(true);
                }
            };

    uut.registerIntChangeListener(listener);
    uut.unregisterIntChangeListener(listener);
    uut.setInt(1);

    assertFalse(called.get());
}
 
Example #14
Source File: SampleTests.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Test if all Interpolators can be used to start an animation.
 */
@UiThreadTest
public void testStartInterpolators() {

    // Start an animation for each interpolator
    final Interpolator[] interpolators = mTestFragment.getInterpolators();

    for (final Interpolator i : interpolators) {
        // Start the animation
        ObjectAnimator animator = mTestFragment.startAnimation(i, 1000L, mTestFragment.getPathIn());
        // Check that the correct interpolator is used for the animation
        assertEquals(i, animator.getInterpolator());
        // Verify the animation has started
        assertTrue(animator.isStarted());
        // Cancel before starting the next animation
        animator.cancel();
    }
}
 
Example #15
Source File: ChangesListenersTestCase.java    From StoreBox with Apache License 2.0 6 votes vote down vote up
@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 #16
Source File: SetTimerActivityTest.java    From PTVGlass with MIT License 6 votes vote down vote up
@UiThreadTest
public void testOnGestureTapSupported() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);

    activity.onResume();
    activity.getView().setSelection(0);

    assertTrue(activity.onGesture(Gesture.TAP));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue());

    Intent startedIntent = getStartedActivityIntent();

    assertNotNull(startedIntent);
    assertEquals(
            SelectValueActivity.class.getName(), startedIntent.getComponent().getClassName());
    assertEquals(
            SetTimerScrollAdapter.TimeComponents.HOURS.getMaxValue(),
            startedIntent.getIntExtra(SelectValueActivity.EXTRA_COUNT, 0));
    assertEquals(
            0, startedIntent.getIntExtra(SelectValueActivity.EXTRA_INITIAL_VALUE, 0));
    assertEquals(SetTimerActivity.SELECT_VALUE, getStartedActivityRequest());
    assertFalse(isFinishCalled());
}
 
Example #17
Source File: RxPermissionsTest.java    From rx-android-permissions with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testObserveNotGrantedThenGrantedPermissions() {

    TestSubscriber<Boolean> subscriber = new TestSubscriber<>();
    RxPermissionsUnderTest permissions = new RxPermissionsUnderTest(getContext(), false);

    Subscription subscription = permissions.observe(
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE)
            .subscribe(subscriber);

    subscriber.assertValues(false);

    permissions.setAllowed(Manifest.permission.READ_EXTERNAL_STORAGE);
    subscriber.assertValues(false, false);

    permissions.setAllowed(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    subscriber.assertValues(false, false, true);

    subscriber.assertNoErrors();
    subscriber.assertNotCompleted();

    subscription.unsubscribe();
}
 
Example #18
Source File: RxPermissionsTest.java    From rx-android-permissions with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testRequestGrantedPermissions() {

    TestSubscriber<Boolean> subscriber = new TestSubscriber<>();
    RxPermissionsUnderTest permissions = new RxPermissionsUnderTest(getContext(), true);
    MockPermissionsRequester requester = new MockPermissionsRequester(true);

    Subscription subscription = permissions.request(requester,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE)
            .subscribe(subscriber);

    subscriber.assertValue(true);
    subscriber.assertNoErrors();
    subscriber.assertCompleted();

    assertTrue(subscription.isUnsubscribed());
}
 
Example #19
Source File: RequestQueueTest.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testAdd_requestProcessedInCorrectOrder() throws Exception {
    int requestsToMake = 100;

    OrderCheckingNetwork network = new OrderCheckingNetwork();
    RequestQueue queue = new RequestQueue(new NoCache(), network, 1, mDelivery);

    for (Request<?> request : makeRequests(requestsToMake)) {
        queue.add(request);
    }

    network.setExpectedRequests(requestsToMake);
    queue.start();
    network.waitUntilExpectedDone(2000); // 2 seconds
    queue.stop();
}
 
Example #20
Source File: SelectValueActivityTest.java    From PTVGlass with MIT License 6 votes vote down vote up
@UiThreadTest
public void testOnGestureTapSupported() {
    MockSelectValueActivity activity = startActivity(mActivityIntent, null, null);
    int expectedSelectedValue = 35;

    activity.onResume();
    activity.getView().setSelection(expectedSelectedValue);

    assertTrue(activity.onGesture(Gesture.TAP));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue());

    assertTrue(isFinishCalled());
    assertEquals(Activity.RESULT_OK, activity.mResultCode);
    assertNotNull(activity.mResultIntent);
    assertEquals(
            expectedSelectedValue,
            activity.mResultIntent.getIntExtra(SelectValueActivity.EXTRA_SELECTED_VALUE, 0));
}
 
Example #21
Source File: SetTimerActivityTest.java    From PTVGlass with MIT License 6 votes vote down vote up
@UiThreadTest
public void testOnGestureTapSupportedSelectValueForMinutes() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);

    activity.onResume();
    activity.getView().setSelection(1);

    assertTrue(activity.onGesture(Gesture.TAP));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.TAP, activity.mPlayedSoundEffects.get(0).intValue());

    Intent startedIntent = getStartedActivityIntent();

    assertNotNull(startedIntent);
    assertEquals(
            SelectValueActivity.class.getName(), startedIntent.getComponent().getClassName());
    assertEquals(
            SetTimerScrollAdapter.TimeComponents.MINUTES.getMaxValue(),
            startedIntent.getIntExtra(SelectValueActivity.EXTRA_COUNT, 0));
    assertEquals(
            5, startedIntent.getIntExtra(SelectValueActivity.EXTRA_INITIAL_VALUE, 0));
    assertEquals(SetTimerActivity.SELECT_VALUE, getStartedActivityRequest());
    assertFalse(isFinishCalled());
}
 
Example #22
Source File: TestActivity.java    From Masaccio with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testFaceDetection3() throws InterruptedException {

    final MasaccioImageView view =
            (MasaccioImageView) getActivity().findViewById(R.id.masaccio_view);

    view.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.pan1));

    assertThat(view.getScaleType()).isEqualTo(ScaleType.MATRIX);

    final float[] coeffs = new float[9];
    view.getImageMatrix().getValues(coeffs);

    assertThat(coeffs[0]).isEqualTo(0.8333333f, Offset.offset(0.01f));
    assertThat(coeffs[1]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[2]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[3]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[4]).isEqualTo(0.8333333f, Offset.offset(0.01f));
    assertThat(coeffs[5]).isEqualTo(-17.239578f, Offset.offset(0.01f));
    assertThat(coeffs[6]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[7]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[8]).isEqualTo(1.0f, Offset.offset(0.01f));
}
 
Example #23
Source File: SpinnerActivityTest.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@UiThreadTest
public void testPauseShouldPreserveInstanceState() {
	Instrumentation mInstr = this.getInstrumentation();
	mActivity.setSpinnerPosition(TEST_STATE_PAUSE_POSITION);
	mActivity.setSpinnerSelection(TEST_STATE_PAUSE_SELECTION);

	//
	mInstr.callActivityOnPause(mActivity);
	mActivity.setSpinnerPosition(0);
	mActivity.setSpinnerSelection("");

	mInstr.callActivityOnResume(mActivity);
	int currentPosition = mActivity.getSpinnerPosition();
	String currentSelection = mActivity.getSpinnerSelection();

	assertEquals(TEST_STATE_PAUSE_POSITION, currentPosition);
	assertEquals(TEST_STATE_PAUSE_SELECTION, currentSelection);
}
 
Example #24
Source File: TestActivity.java    From Masaccio with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testFaceDetection2() throws InterruptedException {

    final MasaccioImageView view =
            (MasaccioImageView) getActivity().findViewById(R.id.masaccio_view);

    view.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.pan0));

    assertThat(view.getScaleType()).isEqualTo(ScaleType.MATRIX);

    final float[] coeffs = new float[9];
    view.getImageMatrix().getValues(coeffs);

    assertThat(coeffs[0]).isEqualTo(0.3125f, Offset.offset(0.01f));
    assertThat(coeffs[1]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[2]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[3]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[4]).isEqualTo(0.3125f, Offset.offset(0.01f));
    assertThat(coeffs[5]).isEqualTo(-10.175781f, Offset.offset(0.01f));
    assertThat(coeffs[6]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[7]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[8]).isEqualTo(1.0f, Offset.offset(0.01f));
}
 
Example #25
Source File: TestActivity.java    From Masaccio with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testFaceDetection() throws InterruptedException {

    final MasaccioImageView view =
            (MasaccioImageView) getActivity().findViewById(R.id.masaccio_view);

    assertThat(view.getScaleType()).isEqualTo(ScaleType.MATRIX);

    final float[] coeffs = new float[9];
    view.getImageMatrix().getValues(coeffs);

    assertThat(coeffs[0]).isEqualTo(0.234375f, Offset.offset(0.01f));
    assertThat(coeffs[1]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[2]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[3]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[4]).isEqualTo(0.234375f, Offset.offset(0.01f));
    assertThat(coeffs[5]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[6]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[7]).isEqualTo(0.0f, Offset.offset(0.01f));
    assertThat(coeffs[8]).isEqualTo(1.0f, Offset.offset(0.01f));
}
 
Example #26
Source File: SetTimerActivityTest.java    From PTVGlass with MIT License 6 votes vote down vote up
@UiThreadTest
public void testOnGestureSwipeDownSupported() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);
    SetTimerScrollAdapter adapter = (SetTimerScrollAdapter) activity.getView().getAdapter();
    long expectedDuration = TimeUnit.SECONDS.toMillis(45);

    adapter.setDurationMillis(expectedDuration);
    assertTrue(activity.onGesture(Gesture.SWIPE_DOWN));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.DISMISSED, activity.mPlayedSoundEffects.get(0).intValue());

    assertTrue(isFinishCalled());
    assertEquals(Activity.RESULT_OK, activity.mResultCode);
    assertNotNull(activity.mResultIntent);
    assertEquals(
            expectedDuration,
            activity.mResultIntent.getLongExtra(SetTimerActivity.EXTRA_DURATION_MILLIS, 0));
}
 
Example #27
Source File: ApplicationTest.java    From roads-api-samples with Apache License 2.0 6 votes vote down vote up
@UiThreadTest
public void testSampleFlow() throws Exception {
    MainActivity activity = getActivity();

    // Click "Load GPX data" button
    View gpxButton = activity.findViewById(R.id.load_gpx_data);
    activity.onGpxButtonClick(gpxButton);
    assertTrue(activity.mCapturedLocations.size() > 0);

    // Click "Send Snap to Roads requests" button
    View snapButton = activity.findViewById(R.id.snap_to_roads);
    activity.onSnapToRoadsButtonClick(snapButton);
    activity.mSnappedPoints = activity.mTaskSnapToRoads.get();
    assertTrue(activity.mSnappedPoints.size() > 0);

    // Click "Request speed limits" button
    View speedsButton = activity.findViewById(R.id.speed_limits);
    activity.onSpeedLimitButtonClick(speedsButton);
    activity.mPlaceSpeeds = activity.mTaskSpeedLimits.get();
    assertTrue(activity.mPlaceSpeeds.size() > 0);
}
 
Example #28
Source File: SetTimerActivityTest.java    From gdk-timer-sample with Apache License 2.0 5 votes vote down vote up
@UiThreadTest
public void testOnGestureSwipeDownSupported() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);

    assertTrue(activity.onGesture(Gesture.SWIPE_DOWN));
    assertEquals(1, activity.mPlayedSoundEffects.size());
    assertEquals(Sounds.DISMISSED, activity.mPlayedSoundEffects.get(0).intValue());

    assertTrue(isFinishCalled());
    assertEquals(Activity.RESULT_CANCELED, activity.mResultCode);
    assertNull(activity.mResultIntent);
}
 
Example #29
Source File: SetTimerActivityTest.java    From PTVGlass with MIT License 5 votes vote down vote up
@UiThreadTest
public void testOnActivityResult() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);
    SetTimerScrollAdapter adapter = (SetTimerScrollAdapter) activity.getView().getAdapter();
    Intent data = new Intent();
    int hoursValue = 3;
    long expectedDurationMillis = TimeUnit.HOURS.toMillis(hoursValue) + INITIAL_DURATION_MILLIS;

    data.putExtra(SelectValueActivity.EXTRA_SELECTED_VALUE, hoursValue);
    activity.onActivityResult(SetTimerActivity.SELECT_VALUE, Activity.RESULT_OK, data);
    assertEquals(expectedDurationMillis, adapter.getDurationMillis());
    assertEquals(
            hoursValue, adapter.getTimeComponent(SetTimerScrollAdapter.TimeComponents.HOURS));
}
 
Example #30
Source File: SetTimerActivityTest.java    From PTVGlass with MIT License 5 votes vote down vote up
@UiThreadTest
public void testOnCreate() {
    MockSetTimerActivity activity = startActivity(mActivityIntent, null, null);
    SetTimerScrollAdapter adapter = (SetTimerScrollAdapter) activity.getView().getAdapter();

    assertEquals(INITIAL_DURATION_MILLIS, adapter.getDurationMillis());
}