2013-11-07 08:18:51 -08:00
|
|
|
package org.mozilla.gecko.tests;
|
2012-12-18 04:34:48 -08:00
|
|
|
|
2014-04-01 22:00:47 -07:00
|
|
|
import org.mozilla.gecko.Actions;
|
2012-12-18 04:34:48 -08:00
|
|
|
|
2013-02-22 19:42:46 -08:00
|
|
|
/** 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 {
|
2012-12-18 04:34:48 -08:00
|
|
|
final int mExpectedTabCount = 1;
|
2013-04-03 11:08:49 -07:00
|
|
|
private static final int AFTER_BACK_SLEEP_MS = 500;
|
2012-12-18 04:34:48 -08:00
|
|
|
|
|
|
|
public void testSystemPages() {
|
|
|
|
blockForGeckoReady();
|
|
|
|
|
2013-09-19 06:38:00 -07:00
|
|
|
String urls [] = { "about:firefox", "about:rights", "about:addons", "about:downloads", "about:buildconfig", "about:feedback", "about:healthreport", "about:" };
|
2013-07-08 18:34:25 -07:00
|
|
|
// Pages to be tested from the menu and their expected urls. This if of the form { {{ <path to item> }, { <expected url> }}* }
|
|
|
|
String menuItems [][][] = {{{ "Apps" }, { "about:apps" }},
|
|
|
|
{{ "Downloads" }, { "about:downloads" }},
|
|
|
|
{{ "Add-ons" }, { "about:addons" }},
|
|
|
|
{{ "Settings", "Mozilla", "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)" }, { "about:" }},
|
|
|
|
{{ "Settings", "Mozilla", "Give feedback" }, { "about:feedback" }},
|
|
|
|
{{ "Settings", "Mozilla", "View my Health Report" }, { "about:healthreport" }}};
|
2012-12-18 04:34:48 -08:00
|
|
|
|
2013-07-08 18:34:25 -07:00
|
|
|
/* Load system pages from url and check that the pages are loaded in the same tab */
|
2012-12-18 04:34:48 -08:00
|
|
|
checkUrl(urls);
|
|
|
|
|
2013-04-03 11:08:49 -07:00
|
|
|
/* 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 */
|
2013-11-05 22:10:30 -08:00
|
|
|
loadAndPaint("about:about");
|
2012-12-18 04:34:48 -08:00
|
|
|
|
2013-04-03 11:08:49 -07:00
|
|
|
// Press back to verify if the keyboard is dismissed or the previous about: page loads
|
|
|
|
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
|
|
|
// may not get a paint on Back...pause briefly to make sure it completes
|
|
|
|
mSolo.sleep(AFTER_BACK_SLEEP_MS);
|
2012-12-18 04:34:48 -08:00
|
|
|
|
2013-07-08 18:34:25 -07:00
|
|
|
// We will use the "about:" page as our reference page.
|
|
|
|
loadAndPaint("about:");
|
2013-04-03 11:08:49 -07:00
|
|
|
verifyUrl("about:"); // Verify that the previous about: page is loaded, meaning no keyboard was present
|
2012-12-18 04:34:48 -08:00
|
|
|
|
2013-07-08 18:34:25 -07:00
|
|
|
// Load system pages by navigating through the UI.
|
|
|
|
loadItemsByLevel(menuItems);
|
2012-12-18 04:34:48 -08:00
|
|
|
}
|
|
|
|
|
2013-02-22 19:42:46 -08:00
|
|
|
// 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);
|
2012-12-18 04:34:48 -08:00
|
|
|
}
|
2013-02-22 19:42:46 -08:00
|
|
|
}
|
|
|
|
|
2013-07-08 18:34:25 -07:00
|
|
|
public void loadItemsByLevel(String[][][] menuItems) {
|
2013-04-03 11:08:49 -07:00
|
|
|
Actions.EventExpecter tabEventExpecter;
|
|
|
|
Actions.EventExpecter contentEventExpecter;
|
2013-07-08 18:34:25 -07:00
|
|
|
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
2013-02-22 19:42:46 -08:00
|
|
|
int expectedTabCount = mExpectedTabCount;
|
2013-07-08 18:34:25 -07:00
|
|
|
// There's some special casing for about: because it's our starting page.
|
|
|
|
for (String[][] item : menuItems) {
|
|
|
|
String [] pathToItem = item[0];
|
|
|
|
String expectedUrl = item[1][0];
|
|
|
|
|
2013-02-22 19:42:46 -08:00
|
|
|
expectedTabCount++;
|
|
|
|
|
2013-07-08 18:34:25 -07:00
|
|
|
// Set up listeners to catch the page load we're about to do
|
|
|
|
tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
|
|
|
|
contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
|
|
|
|
selectMenuItemByPath(pathToItem);
|
2013-02-22 19:42:46 -08:00
|
|
|
|
2013-07-08 18:34:25 -07:00
|
|
|
// Wait for the new tab and page to load
|
|
|
|
if ("about:".equals(expectedUrl)) {
|
2013-02-22 19:42:46 -08:00
|
|
|
waitForPaint(paintExpecter); // Waiting for the page to load
|
2013-04-18 20:18:09 -07:00
|
|
|
paintExpecter.unregisterListener();
|
2013-07-08 18:34:25 -07:00
|
|
|
} else {
|
|
|
|
tabEventExpecter.blockForEvent();
|
|
|
|
contentEventExpecter.blockForEvent();
|
|
|
|
}
|
|
|
|
tabEventExpecter.unregisterListener();
|
|
|
|
contentEventExpecter.unregisterListener();
|
2013-02-22 19:42:46 -08:00
|
|
|
|
2013-07-08 18:34:25 -07:00
|
|
|
verifyUrl(expectedUrl);
|
|
|
|
if ("about:".equals(expectedUrl)) {
|
|
|
|
// Decreasing because we do not expect this to be in a different tab.
|
|
|
|
expectedTabCount--;
|
2013-02-22 19:42:46 -08:00
|
|
|
}
|
2013-07-08 18:34:25 -07:00
|
|
|
verifyTabCount(expectedTabCount);
|
2013-02-22 19:42:46 -08:00
|
|
|
}
|
|
|
|
}
|
2012-12-18 04:34:48 -08:00
|
|
|
}
|