Bug 623207 - Add-ons manager last updated date and sorting bar should be removed from list view. r=Mossop a=b

This commit is contained in:
Geoff Lankow 2011-01-18 14:11:22 +13:00
parent ab3e0c7039
commit 357a880970
6 changed files with 88 additions and 30 deletions

View File

@ -133,6 +133,13 @@ xhtml|link {
display: none;
}
#addons-page:not([warning]) #list-view > .global-warning-container {
display: none;
}
#addon-list .date-updated {
display: none;
}
.view-pane:not(#updates-view) .addon .relnotes-toggle,
.view-pane:not(#updates-view) .addon .include-update,
#updates-view:not([updatetype="available"]) .addon .include-update,

View File

@ -2025,13 +2025,10 @@ var gListView = {
node: null,
_listBox: null,
_emptyNotice: null,
_sorters: null,
_type: null,
initialize: function() {
this.node = document.getElementById("list-view");
this._sorters = document.getElementById("list-sorters");
this._sorters.handler = this;
this._listBox = document.getElementById("addon-list");
this._emptyNotice = document.getElementById("addon-list-empty");
@ -2069,7 +2066,7 @@ var gListView = {
self.showEmptyNotice(elements.length == 0);
if (elements.length > 0) {
sortElements(elements, self._sorters.sortBy, self._sorters.ascending);
sortElements(elements, "name", true);
elements.forEach(function(aElement) {
self._listBox.appendChild(aElement);
});

View File

@ -393,9 +393,6 @@
command="cmd_enableUpdateSecurity"/>
<spacer flex="5000"/> <!-- Necessary to allow the message to wrap -->
</hbox>
<spacer flex="1"/>
<hbox id="list-sorters" class="sort-controls" sortby="name"
ascending="true"/>
</hbox>
<vbox id="addon-list-empty" class="alert-container"
flex="1" hidden="true">

View File

@ -67,21 +67,45 @@ add_test(function() {
add_test(function() {
var updatesList = gManagerWindow.document.getElementById("updates-list");
var items = updatesList.getElementsByTagName("richlistitem");
var possible = ["addon1@tests.mozilla.org", "addon2@tests.mozilla.org", "addon3@tests.mozilla.org"];
var expected = ["addon2@tests.mozilla.org", "addon1@tests.mozilla.org"];
for (let i = 0; i < items.length; i++) {
let item = items[i];
let itemId = item.mAddon.id;
if (possible.indexOf(itemId) == -1)
continue; // skip over any other addons, such as shipped addons that would update on every build
isnot(expected.length, 0, "Should be expecting more items");
is(itemId, expected.shift(), "Should get expected item based on recentness of update");
if (itemId == "addon1@tests.mozilla.org")
is_element_visible(item._relNotesToggle, "Release notes toggle should be visible for addon with release notes");
else
is_element_hidden(item._relNotesToggle, "Release notes toggle should be hidden for addon with no release notes");
var sorters = gManagerWindow.document.getElementById("updates-sorters");
var dateSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "date-btn");
var nameSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "name-btn");
function check_order(expected) {
var items = updatesList.getElementsByTagName("richlistitem");
var possible = ["addon1@tests.mozilla.org", "addon2@tests.mozilla.org", "addon3@tests.mozilla.org"];
for (let i = 0; i < items.length; i++) {
let item = items[i];
let itemId = item.mAddon.id;
if (possible.indexOf(itemId) == -1)
continue; // skip over any other addons, such as shipped addons that would update on every build
isnot(expected.length, 0, "Should be expecting more items");
is(itemId, expected.shift(), "Should get expected item based on sort order");
if (itemId == "addon1@tests.mozilla.org")
is_element_visible(item._relNotesToggle, "Release notes toggle should be visible for addon with release notes");
else
is_element_hidden(item._relNotesToggle, "Release notes toggle should be hidden for addon with no release notes");
}
}
is_element_visible(dateSorter);
is_element_visible(nameSorter);
// sorted by date, descending
check_order(["addon2@tests.mozilla.org", "addon1@tests.mozilla.org"]);
// sorted by date, ascending
EventUtils.synthesizeMouseAtCenter(dateSorter, { }, gManagerWindow);
check_order(["addon1@tests.mozilla.org", "addon2@tests.mozilla.org"]);
// sorted by name, ascending
EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
check_order(["addon2@tests.mozilla.org", "addon1@tests.mozilla.org"]);
// sorted by name, descending
EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
check_order(["addon1@tests.mozilla.org", "addon2@tests.mozilla.org"]);
run_next_test();
});

View File

@ -479,11 +479,13 @@ add_test(function() {
if (currentIndex >= sorterNames.length) {
sorters.handler = originalHandler;
run_next_test();
return;
}
// Simulate clicking on a specific sorter
var buttonId = buttonIds[currentIndex];
var sorter = getAnonymousElementByAttribute(sorters, "anonid", buttonId);
is_element_visible(sorter);
EventUtils.synthesizeMouseAtCenter(sorter, { }, gManagerWindow);
}

View File

@ -2,7 +2,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that sorting of add-ons in the list views works correctly
// Tests that sorting of add-ons works correctly
// (this test uses the list view, even though it no longer has sort buttons - see bug 623207)
var gManagerWindow;
var gProvider;
@ -54,6 +55,20 @@ function end_test() {
});
}
function set_order(aSortBy, aAscending) {
var list = gManagerWindow.document.getElementById("addon-list");
var elements = [];
var node = list.firstChild;
while (node) {
elements.push(node);
node = node.nextSibling;
}
gManagerWindow.sortElements(elements, aSortBy, aAscending);
elements.forEach(function(aElement) {
list.appendChild(aElement);
});
}
function check_order(aExpectedOrder) {
var order = [];
var list = gManagerWindow.document.getElementById("addon-list");
@ -81,11 +96,9 @@ add_test(function() {
run_next_test();
});
// Tests that switching to date ordering works and defaults to descending
// Tests that switching to date ordering works
add_test(function() {
var sorters = gManagerWindow.document.getElementById("list-sorters");
var nameSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "date-btn");
EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
set_order("updateDate", false);
check_order([
"test5@tests.mozilla.org",
@ -95,14 +108,22 @@ add_test(function() {
"test4@tests.mozilla.org"
]);
set_order("updateDate", true);
check_order([
"test4@tests.mozilla.org",
"test2@tests.mozilla.org",
"test1@tests.mozilla.org",
"test3@tests.mozilla.org",
"test5@tests.mozilla.org"
]);
run_next_test();
});
// Tests that switching to name ordering works and defaults to ascending
// Tests that switching to name ordering works
add_test(function() {
var sorters = gManagerWindow.document.getElementById("list-sorters");
var nameSorter = gManagerWindow.document.getAnonymousElementByAttribute(sorters, "anonid", "name-btn");
EventUtils.synthesizeMouseAtCenter(nameSorter, { }, gManagerWindow);
set_order("name", true);
check_order([
"test2@tests.mozilla.org",
@ -112,5 +133,15 @@ add_test(function() {
"test1@tests.mozilla.org"
]);
set_order("name", false);
check_order([
"test1@tests.mozilla.org",
"test5@tests.mozilla.org",
"test3@tests.mozilla.org",
"test4@tests.mozilla.org",
"test2@tests.mozilla.org"
]);
run_next_test();
});