michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // This file tests migration from v5 to v6 michael@0: michael@0: function run_test() michael@0: { michael@0: // First import the downloads.sqlite file michael@0: importDatabaseFile("v5.sqlite"); michael@0: michael@0: // ok, now it is OK to init the download manager - this will perform the michael@0: // migration! michael@0: var dm = Cc["@mozilla.org/download-manager;1"]. michael@0: getService(Ci.nsIDownloadManager); michael@0: var dbConn = dm.DBConnection; michael@0: michael@0: // check schema version michael@0: do_check_true(dbConn.schemaVersion >= 6); michael@0: michael@0: // Check that the columns exist (no throw) and entries are correct michael@0: var stmt = dbConn.createStatement( michael@0: "SELECT name, source, target, startTime, endTime, state, referrer, " + michael@0: "entityID, tempPath, currBytes, maxBytes " + michael@0: "FROM moz_downloads " + michael@0: "WHERE id = 27"); michael@0: stmt.executeStep(); michael@0: do_check_eq("Firefox 2.0.0.6.dmg", stmt.getString(0)); michael@0: do_check_eq("http://ftp-mozilla.netscape.com/pub/mozilla.org/firefox/releases/2.0.0.6/mac/en-US/Firefox%202.0.0.6.dmg", michael@0: stmt.getUTF8String(1)); michael@0: do_check_eq("file:///Users/sdwilsh/Desktop/Firefox%202.0.0.6.dmg", michael@0: stmt.getUTF8String(2)); michael@0: do_check_eq(1187390974170783, stmt.getInt64(3)); michael@0: do_check_eq(1187391001257446, stmt.getInt64(4)); michael@0: do_check_eq(1, stmt.getInt32(5)); michael@0: do_check_eq("http://www.mozilla.com/en-US/products/download.html?product=firefox-2.0.0.6&os=osx&lang=en-US",stmt.getUTF8String(6)); michael@0: do_check_true(stmt.getIsNull(7)); michael@0: do_check_true(stmt.getIsNull(8)); michael@0: do_check_eq(0, stmt.getInt64(9)); michael@0: do_check_eq(-1, stmt.getInt64(10)); michael@0: stmt.finalize(); michael@0: michael@0: cleanup(); michael@0: }