Bug 942915: Part 2: Update tests for Metro button Australis.

This commit is contained in:
Marina Samuel 2013-12-02 11:17:14 -05:00
parent bae45fa1c6
commit 9373ae764c
4 changed files with 92 additions and 18 deletions

View File

@ -28,7 +28,7 @@ let gTests = [
desc: "Creating and destroying a widget should correctly deal with panel placeholders",
run: function() {
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
is(panel.querySelectorAll(".panel-customization-placeholder").length, 3, "The number of placeholders should be correct.");
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 2 : 3, "The number of placeholders should be correct.");
CustomizableUI.createWidget({id: kTestWidget2, label: 'Pretty label', tooltiptext: 'Pretty tooltip', defaultArea: CustomizableUI.AREA_PANEL});
let elem = document.getElementById(kTestWidget2);
let wrapper = document.getElementById("wrapper-" + kTestWidget2);
@ -36,7 +36,7 @@ let gTests = [
ok(wrapper, "There should be a wrapper");
is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget");
is(wrapper.parentNode, panel, "Wrapper should be in panel");
is(panel.querySelectorAll(".panel-customization-placeholder").length, 2, "The number of placeholders should be correct.");
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 1 : 2, "The number of placeholders should be correct.");
CustomizableUI.destroyWidget(kTestWidget2);
wrapper = document.getElementById("wrapper-" + kTestWidget2);
ok(!wrapper, "There should be a wrapper");

View File

@ -21,6 +21,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, printButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
@ -47,6 +48,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should be in default state.");
@ -70,6 +72,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
@ -94,6 +97,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, historyPanelMenu);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
@ -121,6 +125,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, preferencesButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
@ -148,6 +153,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(developerButton, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
@ -186,6 +192,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(developerButton, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
@ -221,6 +228,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
@ -244,6 +252,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
@ -270,6 +279,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, privateBrowsingButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
@ -296,6 +306,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
@ -321,6 +332,7 @@ let gTests = [
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
@ -345,6 +357,7 @@ let gTests = [
"find-button",
"preferences-button",
"add-ons-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
let paletteChildElementCount = palette.childElementCount;
simulateItemDrag(editControls, palette);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -368,7 +381,8 @@ let gTests = [
run: function() {
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
for (let i = 0; i < 3; i++) {
let numPlaceholders = isInWin8() ? 2 : 3;
for (let i = 0; i < numPlaceholders; i++) {
// NB: We can't just iterate over all of the placeholders
// because each drag-drop action recreates them.
let placeholder = panel.getElementsByClassName("panel-customization-placeholder")[i];
@ -383,6 +397,7 @@ let gTests = [
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, placeholder);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
@ -425,11 +440,16 @@ let gTests = [
"preferences-button",
"add-ons-button",
"edit-controls"];
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, target);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let itemToDrag = "sync-button";
let button = document.getElementById(itemToDrag);
placementsAfterMove.push(itemToDrag);
if (!isInWin8()) {
placementsAfterMove.push(itemToDrag);
} else {
placementsAfterMove.splice(11, 0, itemToDrag);
}
simulateItemDrag(button, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);

View File

@ -11,18 +11,25 @@ let gTests = [
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
let placementsAfterAppend = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
if (!isInWin8()) {
placements = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
} else {
ok(CustomizableUI.inDefaultState, "Should be in default state.");
}
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting");
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders after re-entering");
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
if (!isInWin8()) {
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
@ -34,10 +41,15 @@ let gTests = [
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
let placementsAfterAppend = placements.concat(["developer-button", "sync-button"]);
simulateItemDrag(btn, panel);
btn = document.getElementById("sync-button");
let placementsAfterAppend = placements.concat(["developer-button"]);
simulateItemDrag(btn, panel);
if (!isInWin8()) {
placementsAfterAppend = placementsAfterAppend.concat(["sync-button"]);
btn = document.getElementById("sync-button");
simulateItemDrag(btn, panel);
}
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
@ -48,8 +60,11 @@ let gTests = [
let palette = document.getElementById("customization-palette");
simulateItemDrag(btn, palette);
btn = document.getElementById("developer-button");
simulateItemDrag(btn, palette);
if (!isInWin8()) {
btn = document.getElementById("developer-button");
simulateItemDrag(btn, palette);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
@ -58,12 +73,19 @@ let gTests = [
setup: startCustomizing,
run: function() {
let btn = document.getElementById("add-ons-button");
let btn2 = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
let placementsAfterAppend = placements.filter(p => p != btn.id);
simulateItemDrag(btn, palette);
if (isInWin8()) {
placementsAfterAppend = placementsAfterAppend.filter(p => p != btn2.id);
simulateItemDrag(btn2, palette);
}
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
@ -73,6 +95,11 @@ let gTests = [
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders after re-entering");
simulateItemDrag(btn, panel);
if (isInWin8()) {
simulateItemDrag(btn2, panel);
}
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
@ -82,9 +109,17 @@ let gTests = [
setup: startCustomizing,
run: function() {
let btn = document.getElementById("edit-controls");
let metroBtn = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
if (isInWin8()) {
// Remove switch-to-metro-button
placements.pop();
simulateItemDrag(metroBtn, palette);
}
let placementsAfterAppend = placements.concat([placements.shift()]);
simulateItemDrag(btn, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
@ -95,22 +130,26 @@ let gTests = [
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
if (isInWin8()) {
simulateItemDrag(metroBtn, panel);
}
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(btn, zoomControls);
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
},
},
{
desc: "The default placements should have three placeholders at the bottom.",
desc: "The default placements should have three placeholders at the bottom (or 2 in win8).",
setup: startCustomizing,
run: function() {
let numPlaceholders = isInWin8() ? 2 : 3;
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
ok(CustomizableUI.inDefaultState, "Should be in default state.");
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders before exiting");
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting");
yield endCustomizing();
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders after re-entering");
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
},

View File

@ -54,6 +54,21 @@ function resetCustomization() {
return CustomizableUI.reset();
}
function isInWin8() {
let sysInfo = Services.sysinfo;
let osName = sysInfo.getProperty("name");
let version = sysInfo.getProperty("version");
// Windows 8 is version >= 6.2
return osName == "Windows_NT" && version >= 6.2;
}
function addSwitchToMetroButtonInWindows8(areaPanelPlacements) {
if (isInWin8()) {
areaPanelPlacements.push("switch-to-metro-button");
}
}
function assertAreaPlacements(areaId, expectedPlacements) {
let actualPlacements = getAreaWidgetIds(areaId);
is(actualPlacements.length, expectedPlacements.length,