@Override public void runOnMainSync(Runnable runner) { base.runOnMainSync(runner); }
/** * Clicks an ActionBar Home/Up button. */ public void clickOnActionBarHomeButton() { if(config.commandLogging){ Log.d(config.commandLoggingTag, "clickOnActionBarHomeButton()"); } instrumentation.runOnMainSync(new Runnable() { @Override public void run() { clicker.clickOnActionBarHomeButton(); } }); }
/** * Unlocks the lock screen. */ public void unlockScreen(){ if(config.commandLogging){ Log.d(config.commandLoggingTag, "unlockScreen()"); } final Activity activity = activityUtils.getCurrentActivity(false); instrumentation.runOnMainSync(new Runnable() { @Override public void run() { if(activity != null){ activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); } } }); }
public void doScreenshot() { View v = getScreenshotView(); if(v == null) keepRunning = false; String final_name = name+"_"+seqno; ScreenshotRunnable r = new ScreenshotRunnable(v, final_name, quality); Log.d(LOG_TAG, "taking screenshot "+final_name); Activity activity = activityUtils.getCurrentActivity(false); if(activity != null){ activity.runOnUiThread(r); } else { instrumentation.runOnMainSync(r); } }
/** Set the Component for the Activity to display. */ public void setComponent(final Component component) { final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); instrumentation.runOnMainSync( new Runnable() { @Override public void run() { getActivity().setComponent(component); } }); instrumentation.waitForIdleSync(); }
/** Set ComponentTree for the Activity to display. */ public void setComponentTree(final ComponentTree componentTree) { final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); instrumentation.runOnMainSync( new Runnable() { @Override public void run() { getActivity().setComponentTree(componentTree); } }); instrumentation.waitForIdleSync(); }
public static void addToBackstack(final TestActivity activity) { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { activity.getSupportFragmentManager() .beginTransaction() .addToBackStack(null) .replace(R.id.fragments, new ViewLeakingFragment()) .commit(); } }); }
public static void add(final TestActivity activity) { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { leakingFragment = new LeakingFragment(); activity.getSupportFragmentManager() .beginTransaction() .add(0, leakingFragment) .commitNow(); } }); }
/** Skip the given amount of frames */ public void stepAnimationFrames(final int numFrames) { InstrumentationRegistry.getInstrumentation() .runOnMainSync( new Runnable() { @Override public void run() { mFakeTimingSource.step(numFrames); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); } }
public final void runOnMainSync(Runnable action) { InstrumentationRegistry.getInstrumentation().runOnMainSync(action); }
@Before public void init() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { LayoutInflater inflater=LayoutInflater .from(InstrumentationRegistry.getTargetContext()); root=inflater.inflate(R.layout.add, null); } }); root.measure(800, 480); root.layout(0, 0, 800, 480); field=root.findViewById(R.id.title); }
@Before public void init() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { LayoutInflater inflater=LayoutInflater .from(InstrumentationRegistry.getTargetContext()); root=inflater.inflate(R.layout.add, null); } }); root.measure(800, 480); root.layout(0, 0, 800, 480); field=root.findViewById(R.id.title); }
@Before public void init() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { LayoutInflater inflater=LayoutInflater .from(InstrumentationRegistry.getTargetContext()); root=inflater.inflate(R.layout.add, null); } }); root.measure(800, 480); root.layout(0, 0, 800, 480); field=root.findViewById(R.id.title); }
@Before public void init() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { LayoutInflater inflater=LayoutInflater .from(InstrumentationRegistry.getTargetContext()); root=inflater.inflate(R.layout.add, null); } }); root.measure(800, 480); root.layout(0, 0, 800, 480); field=root.findViewById(R.id.title); }
@Before public void init() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { LayoutInflater inflater=LayoutInflater .from(InstrumentationRegistry.getTargetContext()); root=inflater.inflate(R.layout.add, null); } }); root.measure(800, 480); root.layout(0, 0, 800, 480); field=root.findViewById(R.id.title); }
@Before public void init() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { LayoutInflater inflater=LayoutInflater .from(InstrumentationRegistry.getTargetContext()); root=inflater.inflate(R.layout.add, null); } }); root.measure(800, 480); root.layout(0, 0, 800, 480); field=root.findViewById(R.id.title); }
@Test @UiThreadTest public void whenTabWithBadgeClicked_BadgeIsHidden() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby); assertFalse(nearby.badge.isVisible()); } }); }
@Test @UiThreadTest public void setOverrideTabSelectionListener_allowingSelection() { bottomBar.setTabSelectionInterceptor(tabSelectionInterceptor); when(tabSelectionInterceptor.shouldInterceptTabSelection(anyInt(), anyInt())).thenReturn(false); BottomBarTab oldTab = bottomBar.getCurrentTab(); final BottomBarTab newTab = bottomBar.getTabAtPosition(2); getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { newTab.performClick(); } }); verify(tabSelectionInterceptor, times(1)).shouldInterceptTabSelection(oldTab.getId(), newTab.getId()); assertSame(bottomBar.getCurrentTab(), newTab); }
@Test @UiThreadTest public void setOverrideTabSelectionListener_whenNoListenerSet() { bottomBar.removeOverrideTabSelectionListener(); BottomBarTab oldTab = bottomBar.getCurrentTab(); final BottomBarTab newTab = bottomBar.getTabAtPosition(2); getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { newTab.performClick(); } }); verify(tabSelectionInterceptor, times(0)).shouldInterceptTabSelection(oldTab.getId(), newTab.getId()); assertSame(bottomBar.getCurrentTab(), newTab); }
@Test public void recreate() { stubPick(); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { main.getActivity().recreate(); } }); onView(withId(R.id.view)).check(matches(isEnabled())); }