Bug 855638 - Part 2: Remove previous calls to PlacesUtils.backups and move them to PlacesBackups. r=mak

This commit is contained in:
Raymond Lee 2013-04-17 14:10:02 +08:00
parent 77e95e32b8
commit 97e36a07a6
4 changed files with 17 additions and 14 deletions

View File

@ -10,7 +10,7 @@ function run_test() {
do_test_pending();
// Get bookmarkBackups directory
var bookmarksBackupDir = PlacesUtils.backups.folder;
var bookmarksBackupDir = PlacesBackups.folder;
// Create an html dummy backup in the past
var htmlBackupFile = bookmarksBackupDir.clone();
@ -31,7 +31,7 @@ function run_test() {
do_check_true(jsonBackupFile.exists());
// Export bookmarks to JSON.
var backupFilename = PlacesUtils.backups.getFilenameForDate();
var backupFilename = PlacesBackups.getFilenameForDate();
var lastBackupFile = bookmarksBackupDir.clone();
lastBackupFile.append(backupFilename);
if (lastBackupFile.exists())
@ -39,7 +39,7 @@ function run_test() {
do_check_false(lastBackupFile.exists());
Task.spawn(function() {
yield PlacesUtils.backups.create(NUMBER_OF_BACKUPS);
yield PlacesBackups.create(NUMBER_OF_BACKUPS);
do_check_true(lastBackupFile.exists());
// Check that last backup has been retained

View File

@ -7,7 +7,7 @@
function run_test() {
do_test_pending();
let bookmarksBackupDir = PlacesUtils.backups.folder;
let bookmarksBackupDir = PlacesBackups.folder;
// Remove all files from backups folder.
let files = bookmarksBackupDir.directoryEntries;
while (files.hasMoreElements()) {
@ -18,7 +18,7 @@ function run_test() {
// Create a json dummy backup in the future.
let dateObj = new Date();
dateObj.setYear(dateObj.getFullYear() + 1);
let name = PlacesUtils.backups.getFilenameForDate(dateObj);
let name = PlacesBackups.getFilenameForDate(dateObj);
do_check_eq(name, "bookmarks-" + dateObj.toLocaleFormat("%Y-%m-%d") + ".json");
let futureBackupFile = bookmarksBackupDir.clone();
futureBackupFile.append(name);
@ -28,15 +28,15 @@ function run_test() {
futureBackupFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0600);
do_check_true(futureBackupFile.exists());
do_check_eq(PlacesUtils.backups.entries.length, 0);
do_check_eq(PlacesBackups.entries.length, 0);
Task.spawn(function() {
yield PlacesUtils.backups.create();
yield PlacesBackups.create();
// Check that a backup for today has been created.
do_check_eq(PlacesUtils.backups.entries.length, 1);
let mostRecentBackupFile = PlacesUtils.backups.getMostRecent();
do_check_eq(PlacesBackups.entries.length, 1);
let mostRecentBackupFile = PlacesBackups.getMostRecent();
do_check_neq(mostRecentBackupFile, null);
let todayName = PlacesUtils.backups.getFilenameForDate();
let todayName = PlacesBackups.getFilenameForDate();
do_check_eq(mostRecentBackupFile.leafName, todayName);
// Check that future backup has been removed.

View File

@ -33,10 +33,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkJSONUtils",
"resource://gre/modules/BookmarkJSONUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesBackups",
"resource://gre/modules/PlacesBackups.jsm");
// This imports various other objects in addition to PlacesUtils.
Cu.import("resource://gre/modules/PlacesUtils.jsm");
Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "SMALLPNG_DATA_URI", function() {
return NetUtil.newURI(

View File

@ -33,7 +33,7 @@ function run_test() {
dates.sort();
// Get and cleanup the backups folder.
var bookmarksBackupDir = PlacesUtils.backups.folder;
var bookmarksBackupDir = PlacesBackups.folder;
// Fake backups are created backwards to ensure we won't consider file
// creation time.
@ -58,7 +58,7 @@ function run_test() {
}
Task.spawn(function() {
yield PlacesUtils.backups.create(Math.floor(dates.length/2));
yield PlacesBackups.create(Math.floor(dates.length/2));
// Add today's backup.
dates.push(dateObj.toLocaleFormat("%Y-%m-%d"));
@ -84,7 +84,7 @@ function run_test() {
bookmarksBackupDir.remove(true);
do_check_false(bookmarksBackupDir.exists());
// Recreate the folder.
PlacesUtils.backups.folder;
PlacesBackups.folder;
do_test_finished();
});