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