Search in sources :

Example 21 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project xDrip-plus by jamorham.

the class HomeEspressoTest method setUp.

@UiThreadTest
@Before
public synchronized void setUp() throws Exception {
    if (!onetime) {
        onetime = true;
        clearAllPrefs();
    }
    final Activity activity = mActivityRule.getActivity();
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
}
Also used : Activity(android.app.Activity) Before(org.junit.Before) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 22 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project teamward-client by Neamar.

the class FlowTest method setUp.

@UiThreadTest
@Before
public void setUp() throws Throwable {
    // Clean up all accounts
    InstrumentationRegistry.getTargetContext().getSharedPreferences("accounts", Context.MODE_PRIVATE).edit().clear().commit();
    mActivityTestRule.launchActivity(null);
    final Activity activity = mActivityTestRule.getActivity();
    mActivityTestRule.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            KeyguardManager mKG = (KeyguardManager) activity.getSystemService(KEYGUARD_SERVICE);
            KeyguardManager.KeyguardLock mLock = mKG.newKeyguardLock(KEYGUARD_SERVICE);
            mLock.disableKeyguard();
            // turn the screen on
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
        }
    });
}
Also used : Activity(android.app.Activity) KeyguardManager(android.app.KeyguardManager) Before(org.junit.Before) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 23 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project BottomBar by roughike.

the class BottomBarTest method afterConfigurationChanged_SavedStateRestored_AndSelectedTabPersists.

@Test
@UiThreadTest
public void afterConfigurationChanged_SavedStateRestored_AndSelectedTabPersists() {
    bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_favorites);
    Bundle savedState = bottomBar.saveState();
    bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby);
    bottomBar.restoreState(savedState);
    assertEquals(com.roughike.bottombar.test.R.id.tab_favorites, bottomBar.getCurrentTabId());
}
Also used : Bundle(android.os.Bundle) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 24 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project BottomBar by roughike.

the class BottomBarTest method whenTabIsSelected_SelectionListenerIsFired.

@Test
@UiThreadTest
public void whenTabIsSelected_SelectionListenerIsFired() {
    bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_friends);
    bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby);
    bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_favorites);
    InOrder inOrder = inOrder(selectListener);
    inOrder.verify(selectListener, times(1)).onTabSelected(com.roughike.bottombar.test.R.id.tab_friends);
    inOrder.verify(selectListener, times(1)).onTabSelected(com.roughike.bottombar.test.R.id.tab_nearby);
    inOrder.verify(selectListener, times(1)).onTabSelected(com.roughike.bottombar.test.R.id.tab_favorites);
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) UiThreadTest(android.support.test.annotation.UiThreadTest)

Example 25 with UiThreadTest

use of android.support.test.annotation.UiThreadTest in project BottomBar by roughike.

the class BottomBarTest method setTitleTypeface_UpdatesTypeface.

@Test
@UiThreadTest
public void setTitleTypeface_UpdatesTypeface() {
    BottomBarTab tab = bottomBar.getCurrentTab();
    Typeface testTypeface = Typeface.createFromAsset(bottomBar.getContext().getAssets(), "fonts/GreatVibes-Regular.otf");
    assertNotEquals(testTypeface, tab.getTitleTypeFace());
    assertNotEquals(testTypeface, tab.getTitleView().getTypeface());
    bottomBar.setTabTitleTypeface(testTypeface);
    assertEquals(testTypeface, tab.getTitleTypeFace());
    assertEquals(testTypeface, tab.getTitleView().getTypeface());
}
Also used : Typeface(android.graphics.Typeface) UiThreadTest(android.support.test.annotation.UiThreadTest) Test(org.junit.Test) LargeTest(android.support.test.filters.LargeTest) UiThreadTest(android.support.test.annotation.UiThreadTest)

Aggregations

UiThreadTest (android.support.test.annotation.UiThreadTest)51 Test (org.junit.Test)48 RecordingObserver (com.jakewharton.rxbinding2.RecordingObserver)15 Action1 (rx.functions.Action1)14 Activity (android.app.Activity)9 SmallTest (android.support.test.filters.SmallTest)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 Action0 (rx.functions.Action0)7 LargeTest (android.support.test.filters.LargeTest)6 LayoutInflater (android.view.LayoutInflater)6 Menu (android.view.Menu)6 AllTypes (io.realm.entities.AllTypes)6 TextInputLayoutActivity (android.support.design.testapp.TextInputLayoutActivity)5 MediumTest (android.support.test.filters.MediumTest)5 MenuItem (android.view.MenuItem)5 TabLayoutActions.selectTab (android.support.design.testutils.TabLayoutActions.selectTab)4 Bundle (android.os.Bundle)3 KeyEvent (android.view.KeyEvent)3 Before (org.junit.Before)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2