Bug 676110 - Part 2: Tests for mozIVisitInfoCallback::handleCompletion. r=mak

--HG--
extra : rebase_source : d8ca2890775656618ada8417610c5e026cd7aa63
This commit is contained in:
Philipp von Weitershausen 2011-08-19 10:11:37 -07:00
Родитель 66e3b5d80d
Коммит c7939cf0be
1 изменённых файлов: 8 добавлений и 23 удалений

Просмотреть файл

@ -17,7 +17,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gGlobalHistory",
"nsIGlobalHistory2"); "nsIGlobalHistory2");
const TEST_DOMAIN = "http://mozilla.org/"; const TEST_DOMAIN = "http://mozilla.org/";
const TOPIC_UPDATEPLACES_COMPLETE = "places-updatePlaces-complete";
const URI_VISIT_SAVED = "uri-visit-saved"; const URI_VISIT_SAVED = "uri-visit-saved";
const RECENT_EVENT_THRESHOLD = 15 * 60 * 1000000; 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 // 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* // the canAddURI test to make sure that the notification happens after *all*
// of them have had a callback. // of them have had a callback.
let places = [ let places = [
{ uri: NetUtil.newURI(TEST_DOMAIN + { uri: NetUtil.newURI(TEST_DOMAIN +
"test_observer_topic_dispatched_when_complete"), "test_handleCompletion_called_when_complete"),
visits: [ visits: [
new VisitInfo(), new VisitInfo(),
new VisitInfo(TRANSITION_EMBED), new VisitInfo(TRANSITION_EMBED),
@ -777,20 +776,13 @@ function test_observer_topic_dispatched_when_complete()
}, },
handleError: function handleError(aResultCode, aPlaceInfo) { handleError: function handleError(aResultCode, aPlaceInfo) {
callbackCountFailure++; callbackCountFailure++;
} },
}); handleCompletion: function handleCompletion() {
let observer = {
observe: function(aSubject, aTopic, aData)
{
do_check_eq(aTopic, TOPIC_UPDATEPLACES_COMPLETE);
do_check_eq(callbackCountSuccess, EXPECTED_COUNT_SUCCESS); do_check_eq(callbackCountSuccess, EXPECTED_COUNT_SUCCESS);
do_check_eq(callbackCountFailure, EXPECTED_COUNT_FAILURE); do_check_eq(callbackCountFailure, EXPECTED_COUNT_FAILURE);
Services.obs.removeObserver(observer, TOPIC_UPDATEPLACES_COMPLETE);
waitForAsyncUpdates(run_next_test); waitForAsyncUpdates(run_next_test);
}, },
}; });
Services.obs.addObserver(observer, TOPIC_UPDATEPLACES_COMPLETE, false);
} }
function test_add_visit() function test_add_visit()
@ -1300,15 +1292,8 @@ function test_callbacks_not_supplied()
} }
}); });
gHistory.updatePlaces(places, {} ); gHistory.updatePlaces(places, {});
let observer = { waitForAsyncUpdates(run_next_test);
observe: function(aSubject, aTopic, aData)
{
Services.obs.removeObserver(observer, TOPIC_UPDATEPLACES_COMPLETE);
waitForAsyncUpdates(run_next_test);
},
};
Services.obs.addObserver(observer, TOPIC_UPDATEPLACES_COMPLETE, false);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -1333,7 +1318,7 @@ function test_callbacks_not_supplied()
test_unstored_sessionId_ignored, test_unstored_sessionId_ignored,
test_old_referrer_ignored, test_old_referrer_ignored,
test_place_id_ignored, test_place_id_ignored,
test_observer_topic_dispatched_when_complete, test_handleCompletion_called_when_complete,
test_add_visit, test_add_visit,
test_properties_saved, test_properties_saved,
test_guid_saved, test_guid_saved,