OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 EXPECT_FALSE(connection.DoesTableExist("logins")); | 285 EXPECT_FALSE(connection.DoesTableExist("logins")); |
286 EXPECT_TRUE(connection.DoesTableExist("meta")); | 286 EXPECT_TRUE(connection.DoesTableExist("meta")); |
287 EXPECT_TRUE(connection.DoesTableExist("token_service")); | 287 EXPECT_TRUE(connection.DoesTableExist("token_service")); |
288 EXPECT_TRUE(connection.DoesTableExist("web_app_icons")); | 288 EXPECT_TRUE(connection.DoesTableExist("web_app_icons")); |
289 EXPECT_TRUE(connection.DoesTableExist("web_apps")); | 289 EXPECT_TRUE(connection.DoesTableExist("web_apps")); |
290 EXPECT_TRUE(connection.DoesTableExist("web_intents")); | 290 EXPECT_TRUE(connection.DoesTableExist("web_intents")); |
291 EXPECT_TRUE(connection.DoesTableExist("web_intents_defaults")); | 291 EXPECT_TRUE(connection.DoesTableExist("web_intents_defaults")); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
| 295 // Tests that absent Autofill tables do not create any problems when migrating |
| 296 // from a DB written by the earliest publicly released version of Chrome. |
| 297 TEST_F(WebDatabaseMigrationTest, MigrateVersion20ToCurrent) { |
| 298 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_20.sql"))); |
| 299 |
| 300 // Verify pre-conditions. |
| 301 { |
| 302 sql::Connection connection; |
| 303 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 304 |
| 305 EXPECT_FALSE(connection.DoesTableExist("autofill")); |
| 306 EXPECT_FALSE(connection.DoesTableExist("autofill_profiles")); |
| 307 EXPECT_FALSE(connection.DoesTableExist("credit_cards")); |
| 308 } |
| 309 |
| 310 DoMigration(); |
| 311 |
| 312 // Verify post-conditions. These are expectations for current version of the |
| 313 // database. |
| 314 { |
| 315 sql::Connection connection; |
| 316 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 317 |
| 318 // Check version. |
| 319 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
| 320 |
| 321 // Mostly this test just verifies that no SQL errors occur during migration; |
| 322 // but might as well verify that the tables were created as well. |
| 323 EXPECT_TRUE(connection.DoesTableExist("autofill")); |
| 324 EXPECT_TRUE(connection.DoesTableExist("autofill_profiles")); |
| 325 EXPECT_TRUE(connection.DoesTableExist("credit_cards")); |
| 326 } |
| 327 } |
| 328 |
295 // Tests that rows with empty values get removed from the autofill tables. | 329 // Tests that rows with empty values get removed from the autofill tables. |
296 TEST_F(WebDatabaseMigrationTest, MigrateVersion21ToCurrent) { | 330 TEST_F(WebDatabaseMigrationTest, MigrateVersion21ToCurrent) { |
297 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_21.sql"))); | 331 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_21.sql"))); |
298 | 332 |
299 // Verify pre-conditions. | 333 // Verify pre-conditions. |
300 { | 334 { |
301 sql::Connection connection; | 335 sql::Connection connection; |
302 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 336 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
303 | 337 |
304 // Both empty and non-empty values are allowed in a version 21 database. | 338 // Both empty and non-empty values are allowed in a version 21 database. |
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2539 EXPECT_EQ(ASCIIToUTF16("john doe"), s.ColumnString16(1)); | 2573 EXPECT_EQ(ASCIIToUTF16("john doe"), s.ColumnString16(1)); |
2540 EXPECT_EQ(ASCIIToUTF16("john doe"), s.ColumnString16(2)); | 2574 EXPECT_EQ(ASCIIToUTF16("john doe"), s.ColumnString16(2)); |
2541 EXPECT_EQ(1384299200, s.ColumnInt64(3)); | 2575 EXPECT_EQ(1384299200, s.ColumnInt64(3)); |
2542 EXPECT_EQ(1384299200, s.ColumnInt64(4)); | 2576 EXPECT_EQ(1384299200, s.ColumnInt64(4)); |
2543 EXPECT_EQ(1, s.ColumnInt(5)); | 2577 EXPECT_EQ(1, s.ColumnInt(5)); |
2544 | 2578 |
2545 // No more entries expected. | 2579 // No more entries expected. |
2546 ASSERT_FALSE(s.Step()); | 2580 ASSERT_FALSE(s.Step()); |
2547 } | 2581 } |
2548 } | 2582 } |
OLD | NEW |