michael@0: package org.mozilla.gecko.tests; michael@0: michael@0: import org.mozilla.gecko.Actions; michael@0: michael@0: /** This patch tests the System Pages first by loading system pages from michael@0: * the awesome bar and then from Firefox menu michael@0: */ michael@0: public class testSystemPages extends PixelTest { michael@0: final int mExpectedTabCount = 1; michael@0: private static final int AFTER_BACK_SLEEP_MS = 500; michael@0: michael@0: public void testSystemPages() { michael@0: blockForGeckoReady(); michael@0: michael@0: String urls [] = { "about:firefox", "about:rights", "about:addons", "about:downloads", "about:buildconfig", "about:feedback", "about:healthreport", "about:" }; michael@0: // Pages to be tested from the menu and their expected urls. This if of the form { {{ }, { }}* } michael@0: String menuItems [][][] = {{{ "Apps" }, { "about:apps" }}, michael@0: {{ "Downloads" }, { "about:downloads" }}, michael@0: {{ "Add-ons" }, { "about:addons" }}, michael@0: {{ "Settings", "Mozilla", "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)" }, { "about:" }}, michael@0: {{ "Settings", "Mozilla", "Give feedback" }, { "about:feedback" }}, michael@0: {{ "Settings", "Mozilla", "View my Health Report" }, { "about:healthreport" }}}; michael@0: michael@0: /* Load system pages from url and check that the pages are loaded in the same tab */ michael@0: checkUrl(urls); michael@0: michael@0: /* Verify that the search field is not in the focus by pressing back. That will load the previous michael@0: about: page if there is no the keyboard to dismiss, meaning that the search field was not in focus */ michael@0: loadAndPaint("about:about"); michael@0: michael@0: // Press back to verify if the keyboard is dismissed or the previous about: page loads michael@0: mActions.sendSpecialKey(Actions.SpecialKey.BACK); michael@0: // may not get a paint on Back...pause briefly to make sure it completes michael@0: mSolo.sleep(AFTER_BACK_SLEEP_MS); michael@0: michael@0: // We will use the "about:" page as our reference page. michael@0: loadAndPaint("about:"); michael@0: verifyUrl("about:"); // Verify that the previous about: page is loaded, meaning no keyboard was present michael@0: michael@0: // Load system pages by navigating through the UI. michael@0: loadItemsByLevel(menuItems); michael@0: } michael@0: michael@0: // Load from Url the about: pages,verify the Url and the tabs number michael@0: public void checkUrl(String urls []) { michael@0: for (String url:urls) { michael@0: loadAndPaint(url); michael@0: verifyTabCount(mExpectedTabCount); michael@0: verifyUrl(url); michael@0: } michael@0: } michael@0: michael@0: public void loadItemsByLevel(String[][][] menuItems) { michael@0: Actions.EventExpecter tabEventExpecter; michael@0: Actions.EventExpecter contentEventExpecter; michael@0: Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); michael@0: int expectedTabCount = mExpectedTabCount; michael@0: // There's some special casing for about: because it's our starting page. michael@0: for (String[][] item : menuItems) { michael@0: String [] pathToItem = item[0]; michael@0: String expectedUrl = item[1][0]; michael@0: michael@0: expectedTabCount++; michael@0: michael@0: // Set up listeners to catch the page load we're about to do michael@0: tabEventExpecter = mActions.expectGeckoEvent("Tab:Added"); michael@0: contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded"); michael@0: selectMenuItemByPath(pathToItem); michael@0: michael@0: // Wait for the new tab and page to load michael@0: if ("about:".equals(expectedUrl)) { michael@0: waitForPaint(paintExpecter); // Waiting for the page to load michael@0: paintExpecter.unregisterListener(); michael@0: } else { michael@0: tabEventExpecter.blockForEvent(); michael@0: contentEventExpecter.blockForEvent(); michael@0: } michael@0: tabEventExpecter.unregisterListener(); michael@0: contentEventExpecter.unregisterListener(); michael@0: michael@0: verifyUrl(expectedUrl); michael@0: if ("about:".equals(expectedUrl)) { michael@0: // Decreasing because we do not expect this to be in a different tab. michael@0: expectedTabCount--; michael@0: } michael@0: verifyTabCount(expectedTabCount); michael@0: } michael@0: } michael@0: }