@Test public void restoreInstanceState_callsPerformRestoreInstanceStateWhilePaused() { controller.create().restoreInstanceState(new Bundle()); assertThat(transcript).containsAllOf("finishedOnRestoreInstanceState", "onRestoreInstanceState"); }
@Test public void newIntent_callsOnNewIntentWhilePaused() { controller.create().newIntent(new Intent(Intent.ACTION_VIEW)); assertThat(transcript).containsAllOf("finishedOnNewIntent", "onNewIntent"); }
@Test public void testGetByIndex() { DrmInitData testInitData = new DrmInitData(DATA_1, DATA_2); assertThat(getAllSchemeData(testInitData)).containsAllOf(DATA_1, DATA_2); }
@Test public void bind_callsOnBindWhilePaused() { controller.create().bind(); assertThat(transcript).containsAllOf("finishedOnBind", "onBind"); }
@Test public void startCommand_callsOnHandleIntentWhilePaused() { controller.create().startCommand(1, 2); assertThat(transcript).containsAllOf("finishedOnHandleIntent", "onHandleIntent"); }
@Test public void start_callsPerformStartWhilePaused() { controller.create().start(); assertThat(transcript).containsAllOf("finishedOnStart", "onStart"); }
@Test public void destroy_callsPerformDestroyWhilePaused() { controller.create().destroy(); assertThat(transcript).containsAllOf("finishedOnDestroy", "onDestroy"); }
@Test public void userLeaving_callsPerformUserLeavingWhilePaused() { controller.create().userLeaving(); assertThat(transcript).containsAllOf("finishedOnUserLeaveHint", "onUserLeaveHint"); }
@Test public void destroy_callsOnDestroyWhilePaused() { controller.create().destroy(); assertThat(transcript).containsAllOf("finishedOnDestroy", "onDestroy"); }
@Test public void postResume_callsOnPostResumeWhilePaused() { controller.create().postResume(); assertThat(transcript).containsAllOf("finishedOnPostResume", "onPostResume"); }
@Test public void bind_callsOnBindWhilePaused() { controller.create().bind(); assertThat(transcript).containsAllOf("finishedOnBind", "onBind"); }
@Test public void startCommand_callsOnStartCommandWhilePaused() { controller.create().startCommand(1, 2); assertThat(transcript).containsAllOf("finishedOnStartCommand", "onStartCommand"); }
@Test public void configurationChange_callsLifecycleMethodsAndAppliesConfig() { Configuration config = new Configuration( ApplicationProvider.getApplicationContext().getResources().getConfiguration()); final float newFontScale = config.fontScale *= 2; controller.setup(); transcript.clear(); controller.configurationChange(config); assertThat(transcript).containsAllOf("onPause", "onStop", "onDestroy", "onCreate", "onStart", "onRestoreInstanceState", "onPostCreate", "onResume", "onPostResume"); assertThat(controller.get().getResources().getConfiguration().fontScale).isEqualTo(newFontScale); }
@Test public void resume_callsPerformResumeWhilePaused() { controller.create().start().resume(); assertThat(transcript).containsAllOf("finishedOnResume", "onResume"); }
@Test public void unbind_callsUnbindWhilePaused() { controller.create().bind().unbind(); assertThat(transcript).containsAllOf("finishedOnUnbind", "onUnbind"); }
@Test public void unbind_callsUnbindWhilePaused() { controller.create().bind().unbind(); assertThat(transcript).containsAllOf("finishedOnUnbind", "onUnbind"); }
@Test public void whenLooperIsNotPaused_shouldCreateWithMainLooperPaused() throws Exception { ShadowLooper.unPauseMainLooper(); controller.create(); assertThat(shadowOf(Looper.getMainLooper()).isPaused()).isFalse(); assertThat(transcript).containsAllOf("finishedOnCreate", "onCreate"); }
@Test public void restart_callsPerformRestartWhilePaused() { controller.create().start().stop().restart(); assertThat(transcript).containsAllOf("finishedOnRestart", "onRestart"); }
@Test public void rebind_callsRebindWhilePaused() { controller.create().bind().unbind().bind().rebind(); assertThat(transcript).containsAllOf("finishedOnRebind", "onRebind"); }
@Test public void withOverlay_withShadows_maintainsOrder() throws Exception { Config.Implementation base = new Config.Builder().build(); Config withString = overlay(base, new Builder().setShadows(new Class[]{String.class}).build()); assertThat(withString.shadows()).asList().contains(String.class); Config withMore = overlay(withString, new Builder().setShadows(new Class[]{Map.class, String.class}).build()); assertThat(withMore.shadows()).asList().containsAllOf(String.class, Map.class, String.class); }