mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 904893 - Snapped view testing r=sfoster
This commit is contained in:
parent
c6dedb8fa4
commit
dcab1936e5
@ -12,6 +12,8 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MOCHITEST_METRO_FILES = \
|
||||
head.js \
|
||||
helpers/BookmarksHelper.js \
|
||||
helpers/HistoryHelper.js \
|
||||
helpers/ViewStateHelper.js \
|
||||
browser_bookmarks.js \
|
||||
browser_canonizeURL.js \
|
||||
|
@ -31,99 +31,6 @@ function tearDown() {
|
||||
BookmarksTestHelper.restore();
|
||||
}
|
||||
|
||||
var BookmarksTestHelper = {
|
||||
_originalNavHistoryService: null,
|
||||
MockNavHistoryService: {
|
||||
getNewQueryOptions: function () {
|
||||
return {};
|
||||
},
|
||||
getNewQuery: function () {
|
||||
return {
|
||||
setFolders: function(){}
|
||||
};
|
||||
},
|
||||
executeQuery: function () {
|
||||
return {
|
||||
root: {
|
||||
get childCount() {
|
||||
return Object.keys(BookmarksTestHelper._nodes).length;
|
||||
},
|
||||
|
||||
getChild: function (aIndex) BookmarksTestHelper._nodes[Object.keys(BookmarksTestHelper._nodes)[aIndex]]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_originalBookmarkService: null,
|
||||
MockBookmarkService: {
|
||||
getItemIndex: function (aIndex) aIndex,
|
||||
getBookmarkURI: function (aId) BookmarksTestHelper._nodes[aId].uri,
|
||||
getItemTitle: function (aId) BookmarksTestHelper._nodes[aId].title,
|
||||
removeItem: function (aId) {
|
||||
delete BookmarksTestHelper._nodes[aId];
|
||||
|
||||
// Simulate observer notification
|
||||
gStartView._changes.onItemRemoved(aId, gStartView._root);
|
||||
},
|
||||
},
|
||||
|
||||
Node: function (aTitle, aId) {
|
||||
this.type = this.RESULT_TYPE_URI = 0;
|
||||
this.title = aTitle;
|
||||
this.itemId = aId;
|
||||
this.uri = "http://" + aTitle + ".com.br";
|
||||
this.pinned = true
|
||||
},
|
||||
|
||||
_nodes: null,
|
||||
createNodes: function (aMany) {
|
||||
this._nodes = {};
|
||||
for (let i=0; i<aMany; i++) {
|
||||
this._nodes[i] = new this.Node("Mock-Bookmark" + i, i);
|
||||
}
|
||||
},
|
||||
|
||||
_originalPinHelper: null,
|
||||
MockPinHelper: {
|
||||
isPinned: function (aItem) BookmarksTestHelper._nodes[aItem].pinned,
|
||||
setUnpinned: function (aItem) BookmarksTestHelper._nodes[aItem].pinned = false,
|
||||
setPinned: function (aItem) BookmarksTestHelper._nodes[aItem].pinned = true,
|
||||
},
|
||||
|
||||
_originalUpdateFavicon: null,
|
||||
setup: function setup() {
|
||||
// Just enough items so that there will be one less then the limit
|
||||
// after removing 4 items.
|
||||
this.createNodes(gStartView._limit + 3);
|
||||
|
||||
this._originalNavHistoryService = gStartView._navHistoryService;
|
||||
gStartView._navHistoryService = this.MockNavHistoryService;
|
||||
|
||||
this._originalBookmarkService = gStartView._bookmarkService;
|
||||
gStartView._bookmarkService= this.MockBookmarkService;
|
||||
|
||||
this._originalPinHelper = gStartView._pinHelper;
|
||||
gStartView._pinHelper = this.MockPinHelper;
|
||||
|
||||
this._originalUpdateFavicon = gStartView._updateFavicon;
|
||||
gStartView._updateFavicon = function () {};
|
||||
|
||||
gStartView.clearBookmarks();
|
||||
gStartView.getBookmarks();
|
||||
},
|
||||
|
||||
restore: function () {
|
||||
gStartView._navHistoryService = this._originalNavHistoryService;
|
||||
gStartView._bookmarkService= this._originalBookmarkService;
|
||||
gStartView._pinHelper = this._originalPinHelper;
|
||||
gStartView._updateFavicon = this._originalUpdateFavicon;
|
||||
|
||||
gStartView.clearBookmarks();
|
||||
gStartView.getBookmarks();
|
||||
}
|
||||
};
|
||||
|
||||
gTests.push({
|
||||
desc: "Test bookmarks StartUI unpin",
|
||||
setUp: setup,
|
||||
|
@ -38,92 +38,6 @@ function tearDown() {
|
||||
HistoryTestHelper.restore();
|
||||
}
|
||||
|
||||
var HistoryTestHelper = {
|
||||
_originalNavHistoryService: null,
|
||||
MockNavHistoryService: {
|
||||
getNewQueryOptions: function () {
|
||||
return {};
|
||||
},
|
||||
getNewQuery: function () {
|
||||
return {
|
||||
setFolders: function(){}
|
||||
};
|
||||
},
|
||||
executeQuery: function () {
|
||||
return {
|
||||
root: {
|
||||
get childCount() {
|
||||
return Object.keys(HistoryTestHelper._nodes).length;
|
||||
},
|
||||
|
||||
getChild: function (aIndex) HistoryTestHelper._nodes[Object.keys(HistoryTestHelper._nodes)[aIndex]]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_originalHistoryService: null,
|
||||
MockHistoryService: {
|
||||
removePage: function (aURI) {
|
||||
delete HistoryTestHelper._nodes[aURI.spec];
|
||||
|
||||
// Simulate observer notification
|
||||
gStartView.onDeleteURI(aURI);
|
||||
},
|
||||
},
|
||||
|
||||
Node: function (aTitle, aURISpec) {
|
||||
this.title = aTitle;
|
||||
this.uri = aURISpec;
|
||||
this.pinned = true
|
||||
},
|
||||
|
||||
_nodes: null,
|
||||
createNodes: function (aMany) {
|
||||
this._nodes = {};
|
||||
for (let i=0; i<aMany; i++) {
|
||||
let title = "mock-history-" + i;
|
||||
let uri = "http://" + title + ".com.br/";
|
||||
|
||||
this._nodes[uri] = new this.Node(title, uri);
|
||||
}
|
||||
},
|
||||
|
||||
_originalPinHelper: null,
|
||||
MockPinHelper: {
|
||||
isPinned: function (aItem) HistoryTestHelper._nodes[aItem].pinned,
|
||||
setUnpinned: function (aItem) HistoryTestHelper._nodes[aItem].pinned = false,
|
||||
setPinned: function (aItem) HistoryTestHelper._nodes[aItem].pinned = true,
|
||||
},
|
||||
|
||||
setup: function setup() {
|
||||
// Just enough items so that there will be one less then the limit
|
||||
// after removing 4 items.
|
||||
this.createNodes(gStartView._limit + 3);
|
||||
|
||||
this._originalNavHistoryService = gStartView._navHistoryService;
|
||||
gStartView._navHistoryService = this.MockNavHistoryService;
|
||||
|
||||
this._originalHistoryService = gStartView._historyService;
|
||||
gStartView._historyService= this.MockHistoryService;
|
||||
|
||||
this._originalPinHelper = gStartView._pinHelper;
|
||||
gStartView._pinHelper = this.MockPinHelper;
|
||||
|
||||
gStartView._set.clearAll();
|
||||
gStartView.populateGrid();
|
||||
},
|
||||
|
||||
restore: function () {
|
||||
gStartView._navHistoryService = this._originalNavHistoryService;
|
||||
gStartView._historyService= this._originalHistoryService;
|
||||
gStartView._pinHelper = this._originalPinHelper;
|
||||
|
||||
gStartView._set.clearAll();
|
||||
gStartView.populateGrid();
|
||||
}
|
||||
};
|
||||
|
||||
function uriFromIndex(aIndex) {
|
||||
return "http://mock-history-" + aIndex + ".com.br/"
|
||||
}
|
||||
|
@ -95,9 +95,35 @@ gTests.push({
|
||||
|
||||
gTests.push({
|
||||
desc: "Test Snapped scrolls vertically",
|
||||
setUp: function() {
|
||||
|
||||
// Populate with mock data and expand bookmarks
|
||||
BookmarksTestHelper.setup();
|
||||
sendElementTap(Browser.selectedBrowser.contentWindow, getNarrowTitle("start-bookmarks"));
|
||||
|
||||
yield waitForCondition(() => gStartDoc.getElementById("start-bookmarks").hasAttribute("expanded"));
|
||||
|
||||
yield setUpSnapped();
|
||||
},
|
||||
run: function() {
|
||||
ok(Browser.selectedBrowser.contentWindow.scrollMaxY !== 0, "Snapped scrolls vertically");
|
||||
ok(Browser.selectedBrowser.contentWindow.scrollMaxX === 0, "Snapped does not scroll horizontally");
|
||||
},
|
||||
tearDown: function() {
|
||||
BookmarksTestHelper.restore();
|
||||
restoreViewstate();
|
||||
}
|
||||
});
|
||||
|
||||
gTests.push({
|
||||
desc: "Navbar contextual buttons are not shown in snapped",
|
||||
setUp: setUpSnapped,
|
||||
run: function() {
|
||||
todo(false, "We need to populate startUI to verify that it's scrollable");
|
||||
let toolbarContextual = document.getElementById("toolbar-contextual");
|
||||
|
||||
let visibility = getComputedStyle(toolbarContextual).getPropertyValue("visibility");
|
||||
|
||||
ok(visibility === "collapse" || visibility === "hidden", "Contextual buttons not shown in navbar");
|
||||
},
|
||||
tearDown: restoreViewstate
|
||||
});
|
||||
@ -117,3 +143,23 @@ gTests.push({
|
||||
},
|
||||
tearDown: restoreViewstate
|
||||
});
|
||||
|
||||
gTests.push({
|
||||
desc: "Test portrait scrolls vertically",
|
||||
setUp: function() {
|
||||
// Populate with mock data
|
||||
BookmarksTestHelper.setup();
|
||||
HistoryTestHelper.setup();
|
||||
|
||||
yield setUpPortrait();
|
||||
},
|
||||
run: function() {
|
||||
ok(Browser.selectedBrowser.contentWindow.scrollMaxY !== 0, "Portrait scrolls vertically");
|
||||
ok(Browser.selectedBrowser.contentWindow.scrollMaxX === 0, "Portrait does not scroll horizontally");
|
||||
},
|
||||
tearDown: function() {
|
||||
BookmarksTestHelper.restore();
|
||||
HistoryTestHelper.restore();
|
||||
restoreViewstate();
|
||||
}
|
||||
});
|
||||
|
@ -34,6 +34,8 @@ splitPath.push('mochitest');
|
||||
const mochitestPath = splitPath.join('/') + '/';
|
||||
|
||||
[
|
||||
"BookmarksHelper.js",
|
||||
"HistoryHelper.js",
|
||||
"ViewStateHelper.js"
|
||||
].forEach(function(lib) {
|
||||
Services.scriptloader.loadSubScript(mochitestPath + lib, this);
|
||||
|
101
browser/metro/base/tests/mochitest/helpers/BookmarksHelper.js
Normal file
101
browser/metro/base/tests/mochitest/helpers/BookmarksHelper.js
Normal file
@ -0,0 +1,101 @@
|
||||
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
var BookmarksTestHelper = {
|
||||
_originalNavHistoryService: null,
|
||||
_startView: null,
|
||||
MockNavHistoryService: {
|
||||
getNewQueryOptions: function () {
|
||||
return {};
|
||||
},
|
||||
getNewQuery: function () {
|
||||
return {
|
||||
setFolders: function(){}
|
||||
};
|
||||
},
|
||||
executeQuery: function () {
|
||||
return {
|
||||
root: {
|
||||
get childCount() {
|
||||
return Object.keys(BookmarksTestHelper._nodes).length;
|
||||
},
|
||||
|
||||
getChild: function (aIndex) BookmarksTestHelper._nodes[Object.keys(BookmarksTestHelper._nodes)[aIndex]]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_originalBookmarkService: null,
|
||||
MockBookmarkService: {
|
||||
getItemIndex: function (aIndex) aIndex,
|
||||
getBookmarkURI: function (aId) BookmarksTestHelper._nodes[aId].uri,
|
||||
getItemTitle: function (aId) BookmarksTestHelper._nodes[aId].title,
|
||||
removeItem: function (aId) {
|
||||
delete BookmarksTestHelper._nodes[aId];
|
||||
|
||||
// Simulate observer notification
|
||||
BookmarksTestHelper._startView._changes.onItemRemoved(aId, BookmarksTestHelper._startView._root);
|
||||
},
|
||||
},
|
||||
|
||||
Node: function (aTitle, aId) {
|
||||
this.type = this.RESULT_TYPE_URI = 0;
|
||||
this.title = aTitle;
|
||||
this.itemId = aId;
|
||||
this.uri = "http://" + aTitle + ".com.br";
|
||||
this.pinned = true
|
||||
},
|
||||
|
||||
_nodes: null,
|
||||
createNodes: function (aMany) {
|
||||
this._nodes = {};
|
||||
for (let i=0; i<aMany; i++) {
|
||||
this._nodes[i] = new this.Node("Mock-Bookmark" + i, i);
|
||||
}
|
||||
},
|
||||
|
||||
_originalPinHelper: null,
|
||||
MockPinHelper: {
|
||||
isPinned: function (aItem) BookmarksTestHelper._nodes[aItem].pinned,
|
||||
setUnpinned: function (aItem) BookmarksTestHelper._nodes[aItem].pinned = false,
|
||||
setPinned: function (aItem) BookmarksTestHelper._nodes[aItem].pinned = true,
|
||||
},
|
||||
|
||||
_originalUpdateFavicon: null,
|
||||
setup: function setup() {
|
||||
this._startView = Browser.selectedBrowser.contentWindow.BookmarksStartView._view;
|
||||
|
||||
// Just enough items so that there will be one less then the limit
|
||||
// after removing 4 items.
|
||||
this.createNodes(this._startView._limit + 3);
|
||||
|
||||
this._originalNavHistoryService = this._startView._navHistoryService;
|
||||
this._startView._navHistoryService = this.MockNavHistoryService;
|
||||
|
||||
this._originalBookmarkService = this._startView._bookmarkService;
|
||||
this._startView._bookmarkService= this.MockBookmarkService;
|
||||
|
||||
this._originalPinHelper = this._startView._pinHelper;
|
||||
this._startView._pinHelper = this.MockPinHelper;
|
||||
|
||||
this._originalUpdateFavicon = this._startView._updateFavicon;
|
||||
this._startView._updateFavicon = function () {};
|
||||
|
||||
this._startView.clearBookmarks();
|
||||
this._startView.getBookmarks();
|
||||
},
|
||||
|
||||
restore: function () {
|
||||
this._startView._navHistoryService = this._originalNavHistoryService;
|
||||
this._startView._bookmarkService= this._originalBookmarkService;
|
||||
this._startView._pinHelper = this._originalPinHelper;
|
||||
this._startView._updateFavicon = this._originalUpdateFavicon;
|
||||
|
||||
this._startView.clearBookmarks();
|
||||
this._startView.getBookmarks();
|
||||
}
|
||||
};
|
94
browser/metro/base/tests/mochitest/helpers/HistoryHelper.js
Normal file
94
browser/metro/base/tests/mochitest/helpers/HistoryHelper.js
Normal file
@ -0,0 +1,94 @@
|
||||
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
var HistoryTestHelper = {
|
||||
_originalNavHistoryService: null,
|
||||
_startView: null,
|
||||
MockNavHistoryService: {
|
||||
getNewQueryOptions: function () {
|
||||
return {};
|
||||
},
|
||||
getNewQuery: function () {
|
||||
return {
|
||||
setFolders: function(){}
|
||||
};
|
||||
},
|
||||
executeQuery: function () {
|
||||
return {
|
||||
root: {
|
||||
get childCount() {
|
||||
return Object.keys(HistoryTestHelper._nodes).length;
|
||||
},
|
||||
|
||||
getChild: function (aIndex) HistoryTestHelper._nodes[Object.keys(HistoryTestHelper._nodes)[aIndex]]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_originalHistoryService: null,
|
||||
MockHistoryService: {
|
||||
removePage: function (aURI) {
|
||||
delete HistoryTestHelper._nodes[aURI.spec];
|
||||
|
||||
// Simulate observer notification
|
||||
HistoryTestHelper._startView.onDeleteURI(aURI);
|
||||
},
|
||||
},
|
||||
|
||||
Node: function (aTitle, aURISpec) {
|
||||
this.title = aTitle;
|
||||
this.uri = aURISpec;
|
||||
this.pinned = true
|
||||
},
|
||||
|
||||
_nodes: null,
|
||||
createNodes: function (aMany) {
|
||||
this._nodes = {};
|
||||
for (let i=0; i<aMany; i++) {
|
||||
let title = "mock-history-" + i;
|
||||
let uri = "http://" + title + ".com.br/";
|
||||
|
||||
this._nodes[uri] = new this.Node(title, uri);
|
||||
}
|
||||
},
|
||||
|
||||
_originalPinHelper: null,
|
||||
MockPinHelper: {
|
||||
isPinned: function (aItem) HistoryTestHelper._nodes[aItem].pinned,
|
||||
setUnpinned: function (aItem) HistoryTestHelper._nodes[aItem].pinned = false,
|
||||
setPinned: function (aItem) HistoryTestHelper._nodes[aItem].pinned = true,
|
||||
},
|
||||
|
||||
setup: function setup() {
|
||||
this._startView = Browser.selectedBrowser.contentWindow.HistoryStartView._view;
|
||||
|
||||
// Just enough items so that there will be one less then the limit
|
||||
// after removing 4 items.
|
||||
this.createNodes(this._startView._limit + 3);
|
||||
|
||||
this._originalNavHistoryService = this._startView._navHistoryService;
|
||||
this._startView._navHistoryService = this.MockNavHistoryService;
|
||||
|
||||
this._originalHistoryService = this._startView._historyService;
|
||||
this._startView._historyService= this.MockHistoryService;
|
||||
|
||||
this._originalPinHelper = this._startView._pinHelper;
|
||||
this._startView._pinHelper = this.MockPinHelper;
|
||||
|
||||
this._startView._set.clearAll();
|
||||
this._startView.populateGrid();
|
||||
},
|
||||
|
||||
restore: function () {
|
||||
this._startView._navHistoryService = this._originalNavHistoryService;
|
||||
this._startView._historyService= this._originalHistoryService;
|
||||
this._startView._pinHelper = this._originalPinHelper;
|
||||
|
||||
this._startView._set.clearAll();
|
||||
this._startView.populateGrid();
|
||||
}
|
||||
};
|
@ -6,14 +6,11 @@
|
||||
"use strict";
|
||||
|
||||
const snappedSize = 330;
|
||||
const portraitSize = 660;
|
||||
const portraitSize = 900;
|
||||
|
||||
function setSnappedViewstate() {
|
||||
ok(isLandscapeMode(), "setSnappedViewstate expects landscape mode to work.");
|
||||
|
||||
// Communicate viewstate change
|
||||
Services.obs.notifyObservers(null, 'metro_viewstate_changed', 'snapped');
|
||||
|
||||
let browser = Browser.selectedBrowser;
|
||||
|
||||
// Reduce browser width to simulate small screen size.
|
||||
@ -22,6 +19,9 @@ function setSnappedViewstate() {
|
||||
|
||||
browser.style.borderRight = padding + "px solid gray";
|
||||
|
||||
// Communicate viewstate change
|
||||
Services.obs.notifyObservers(null, 'metro_viewstate_changed', 'snapped');
|
||||
|
||||
// Make sure it renders the new mode properly
|
||||
yield waitForMs(0);
|
||||
}
|
||||
@ -29,8 +29,6 @@ function setSnappedViewstate() {
|
||||
function setPortraitViewstate() {
|
||||
ok(isLandscapeMode(), "setPortraitViewstate expects landscape mode to work.");
|
||||
|
||||
Services.obs.notifyObservers(null, 'metro_viewstate_changed', 'portrait');
|
||||
|
||||
let browser = Browser.selectedBrowser;
|
||||
|
||||
let fullWidth = browser.clientWidth;
|
||||
@ -38,6 +36,8 @@ function setPortraitViewstate() {
|
||||
|
||||
browser.style.borderRight = padding + "px solid gray";
|
||||
|
||||
Services.obs.notifyObservers(null, 'metro_viewstate_changed', 'portrait');
|
||||
|
||||
// Make sure it renders the new mode properly
|
||||
yield waitForMs(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user