mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-30 12:13:00 -04:00
Fix unit tests
This commit is contained in:
@@ -37,14 +37,6 @@ public class MainActivityTest
|
||||
{
|
||||
private SharedPreferences prefs;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
// Assume that this is not the first launch
|
||||
prefs = RuntimeEnvironment.application.getSharedPreferences("protect.card_locker", Context.MODE_PRIVATE);
|
||||
prefs.edit().putBoolean("firstrun", false).commit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initiallyNoLoyaltyCards() throws Exception
|
||||
{
|
||||
@@ -70,12 +62,9 @@ public class MainActivityTest
|
||||
assertTrue(menu != null);
|
||||
|
||||
// The settings, search and add button should be present
|
||||
assertEquals(menu.size(), 6);
|
||||
|
||||
assertEquals(menu.size(), 4);
|
||||
assertEquals("Search", menu.findItem(R.id.action_search).getTitle().toString());
|
||||
assertEquals("Add", menu.findItem(R.id.action_add).getTitle().toString());
|
||||
assertEquals("Import/Export", menu.findItem(R.id.action_import_export).getTitle().toString());
|
||||
assertEquals("Start Intro", menu.findItem(R.id.action_intro).getTitle().toString());
|
||||
assertEquals("About", menu.findItem(R.id.action_about).getTitle().toString());
|
||||
assertEquals("Settings", menu.findItem(R.id.action_settings).getTitle().toString());
|
||||
}
|
||||
@@ -85,7 +74,7 @@ public class MainActivityTest
|
||||
{
|
||||
final MainActivity activity = Robolectric.setupActivity(MainActivity.class);
|
||||
|
||||
shadowOf(activity).clickMenuItem(R.id.action_add);
|
||||
activity.findViewById(R.id.fabAdd).performClick();
|
||||
|
||||
Intent intent = shadowOf(activity).peekNextStartedActivityForResult().intent;
|
||||
|
||||
@@ -219,26 +208,4 @@ public class MainActivityTest
|
||||
|
||||
assertEquals(2, list.getCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstRunStartsIntro()
|
||||
{
|
||||
prefs.edit().remove("firstrun").commit();
|
||||
|
||||
ActivityController controller = Robolectric.buildActivity(MainActivity.class).create();
|
||||
Activity activity = (Activity)controller.get();
|
||||
|
||||
assertTrue(activity.isFinishing() == false);
|
||||
|
||||
Intent next = shadowOf(activity).getNextStartedActivity();
|
||||
|
||||
ComponentName componentName = next.getComponent();
|
||||
String name = componentName.flattenToShortString();
|
||||
assertEquals("protect.card_locker/.intro.IntroActivity", name);
|
||||
|
||||
Bundle extras = next.getExtras();
|
||||
assertNull(extras);
|
||||
|
||||
assertEquals(false, prefs.getBoolean("firstrun", true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user