@Implementation public void onForceLoad() { Robolectric.getBackgroundThreadScheduler() .post( new Runnable() { @Override public void run() { future.run(); } }); }
@Test public void handleOpen_withHttpApplicationUrl_shouldStartMoPubBrowser() { String applicationUrl = "https://www.mopub.com/"; subject.handleOpen(applicationUrl); Robolectric.getBackgroundThreadScheduler().advanceBy(0); Intent startedIntent = ShadowApplication.getInstance().getNextStartedActivity(); assertThat(startedIntent).isNotNull(); // Since we are not using an Activity context, we should have FLAG_ACTIVITY_NEW_TASK assertThat(Utils.bitMaskContainsFlag(startedIntent.getFlags(), Intent.FLAG_ACTIVITY_NEW_TASK)) .isTrue(); assertThat(startedIntent.getComponent().getClassName()) .isEqualTo("com.mopub.common.MoPubBrowser"); verify(mockMraidListener).onOpen(); }
@Before public void setup() throws Exception { ShadowLog.stream = System.out; mServer = new MockWebServer(); mServer.setDispatcher(NCMBDispatcher.dispatcher); mServer.start(); mScriptUrl = mServer.getUrl("/").toString() + "2015-09-01/script"; NCMB.initialize( RuntimeEnvironment.application.getApplicationContext(), "appKey", "cliKey", null, null); Robolectric.getBackgroundThreadScheduler().pause(); Robolectric.getForegroundThreadScheduler().pause(); mCallbackFlag = false; }
@Before public void setup() throws Exception { // create mocServer mServer = new MockWebServer(); mServer.setDispatcher(NCMBDispatcher.dispatcher); mServer.start(); // initialize NCMB.initialize( RuntimeEnvironment.application.getApplicationContext(), "appKey", "cliKey", mServer.getUrl("/").toString(), null); // log stream ShadowLog.stream = System.out; Robolectric.getBackgroundThreadScheduler().pause(); Robolectric.getForegroundThreadScheduler().pause(); callbackFlag = false; }