| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <list> | 5 #include <list> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), | 1501 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), |
| 1502 ASCIIToUTF16("Open Road")); | 1502 ASCIIToUTF16("Open Road")); |
| 1503 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), | 1503 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), |
| 1504 ASCIIToUTF16("Route 66")); | 1504 ASCIIToUTF16("Route 66")); |
| 1505 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), | 1505 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), |
| 1506 ASCIIToUTF16("NFA")); | 1506 ASCIIToUTF16("NFA")); |
| 1507 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), ASCIIToUTF16("NY")); | 1507 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), ASCIIToUTF16("NY")); |
| 1508 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), | 1508 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), |
| 1509 ASCIIToUTF16("10011")); | 1509 ASCIIToUTF16("10011")); |
| 1510 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), | 1510 billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), |
| 1511 ASCIIToUTF16("USA")); | 1511 ASCIIToUTF16("United States")); |
| 1512 billing_profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), | 1512 billing_profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), |
| 1513 ASCIIToUTF16("18181230000")); | 1513 ASCIIToUTF16("18181230000")); |
| 1514 billing_profile.SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER), | 1514 billing_profile.SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER), |
| 1515 ASCIIToUTF16("1915240000")); | 1515 ASCIIToUTF16("1915240000")); |
| 1516 Time pre_modification_time_2 = Time::Now(); | 1516 Time pre_modification_time_2 = Time::Now(); |
| 1517 EXPECT_TRUE(db.UpdateAutoFillProfile(billing_profile)); | 1517 EXPECT_TRUE(db.UpdateAutoFillProfile(billing_profile)); |
| 1518 Time post_modification_time_2 = Time::Now(); | 1518 Time post_modification_time_2 = Time::Now(); |
| 1519 ASSERT_TRUE(db.GetAutoFillProfile(billing_profile.guid(), &db_profile)); | 1519 ASSERT_TRUE(db.GetAutoFillProfile(billing_profile.guid(), &db_profile)); |
| 1520 EXPECT_EQ(billing_profile, *db_profile); | 1520 EXPECT_EQ(billing_profile, *db_profile); |
| 1521 sql::Statement s_billing_updated_2(db.db_.GetUniqueStatement( | 1521 sql::Statement s_billing_updated_2(db.db_.GetUniqueStatement( |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2086 return s.ColumnInt(0); | 2086 return s.ColumnInt(0); |
| 2087 } | 2087 } |
| 2088 | 2088 |
| 2089 // The sql files located in "chrome/test/data/web_database" were generated by | 2089 // The sql files located in "chrome/test/data/web_database" were generated by |
| 2090 // launching the Chromium application prior to schema change, then using the | 2090 // launching the Chromium application prior to schema change, then using the |
| 2091 // sqlite3 command-line application to dump the contents of the "Web Data" | 2091 // sqlite3 command-line application to dump the contents of the "Web Data" |
| 2092 // database. | 2092 // database. |
| 2093 // Like this: | 2093 // Like this: |
| 2094 // > .output version_nn.sql | 2094 // > .output version_nn.sql |
| 2095 // > .dump | 2095 // > .dump |
| 2096 void LoadDatabase(const FilePath& path); | 2096 void LoadDatabase(const FilePath::StringType& file); |
| 2097 | 2097 |
| 2098 // Assertion testing for migrating from version 27 and 28. | 2098 // Assertion testing for migrating from version 27 and 28. |
| 2099 void MigrateVersion28Assertions(); | 2099 void MigrateVersion28Assertions(); |
| 2100 | 2100 |
| 2101 private: | 2101 private: |
| 2102 ScopedTempDir temp_dir_; | 2102 ScopedTempDir temp_dir_; |
| 2103 | 2103 |
| 2104 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); | 2104 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); |
| 2105 }; | 2105 }; |
| 2106 | 2106 |
| 2107 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 33; | 2107 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 34; |
| 2108 | 2108 |
| 2109 void WebDatabaseMigrationTest::LoadDatabase(const FilePath& file) { | 2109 void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) { |
| 2110 std::string contents; | 2110 std::string contents; |
| 2111 ASSERT_TRUE(GetWebDatabaseData(file, &contents)); | 2111 ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents)); |
| 2112 | 2112 |
| 2113 sql::Connection connection; | 2113 sql::Connection connection; |
| 2114 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2114 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2115 ASSERT_TRUE(connection.Execute(contents.data())); | 2115 ASSERT_TRUE(connection.Execute(contents.data())); |
| 2116 } | 2116 } |
| 2117 | 2117 |
| 2118 void WebDatabaseMigrationTest::MigrateVersion28Assertions() { | 2118 void WebDatabaseMigrationTest::MigrateVersion28Assertions() { |
| 2119 // Load the database via the WebDatabase class and migrate the database to | 2119 // Load the database via the WebDatabase class and migrate the database to |
| 2120 // the current version. | 2120 // the current version. |
| 2121 { | 2121 { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 EXPECT_TRUE(connection.DoesTableExist("token_service")); | 2206 EXPECT_TRUE(connection.DoesTableExist("token_service")); |
| 2207 } | 2207 } |
| 2208 } | 2208 } |
| 2209 | 2209 |
| 2210 // Tests that the |credit_card| table gets added to the schema for a version 22 | 2210 // Tests that the |credit_card| table gets added to the schema for a version 22 |
| 2211 // database. | 2211 // database. |
| 2212 TEST_F(WebDatabaseMigrationTest, MigrateVersion22ToCurrent) { | 2212 TEST_F(WebDatabaseMigrationTest, MigrateVersion22ToCurrent) { |
| 2213 // This schema is taken from a build prior to the addition of the | 2213 // This schema is taken from a build prior to the addition of the |
| 2214 // |credit_card| table. Version 22 of the schema. Contrast this with the | 2214 // |credit_card| table. Version 22 of the schema. Contrast this with the |
| 2215 // corrupt version below. | 2215 // corrupt version below. |
| 2216 ASSERT_NO_FATAL_FAILURE( | 2216 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_22.sql"))); |
| 2217 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_22.sql")))); | |
| 2218 | 2217 |
| 2219 // Verify pre-conditions. | 2218 // Verify pre-conditions. |
| 2220 { | 2219 { |
| 2221 sql::Connection connection; | 2220 sql::Connection connection; |
| 2222 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2221 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2223 | 2222 |
| 2224 // No |credit_card| table prior to version 23. | 2223 // No |credit_card| table prior to version 23. |
| 2225 ASSERT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); | 2224 ASSERT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); |
| 2226 ASSERT_FALSE( | 2225 ASSERT_FALSE( |
| 2227 connection.DoesColumnExist("credit_cards", "card_number_encrypted")); | 2226 connection.DoesColumnExist("credit_cards", "card_number_encrypted")); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2253 // Tests that the |credit_card| table gets added to the schema for a corrupt | 2252 // Tests that the |credit_card| table gets added to the schema for a corrupt |
| 2254 // version 22 database. The corruption is that the |credit_cards| table exists | 2253 // version 22 database. The corruption is that the |credit_cards| table exists |
| 2255 // but the schema version number was not set correctly to 23 or later. This | 2254 // but the schema version number was not set correctly to 23 or later. This |
| 2256 // test exercises code introduced to fix bug http://crbug.com/50699 that | 2255 // test exercises code introduced to fix bug http://crbug.com/50699 that |
| 2257 // resulted from the corruption. | 2256 // resulted from the corruption. |
| 2258 TEST_F(WebDatabaseMigrationTest, MigrateVersion22CorruptedToCurrent) { | 2257 TEST_F(WebDatabaseMigrationTest, MigrateVersion22CorruptedToCurrent) { |
| 2259 // This schema is taken from a build after the addition of the |credit_card| | 2258 // This schema is taken from a build after the addition of the |credit_card| |
| 2260 // table. Due to a bug in the migration logic the version is set incorrectly | 2259 // table. Due to a bug in the migration logic the version is set incorrectly |
| 2261 // to 22 (it should have been updated to 23 at least). | 2260 // to 22 (it should have been updated to 23 at least). |
| 2262 ASSERT_NO_FATAL_FAILURE( | 2261 ASSERT_NO_FATAL_FAILURE( |
| 2263 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_22_corrupt.sql")))); | 2262 LoadDatabase(FILE_PATH_LITERAL("version_22_corrupt.sql"))); |
| 2264 | 2263 |
| 2265 // Verify pre-conditions. These are expectations for corrupt version 22 of | 2264 // Verify pre-conditions. These are expectations for corrupt version 22 of |
| 2266 // the database. | 2265 // the database. |
| 2267 { | 2266 { |
| 2268 sql::Connection connection; | 2267 sql::Connection connection; |
| 2269 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2268 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2270 | 2269 |
| 2271 // Columns existing and not existing before current version. | 2270 // Columns existing and not existing before current version. |
| 2272 ASSERT_TRUE(connection.DoesColumnExist("credit_cards", "unique_id")); | 2271 ASSERT_TRUE(connection.DoesColumnExist("credit_cards", "unique_id")); |
| 2273 ASSERT_TRUE( | 2272 ASSERT_TRUE( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2301 EXPECT_TRUE(connection.DoesColumnExist("keywords", "id")); | 2300 EXPECT_TRUE(connection.DoesColumnExist("keywords", "id")); |
| 2302 EXPECT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); | 2301 EXPECT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); |
| 2303 } | 2302 } |
| 2304 } | 2303 } |
| 2305 | 2304 |
| 2306 // Tests that the |keywords| |logo_id| column gets added to the schema for a | 2305 // Tests that the |keywords| |logo_id| column gets added to the schema for a |
| 2307 // version 24 database. | 2306 // version 24 database. |
| 2308 TEST_F(WebDatabaseMigrationTest, MigrateVersion24ToCurrent) { | 2307 TEST_F(WebDatabaseMigrationTest, MigrateVersion24ToCurrent) { |
| 2309 // This schema is taken from a build prior to the addition of the |keywords| | 2308 // This schema is taken from a build prior to the addition of the |keywords| |
| 2310 // |logo_id| column. | 2309 // |logo_id| column. |
| 2311 ASSERT_NO_FATAL_FAILURE( | 2310 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_24.sql"))); |
| 2312 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_24.sql")))); | |
| 2313 | 2311 |
| 2314 // Verify pre-conditions. These are expectations for version 24 of the | 2312 // Verify pre-conditions. These are expectations for version 24 of the |
| 2315 // database. | 2313 // database. |
| 2316 { | 2314 { |
| 2317 sql::Connection connection; | 2315 sql::Connection connection; |
| 2318 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2316 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2319 | 2317 |
| 2320 // Columns existing and not existing before current version. | 2318 // Columns existing and not existing before current version. |
| 2321 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); | 2319 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); |
| 2322 ASSERT_FALSE(connection.DoesColumnExist("keywords", "logo_id")); | 2320 ASSERT_FALSE(connection.DoesColumnExist("keywords", "logo_id")); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2342 EXPECT_TRUE(connection.DoesColumnExist("keywords", "id")); | 2340 EXPECT_TRUE(connection.DoesColumnExist("keywords", "id")); |
| 2343 EXPECT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); | 2341 EXPECT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); |
| 2344 } | 2342 } |
| 2345 } | 2343 } |
| 2346 | 2344 |
| 2347 // Tests that the |keywords| |created_by_policy| column gets added to the schema | 2345 // Tests that the |keywords| |created_by_policy| column gets added to the schema |
| 2348 // for a version 25 database. | 2346 // for a version 25 database. |
| 2349 TEST_F(WebDatabaseMigrationTest, MigrateVersion25ToCurrent) { | 2347 TEST_F(WebDatabaseMigrationTest, MigrateVersion25ToCurrent) { |
| 2350 // This schema is taken from a build prior to the addition of the |keywords| | 2348 // This schema is taken from a build prior to the addition of the |keywords| |
| 2351 // |created_by_policy| column. | 2349 // |created_by_policy| column. |
| 2352 ASSERT_NO_FATAL_FAILURE( | 2350 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_25.sql"))); |
| 2353 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_25.sql")))); | |
| 2354 | 2351 |
| 2355 // Verify pre-conditions. These are expectations for version 25 of the | 2352 // Verify pre-conditions. These are expectations for version 25 of the |
| 2356 // database. | 2353 // database. |
| 2357 { | 2354 { |
| 2358 sql::Connection connection; | 2355 sql::Connection connection; |
| 2359 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2356 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2360 } | 2357 } |
| 2361 | 2358 |
| 2362 // Load the database via the WebDatabase class and migrate the database to | 2359 // Load the database via the WebDatabase class and migrate the database to |
| 2363 // the current version. | 2360 // the current version. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2380 EXPECT_TRUE(connection.DoesColumnExist("keywords", "created_by_policy")); | 2377 EXPECT_TRUE(connection.DoesColumnExist("keywords", "created_by_policy")); |
| 2381 } | 2378 } |
| 2382 } | 2379 } |
| 2383 | 2380 |
| 2384 // Tests that the credit_cards.billing_address column is changed from a string | 2381 // Tests that the credit_cards.billing_address column is changed from a string |
| 2385 // to an int whilst preserving the associated billing address. This version of | 2382 // to an int whilst preserving the associated billing address. This version of |
| 2386 // the test makes sure a stored label is converted to an ID. | 2383 // the test makes sure a stored label is converted to an ID. |
| 2387 TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringLabels) { | 2384 TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringLabels) { |
| 2388 // This schema is taken from a build prior to the change of column type for | 2385 // This schema is taken from a build prior to the change of column type for |
| 2389 // credit_cards.billing_address from string to int. | 2386 // credit_cards.billing_address from string to int. |
| 2390 ASSERT_NO_FATAL_FAILURE( | 2387 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_26.sql"))); |
| 2391 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_26.sql")))); | |
| 2392 | 2388 |
| 2393 // Verify pre-conditions. These are expectations for version 26 of the | 2389 // Verify pre-conditions. These are expectations for version 26 of the |
| 2394 // database. | 2390 // database. |
| 2395 { | 2391 { |
| 2396 sql::Connection connection; | 2392 sql::Connection connection; |
| 2397 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2393 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2398 | 2394 |
| 2399 // Columns existing and not existing before current version. | 2395 // Columns existing and not existing before current version. |
| 2400 EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "billing_address")); | 2396 EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "billing_address")); |
| 2401 | 2397 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 // Column 6 is date_modified. | 2449 // Column 6 is date_modified. |
| 2454 } | 2450 } |
| 2455 } | 2451 } |
| 2456 | 2452 |
| 2457 // Tests that the credit_cards.billing_address column is changed from a string | 2453 // Tests that the credit_cards.billing_address column is changed from a string |
| 2458 // to an int whilst preserving the associated billing address. This version of | 2454 // to an int whilst preserving the associated billing address. This version of |
| 2459 // the test makes sure a stored string ID is converted to an integer ID. | 2455 // the test makes sure a stored string ID is converted to an integer ID. |
| 2460 TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringIDs) { | 2456 TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringIDs) { |
| 2461 // This schema is taken from a build prior to the change of column type for | 2457 // This schema is taken from a build prior to the change of column type for |
| 2462 // credit_cards.billing_address from string to int. | 2458 // credit_cards.billing_address from string to int. |
| 2463 ASSERT_NO_FATAL_FAILURE( | 2459 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_26.sql"))); |
| 2464 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_26.sql")))); | |
| 2465 | 2460 |
| 2466 // Verify pre-conditions. These are expectations for version 26 of the | 2461 // Verify pre-conditions. These are expectations for version 26 of the |
| 2467 // database. | 2462 // database. |
| 2468 { | 2463 { |
| 2469 sql::Connection connection; | 2464 sql::Connection connection; |
| 2470 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2465 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2471 EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "billing_address")); | 2466 EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "billing_address")); |
| 2472 | 2467 |
| 2473 std::string stmt = "INSERT INTO autofill_profiles" | 2468 std::string stmt = "INSERT INTO autofill_profiles" |
| 2474 "(label, unique_id, first_name, middle_name, last_name, email," | 2469 "(label, unique_id, first_name, middle_name, last_name, email," |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 EXPECT_EQ(2012, s.ColumnInt(3)); | 2521 EXPECT_EQ(2012, s.ColumnInt(3)); |
| 2527 // Column 5 is encrypted credit card number blob. | 2522 // Column 5 is encrypted credit card number blob. |
| 2528 // Column 6 is date_modified. | 2523 // Column 6 is date_modified. |
| 2529 } | 2524 } |
| 2530 } | 2525 } |
| 2531 | 2526 |
| 2532 // Tests migration from 27->current. This test is now the same as 28->current | 2527 // Tests migration from 27->current. This test is now the same as 28->current |
| 2533 // as the column added in 28 was nuked in 29. | 2528 // as the column added in 28 was nuked in 29. |
| 2534 TEST_F(WebDatabaseMigrationTest, MigrateVersion27ToCurrent) { | 2529 TEST_F(WebDatabaseMigrationTest, MigrateVersion27ToCurrent) { |
| 2535 // Initialize the database. | 2530 // Initialize the database. |
| 2536 ASSERT_NO_FATAL_FAILURE( | 2531 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_27.sql"))); |
| 2537 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_27.sql")))); | |
| 2538 | 2532 |
| 2539 // Verify pre-conditions. These are expectations for version 28 of the | 2533 // Verify pre-conditions. These are expectations for version 28 of the |
| 2540 // database. | 2534 // database. |
| 2541 { | 2535 { |
| 2542 sql::Connection connection; | 2536 sql::Connection connection; |
| 2543 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2537 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2544 | 2538 |
| 2545 ASSERT_FALSE(connection.DoesColumnExist("keywords", "supports_instant")); | 2539 ASSERT_FALSE(connection.DoesColumnExist("keywords", "supports_instant")); |
| 2546 ASSERT_FALSE(connection.DoesColumnExist("keywords", "instant_url")); | 2540 ASSERT_FALSE(connection.DoesColumnExist("keywords", "instant_url")); |
| 2547 } | 2541 } |
| 2548 | 2542 |
| 2549 MigrateVersion28Assertions(); | 2543 MigrateVersion28Assertions(); |
| 2550 } | 2544 } |
| 2551 | 2545 |
| 2552 // Makes sure instant_url is added correctly to keywords. | 2546 // Makes sure instant_url is added correctly to keywords. |
| 2553 TEST_F(WebDatabaseMigrationTest, MigrateVersion28ToCurrent) { | 2547 TEST_F(WebDatabaseMigrationTest, MigrateVersion28ToCurrent) { |
| 2554 // Initialize the database. | 2548 // Initialize the database. |
| 2555 ASSERT_NO_FATAL_FAILURE( | 2549 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_28.sql"))); |
| 2556 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_28.sql")))); | |
| 2557 | 2550 |
| 2558 // Verify pre-conditions. These are expectations for version 28 of the | 2551 // Verify pre-conditions. These are expectations for version 28 of the |
| 2559 // database. | 2552 // database. |
| 2560 { | 2553 { |
| 2561 sql::Connection connection; | 2554 sql::Connection connection; |
| 2562 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2555 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2563 | 2556 |
| 2564 ASSERT_TRUE(connection.DoesColumnExist("keywords", "supports_instant")); | 2557 ASSERT_TRUE(connection.DoesColumnExist("keywords", "supports_instant")); |
| 2565 ASSERT_FALSE(connection.DoesColumnExist("keywords", "instant_url")); | 2558 ASSERT_FALSE(connection.DoesColumnExist("keywords", "instant_url")); |
| 2566 } | 2559 } |
| 2567 | 2560 |
| 2568 MigrateVersion28Assertions(); | 2561 MigrateVersion28Assertions(); |
| 2569 } | 2562 } |
| 2570 | 2563 |
| 2571 // Makes sure date_modified is added correctly to autofill_profiles and | 2564 // Makes sure date_modified is added correctly to autofill_profiles and |
| 2572 // credit_cards. | 2565 // credit_cards. |
| 2573 TEST_F(WebDatabaseMigrationTest, MigrateVersion29ToCurrent) { | 2566 TEST_F(WebDatabaseMigrationTest, MigrateVersion29ToCurrent) { |
| 2574 // Initialize the database. | 2567 // Initialize the database. |
| 2575 ASSERT_NO_FATAL_FAILURE( | 2568 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_29.sql"))); |
| 2576 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_29.sql")))); | |
| 2577 | 2569 |
| 2578 // Verify pre-conditions. These are expectations for version 29 of the | 2570 // Verify pre-conditions. These are expectations for version 29 of the |
| 2579 // database. | 2571 // database. |
| 2580 { | 2572 { |
| 2581 sql::Connection connection; | 2573 sql::Connection connection; |
| 2582 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2574 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2583 | 2575 |
| 2584 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", | 2576 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", |
| 2585 "date_modified")); | 2577 "date_modified")); |
| 2586 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", | 2578 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2631 EXPECT_LE(s_credit_cards.ColumnInt64(0), | 2623 EXPECT_LE(s_credit_cards.ColumnInt64(0), |
| 2632 post_creation_time.ToTimeT()); | 2624 post_creation_time.ToTimeT()); |
| 2633 } | 2625 } |
| 2634 EXPECT_TRUE(s_credit_cards.Succeeded()); | 2626 EXPECT_TRUE(s_credit_cards.Succeeded()); |
| 2635 } | 2627 } |
| 2636 } | 2628 } |
| 2637 | 2629 |
| 2638 // Makes sure guids are added to autofill_profiles and credit_cards tables. | 2630 // Makes sure guids are added to autofill_profiles and credit_cards tables. |
| 2639 TEST_F(WebDatabaseMigrationTest, MigrateVersion30ToCurrent) { | 2631 TEST_F(WebDatabaseMigrationTest, MigrateVersion30ToCurrent) { |
| 2640 // Initialize the database. | 2632 // Initialize the database. |
| 2641 ASSERT_NO_FATAL_FAILURE( | 2633 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_30.sql"))); |
| 2642 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_30.sql")))); | |
| 2643 | 2634 |
| 2644 // Verify pre-conditions. These are expectations for version 29 of the | 2635 // Verify pre-conditions. These are expectations for version 29 of the |
| 2645 // database. | 2636 // database. |
| 2646 { | 2637 { |
| 2647 sql::Connection connection; | 2638 sql::Connection connection; |
| 2648 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2639 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2649 | 2640 |
| 2650 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "guid")); | 2641 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "guid")); |
| 2651 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); | 2642 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); |
| 2652 } | 2643 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 EXPECT_TRUE(guid::IsValidGUID(guid2)); | 2675 EXPECT_TRUE(guid::IsValidGUID(guid2)); |
| 2685 | 2676 |
| 2686 EXPECT_NE(guid1, guid2); | 2677 EXPECT_NE(guid1, guid2); |
| 2687 } | 2678 } |
| 2688 } | 2679 } |
| 2689 | 2680 |
| 2690 // Removes unique IDs and make GUIDs the primary key. Also removes unused | 2681 // Removes unique IDs and make GUIDs the primary key. Also removes unused |
| 2691 // columns. | 2682 // columns. |
| 2692 TEST_F(WebDatabaseMigrationTest, MigrateVersion31ToCurrent) { | 2683 TEST_F(WebDatabaseMigrationTest, MigrateVersion31ToCurrent) { |
| 2693 // Initialize the database. | 2684 // Initialize the database. |
| 2694 ASSERT_NO_FATAL_FAILURE( | 2685 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_31.sql"))); |
| 2695 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_31.sql")))); | |
| 2696 | 2686 |
| 2697 // Verify pre-conditions. These are expectations for version 30 of the | 2687 // Verify pre-conditions. These are expectations for version 30 of the |
| 2698 // database. | 2688 // database. |
| 2699 AutoFillProfile profile; | 2689 AutoFillProfile profile; |
| 2700 string16 profile_label; | 2690 string16 profile_label; |
| 2701 int profile_unique_id = 0; | 2691 int profile_unique_id = 0; |
| 2702 int64 profile_date_modified = 0; | 2692 int64 profile_date_modified = 0; |
| 2703 CreditCard credit_card; | 2693 CreditCard credit_card; |
| 2704 string16 cc_label; | 2694 string16 cc_label; |
| 2705 int cc_unique_id = 0; | 2695 int cc_unique_id = 0; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2833 EXPECT_EQ(cc_label, cc_label_a); | 2823 EXPECT_EQ(cc_label, cc_label_a); |
| 2834 EXPECT_EQ(cc_number_encrypted, cc_number_encrypted_a); | 2824 EXPECT_EQ(cc_number_encrypted, cc_number_encrypted_a); |
| 2835 EXPECT_EQ(cc_date_modified, cc_date_modified_a); | 2825 EXPECT_EQ(cc_date_modified, cc_date_modified_a); |
| 2836 } | 2826 } |
| 2837 } | 2827 } |
| 2838 | 2828 |
| 2839 // Factor |autofill_profiles| address information separately from name, email, | 2829 // Factor |autofill_profiles| address information separately from name, email, |
| 2840 // and phone. | 2830 // and phone. |
| 2841 TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) { | 2831 TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) { |
| 2842 // Initialize the database. | 2832 // Initialize the database. |
| 2843 ASSERT_NO_FATAL_FAILURE( | 2833 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_32.sql"))); |
| 2844 LoadDatabase(FilePath(FILE_PATH_LITERAL("version_32.sql")))); | |
| 2845 | 2834 |
| 2846 // Verify pre-conditions. These are expectations for version 32 of the | 2835 // Verify pre-conditions. These are expectations for version 32 of the |
| 2847 // database. | 2836 // database. |
| 2848 { | 2837 { |
| 2849 sql::Connection connection; | 2838 sql::Connection connection; |
| 2850 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 2839 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 2851 | 2840 |
| 2852 // Verify existence of columns we'll be changing. | 2841 // Verify existence of columns we'll be changing. |
| 2853 EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "guid")); | 2842 EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "guid")); |
| 2854 EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "label")); | 2843 EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", "label")); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2947 | 2936 |
| 2948 // John Doe. | 2937 // John Doe. |
| 2949 ASSERT_TRUE(s1.Step()); | 2938 ASSERT_TRUE(s1.Step()); |
| 2950 EXPECT_EQ("00580526-FF81-EE2A-0546-1AC593A32E2F", s1.ColumnString(0)); | 2939 EXPECT_EQ("00580526-FF81-EE2A-0546-1AC593A32E2F", s1.ColumnString(0)); |
| 2951 EXPECT_EQ(ASCIIToUTF16("Doe Enterprises"), s1.ColumnString16(1)); | 2940 EXPECT_EQ(ASCIIToUTF16("Doe Enterprises"), s1.ColumnString16(1)); |
| 2952 EXPECT_EQ(ASCIIToUTF16("1 Main St"), s1.ColumnString16(2)); | 2941 EXPECT_EQ(ASCIIToUTF16("1 Main St"), s1.ColumnString16(2)); |
| 2953 EXPECT_EQ(ASCIIToUTF16("Apt 1"), s1.ColumnString16(3)); | 2942 EXPECT_EQ(ASCIIToUTF16("Apt 1"), s1.ColumnString16(3)); |
| 2954 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); | 2943 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); |
| 2955 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); | 2944 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); |
| 2956 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); | 2945 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); |
| 2957 EXPECT_EQ(ASCIIToUTF16("USA"), s1.ColumnString16(7)); | 2946 EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7)); |
| 2958 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); | 2947 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); |
| 2959 | 2948 |
| 2960 // John P. Doe. | 2949 // John P. Doe. |
| 2961 ASSERT_TRUE(s1.Step()); | 2950 ASSERT_TRUE(s1.Step()); |
| 2962 EXPECT_EQ("589636FD-9037-3053-200C-80ABC97D7344", s1.ColumnString(0)); | 2951 EXPECT_EQ("589636FD-9037-3053-200C-80ABC97D7344", s1.ColumnString(0)); |
| 2963 EXPECT_EQ(ASCIIToUTF16("Doe Enterprises"), s1.ColumnString16(1)); | 2952 EXPECT_EQ(ASCIIToUTF16("Doe Enterprises"), s1.ColumnString16(1)); |
| 2964 EXPECT_EQ(ASCIIToUTF16("1 Main St"), s1.ColumnString16(2)); | 2953 EXPECT_EQ(ASCIIToUTF16("1 Main St"), s1.ColumnString16(2)); |
| 2965 EXPECT_EQ(ASCIIToUTF16("Apt 1"), s1.ColumnString16(3)); | 2954 EXPECT_EQ(ASCIIToUTF16("Apt 1"), s1.ColumnString16(3)); |
| 2966 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); | 2955 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); |
| 2967 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); | 2956 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); |
| 2968 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); | 2957 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); |
| 2969 EXPECT_EQ(ASCIIToUTF16("USA"), s1.ColumnString16(7)); | 2958 EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7)); |
| 2970 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); | 2959 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); |
| 2971 | 2960 |
| 2972 // Dave Smith. | 2961 // Dave Smith. |
| 2973 ASSERT_TRUE(s1.Step()); | 2962 ASSERT_TRUE(s1.Step()); |
| 2974 EXPECT_EQ("4C74A9D8-7EEE-423E-F9C2-E7FA70ED1396", s1.ColumnString(0)); | 2963 EXPECT_EQ("4C74A9D8-7EEE-423E-F9C2-E7FA70ED1396", s1.ColumnString(0)); |
| 2975 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); | 2964 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); |
| 2976 EXPECT_EQ(ASCIIToUTF16("2 Main Street"), s1.ColumnString16(2)); | 2965 EXPECT_EQ(ASCIIToUTF16("2 Main Street"), s1.ColumnString16(2)); |
| 2977 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); | 2966 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); |
| 2978 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); | 2967 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); |
| 2979 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); | 2968 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); |
| 2980 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); | 2969 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); |
| 2981 EXPECT_EQ(ASCIIToUTF16("USA"), s1.ColumnString16(7)); | 2970 EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7)); |
| 2982 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); | 2971 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); |
| 2983 | 2972 |
| 2984 // Dave Smith (Part 2). | 2973 // Dave Smith (Part 2). |
| 2985 ASSERT_TRUE(s1.Step()); | 2974 ASSERT_TRUE(s1.Step()); |
| 2986 EXPECT_EQ("722DF5C4-F74A-294A-46F0-31FFDED0D635", s1.ColumnString(0)); | 2975 EXPECT_EQ("722DF5C4-F74A-294A-46F0-31FFDED0D635", s1.ColumnString(0)); |
| 2987 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); | 2976 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); |
| 2988 EXPECT_EQ(ASCIIToUTF16("2 Main St"), s1.ColumnString16(2)); | 2977 EXPECT_EQ(ASCIIToUTF16("2 Main St"), s1.ColumnString16(2)); |
| 2989 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); | 2978 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); |
| 2990 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); | 2979 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); |
| 2991 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); | 2980 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); |
| 2992 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); | 2981 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); |
| 2993 EXPECT_EQ(ASCIIToUTF16("USA"), s1.ColumnString16(7)); | 2982 EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7)); |
| 2994 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); | 2983 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); |
| 2995 | 2984 |
| 2996 // Alfred E Newman. | 2985 // Alfred E Newman. |
| 2997 ASSERT_TRUE(s1.Step()); | 2986 ASSERT_TRUE(s1.Step()); |
| 2998 EXPECT_EQ("584282AC-5D21-8D73-A2DB-4F892EF61F3F", s1.ColumnString(0)); | 2987 EXPECT_EQ("584282AC-5D21-8D73-A2DB-4F892EF61F3F", s1.ColumnString(0)); |
| 2999 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); | 2988 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); |
| 3000 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(2)); | 2989 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(2)); |
| 3001 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); | 2990 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); |
| 3002 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(4)); | 2991 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(4)); |
| 3003 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(5)); | 2992 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(5)); |
| 3004 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(6)); | 2993 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(6)); |
| 3005 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(7)); | 2994 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(7)); |
| 3006 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); | 2995 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); |
| 3007 | 2996 |
| 3008 // 3 Main St. | 2997 // 3 Main St. |
| 3009 ASSERT_TRUE(s1.Step()); | 2998 ASSERT_TRUE(s1.Step()); |
| 3010 EXPECT_EQ("9E5FE298-62C7-83DF-6293-381BC589183F", s1.ColumnString(0)); | 2999 EXPECT_EQ("9E5FE298-62C7-83DF-6293-381BC589183F", s1.ColumnString(0)); |
| 3011 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); | 3000 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(1)); |
| 3012 EXPECT_EQ(ASCIIToUTF16("3 Main St"), s1.ColumnString16(2)); | 3001 EXPECT_EQ(ASCIIToUTF16("3 Main St"), s1.ColumnString16(2)); |
| 3013 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); | 3002 EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(3)); |
| 3014 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); | 3003 EXPECT_EQ(ASCIIToUTF16("Los Altos"), s1.ColumnString16(4)); |
| 3015 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); | 3004 EXPECT_EQ(ASCIIToUTF16("CA"), s1.ColumnString16(5)); |
| 3016 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); | 3005 EXPECT_EQ(ASCIIToUTF16("94022"), s1.ColumnString16(6)); |
| 3017 EXPECT_EQ(ASCIIToUTF16("USA"), s1.ColumnString16(7)); | 3006 EXPECT_EQ(ASCIIToUTF16("United States"), s1.ColumnString16(7)); |
| 3018 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); | 3007 EXPECT_EQ(1297882100L, s1.ColumnInt64(8)); |
| 3019 | 3008 |
| 3020 // That should be all. | 3009 // That should be all. |
| 3021 EXPECT_FALSE(s1.Step()); | 3010 EXPECT_FALSE(s1.Step()); |
| 3022 | 3011 |
| 3023 sql::Statement s2( | 3012 sql::Statement s2( |
| 3024 connection.GetUniqueStatement( | 3013 connection.GetUniqueStatement( |
| 3025 "SELECT guid, first_name, middle_name, last_name " | 3014 "SELECT guid, first_name, middle_name, last_name " |
| 3026 "FROM autofill_profile_names")); | 3015 "FROM autofill_profile_names")); |
| 3027 | 3016 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3124 | 3113 |
| 3125 // Note no phone or fax for 2 Main Street. | 3114 // Note no phone or fax for 2 Main Street. |
| 3126 // Note no phone or fax for 2 Main St. | 3115 // Note no phone or fax for 2 Main St. |
| 3127 // Note no phone or fax for Alfred E Newman. | 3116 // Note no phone or fax for Alfred E Newman. |
| 3128 // Note no phone or fax for 3 Main St. | 3117 // Note no phone or fax for 3 Main St. |
| 3129 | 3118 |
| 3130 // Should be all. | 3119 // Should be all. |
| 3131 EXPECT_FALSE(s4.Step()); | 3120 EXPECT_FALSE(s4.Step()); |
| 3132 } | 3121 } |
| 3133 } | 3122 } |
| 3123 |
| 3124 // Adds a column for the autofill profile's country code. |
| 3125 TEST_F(WebDatabaseMigrationTest, MigrateVersion33ToCurrent) { |
| 3126 // Initialize the database. |
| 3127 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_33.sql"))); |
| 3128 |
| 3129 // Verify pre-conditions. These are expectations for version 33 of the |
| 3130 // database. |
| 3131 { |
| 3132 sql::Connection connection; |
| 3133 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 3134 |
| 3135 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", |
| 3136 "country_code")); |
| 3137 |
| 3138 // Check that the country value is the one we expect. |
| 3139 sql::Statement s( |
| 3140 connection.GetUniqueStatement("SELECT country FROM autofill_profiles")); |
| 3141 |
| 3142 ASSERT_TRUE(s.Step()); |
| 3143 std::string country = s.ColumnString(0); |
| 3144 EXPECT_EQ("United States", country); |
| 3145 } |
| 3146 |
| 3147 // Load the database via the WebDatabase class and migrate the database to |
| 3148 // the current version. |
| 3149 { |
| 3150 WebDatabase db; |
| 3151 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); |
| 3152 } |
| 3153 |
| 3154 // Verify post-conditions. These are expectations for current version of the |
| 3155 // database. |
| 3156 { |
| 3157 sql::Connection connection; |
| 3158 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 3159 |
| 3160 // Check version. |
| 3161 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
| 3162 |
| 3163 ASSERT_TRUE(connection.DoesColumnExist("autofill_profiles", |
| 3164 "country_code")); |
| 3165 |
| 3166 // Check that the country code is properly converted. |
| 3167 sql::Statement s(connection.GetUniqueStatement( |
| 3168 "SELECT country_code FROM autofill_profiles")); |
| 3169 |
| 3170 ASSERT_TRUE(s.Step()); |
| 3171 std::string country_code = s.ColumnString(0); |
| 3172 EXPECT_EQ("US", country_code); |
| 3173 } |
| 3174 } |
| OLD | NEW |