toolkit/components/places/tests/unit/test_preventive_maintenance_runTasks.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/unit/test_preventive_maintenance_runTasks.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 + /**
     1.9 +  * Test preventive maintenance runTasks.
    1.10 +  */
    1.11 +
    1.12 +// Include PlacesDBUtils module.
    1.13 +Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
    1.14 +
    1.15 +function run_test() {
    1.16 +  do_test_pending();
    1.17 +  PlacesDBUtils.runTasks([PlacesDBUtils.reindex], function(aLog) {
    1.18 +    let sections = [];
    1.19 +    let positives = [];
    1.20 +    let negatives = [];
    1.21 +    let infos = [];
    1.22 +
    1.23 +    aLog.forEach(function (aMsg) {
    1.24 +      print (aMsg);
    1.25 +      switch (aMsg.substr(0, 1)) {
    1.26 +        case "+":
    1.27 +          positives.push(aMsg);
    1.28 +          break;
    1.29 +        case "-":
    1.30 +          negatives.push(aMsg);
    1.31 +          break;
    1.32 +        case ">":
    1.33 +          sections.push(aMsg);
    1.34 +          break;
    1.35 +        default:
    1.36 +          infos.push(aMsg);
    1.37 +      }
    1.38 +    });
    1.39 +
    1.40 +    print("Check that we have run all sections.");
    1.41 +    do_check_eq(sections.length, 1);
    1.42 +    print("Check that we have no negatives.");
    1.43 +    do_check_false(!!negatives.length);
    1.44 +    print("Check that we have positives.");
    1.45 +    do_check_true(!!positives.length);
    1.46 +
    1.47 +    do_test_finished();
    1.48 +  });
    1.49 +}

mercurial