use of org.odk.collect.android.preferences.PreferencesActivity in project collect by opendatakit.
the class MainActivityTest method optionsMenuTest.
/**
* {@link Test} to assert Options Menu's functioning.
*/
@Test
public void optionsMenuTest() throws Exception {
Menu menu = shadowOf(mainMenuActivity).getOptionsMenu();
assertNotNull(menu);
assertNotNull(mainMenuActivity.onCreateOptionsMenu(menu));
// Test for AboutActivity
mainMenuActivity.onOptionsItemSelected(menu.getItem(0));
ShadowActivity shadowActivity = shadowOf(mainMenuActivity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = shadowOf(startedIntent);
assertEquals(AboutActivity.class.getName(), shadowIntent.getIntentClass().getName());
// Test for About Menu Title
String menuTitle = mainMenuActivity.getResources().getString(R.string.about_preferences);
String shadowTitle = menu.getItem(0).getTitle().toString();
assertEquals(shadowTitle, menuTitle);
// Test for PreferencesActivity
mainMenuActivity.onOptionsItemSelected(menu.getItem(1));
shadowActivity = shadowOf(mainMenuActivity);
startedIntent = shadowActivity.getNextStartedActivity();
shadowIntent = shadowOf(startedIntent);
assertEquals(PreferencesActivity.class.getName(), shadowIntent.getIntentClass().getName());
// Test for General Settings Menu Title
menuTitle = mainMenuActivity.getResources().getString(R.string.general_preferences);
shadowTitle = menu.getItem(1).getTitle().toString();
assertEquals(shadowTitle, menuTitle);
// Test for Admin Settings Menu Title
menuTitle = mainMenuActivity.getResources().getString(R.string.admin_preferences);
shadowTitle = menu.getItem(2).getTitle().toString();
assertEquals(shadowTitle, menuTitle);
}
Aggregations