From 4d747d88f11765b152a8d4a0c60aae3df7ca0469 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 21 Aug 2009 11:53:59 +0200 Subject: [PATCH] Bug 511374 - fix test_results-as-visit.js, r=dietrich --- .../components/places/src/nsNavHistory.cpp | 1 - .../places/tests/queries/head_queries.js | 4 ++ .../tests/queries/test_results-as-visit.js | 68 +++++++++++-------- 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/toolkit/components/places/src/nsNavHistory.cpp b/toolkit/components/places/src/nsNavHistory.cpp index b59774c4947..58a173fc3ba 100644 --- a/toolkit/components/places/src/nsNavHistory.cpp +++ b/toolkit/components/places/src/nsNavHistory.cpp @@ -3321,7 +3321,6 @@ PlacesSQLQueryBuilder::SelectAsVisit() "WHERE h.id NOT IN (SELECT id FROM moz_places_temp) " "{QUERY_OPTIONS_VISITS} {QUERY_OPTIONS_PLACES} " "{ADDITIONAL_CONDITIONS} " - "AND h.id NOT IN (SELECT id FROM moz_places_temp) " "UNION ALL " "SELECT h.id, h.url, h.title, h.rev_host, h.visit_count, " "v.visit_date, f.url, v.session, null " diff --git a/toolkit/components/places/tests/queries/head_queries.js b/toolkit/components/places/tests/queries/head_queries.js index 8ca121257b8..2cf5944dc0b 100644 --- a/toolkit/components/places/tests/queries/head_queries.js +++ b/toolkit/components/places/tests/queries/head_queries.js @@ -176,6 +176,8 @@ function populateDB(aArray) { stmt.params.url = qdata.uri; try { stmt.execute(); + // Force a notification so results are updated. + histsvc.runInBatchMode({runBatched: function(){}}, null); } finally { stmt.finalize(); @@ -193,6 +195,8 @@ function populateDB(aArray) { stmt.params.url = qdata.uri; try { stmt.execute(); + // Force a notification so results are updated. + histsvc.runInBatchMode({runBatched: function(){}}, null); } finally { stmt.finalize(); diff --git a/toolkit/components/places/tests/queries/test_results-as-visit.js b/toolkit/components/places/tests/queries/test_results-as-visit.js index 4b640ce1cd3..874632e81ec 100644 --- a/toolkit/components/places/tests/queries/test_results-as-visit.js +++ b/toolkit/components/places/tests/queries/test_results-as-visit.js @@ -36,24 +36,28 @@ * * ***** END LICENSE BLOCK ***** */ var testData = []; - +var now = Date.now() * 1000; function createTestData() { - function generateVisits(aObj, aNum) { - for(var i=0; i < aNum; i++) - testData.push(aObj); + function generateVisits(aPage) { + for (var i = 0; i < aPage.visitCount; i++) { + testData.push({ isInQuery: aPage.inQuery, + isVisit: true, + title: aPage.title, + uri: aPage.uri, + lastVisit: now++, + isTag: aPage.tags && aPage.tags.length > 0, + tagArray: aPage.tags }); + } } - generateVisits({isInQuery: true, isDetails: true, title: "amo", - uri: "http://foo.com/", lastVisit: lastweek, isTag: true, - tagArray: ["moz"]}, 3); - generateVisits({isInQuery: true, isDetails: true, isTag: true, - title: "bMoz", tagArray: ["bugzilla"], uri: "http://moilla.com/", - lastVisit: yesterday}, 5); - generateVisits({isInQuery: true, isDetails: true, title: "C Moz", - uri: "http://foo.mail.com/changeme1.html"}, 7); - generateVisits({isInQuery: false, isVisit: true, isTag: true, tagArray: ["moz"], - uri: "http://foo.change.co/changeme2.html"}, 1); - generateVisits({isInQuery: false, isVisit: true, isDetails: true, - title: "zydeco", uri: "http://foo.com/changeme3.html"}, 5); + + var pages = [ + { uri: "http://foo.com/", title: "amo", tags: ["moz"], visitCount: 3, inQuery: true }, + { uri: "http://moilla.com/", title: "bMoz", tags: ["bugzilla"], visitCount: 5, inQuery: true }, + { uri: "http://foo.mail.com/changeme1.html", title: "c Moz", visitCount: 7, inQuery: true }, + { uri: "http://foo.mail.com/changeme2.html", tags: ["moz"], title: "", visitCount: 1, inQuery: false }, + { uri: "http://foo.mail.com/changeme3.html", title: "zydeco", visitCount: 5, inQuery: false }, + ]; + pages.forEach(generateVisits); } /** @@ -89,8 +93,9 @@ function createTestData() { LOG("Adding item to query") var tmp = []; for (var i=0; i < 2; i++) { - tmp.push({isVisit: true, isDetails: true, uri: "http://foo.com/added.html", - title: "ab moz"}); + tmp.push({ isVisit: true, + uri: "http://foo.com/added.html", + title: "ab moz" }); } populateDB(tmp); for (var i=0; i < 2; i++) @@ -98,8 +103,9 @@ function createTestData() { // Update an existing URI LOG("Updating Item"); - var change2 = [{isVisit: true, isDetails: true, title: "moz", - uri: "http://foo.change.co/changeme2.html"}]; + var change2 = [{ isVisit: true, + title: "moz", + uri: "http://foo.mail.com/changeme2.html" }]; populateDB(change2); do_check_true(isInResult(change2, root)); @@ -108,21 +114,29 @@ function createTestData() { LOG("Updating Items in batch"); var updateBatch = { runBatched: function (aUserData) { - batchchange = [{isDetails: true, uri: "http://foo.mail.com/changeme1.html", - title: "foo"}, - {isTag: true, uri: "http://foo.com/changeme3.html", - tagArray: ["foo", "moz"]}]; + batchchange = [{ isVisit: true, + lastVisit: now++, + uri: "http://foo.mail.com/changeme1.html", + title: "foo"}, + { isVisit: true, + lastVisit: now++, + uri: "http://foo.mail.com/changeme3.html", + title: "moz", + isTag: true, + tagArray: ["foo", "moz"] }]; populateDB(batchchange); } }; histsvc.runInBatchMode(updateBatch, null); do_check_false(isInResult({uri: "http://foo.mail.com/changeme1.html"}, root)); - do_check_true(isInResult({uri: "http://foo.com/changeme3.html"}, root)); + do_check_true(isInResult({uri: "http://foo.mail.com/changeme3.html"}, root)); // And now, delete one LOG("Delete item outside of batch"); - var change4 = [{isDetails: true, uri: "http://moilla.com/", - title: "mo,z"}]; + var change4 = [{ isVisit: true, + lastVisit: now++, + uri: "http://moilla.com/", + title: "mo,z" }]; populateDB(change4); do_check_false(isInResult(change4, root)); }