gecko-dev/mobile/android/base/tests/testDoorHanger.java.in
Brian Nicholson fe44f36220 Bug 850487 - More code cleanup (@Overrides and unused imports). r=kats
--HG--
extra : rebase_source : 376574e0c41b91c16a6be335584a4a61768bb4a9
2013-03-13 13:20:57 -07:00

108 lines
4.2 KiB
Java

#filter substitution
package @ANDROID_PACKAGE_NAME@.tests;
/* This test will test if doorhangers are displayed and dismissed
The test will test:
* geolocation doorhangers - sharing and not sharing the location dismisses the doorhanger
* opening a new tab hides the doorhanger
* offline storage permission doorhangers - allowing and not allowing offline storage dismisses the doorhanger
* Password Manager doorhangers - Remember and Not Now options dismiss the doorhanger
*/
public class testDoorHanger extends BaseTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testDoorHanger() {
String GEO_URL = getAbsoluteUrl("/robocop/robocop_geolocation.html");
String BLANK_URL = getAbsoluteUrl("/robocop/robocop_blank_01.html");
String OFFLINE_STORAGE_URL = getAbsoluteUrl("/robocop/robocop_offline_storage.html");
String LOGIN_URL = getAbsoluteUrl("/robocop/robocop_login.html");
// Strings used in doorhanger messages and buttons
String GEO_MESSAGE = "Share your location with";
String GEO_ALLOW = "Share";
String GEO_DENY = "Don't share";
String OFFLINE_MESSAGE = "to store data on your device for offline use";
String OFFLINE_ALLOW = "Allow";
String OFFLINE_DENY = "Don't allow";
String LOGIN_MESSAGE = "Save password";
String LOGIN_ALLOW = "Save";
String LOGIN_DENY = "Don't save";
blockForGeckoReady();
// Test geolocation notification
loadUrl(GEO_URL);
waitForText(GEO_MESSAGE);
mAsserter.is(mSolo.searchText(GEO_MESSAGE), true, "Geolocation doorhanger has been displayed");
// Test "Share" button hides the notification
mSolo.clickOnCheckBox(0);
mSolo.clickOnButton(GEO_ALLOW);
mAsserter.is(mSolo.searchText(GEO_MESSAGE), false, "Geolocation doorhanger has been hidden");
// Re-trigger geolocation notification
loadUrl(GEO_URL);
waitForText(GEO_MESSAGE);
// Test "Don't share" button hides the notification
mSolo.clickOnCheckBox(0);
mSolo.clickOnButton(GEO_DENY);
mAsserter.is(mSolo.searchText(GEO_MESSAGE), false, "Geolocation doorhanger has been hidden");
// Re-trigger geolocation notification
loadUrl(GEO_URL);
waitForText(GEO_MESSAGE);
// Add a new tab
addTab(BLANK_URL);
// Make sure doorhanger is hidden
mAsserter.is(mSolo.searchText(GEO_MESSAGE), false, "Doorhanger notification is hidden");
// Load offline storage page
loadUrl(OFFLINE_STORAGE_URL);
waitForText(OFFLINE_MESSAGE);
// Test doorhanger dismissed when tapping "Don't share"
mSolo.clickOnCheckBox(0);
mSolo.clickOnButton(OFFLINE_DENY);
mAsserter.is(mSolo.searchText(OFFLINE_MESSAGE), false, "Doorhanger notification is hidden");
// Load offline storage page
loadUrl(OFFLINE_STORAGE_URL);
waitForText(OFFLINE_MESSAGE);
// Test doorhanger dismissed when tapping "Allow" and is not displayed again
mSolo.clickOnButton(OFFLINE_ALLOW);
mAsserter.is(mSolo.searchText(OFFLINE_MESSAGE), false, "Doorhanger notification is hidden");
loadUrl(OFFLINE_STORAGE_URL);
mAsserter.is(mSolo.searchText(OFFLINE_MESSAGE), false, "Doorhanger is no longer triggered");
// Load login page
loadUrl(LOGIN_URL);
waitForText(LOGIN_MESSAGE);
// Test doorhanger is dismissed when tapping "Don't save"
mSolo.clickOnButton(LOGIN_DENY);
mAsserter.is(mSolo.searchText(LOGIN_MESSAGE), false, "Doorhanger notification is hidden");
// Load login page
loadUrl(LOGIN_URL);
waitForText(LOGIN_MESSAGE);
// Test doorhanger is dismissed when tapping "Save" and is no longer triggered
mSolo.clickOnButton(LOGIN_ALLOW);
mAsserter.is(mSolo.searchText(LOGIN_MESSAGE), false, "Doorhanger notification is hidden");
// Reload the page and check that there is no doorhanger displayed
loadUrl(LOGIN_URL);
mAsserter.is(mSolo.searchText(LOGIN_MESSAGE), false, "Doorhanger notification is hidden");
}
}