Bug 952663 - mochitests for expected tab strip scrolling behavior. r=jimm

This commit is contained in:
Sam Foster 2014-01-06 16:07:40 -08:00
Родитель 1dcc57284c
Коммит 468652a32b
4 изменённых файлов: 134 добавлений и 9 удалений

Просмотреть файл

@ -32,15 +32,6 @@ function testState(aState) {
} }
} }
function notifyPrecise()
{
Services.obs.notifyObservers(null, "metro_precise_input", null);
}
function notifyImprecise()
{
Services.obs.notifyObservers(null, "metro_imprecise_input", null);
}
gTests.push({ gTests.push({
desc: "precise/imprecise input switcher", desc: "precise/imprecise input switcher",

Просмотреть файл

@ -0,0 +1,114 @@
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
function test() {
runTests();
}
function setup() {
yield waitForCondition(function () {
return Elements.tabList && Elements.tabList.strip;
});
if (!ContextUI.tabbarVisible) {
ContextUI.displayTabs();
}
}
function tearDown() {
cleanUpOpenedTabs();
}
function isElementVisible(elm) {
return elm.ownerDocument.defaultView.getComputedStyle(elm).getPropertyValue("visibility") == "visible";
}
gTests.push({
desc: "No scrollbuttons when tab strip doesnt require overflow",
setUp: setup,
run: function () {
let tabStrip = Elements.tabList.strip;
let tabs = Elements.tabList.strip.querySelectorAll("documenttab");
// sanity check tab count:
is(tabs.length, 1, "1 tab present");
// test imprecise mode
let imprecisePromise = waitForObserver("metro_imprecise_input");
notifyImprecise();
yield imprecisePromise;
ok(!isElementVisible(tabStrip._scrollButtonUp), "left scrollbutton is hidden in imprecise mode");
ok(!isElementVisible(tabStrip._scrollButtonDown), "right scrollbutton is hidden in imprecise mode");
// test precise mode
let precisePromise = waitForObserver("metro_precise_input");
notifyPrecise();
yield precisePromise;
todo(!isElementVisible(tabStrip._scrollButtonUp), "Bug 952297 - left scrollbutton is hidden in precise mode");
ok(!isElementVisible(tabStrip._scrollButtonDown), "right scrollbutton is hidden in precise mode");
},
tearDown: tearDown
});
gTests.push({
desc: "Scrollbuttons not visible when tabstrip has overflow in imprecise input mode",
setUp: function(){
yield setup();
// ensure we're in imprecise mode
let imprecisePromise = waitForObserver("metro_imprecise_input");
notifyImprecise();
yield imprecisePromise;
},
run: function () {
// add enough tabs to get overflow in the tabstrip
let strip = Elements.tabList.strip;
ok(strip && strip.scrollClientSize && strip.scrollSize, "Sanity check tabstrip strip is present and expected properties available");
while (strip.scrollSize <= strip.scrollClientSize) {
yield addTab("about:mozilla");
}
ok(!isElementVisible(Elements.tabList.strip._scrollButtonUp), "left scrollbutton is hidden in imprecise mode");
ok(!isElementVisible(Elements.tabList.strip._scrollButtonDown), "right scrollbutton is hidden in imprecise mode");
}
});
gTests.push({
desc: "Scrollbuttons become visible when tabstrip has overflow in precise input mode",
setUp: function(){
yield setup();
// ensure we're in precise mode
let precisePromise = waitForObserver("metro_precise_input");
notifyPrecise();
yield precisePromise;
},
run: function () {
let strip = Elements.tabList.strip;
ok(strip && strip.scrollClientSize && strip.scrollSize, "Sanity check tabstrip is present and expected properties available");
// add enough tabs to get overflow in the tabstrip
while (strip.scrollSize <= strip.scrollClientSize) {
yield addTab("about:mozilla");
}
let tabs = Elements.tabList.strip.querySelectorAll("documenttab");
// select the first tab
Elements.tabs.selectedTab = tabs[0];
ok(isElementVisible(Elements.tabList.strip._scrollButtonDown), "right scrollbutton should be visible when tabList has overflow");
todo(!isElementVisible(Elements.tabList.strip._scrollButtonUp), "Bug 952297 - left scrollbutton should not visible when 1st tab is selected and tablist has overflow");
// select the last tab
Elements.tabs.selectedTab = tabs[tabs.length-1];
ok(isElementVisible(Elements.tabList.strip._scrollButtonUp), "left scrollbutton should be visible when tablist has overflow and last tab is selected");
todo(!isElementVisible(Elements.tabList.strip._scrollButtonDown), "Bug 952297 - right scrollbutton should not visible when last tab is selected and tablist has overflow");
}
});

Просмотреть файл

@ -556,6 +556,25 @@ function waitForObserver(aObsEvent, aTimeoutMs) {
} }
} }
/*=============================================================================
* Input mode helpers - these helpers notify observers to metro_precise_input
* and metro_imprecise_input respectively, triggering the same behaviour as user touch or mouse input
*
* Usage: let promise = waitForObservers("metro_imprecise_input");
* notifyImprecise();
* yield promise; // you are now in imprecise mode
*===========================================================================*/
function notifyPrecise()
{
Services.obs.notifyObservers(null, "metro_precise_input", null);
}
function notifyImprecise()
{
Services.obs.notifyObservers(null, "metro_imprecise_input", null);
}
/*============================================================================= /*=============================================================================
* Native input helpers - these helpers send input directly to the os * Native input helpers - these helpers send input directly to the os
* generating os level input events that get processed by widget and * generating os level input events that get processed by widget and

Просмотреть файл

@ -51,6 +51,7 @@ support-files =
[browser_remotetabs.js] [browser_remotetabs.js]
[browser_snappedState.js] [browser_snappedState.js]
[browser_tabs.js] [browser_tabs.js]
[browser_tabs_container.js]
[browser_test.js] [browser_test.js]
[browser_tiles.js] [browser_tiles.js]
[browser_topsites.js] [browser_topsites.js]