Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1613)

Unified Diff: chrome/browser/history/shortcuts_database_unittest.cc

Issue 134853004: Migrate old Shortcuts DB data to conform to new type values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Peter's comments - 2 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/shortcuts_database_unittest.cc
diff --git a/chrome/browser/history/shortcuts_database_unittest.cc b/chrome/browser/history/shortcuts_database_unittest.cc
index bc270c3e361fb7e55059c79996db5ffe42fc0938..18603bba47df0c8c595fb97dd09ab5e08fb62618 100644
--- a/chrome/browser/history/shortcuts_database_unittest.cc
+++ b/chrome/browser/history/shortcuts_database_unittest.cc
@@ -299,4 +299,33 @@ TEST(ShortcutsDatabaseMigrationTest, MigrateV1ToV2) {
EXPECT_TRUE(statement.Succeeded());
}
+TEST(ShortcutsDatabaseMigrationTest, MigrateV2ToV3) {
Peter Kasting 2014/02/12 00:27:50 Nit: Hmm, I see we're using "v2" and "v3" here bec
Anuj 2014/02/12 23:54:40 I think we are caught in a no good-names situation
+ // Open the v1 test file and use it to create a test database in a temp dir.
+ base::FilePath sql_path;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &sql_path));
+ sql_path = sql_path.AppendASCII("History").AppendASCII("Shortcuts.v2.sql");
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ base::FilePath db_path(temp_dir.path().AppendASCII("TestShortcuts.db"));
+ ASSERT_TRUE(sql::test::CreateDatabaseFromSQL(db_path, sql_path));
+
+ // Create a ShortcutsDatabase from the test database, which will migrate the
+ // test database to the current version.
+ {
+ scoped_refptr<ShortcutsDatabase> db(new ShortcutsDatabase(db_path));
+ db->Init();
+ }
+
+ // Check the values in each of the new columns.
Peter Kasting 2014/02/12 00:27:50 Nit: Maybe "Check that all the old type values got
Anuj 2014/02/12 23:54:40 Done.
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(db_path));
+ sql::Statement statement(connection.GetUniqueStatement(
+ "SELECT count(1) FROM omni_box_shortcuts WHERE type in (9, 10, 11, 12)"));
+ ASSERT_TRUE(statement.is_valid());
+ while (statement.Step()) {
Peter Kasting 2014/02/12 00:27:50 Nit: {} not necessary
Anuj 2014/02/12 23:54:40 Done.
+ EXPECT_EQ(0, statement.ColumnInt(0));
+ }
+ EXPECT_TRUE(statement.Succeeded());
+}
+
} // namespace history

Powered by Google App Engine
This is Rietveld 408576698