mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Backed out changeset b17854552298 (bug 1042252) for intermittent test failures
This commit is contained in:
parent
81d55839dd
commit
da454dd438
@ -102,7 +102,6 @@ skip-if = android_version == "10"
|
||||
[testDeviceSearchEngine]
|
||||
[testJNI]
|
||||
# [testMozPay] # see bug 945675
|
||||
[testNativeWindow]
|
||||
[testOrderedBroadcast]
|
||||
[testResourceSubstitutions]
|
||||
[testRestrictedProfiles]
|
||||
|
@ -1,113 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>NativeWindow test page</title>
|
||||
<meta name="viewport" content="initial-scale=1.0"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script type="application/javascript">
|
||||
Components.utils.import("resource://gre/modules/Messaging.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const TOAST_TEXT = "TOAST!";
|
||||
const MENU_TEXT1 = "MENU-A";
|
||||
const MENU_TEXT2 = "MENU-B";
|
||||
const DOORHANGER_TEXT = "DOORHANGER";
|
||||
const DOORHANGER_BUTTON1 = "BUTTON1";
|
||||
const DOORHANGER_BUTTON2 = "BUTTON2";
|
||||
const DOORHANGER_CHECK = "CHECKBOX";
|
||||
|
||||
// Entry point for the roboextender style tests. Called from <body onload>
|
||||
function start() {
|
||||
// Grad the name of the test from the hash/anchor
|
||||
var test = location.hash.substring(1);
|
||||
window[test]();
|
||||
}
|
||||
|
||||
// Show a toast and expect Java to watch for it to appear
|
||||
function showToast() {
|
||||
// Signal Java that we are ready so Java can start looking for the toast text
|
||||
sendMessageToJava({ type: "TestNativeWindow:ShowToast" });
|
||||
|
||||
// Show the toast
|
||||
var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
chromeWin.NativeWindow.toast.show(TOAST_TEXT, "short");
|
||||
}
|
||||
|
||||
// Add a menu and expect Java to find it and click it
|
||||
function addMenu() {
|
||||
// Add the menu
|
||||
var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
var menuID = chromeWin.NativeWindow.menu.add({
|
||||
name: MENU_TEXT1,
|
||||
icon: null,
|
||||
callback: function() {
|
||||
sendMessageToJava({ type: "TestNativeWindow:FireMenu" });
|
||||
}
|
||||
});
|
||||
|
||||
// Save the menuID for the next tests
|
||||
Services.prefs.setIntPref("test.nativewindow.menuID", menuID);
|
||||
|
||||
// Signal Java that we are ready. We signal last so there is no race.
|
||||
sendMessageToJava({ type: "TestNativeWindow:AddMenu" });
|
||||
}
|
||||
|
||||
// Update the menu text and expect Java to find it and click it
|
||||
function updateMenu() {
|
||||
// Get the menu's ID from storage
|
||||
menuID = Services.prefs.getIntPref("test.nativewindow.menuID");
|
||||
|
||||
var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
chromeWin.NativeWindow.menu.update(menuID, {
|
||||
name: MENU_TEXT2,
|
||||
});
|
||||
|
||||
// Signal Java that we are ready. We signal last so there is no race.
|
||||
sendMessageToJava({ type: "TestNativeWindow:UpdateMenu" });
|
||||
}
|
||||
|
||||
// Remove the menu and expect Java to not find it
|
||||
function removeMenu() {
|
||||
// Get the menu's ID from storage
|
||||
menuID = Services.prefs.getIntPref("test.nativewindow.menuID");
|
||||
|
||||
// Remove the menu
|
||||
var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
chromeWin.NativeWindow.menu.remove(menuID);
|
||||
|
||||
// Signal Java that we are ready. We signal last so there is no race.
|
||||
sendMessageToJava({ type: "TestNativeWindow:RemoveMenu" });
|
||||
}
|
||||
|
||||
// Add a doorhanger
|
||||
function addDoorhanger() {
|
||||
var buttons = [
|
||||
{
|
||||
label: DOORHANGER_BUTTON1,
|
||||
callback: function(aChecked) {
|
||||
// If the user checked "Don't ask again", make a permanent exception
|
||||
if (aChecked)
|
||||
sendMessageToJava({ type: "TestNativeWindow:FireDoorhangerChecked" });
|
||||
else
|
||||
sendMessageToJava({ type: "TestNativeWindow:FireDoorhanger" });
|
||||
}
|
||||
},
|
||||
{
|
||||
label: DOORHANGER_BUTTON2,
|
||||
callback: function(aChecked) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// Show the doorhanger
|
||||
var chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
chromeWin.NativeWindow.doorhanger.show(DOORHANGER_TEXT, "test-nativewindow", buttons, null, { checkbox: DOORHANGER_CHECK });
|
||||
|
||||
// Signal Java that we are ready. We signal last so there is no race.
|
||||
sendMessageToJava({ type: "TestNativeWindow:AddDoorhanger" });
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="start();">
|
||||
</body>
|
||||
</html>
|
@ -1,130 +0,0 @@
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import org.mozilla.gecko.Actions;
|
||||
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class testNativeWindow extends BaseTest {
|
||||
|
||||
private static final String TEST_URL = "chrome://roboextender/content/testNativeWindow.html";
|
||||
private static final String TOAST_TEXT = "TOAST!";
|
||||
private static final String MENU_TEXT1 = "MENU-A";
|
||||
private static final String MENU_TEXT2 = "MENU-B";
|
||||
private static final String DOORHANGER_TEXT = "DOORHANGER";
|
||||
private static final String DOORHANGER_BUTTON1 = "BUTTON1";
|
||||
private static final String DOORHANGER_BUTTON2 = "BUTTON2";
|
||||
private static final String DOORHANGER_CHECK = "CHECKBOX";
|
||||
|
||||
public void testNativeWindow() {
|
||||
blockForGeckoReady();
|
||||
|
||||
// NOTE: These test methods depend on being run in this order.
|
||||
addToastTest();
|
||||
|
||||
prepNextTest();
|
||||
addMenuTest();
|
||||
|
||||
prepNextTest();
|
||||
updateMenuTest();
|
||||
|
||||
prepNextTest();
|
||||
removeMenuTest();
|
||||
|
||||
prepNextTest();
|
||||
addDoorhangerTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load about:blank between each test to ensure we reset state.
|
||||
*/
|
||||
private void prepNextTest() {
|
||||
loadUrl("about:blank");
|
||||
mAsserter.ok(waitForText("about:blank"), "Loaded blank page", "page title match");
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a toast, verifies that it appears when it should.
|
||||
*/
|
||||
private void addToastTest() {
|
||||
Actions.EventExpecter eventExpecter = mActions.expectGeckoEvent("TestNativeWindow:ShowToast");
|
||||
loadUrl(TEST_URL + "#showToast");
|
||||
eventExpecter.blockForEvent();
|
||||
|
||||
// Verify that the toast is visible with the correct text.
|
||||
mAsserter.ok(waitForText(TOAST_TEXT), "Waiting for the toast", "Toast has been displayed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a menu and verifies the callback fires when clicked.
|
||||
*/
|
||||
private void addMenuTest() {
|
||||
Actions.EventExpecter eventExpecter = mActions.expectGeckoEvent("TestNativeWindow:AddMenu");
|
||||
loadUrl(TEST_URL + "#addMenu");
|
||||
eventExpecter.blockForEvent();
|
||||
|
||||
// Press the menu and wait for the callback to send a message
|
||||
Actions.EventExpecter menuExpecter = mActions.expectGeckoEvent("TestNativeWindow:FireMenu");
|
||||
selectMenuItem(MENU_TEXT1);
|
||||
menuExpecter.blockForEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a menu and verifies the callback fires when clicked.
|
||||
*/
|
||||
private void updateMenuTest() {
|
||||
// Load about:home and make sure the onshown handler is called.
|
||||
Actions.EventExpecter eventExpecter = mActions.expectGeckoEvent("TestNativeWindow:UpdateMenu");
|
||||
loadUrl(TEST_URL + "#updateMenu");
|
||||
eventExpecter.blockForEvent();
|
||||
|
||||
// Press the menu and wait for the callback to send a message
|
||||
Actions.EventExpecter menuExpecter = mActions.expectGeckoEvent("TestNativeWindow:FireMenu");
|
||||
selectMenuItem(MENU_TEXT2);
|
||||
menuExpecter.blockForEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a menu and verifies the menu is not found.
|
||||
*/
|
||||
private void removeMenuTest() {
|
||||
Actions.EventExpecter eventExpecter = mActions.expectGeckoEvent("TestNativeWindow:RemoveMenu");
|
||||
loadUrl(TEST_URL + "#removeMenu");
|
||||
eventExpecter.blockForEvent();
|
||||
|
||||
// Do a simple search for the menu text on the main menu
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.MENU);
|
||||
waitForText("^New Tab$");
|
||||
mAsserter.ok(mSolo.searchText("^" + MENU_TEXT2 + "$") == false, "Checking for menu", "Menu has been removed");
|
||||
|
||||
// Close the menu, if it's still open
|
||||
if (mSolo.searchText("^New Tab$")) {
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.BACK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a doorhanger and verifies the callback fires when clicked.
|
||||
*/
|
||||
private void addDoorhangerTest() {
|
||||
Actions.EventExpecter eventExpecter = mActions.expectGeckoEvent("TestNativeWindow:AddDoorhanger");
|
||||
loadUrl(TEST_URL + "#addDoorhanger");
|
||||
eventExpecter.blockForEvent();
|
||||
|
||||
// Press the doorhanger button and wait for the callback to send a message
|
||||
Actions.EventExpecter menuExpecter = mActions.expectGeckoEvent("TestNativeWindow:FireDoorhanger");
|
||||
waitForText(DOORHANGER_TEXT);
|
||||
|
||||
// Uncheck the checkbox
|
||||
ArrayList<CheckBox> checkBoxes = mSolo.getCurrentViews(CheckBox.class);
|
||||
mAsserter.ok(checkBoxes.size() == 1, "checkbox count", "only one checkbox visible");
|
||||
mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked");
|
||||
mSolo.clickOnCheckBox(0);
|
||||
mAsserter.ok(!mSolo.isCheckBoxChecked(0), "checkbox not checked", "checkbox is not checked");
|
||||
|
||||
mSolo.clickOnText(DOORHANGER_BUTTON1);
|
||||
|
||||
menuExpecter.blockForEvent();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user