test for Bug 473157 - Want to sort history in container view without sorting the containers, r=mak77 a191=tests-only
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Wed, 15 Apr 2009 22:24:42 +0200
changeset 24729 21a56d7f1497097af40fdf5f0943b2379516d665
parent 24728 58c8ebe9c2680bd1c2605ce0c4e779231cb3d1af
child 24730 c51d6084775c32a3a7d9ac98d6713685a6b2eb32
push id1205
push usermak77@bonardo.net
push dateWed, 15 Apr 2009 20:25:28 +0000
reviewersmak77
bugs473157
milestone1.9.1b4pre
test for Bug 473157 - Want to sort history in container view without sorting the containers, r=mak77 a191=tests-only
toolkit/components/places/tests/unit/test_history_sidebar.js
--- a/toolkit/components/places/tests/unit/test_history_sidebar.js
+++ b/toolkit/components/places/tests/unit/test_history_sidebar.js
@@ -209,16 +209,41 @@ function test_RESULTS_AS_DATE_SITE_QUERY
 
   site1.containerOpen = true;
   do_check_eq(site1.childCount, 2);
 
   // Inside of host sites are sorted by title
   var site1visit = site1.getChild(0);
   do_check_eq(site1visit.uri, "http://mirror0.google.com/a");
 
+  // Bug 473157: changing sorting mode should not affect the containers
+  result.sortingMode = options.SORT_BY_TITLE_DESCENDING;
+
+  // Check one of the days
+  var dayNode = root.getChild(0)
+                    .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  dayNode.containerOpen = true;
+  do_check_eq(dayNode.childCount, 2);
+
+  // Hosts are still sorted by title
+  var site1 = dayNode.getChild(0)
+                     .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  do_check_eq(site1.title, "mirror0.google.com");
+
+  var site2 = dayNode.getChild(1)
+                     .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  do_check_eq(site2.title, "mirror0.mozilla.com");
+
+  site1.containerOpen = true;
+  do_check_eq(site1.childCount, 2);
+
+  // But URLs are now sorted by title descending
+  var site1visit = site1.getChild(0);
+  do_check_eq(site1visit.uri, "http://mirror0.google.com/b");
+
   site1.containerOpen = false;
   dayNode.containerOpen = false;
   root.containerOpen = false;
 }
 
 /**
  * Queries history grouped by date, checking containers' labels and children.
  */
@@ -250,16 +275,32 @@ function test_RESULTS_AS_DATE_QUERY() {
 
   // Items should be sorted by title
   var visit1 = dayNode.getChild(0);
   do_check_eq(visit1.uri, "http://mirror0.google.com/a");
 
   var visit2 = dayNode.getChild(3);
   do_check_eq(visit2.uri, "http://mirror0.mozilla.com/b");
 
+  // Bug 473157: changing sorting mode should not affect the containers
+  result.sortingMode = options.SORT_BY_TITLE_DESCENDING;
+
+  // Check one of the days
+  var dayNode = root.getChild(0)
+                    .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  dayNode.containerOpen = true;
+  do_check_eq(dayNode.childCount, 4);
+
+  // But URLs are now sorted by title descending
+  var visit1 = dayNode.getChild(0);
+  do_check_eq(visit1.uri, "http://mirror0.mozilla.com/b");
+
+  var visit2 = dayNode.getChild(3);
+  do_check_eq(visit2.uri, "http://mirror0.google.com/a");
+
   dayNode.containerOpen = false;
   root.containerOpen = false;
 }
 
 /**
  * Queries history grouped by site, checking containers' labels and children.
  */
 function test_RESULTS_AS_SITE_QUERY() {
@@ -299,16 +340,29 @@ function test_RESULTS_AS_SITE_QUERY() {
 
   siteNode.containerOpen = true;
   do_check_eq(siteNode.childCount, 2);
 
   // Inside of host sites are sorted by title
   var visitNode = siteNode.getChild(0);
   do_check_eq(visitNode.uri, "http://mirror3.google.com/a");
 
+  // Bug 473157: changing sorting mode should not affect the containers
+  result.sortingMode = options.SORT_BY_TITLE_DESCENDING;
+  var siteNode = root.getChild(6)
+                     .QueryInterface(Ci.nsINavHistoryContainerResultNode);
+  do_check_eq(siteNode.title, "mirror3.google.com");
+
+  siteNode.containerOpen = true;
+  do_check_eq(siteNode.childCount, 2);
+
+  // But URLs are now sorted by title descending
+  var visit = siteNode.getChild(0);
+  do_check_eq(visit.uri, "http://mirror3.google.com/b");
+
   siteNode.containerOpen = false;
   root.containerOpen = false;
 
   // Cleanup.
   bs.removeItem(itemId);
 }
 
 /**