fix release intents in a separate method

This commit is contained in:
siddharth2010 2018-08-04 11:32:46 +05:30 committed by Isaac Hutt
parent 18daf6b817
commit 7c38b7cec6

View File

@ -61,12 +61,12 @@ public class SplashActivityTest {
@Before @Before
public void setUp(){ public void setUp(){
Intents.init();
context = getInstrumentation().getTargetContext(); context = getInstrumentation().getTargetContext();
} }
@Test @Test
public void testFirstRun() { public void testFirstRun() {
Intents.init();
activityTestRule.launchActivity(); activityTestRule.launchActivity();
BaristaSleepInteractions.sleep(TEST_PAUSE_MS); BaristaSleepInteractions.sleep(TEST_PAUSE_MS);
@ -76,12 +76,10 @@ public class SplashActivityTest {
// Verify that the value of the "intro shown" boolean inside the SharedPreferences Database is not changed until the "Get started" button is pressed // Verify that the value of the "intro shown" boolean inside the SharedPreferences Database is not changed until the "Get started" button is pressed
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
assertEquals(true, preferences.getBoolean(PREF_SHOW_INTRO, true)); assertEquals(true, preferences.getBoolean(PREF_SHOW_INTRO, true));
Intents.release();
} }
@Test @Test
public void testNormalRun() { public void testNormalRun() {
Intents.init();
SharedPreferences.Editor preferencesEditor = PreferenceManager.getDefaultSharedPreferences(context).edit(); SharedPreferences.Editor preferencesEditor = PreferenceManager.getDefaultSharedPreferences(context).edit();
preferencesEditor.putBoolean(PREF_SHOW_INTRO, false).apply(); preferencesEditor.putBoolean(PREF_SHOW_INTRO, false).apply();
@ -90,6 +88,10 @@ public class SplashActivityTest {
// Verify that the SplashActivity is followed by MainActivity // Verify that the SplashActivity is followed by MainActivity
intended(hasComponent(MainActivity.class.getName())); intended(hasComponent(MainActivity.class.getName()));
}
@After
public void endTest() {
Intents.release(); Intents.release();
} }
} }