1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/base/tests/testSystemPages.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +package org.mozilla.gecko.tests; 1.5 + 1.6 +import org.mozilla.gecko.Actions; 1.7 + 1.8 +/** This patch tests the System Pages first by loading system pages from 1.9 + * the awesome bar and then from Firefox menu 1.10 + */ 1.11 +public class testSystemPages extends PixelTest { 1.12 + final int mExpectedTabCount = 1; 1.13 + private static final int AFTER_BACK_SLEEP_MS = 500; 1.14 + 1.15 + public void testSystemPages() { 1.16 + blockForGeckoReady(); 1.17 + 1.18 + String urls [] = { "about:firefox", "about:rights", "about:addons", "about:downloads", "about:buildconfig", "about:feedback", "about:healthreport", "about:" }; 1.19 + // Pages to be tested from the menu and their expected urls. This if of the form { {{ <path to item> }, { <expected url> }}* } 1.20 + String menuItems [][][] = {{{ "Apps" }, { "about:apps" }}, 1.21 + {{ "Downloads" }, { "about:downloads" }}, 1.22 + {{ "Add-ons" }, { "about:addons" }}, 1.23 + {{ "Settings", "Mozilla", "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)" }, { "about:" }}, 1.24 + {{ "Settings", "Mozilla", "Give feedback" }, { "about:feedback" }}, 1.25 + {{ "Settings", "Mozilla", "View my Health Report" }, { "about:healthreport" }}}; 1.26 + 1.27 + /* Load system pages from url and check that the pages are loaded in the same tab */ 1.28 + checkUrl(urls); 1.29 + 1.30 + /* Verify that the search field is not in the focus by pressing back. That will load the previous 1.31 + about: page if there is no the keyboard to dismiss, meaning that the search field was not in focus */ 1.32 + loadAndPaint("about:about"); 1.33 + 1.34 + // Press back to verify if the keyboard is dismissed or the previous about: page loads 1.35 + mActions.sendSpecialKey(Actions.SpecialKey.BACK); 1.36 + // may not get a paint on Back...pause briefly to make sure it completes 1.37 + mSolo.sleep(AFTER_BACK_SLEEP_MS); 1.38 + 1.39 + // We will use the "about:" page as our reference page. 1.40 + loadAndPaint("about:"); 1.41 + verifyUrl("about:"); // Verify that the previous about: page is loaded, meaning no keyboard was present 1.42 + 1.43 + // Load system pages by navigating through the UI. 1.44 + loadItemsByLevel(menuItems); 1.45 + } 1.46 + 1.47 + // Load from Url the about: pages,verify the Url and the tabs number 1.48 + public void checkUrl(String urls []) { 1.49 + for (String url:urls) { 1.50 + loadAndPaint(url); 1.51 + verifyTabCount(mExpectedTabCount); 1.52 + verifyUrl(url); 1.53 + } 1.54 + } 1.55 + 1.56 + public void loadItemsByLevel(String[][][] menuItems) { 1.57 + Actions.EventExpecter tabEventExpecter; 1.58 + Actions.EventExpecter contentEventExpecter; 1.59 + Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint(); 1.60 + int expectedTabCount = mExpectedTabCount; 1.61 + // There's some special casing for about: because it's our starting page. 1.62 + for (String[][] item : menuItems) { 1.63 + String [] pathToItem = item[0]; 1.64 + String expectedUrl = item[1][0]; 1.65 + 1.66 + expectedTabCount++; 1.67 + 1.68 + // Set up listeners to catch the page load we're about to do 1.69 + tabEventExpecter = mActions.expectGeckoEvent("Tab:Added"); 1.70 + contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded"); 1.71 + selectMenuItemByPath(pathToItem); 1.72 + 1.73 + // Wait for the new tab and page to load 1.74 + if ("about:".equals(expectedUrl)) { 1.75 + waitForPaint(paintExpecter); // Waiting for the page to load 1.76 + paintExpecter.unregisterListener(); 1.77 + } else { 1.78 + tabEventExpecter.blockForEvent(); 1.79 + contentEventExpecter.blockForEvent(); 1.80 + } 1.81 + tabEventExpecter.unregisterListener(); 1.82 + contentEventExpecter.unregisterListener(); 1.83 + 1.84 + verifyUrl(expectedUrl); 1.85 + if ("about:".equals(expectedUrl)) { 1.86 + // Decreasing because we do not expect this to be in a different tab. 1.87 + expectedTabCount--; 1.88 + } 1.89 + verifyTabCount(expectedTabCount); 1.90 + } 1.91 + } 1.92 +}