From 889655656119098af4919b5e1096a8d82df77fc6 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 29 Apr 2011 18:12:23 +0200 Subject: [PATCH] Bug 619623 - Disable Idle Service to check if it's related with the intermittent failure. r=sdwilsh --- .../tests/cpp/places_test_harness_tail.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/toolkit/components/places/tests/cpp/places_test_harness_tail.h b/toolkit/components/places/tests/cpp/places_test_harness_tail.h index 98baa192a56d..4a523d70aa49 100644 --- a/toolkit/components/places/tests/cpp/places_test_harness_tail.h +++ b/toolkit/components/places/tests/cpp/places_test_harness_tail.h @@ -37,6 +37,9 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsWidgetsCID.h" +#include "nsIComponentRegistrar.h" + #ifndef TEST_NAME #error "Must #define TEST_NAME before including places_test_harness_tail.h" #endif @@ -92,12 +95,31 @@ do_test_finished() gPendingTests--; } +void +disable_idle_service() +{ + (void)fprintf(stderr, TEST_INFO_STR "Disabling Idle Service.\n", TEST_FILE); + static NS_DEFINE_IID(kIdleCID, NS_IDLE_SERVICE_CID); + nsresult rv; + nsCOMPtr idleFactory = do_GetClassObject(kIdleCID, &rv); + do_check_success(rv); + nsCOMPtr registrar; + rv = NS_GetComponentRegistrar(getter_AddRefs(registrar)); + do_check_success(rv); + rv = registrar->UnregisterFactory(kIdleCID, idleFactory); + do_check_success(rv); +} + int main(int aArgc, char** aArgv) { ScopedXPCOM xpcom(TEST_NAME); + // Tinderboxes are constantly on idle. Since idle tasks can interact with + // tests, causing random failures, disable the idle service. + disable_idle_service(); + do_test_pending(); run_next_test();