Closed Bug 376630 Opened 17 years ago Closed 17 years ago

Test sorting functionality

Categories

(Firefox :: Bookmarks & History, defect, P2)

defect

Tracking

()

RESOLVED FIXED
Firefox 3 alpha4

People

(Reporter: asaf, Assigned: asaf)

References

Details

(Whiteboard: [a5])

Attachments

(1 file, 1 obsolete file)

It seems like we have no tests for querying with SORT_*.
Depends on: 376633
Depends on: 377500
Depends on: 376851
Depends on: 378802
Depends on: 378808
Depends on: 378816
Attached patch initial tests (obsolete) — Splinter Review
Assignee: nobody → mano
Status: NEW → ASSIGNED
Attachment #262838 - Flags: review?(dietrich)
Priority: -- → P2
Whiteboard: [a5]
Target Milestone: --- → Firefox 3 alpha4
Comment on attachment 262838 [details] [diff] [review]
initial tests


r=me, a typo and some spelling nits below

>+
>+// adds a test URI visit to the database
>+function add_visit(aURI, aTime) {
>+  vhistsvc.addVisit(aURI,
>+                    aTime,
>+                    0, // no referrer
>+                    histsvc.TRANSITION_TYPED, // user typed in URL bar
>+                    false, // not redirect
>+                    0);

s/vhistsvc/histsvc/

probably not the cause of the crash, but certainly shouldn't work as is :)

>+}
>+
>+// main
>+function run_test() {
>+  var testRoot = bmsvc.createFolder(root,
>+                                    "Result-sort functionality tests root",
>+                                    bmsvc.DEFAULT_INDEX);
>+  var uri1 = uri("http://foo.tld/a");
>+  var uri2 = uri("http://foo.tld/b");
>+  var id1 = bmsvc.insertItem(testRoot, uri1, bmsvc.DEFAULT_INDEX);
>+  bmsvc.setItemTitle(id1, "b");
>+  var id2 = bmsvc.insertItem(testRoot, uri2, bmsvc.DEFAULT_INDEX);
>+  bmsvc.setItemTitle(id2, "a");
>+
>+  // url of id1, title of id2
>+  var id3 = bmsvc.insertItem(testRoot, uri1, bmsvc.DEFAULT_INDEX);
>+  bmsvc.setItemTitle(id3, "a");
>+
>+  // this crashes - Bug 378820
>+  //add_visit(uri2, Data.now());
>+
>+  // query with natural order
>+  var options = histsvc.getNewQueryOptions();
>+  var query = histsvc.getNewQuery();
>+  query.setFolders([testRoot], 1);
>+  var result = histsvc.executeQuery(query, options);
>+  var root = result.root;
>+  root.containerOpen = true;
>+
>+  do_check_eq(root.childCount, 3);
>+
>+  const NHQO = Ci.nsINavHistoryQueryOptions;
>+
>+  function checkOrder(a, b, c) {
>+    do_check_eq(root.getChild(0).bookmarkId, a);
>+    do_check_eq(root.getChild(1).bookmarkId, b);
>+    do_check_eq(root.getChild(2).bookmarkId, c);
>+  }
>+
>+  // natural order
>+  checkOrder(id1, id2, id3);
>+
>+  // title: id3 should precede id2 since we fall-back to URI-based sorting
>+  result.sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
>+  checkOrder(id3, id2, id1);
>+
>+  // In reverse
>+  result.sortingMode = NHQO.SORT_BY_TITLE_DESCENDING;
>+  checkOrder(id1, id2, id3);
>+
>+  // uri sort: id1 should precede id3 since we fall-back to natural order
>+  result.sortingMode = NHQO.SORT_BY_URI_ASCENDING;
>+  checkOrder(id1, id3, id2);
>+
>+  // test live update
>+  bmsvc.changeBookmarkURI(id1, uri2);
>+  checkOrder(id3, id1, id2);
>+  bmsvc.changeBookmarkURI(id1, uri1);
>+  checkOrder(id1, id3, id2);
>+
>+  // XXXtodo: test histroy sortings (visit count, visit date)

s/histroy/history/

>+  // XXXtodo: test different item types once folderId and bookmarkId are merged.
>+
>+  annosvc.setAnnotationString(bmsvc.getItemURI(id1), "testAnno", "a", 0, 0);
>+  annosvc.setAnnotationString(bmsvc.getItemURI(id3), "testAnno", "b", 0, 0);
>+  result.sortingAnnotation = "testAnno";
>+  result.sortingMode = NHQO.SORT_BY_ANNOTATION_DESCENDING;
>+
>+  // id1 precedes id2 per title-descendeing fallback
>+  checkOrder(id3, id1, id2);

s/descendeing/descending/

>+  
>+  // diffrent annotation types, we fall back to the title sorting route
>+  annosvc.setAnnotationInt32(bmsvc.getItemURI(id3), "testAnno", 10, 0, 0);
>+

s/diffrent/different/

>+  // XXXtodo: test live update for sortingAnnotation (not yet implemented);
>+  // manually force sort for now...
>+  result.sortingMode = result.sortingMode;
>+  checkOrder(id1, id2, id3);
>+}
Attachment #262838 - Flags: review?(dietrich) → review+
Attached patch as checked inSplinter Review
mozilla/toolkit/components/places/tests/unit/test_result_sort.js initial revision: 1.1
Attachment #262838 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Flags: in-testsuite+
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h".

In Thunderbird 3.0b, you do that as follows:
Tools | Message Filters
Make sure the correct account is selected. Click "New"
Conditions: Body   contains   places-to-b-and-h
Change the action to "Delete Message".
Select "Manually Run" from the dropdown at the top.
Click OK.

Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter.

Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: