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

100 lines
4.0 KiB
Java

#filter substitution
package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
import java.util.Arrays;
/** This patch tests the System Pages first by loading system pages from
* the awesome bar and then from Firefox menu
*/
public class testSystemPages extends PixelTest {
Actions.EventExpecter tabEventExpecter;
Actions.EventExpecter contentEventExpecter;
Actions.RepeatedEventExpecter paintExpecter;
final int mExpectedTabCount = 1;
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
public void testSystemPages() {
blockForGeckoReady();
String urls [] = { "about:firefox", "about:rights", "about:home", "about:addons", "about:downloads", "about:buildconfig", "about:"};
String expectedUrls [] = { "about:apps", "about:downloads", "about:addons", "about:"};
String menuItems [] = { "Apps", "Downloads", "Add-ons", "Settings"};
/* This first section loads system pages from the awesome bar
and checks that the pages are loaded in the same tab */
checkUrl(urls);
/* Verify that the search field is not in the focus by pressing back. That will load the previous
about: page if there is no the keyboard to dismiss, meaning that the search field was not in focus */
loadUrl("about:config");
paintExpecter = mActions.expectPaint();// Set up listener to catch the page load
// Press back to verify if the keyboard is dismissed or the previous about: page loads
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
PaintedSurface painted = waitForPaint(paintExpecter);
verifyUrl("about:"); // Verify that the previous about: page is loaded, meaning no keyboard was present
// The second section loads system pages from Firefox menu in different tabs
loadFromMenu(menuItems, expectedUrls);
}
// Load from Url the about: pages,verify the Url and the tabs number
public void checkUrl(String urls []) {
for (String url:urls) {
loadAndPaint(url);
verifyTabCount(mExpectedTabCount);
verifyUrl(url);
}
}
public void loadFromMenu(String menuItems [], String expectedUrls []) {
int expectedTabCount = mExpectedTabCount;
for (String item:menuItems) {
paintExpecter = mActions.expectPaint(); // Set up listener to catch the page load
expectedTabCount++;
mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Press back to dismiss the awesomebar
int i = Arrays.asList(menuItems).indexOf(item);
if (!item.equals("Settings")) {
// Set up listeners to catch the page load we're about to do
tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
waitForPaint(paintExpecter);// waiting for the page to load
selectMenuItem(item);
// Wait for the new tab and page to load
tabEventExpecter.blockForEvent();
contentEventExpecter.blockForEvent();
verifyTabCount(expectedTabCount);
verifyUrl(expectedUrls[i]);
} else {
// Make sure the about: page was loaded without opening a new tab and verify the page Url
waitForPaint(paintExpecter); // waiting for the page to load
selectMenuItem(item);
waitForText("About");
paintExpecter = mActions.expectPaint(); // Set up listener to catch the page load
mSolo.clickOnText("About");
waitForPaint(paintExpecter); // Waiting for the page to load
expectedTabCount--; // Decreasing since we don't expect this in a new tab
verifyTabCount(expectedTabCount);
verifyUrl(expectedUrls[i]); // Since the page is already loaded this should be instantly
}
}
}
}