android.support.test.filters.SmallTest Java Examples

The following examples show how to use android.support.test.filters.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: RxTimerSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testStop() {
    assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
    mTimerSupport.register(1, new OnTickListener() {

        @Override
        public void onTick() {
            //should not here
            assertTrue(false);
        }
    });

    mTimerSupport.register(3, new OnTickListener() {

        @Override
        public void onTick() {
            //should not here
            assertTrue(false);
        }
    });
    mTimerSupport.clear();
}
 
Example #2
Source File: RxClickSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testOneConsumerSubscribeTwoCellClicks() {
    Consumer<ClickExposureCellOp> consumer = new Consumer<ClickExposureCellOp>() {

        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertTrue(clickEvent.getArg1() == mView1 || clickEvent.getArg1() == mView2);
            assertTrue(clickEvent.getArg2() == mBaseCell1 || clickEvent.getArg2() == mBaseCell2);
            Log.d("RxClickSupportTest", "testOneConsumerSubscribeTwoCellClicks mEventType " + clickEvent.getArg3());
        }
    };
    //mSimpleClickSupport.setConsumer(consumer);

    mBaseCell1.click(mView1);
    mView1.performClick();

    mBaseCell2.click(mView2);
    mView2.performClick();

}
 
Example #3
Source File: RxClickSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testOneCellClicks() {
    Consumer<ClickExposureCellOp> consumer1 = new Consumer<ClickExposureCellOp>() {
        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertEquals(clickEvent.getArg1(), mView1);
            assertEquals(clickEvent.getArg2(), mBaseCell1);
            assertEquals(clickEvent.getArg3().intValue(), 10);
            Log.d("RxClickSupportTest", "testOneCellClicks test One cell mEventType " + clickEvent.getArg3());
        }
    };
    //mSimpleClickSupport.setConsumer(consumer1);
    mBaseCell1.click(mView1);
    mView1.performClick();
}
 
Example #4
Source File: RxClickSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testCellClickDispose() {
    Consumer<ClickExposureCellOp> consumer = new Consumer<ClickExposureCellOp>() {

        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            //should not execute this code
            assertTrue(false);
        }
    };
    //mSimpleClickSupport.setConsumer(consumer);

    mBaseCell1.click(mView1);
    //mSimpleClickSupport.destroy();
    mView1.performClick();
}
 
Example #5
Source File: RxExposureSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testOneConsumerSubscribeTwoCellExposure() {
    Consumer<ClickExposureCellOp> consumer = new Consumer<ClickExposureCellOp>() {

        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertTrue(clickEvent.getArg1() == mView1 || clickEvent.getArg1() == mView2);
            assertTrue(clickEvent.getArg2() == mBaseCell1 || clickEvent.getArg2() == mBaseCell2);
            Log.d("RxExposureSupportTest", "testOneConsumerSubscribeTwoCellExposure mEventType " + clickEvent.getArg3());
        }
    };
    //mExposureSupport.setConsumer(consumer);
    mBaseCell1.exposure(mView1);
    mBaseCell2.exposure(mView2);
}
 
Example #6
Source File: RxExposureSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testOneCellWithMultiViewExposure() {
    Consumer<ClickExposureCellOp> consumer1 = new Consumer<ClickExposureCellOp>() {
        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertTrue(Looper.myLooper() == Looper.getMainLooper());
            assertTrue(clickEvent.getArg1() == mView1 || clickEvent.getArg1() == mView2);
            assertTrue(clickEvent.getArg2() == mBaseCell1);
            Log.d("RxExposureSupportTest", "testOneCellWithMultiViewExposure mEventType " + clickEvent.getArg3());
            Log.d("RxExposureSupportTest", "testOneCellWithMultiViewExposure view " + clickEvent.getArg1());
        }
    };
    //mExposureSupport.setConsumer(consumer1);

    mBaseCell1.exposure(mView1);
    mBaseCell1.exposure(mView2);
}
 
Example #7
Source File: RxExposureSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testOneCellExposure() {
    Consumer<ClickExposureCellOp> consumer1 = new Consumer<ClickExposureCellOp>() {
        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertEquals(clickEvent.getArg1(), mView1);
            assertEquals(clickEvent.getArg2(), mBaseCell1);
            assertEquals(clickEvent.getArg3().intValue(), 10);
            Log.d("RxExposureSupportTest", "testOneCellExposure test One cell mEventType " + clickEvent.getArg3());
        }
    };
    //mExposureSupport.setConsumer(consumer1);
    mBaseCell1.exposure(mView1);
}
 
Example #8
Source File: RxClickSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testCellClickDisposeAndResubscribe() {
    Consumer<ClickExposureCellOp> consumer = new Consumer<ClickExposureCellOp>() {

        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertTrue(clickEvent.getArg1() == mView1);
            Log.d("RxClickSupportTest", "testCellClickDisposeAndResubscribe mEventType " + clickEvent.getArg3());
        }
    };
    //mSimpleClickSupport.setConsumer(consumer);

    mBaseCell1.click(mView1);
    mBaseCell1.click(mView1);
    mView1.performClick();
}
 
Example #9
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testObservableApi() {
    mTimerSupport.getTickObservable(2, false).subscribe(new Consumer<Long>() {

        long start = System.currentTimeMillis();

        @Override
        public void accept(Long aLong) throws Exception {
            long end = System.currentTimeMillis();
            long time = (end - start);
            Log.d("RxTimerSupportTest", "testObservableApi " + time);
            assertTrue(Math.abs(time - 2 * 1000) < 50);
            start = end;
        }
    });
}
 
Example #10
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testResume() {
    assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
    mTimerSupport.register(1, new OnTickListener() {

        @Override
        public void onTick() {
            assertEquals(Looper.myLooper(), Looper.getMainLooper());
            assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
            Log.d("RxTimerSupportTest", "testResume");
        }
    });

    mTimerSupport.pause();
    mTimerSupport.restart();
}
 
Example #11
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testPause() {
    assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
    mTimerSupport.register(1, new OnTickListener() {

        long start = System.currentTimeMillis();

        @Override
        public void onTick() {
            //should not here
            assertTrue(false);
        }
    });

    mTimerSupport.pause();
}
 
Example #12
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testIntervalLargerThan1() {
    assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
    mTimerSupport.register(3, new OnTickListener() {

        long start = System.currentTimeMillis();

        @Override
        public void onTick() {
            assertEquals(Looper.myLooper(), Looper.getMainLooper());
            assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
            long end = System.currentTimeMillis();
            long time = (end - start);
            Log.d("RxTimerSupportTest", "3 testTimerExecution " + time);
            assertTrue(Math.abs(time - 3 * 1000) < 50);
            start = end;
        }
    });
}
 
Example #13
Source File: RxClickSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testOneCellWithMultiViewClick() {
    Consumer<ClickExposureCellOp> consumer = new Consumer<ClickExposureCellOp>() {

        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertTrue(clickEvent.getArg1() == mView1 || clickEvent.getArg1() == mView2);
            assertTrue(clickEvent.getArg2() == mBaseCell1);
            Log.d("RxClickSupportTest", "testOneCellWithMultiViewClick mEventType " + clickEvent.getArg3());
            Log.d("RxClickSupportTest", "testOneCellWithMultiViewClick view " + clickEvent.getArg1());
        }
    };
    //mSimpleClickSupport.setConsumer(consumer);

    mBaseCell1.click(mView1);
    mBaseCell1.click(mView2);
    mView1.performClick();
    mView2.performClick();
}
 
Example #14
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testTimerIntermediateArg() {
    assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
    mTimerSupport.register(1, new OnTickListener() {

        long start = System.currentTimeMillis();

        @Override
        public void onTick() {
            assertEquals(Looper.myLooper(), Looper.getMainLooper());
            assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
            long end = System.currentTimeMillis();
            long time = (end - start);
            Log.d("RxTimerSupportTest", "testTimerIntermediateArg " + time);
            assertTrue(Math.abs(time) < 50 || Math.abs(time - 1 * 1000) < 50);
            start = end;
        }
    }, true);

}
 
Example #15
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 6 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testTimerExecution() {
    assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
    mTimerSupport.register(1, new OnTickListener() {
        long start = System.currentTimeMillis();

        @Override
        public void onTick() {
            assertEquals(Looper.myLooper(), Looper.getMainLooper());
            assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
            long end = System.currentTimeMillis();
            long time = (end - start);
            Log.d("RxTimerSupportTest", "testTimerExecution " + time);
            assertTrue(Math.abs(time - 1 * 1000) < 50);
            start = end;
        }
    });
}
 
Example #16
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 5 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testObservableApi2() {
    final TestConsumer<Long> testConsumer = new TestConsumer<>();
    mTimerSupport.getTickObservable(2, 5, false)
        .doOnComplete(new Action() {
            @Override
            public void run() throws Exception {
                Log.d("RxTimerSupportTest", "testObservableApi2 onComlete");
                assertTrue(testConsumer.getCount() == 5);
            }
        })
        .subscribe(testConsumer);
}
 
Example #17
Source File: RxClickSupportTest.java    From Tangram-Android with MIT License 5 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testOneCellWithMultiViewClickDispose() {
    Consumer<ClickExposureCellOp> consumer = new Consumer<ClickExposureCellOp>() {

        @Override
        public void accept(ClickExposureCellOp clickEvent) throws Exception {
            assertTrue(clickEvent.getArg1() == mView1 || clickEvent.getArg1() == mView2);
            assertTrue(clickEvent.getArg2() == mBaseCell1);
            Log.d("RxClickSupportTest", "testOneCellWithMultiViewClickDispose mEventType " + clickEvent.getArg3());
            Log.d("RxClickSupportTest", "testOneCellWithMultiViewClickDispose view " + clickEvent.getArg1());

            //should not execute this code
            assertTrue(false);
        }
    };
    //mSimpleClickSupport.setConsumer(consumer);

    mBaseCell1.click(mView1);
    mBaseCell1.click(mView2);

    //mSimpleClickSupport.destroy();

    mView1.performClick();
    mView2.performClick();
}
 
Example #18
Source File: MainActivityTest.java    From android-testing-guide with MIT License 5 votes vote down vote up
@Test
@SmallTest
public void testSmallTest() {
    Log.d("Test Filters", "this is a small test");
    Activity activity = activityTestRule.getActivity();
    assertNotNull("MainActivity is not available", activity);
}
 
Example #19
Source File: RxTimerSupportTest.java    From Tangram-Android with MIT License 5 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testRegisterAndUnregister() {
    assertEquals(mTimerSupport.getStatus(), TimerStatus.Waiting);
    OnTickListener onTickListener = new OnTickListener() {

        long start = System.currentTimeMillis();

        @Override
        public void onTick() {
            assertEquals(Looper.myLooper(), Looper.getMainLooper());
            assertEquals(mTimerSupport.getStatus(), TimerStatus.Running);
            long end = System.currentTimeMillis();
            long time = (end - start);
            Log.d("RxTimerSupportTest", "testTimerIntermediateArg " + time);
            //assertTrue(Math.abs(time) < 50 || Math.abs(time - 1 * 1000) < 50);
            start = end;
        }
    };
    mTimerSupport.register(1, onTickListener, true);
    mTimerSupport.unregister(onTickListener);
    mTimerSupport.register(1, onTickListener, true);
    mTimerSupport.unregister(onTickListener);
    mTimerSupport.register(1, onTickListener, true);
    mTimerSupport.unregister(onTickListener);
    mTimerSupport.register(1, onTickListener, true);
}
 
Example #20
Source File: RxExposureSupportTest.java    From Tangram-Android with MIT License 4 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testDestroyExposure() {
    ExposureSupport exposureSupport = new ExposureSupport() {

        private CompositeDisposable mCompositeDisposable = new CompositeDisposable();

        Consumer<ClickExposureCellOp> consumer = new Consumer<ClickExposureCellOp>() {

            @Override
            public void accept(ClickExposureCellOp clickEvent) throws Exception {
                //should not execute here
                assertTrue(false);
                assertTrue(Looper.myLooper() == Looper.getMainLooper());
                assertEquals(clickEvent.getArg1(), mView1);
                assertEquals(clickEvent.getArg2(), mBaseCell1);
                assertEquals(clickEvent.getArg3().intValue(), 10);
                Log.d("RxExposureSupportTest", "testExposureTaskAsyncThenCancelItButResubscribe  mEventType " + clickEvent.getArg3());
                Log.d("RxExposureSupportTest",
                    "testDestroyExposure  thread " + Thread.currentThread().getId() + ": " + Thread.currentThread()
                        .getName());
            }
        };


        @Override
        public void onExposure(@NonNull Card card, int offset, int position) {

        }

        //@Override
        //public void onRxExposure(Observable<ClickExposureCellOp> exposureCellOpObservable,
        //    ClickExposureCellOp rxEvent) {
        //    mCompositeDisposable.add(
        //        exposureCellOpObservable.delaySubscription(1, TimeUnit.MINUTES).subscribe(consumer));
        //}

        //@Override
        //public void destroy() {
        //    super.destroy();
        //    mCompositeDisposable.clear();
        //}
    };
    mServiceManager.register(ExposureSupport.class, exposureSupport);
    mBaseCell1.exposure(mView1);
    mBaseCell1.exposure(mView1);
    exposureSupport.destroy();

}
 
Example #21
Source File: LifeCycleHelperTest.java    From Tangram-Android with MIT License 3 votes vote down vote up
@Test
@SmallTest
@UiThreadTest
public void testBindUntil() {
    LifeCycleProviderImpl<ActivityLFEvent> activityEventLifeCycleProvider = new LifeCycleProviderImpl<>(
        ActivityLFEvent.ACTIVITY_LIFECYCLE);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.CREATE);

    mObservable.compose(activityEventLifeCycleProvider.<Long>bindUntil(ActivityLFEvent.STOP)).subscribe(mObserver);

    mObserver.assertSubscribed();
    mObserver.assertEmpty();

    mTestScheduler.advanceTimeTo(70, TimeUnit.SECONDS);
    mObserver.assertValues(0L);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.START);

    mTestScheduler.advanceTimeTo(6, TimeUnit.MINUTES);
    mObserver.assertValues(0L, 1L, 2L, 3L, 4L, 5L);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.RESUME);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.PAUSE);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.STOP);

    mObserver.assertComplete();

    mTestScheduler.advanceTimeTo(10, TimeUnit.MINUTES);

    mObserver.assertValueCount(6);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.DESTROY);
}
 
Example #22
Source File: LifeCycleHelperTest.java    From Tangram-Android with MIT License 3 votes vote down vote up
@Test
@UiThreadTest
@SmallTest
public void testBindToLifecycle() {
    LifeCycleProviderImpl<ActivityLFEvent> activityEventLifeCycleProvider = new LifeCycleProviderImpl<>(
        ActivityLFEvent.ACTIVITY_LIFECYCLE);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.CREATE);

    mObservable.compose(activityEventLifeCycleProvider.<Long>bindToLifecycle()).subscribe(mObserver);

    mTestScheduler.advanceTimeTo(70, TimeUnit.SECONDS);

    mObserver.assertValues(0L);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.START);

    mTestScheduler.advanceTimeTo(6, TimeUnit.MINUTES);

    mObserver.assertValues(0L, 1L, 2L, 3L, 4L, 5L);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.RESUME);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.PAUSE);

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.STOP);

    mObserver.assertNotComplete();

    activityEventLifeCycleProvider.emitNext(ActivityLFEvent.DESTROY);

    mObserver.assertComplete();
}
 
Example #23
Source File: LifeCycleHelperTest.java    From Tangram-Android with MIT License 2 votes vote down vote up
@Test
@UiThreadTest
@SmallTest
public void testCustomLifecycleEvent() {
    LifeCycleProviderImpl<CellBindLFEvent> customLifecycleProvider = new LifeCycleProviderImpl<>(
        CellBindLFEvent.CELLBIND_LIFECYCLE);

    mObservable.compose(customLifecycleProvider.<Long>bindUntil(CellBindLFEvent.UNBIND)).subscribe(mObserver);

    mObserver.assertEmpty();

    mTestScheduler.advanceTimeTo(70, TimeUnit.SECONDS);

    mObserver.assertValue(0L);

    customLifecycleProvider.emitNext(CellBindLFEvent.PRE_BIND);

    mTestScheduler.advanceTimeTo(2, TimeUnit.MINUTES);

    mObserver.assertValues(0L, 1L);

    customLifecycleProvider.emitNext(CellBindLFEvent.BIND);

    customLifecycleProvider.emitNext(CellBindLFEvent.POST_BIND);

    mTestScheduler.advanceTimeTo(3, TimeUnit.MINUTES);

    mObserver.assertValues(0L, 1L, 2L);

    customLifecycleProvider.emitNext(CellBindLFEvent.PRE_UNBIND);

    customLifecycleProvider.emitNext(CellBindLFEvent.UNBIND);

    mTestScheduler.advanceTimeTo(4, TimeUnit.MINUTES);

    mObserver.assertValues(0L, 1L, 2L);

    mObserver.assertComplete();

    customLifecycleProvider.emitNext(CellBindLFEvent.POST_UNBIND);
}