From c7939cf0be952ba24e8f2ee5038bc96c0cd0529e Mon Sep 17 00:00:00 2001 From: Philipp von Weitershausen Date: Fri, 19 Aug 2011 10:11:37 -0700 Subject: [PATCH] Bug 676110 - Part 2: Tests for mozIVisitInfoCallback::handleCompletion. r=mak --HG-- extra : rebase_source : d8ca2890775656618ada8417610c5e026cd7aa63 --- .../tests/unit/test_async_history_api.js | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/toolkit/components/places/tests/unit/test_async_history_api.js b/toolkit/components/places/tests/unit/test_async_history_api.js index a4c006bdd0e6..6e9822059a73 100644 --- a/toolkit/components/places/tests/unit/test_async_history_api.js +++ b/toolkit/components/places/tests/unit/test_async_history_api.js @@ -17,7 +17,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gGlobalHistory", "nsIGlobalHistory2"); const TEST_DOMAIN = "http://mozilla.org/"; -const TOPIC_UPDATEPLACES_COMPLETE = "places-updatePlaces-complete"; const URI_VISIT_SAVED = "uri-visit-saved"; const RECENT_EVENT_THRESHOLD = 15 * 60 * 1000000; @@ -742,14 +741,14 @@ function test_place_id_ignored() })); } -function test_observer_topic_dispatched_when_complete() +function test_handleCompletion_called_when_complete() { // We test a normal visit, and embeded visit, and a uri that would fail // the canAddURI test to make sure that the notification happens after *all* // of them have had a callback. let places = [ { uri: NetUtil.newURI(TEST_DOMAIN + - "test_observer_topic_dispatched_when_complete"), + "test_handleCompletion_called_when_complete"), visits: [ new VisitInfo(), new VisitInfo(TRANSITION_EMBED), @@ -777,20 +776,13 @@ function test_observer_topic_dispatched_when_complete() }, handleError: function handleError(aResultCode, aPlaceInfo) { callbackCountFailure++; - } - }); - - let observer = { - observe: function(aSubject, aTopic, aData) - { - do_check_eq(aTopic, TOPIC_UPDATEPLACES_COMPLETE); + }, + handleCompletion: function handleCompletion() { do_check_eq(callbackCountSuccess, EXPECTED_COUNT_SUCCESS); do_check_eq(callbackCountFailure, EXPECTED_COUNT_FAILURE); - Services.obs.removeObserver(observer, TOPIC_UPDATEPLACES_COMPLETE); waitForAsyncUpdates(run_next_test); }, - }; - Services.obs.addObserver(observer, TOPIC_UPDATEPLACES_COMPLETE, false); + }); } function test_add_visit() @@ -1300,15 +1292,8 @@ function test_callbacks_not_supplied() } }); - gHistory.updatePlaces(places, {} ); - let observer = { - observe: function(aSubject, aTopic, aData) - { - Services.obs.removeObserver(observer, TOPIC_UPDATEPLACES_COMPLETE); - waitForAsyncUpdates(run_next_test); - }, - }; - Services.obs.addObserver(observer, TOPIC_UPDATEPLACES_COMPLETE, false); + gHistory.updatePlaces(places, {}); + waitForAsyncUpdates(run_next_test); } //////////////////////////////////////////////////////////////////////////////// @@ -1333,7 +1318,7 @@ function test_callbacks_not_supplied() test_unstored_sessionId_ignored, test_old_referrer_ignored, test_place_id_ignored, - test_observer_topic_dispatched_when_complete, + test_handleCompletion_called_when_complete, test_add_visit, test_properties_saved, test_guid_saved,