Chromium Code Reviews| Index: chrome/browser/webdata/web_database_migration_unittest.cc |
| =================================================================== |
| --- chrome/browser/webdata/web_database_migration_unittest.cc (revision 135424) |
| +++ chrome/browser/webdata/web_database_migration_unittest.cc (working copy) |
| @@ -194,7 +194,7 @@ |
| DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); |
| }; |
| -const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 44; |
| +const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 45; |
| void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) { |
| std::string contents; |
| @@ -303,7 +303,6 @@ |
| ASSERT_TRUE( |
| connection.DoesColumnExist("credit_cards", "card_number_encrypted")); |
| ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); |
| - ASSERT_FALSE(connection.DoesColumnExist("keywords", "logo_id")); |
| } |
| // Load the database via the WebDatabase class and migrate the database to |
| @@ -329,50 +328,9 @@ |
| EXPECT_TRUE( |
| connection.DoesColumnExist("credit_cards", "card_number_encrypted")); |
| EXPECT_TRUE(connection.DoesColumnExist("keywords", "id")); |
| - EXPECT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); |
| } |
| } |
| -// Tests that the |keywords| |logo_id| column gets added to the schema for a |
| -// version 24 database. |
| -TEST_F(WebDatabaseMigrationTest, MigrateVersion24ToCurrent) { |
| - // This schema is taken from a build prior to the addition of the |keywords| |
| - // |logo_id| column. |
| - ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_24.sql"))); |
| - |
| - // Verify pre-conditions. These are expectations for version 24 of the |
| - // database. |
| - { |
| - sql::Connection connection; |
| - ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| - |
| - // Columns existing and not existing before current version. |
| - ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); |
| - ASSERT_FALSE(connection.DoesColumnExist("keywords", "logo_id")); |
| - } |
| - |
| - // Load the database via the WebDatabase class and migrate the database to |
| - // the current version. |
| - { |
| - WebDatabase db; |
| - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); |
| - } |
| - |
| - // Verify post-conditions. These are expectations for current version of the |
| - // database. |
| - { |
| - sql::Connection connection; |
| - ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| - |
| - // Check version. |
| - EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
| - |
| - // |keywords| |logo_id| column should have been added. |
| - EXPECT_TRUE(connection.DoesColumnExist("keywords", "id")); |
| - EXPECT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); |
| - } |
| -} |
| - |
| // Tests that the |keywords| |created_by_policy| column gets added to the schema |
| // for a version 25 database. |
| TEST_F(WebDatabaseMigrationTest, MigrateVersion25ToCurrent) { |
| @@ -618,12 +576,10 @@ |
| EXPECT_EQ(std::string("{google:baseSuggestURL}search?client=chrome&hl=" |
| "{language}&q={searchTerms}"), s2.ColumnString(11)); |
| EXPECT_EQ(1, s2.ColumnInt(12)); |
| - EXPECT_TRUE(s2.ColumnBool(13)); |
| - EXPECT_EQ(6245, s2.ColumnInt(14)); |
| - EXPECT_FALSE(s2.ColumnBool(15)); |
| + EXPECT_EQ(false, s2.ColumnBool(13)); |
| + EXPECT_EQ(std::string(), s2.ColumnString(14)); |
| + EXPECT_EQ(0, s2.ColumnInt(15)); |
| EXPECT_EQ(std::string(), s2.ColumnString(16)); |
| - EXPECT_EQ(0, s2.ColumnInt(17)); |
| - EXPECT_EQ(std::string(), s2.ColumnString(18)); |
| } |
| } |
| @@ -1845,14 +1801,12 @@ |
| EXPECT_EQ("{google:baseSuggestURL}search?client=chrome&hl={language}&" |
| "q={searchTerms}", s.ColumnString(11)); |
| EXPECT_EQ(1, s.ColumnInt(12)); |
| - EXPECT_TRUE(s.ColumnBool(13)); |
| - EXPECT_EQ(6262, s.ColumnInt(14)); |
| - EXPECT_FALSE(s.ColumnBool(15)); |
| + EXPECT_EQ(false, s.ColumnBool(13)); |
| EXPECT_EQ("{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&" |
| "ie={inputEncoding}&ion=1{searchTerms}&nord=1", |
| - s.ColumnString(16)); |
| - EXPECT_EQ(0, s.ColumnInt(17)); |
| - EXPECT_EQ("{1234-5678-90AB-CDEF}", s.ColumnString(18)); |
| + s.ColumnString(14)); |
| + EXPECT_EQ(0, s.ColumnInt(15)); |
| + EXPECT_EQ("{1234-5678-90AB-CDEF}", s.ColumnString(16)); |
| EXPECT_FALSE(s.Step()); |
| } |
| @@ -1936,3 +1890,55 @@ |
| EXPECT_FALSE(default_search_provider_id_backup_signature.empty()); |
| } |
| } |
| + |
|
Ivan Korotkov
2012/05/07 20:56:49
This test has to be in #if !defined(GOOGLE_CHROME_
Peter Kasting
2012/05/08 00:37:06
Done.
|
| +// Tests that the |autogenerate_keyword| and |logo_id| columns get removed from |
| +// the keyword table schema for a version 45 database. |
| +TEST_F(WebDatabaseMigrationTest, MigrateVersion44ToCurrent) { |
| + ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_44.sql"))); |
|
Ivan Korotkov
2012/05/07 20:56:49
Can you please make a second unit-test with a diff
Peter Kasting
2012/05/08 00:37:06
Done.
|
| + |
| + // Verify pre-conditions. These are expectations for version 44 of the |
| + // database. |
| + { |
| + sql::Connection connection; |
| + ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| + ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
| + |
| + sql::MetaTable meta_table; |
| + ASSERT_TRUE(meta_table.Init(&connection, 44, 44)); |
| + |
| + ASSERT_TRUE(connection.DoesColumnExist("keywords", "autogenerate_keyword")); |
| + ASSERT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); |
| + } |
| + |
| + // Load the database via the WebDatabase class and migrate the database to |
| + // the current version. |
| + { |
| + WebDatabase db; |
| + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); |
|
Ivan Korotkov
2012/05/07 20:56:49
Since this migration affects protector, please add
Peter Kasting
2012/05/08 00:37:06
Done.
|
| + } |
| + |
| + // Verify post-conditions. These are expectations for current version of the |
| + // database. |
| + { |
| + sql::Connection connection; |
| + ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| + ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
| + |
| + // Check version. |
| + EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
| + |
| + sql::MetaTable meta_table; |
| + ASSERT_TRUE(meta_table.Init(&connection, kCurrentTestedVersionNumber, |
| + kCurrentTestedVersionNumber)); |
| + |
| + // We should have removed this obsolete key. |
| + std::string default_search_provider_backup; |
| + EXPECT_FALSE(meta_table.GetValue("Default Search Provider Backup", |
| + &default_search_provider_backup)); |
| + |
| + // Two columns should have been removed. |
| + EXPECT_FALSE(connection.DoesColumnExist("keywords", |
| + "autogenerate_keyword")); |
| + EXPECT_FALSE(connection.DoesColumnExist("keywords", "logo_id")); |
| + } |
|
Ivan Korotkov
2012/05/07 20:56:49
Please check in post-cond that keywords and keywor
Peter Kasting
2012/05/08 00:37:06
Done.
|
| +} |