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.h" | 10 #include "base/message_loop.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/webdata/autofill_change.h" | 17 #include "chrome/browser/webdata/autofill_change.h" |
18 #include "chrome/browser/webdata/autofill_entry.h" | 18 #include "chrome/browser/webdata/autofill_entry.h" |
19 #include "chrome/browser/webdata/autofill_table.h" | |
19 #include "chrome/browser/webdata/keyword_table.h" | 20 #include "chrome/browser/webdata/keyword_table.h" |
21 #include "chrome/browser/webdata/logins_table.h" | |
22 #include "chrome/browser/webdata/token_service_table.h" | |
23 #include "chrome/browser/webdata/web_apps_table.h" | |
20 #include "chrome/browser/webdata/web_database.h" | 24 #include "chrome/browser/webdata/web_database.h" |
21 #include "chrome/browser/webdata/web_intents_table.h" | 25 #include "chrome/browser/webdata/web_intents_table.h" |
22 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
24 #include "components/autofill/browser/autofill_profile.h" | 28 #include "components/autofill/browser/autofill_profile.h" |
25 #include "components/autofill/browser/autofill_type.h" | 29 #include "components/autofill/browser/autofill_type.h" |
26 #include "components/autofill/browser/credit_card.h" | 30 #include "components/autofill/browser/credit_card.h" |
27 #include "content/public/test/test_browser_thread.h" | 31 #include "content/public/test/test_browser_thread.h" |
28 #include "sql/statement.h" | 32 #include "sql/statement.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 // running on the DB thread. Once that verification is added, this code will | 161 // running on the DB thread. Once that verification is added, this code will |
158 // need to be updated to create both threads. | 162 // need to be updated to create both threads. |
159 WebDatabaseMigrationTest() | 163 WebDatabaseMigrationTest() |
160 : ui_thread_(BrowserThread::UI, &message_loop_for_ui_) {} | 164 : ui_thread_(BrowserThread::UI, &message_loop_for_ui_) {} |
161 virtual ~WebDatabaseMigrationTest() {} | 165 virtual ~WebDatabaseMigrationTest() {} |
162 | 166 |
163 virtual void SetUp() { | 167 virtual void SetUp() { |
164 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 168 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
165 } | 169 } |
166 | 170 |
171 // Load the database via the WebDatabase class and migrate the database to | |
172 // the current version. | |
173 void DoMigration() { | |
174 // TODO(joi): This whole unit test file needs to stay in //chrome | |
dhollowa
2013/03/12 21:29:38
Is there a bug to track this? Need one?
Jói
2013/03/12 21:59:53
Just the overall "Componentize WebData" bug (http:
| |
175 // for now, as it needs to know about all the different table | |
176 // types. Once all webdata datatypes have been componentized, this | |
177 // could move to components_unittests. | |
178 AutofillTable autofill_table; | |
179 KeywordTable keyword_table; | |
180 LoginsTable logins_table; | |
181 TokenServiceTable token_service_table; | |
182 WebAppsTable web_apps_table; | |
183 WebIntentsTable web_intents_table; | |
184 | |
185 WebDatabase db; | |
186 db.AddTable(&autofill_table); | |
187 db.AddTable(&keyword_table); | |
188 db.AddTable(&logins_table); | |
189 db.AddTable(&token_service_table); | |
190 db.AddTable(&web_apps_table); | |
191 db.AddTable(&web_intents_table); | |
192 | |
193 // This causes the migration to occur. | |
194 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
195 } | |
196 | |
167 protected: | 197 protected: |
168 // Current tested version number. When adding a migration in | 198 // Current tested version number. When adding a migration in |
169 // |WebDatabase::MigrateOldVersionsAsNeeded()| and changing the version number | 199 // |WebDatabase::MigrateOldVersionsAsNeeded()| and changing the version number |
170 // |kCurrentVersionNumber| this value should change to reflect the new version | 200 // |kCurrentVersionNumber| this value should change to reflect the new version |
171 // number and a new migration test added below. | 201 // number and a new migration test added below. |
172 static const int kCurrentTestedVersionNumber; | 202 static const int kCurrentTestedVersionNumber; |
173 | 203 |
174 base::FilePath GetDatabasePath() { | 204 base::FilePath GetDatabasePath() { |
175 const base::FilePath::CharType kWebDatabaseFilename[] = | 205 const base::FilePath::CharType kWebDatabaseFilename[] = |
176 FILE_PATH_LITERAL("TestWebDatabase.sqlite3"); | 206 FILE_PATH_LITERAL("TestWebDatabase.sqlite3"); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 std::string contents; | 250 std::string contents; |
221 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); | 251 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); |
222 | 252 |
223 sql::Connection connection; | 253 sql::Connection connection; |
224 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 254 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
225 ASSERT_TRUE(connection.Execute(contents.data())); | 255 ASSERT_TRUE(connection.Execute(contents.data())); |
226 } | 256 } |
227 | 257 |
228 // Tests that the all migrations from an empty database succeed. | 258 // Tests that the all migrations from an empty database succeed. |
229 TEST_F(WebDatabaseMigrationTest, MigrateEmptyToCurrent) { | 259 TEST_F(WebDatabaseMigrationTest, MigrateEmptyToCurrent) { |
230 // Load the database via the WebDatabase class and migrate the database to | 260 DoMigration(); |
231 // the current version. | |
232 { | |
233 WebDatabase db; | |
234 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
235 } | |
236 | 261 |
237 // Verify post-conditions. These are expectations for current version of the | 262 // Verify post-conditions. These are expectations for current version of the |
238 // database. | 263 // database. |
239 { | 264 { |
240 sql::Connection connection; | 265 sql::Connection connection; |
241 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 266 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
242 | 267 |
243 // Check version. | 268 // Check version. |
244 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 269 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
245 | 270 |
(...skipping 26 matching lines...) Expand all Loading... | |
272 { | 297 { |
273 sql::Connection connection; | 298 sql::Connection connection; |
274 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 299 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
275 | 300 |
276 // No |credit_card| table prior to version 23. | 301 // No |credit_card| table prior to version 23. |
277 ASSERT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); | 302 ASSERT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); |
278 ASSERT_FALSE( | 303 ASSERT_FALSE( |
279 connection.DoesColumnExist("credit_cards", "card_number_encrypted")); | 304 connection.DoesColumnExist("credit_cards", "card_number_encrypted")); |
280 } | 305 } |
281 | 306 |
282 // Load the database via the WebDatabase class and migrate the database to | 307 DoMigration(); |
283 // the current version. | |
284 { | |
285 WebDatabase db; | |
286 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
287 } | |
288 | 308 |
289 // Verify post-conditions. These are expectations for current version of the | 309 // Verify post-conditions. These are expectations for current version of the |
290 // database. | 310 // database. |
291 { | 311 { |
292 sql::Connection connection; | 312 sql::Connection connection; |
293 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 313 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
294 | 314 |
295 // Check version. | 315 // Check version. |
296 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 316 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
297 | 317 |
(...skipping 22 matching lines...) Expand all Loading... | |
320 sql::Connection connection; | 340 sql::Connection connection; |
321 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 341 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
322 | 342 |
323 // Columns existing and not existing before current version. | 343 // Columns existing and not existing before current version. |
324 ASSERT_TRUE(connection.DoesColumnExist("credit_cards", "unique_id")); | 344 ASSERT_TRUE(connection.DoesColumnExist("credit_cards", "unique_id")); |
325 ASSERT_TRUE( | 345 ASSERT_TRUE( |
326 connection.DoesColumnExist("credit_cards", "card_number_encrypted")); | 346 connection.DoesColumnExist("credit_cards", "card_number_encrypted")); |
327 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); | 347 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); |
328 } | 348 } |
329 | 349 |
330 // Load the database via the WebDatabase class and migrate the database to | 350 DoMigration(); |
331 // the current version. | |
332 { | |
333 WebDatabase db; | |
334 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
335 } | |
336 | 351 |
337 // Verify post-conditions. These are expectations for current version of the | 352 // Verify post-conditions. These are expectations for current version of the |
338 // database. | 353 // database. |
339 { | 354 { |
340 sql::Connection connection; | 355 sql::Connection connection; |
341 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 356 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
342 | 357 |
343 // Check version. | 358 // Check version. |
344 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 359 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
345 | 360 |
(...skipping 14 matching lines...) Expand all Loading... | |
360 // |created_by_policy| column. | 375 // |created_by_policy| column. |
361 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_25.sql"))); | 376 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_25.sql"))); |
362 | 377 |
363 // Verify pre-conditions. These are expectations for version 25 of the | 378 // Verify pre-conditions. These are expectations for version 25 of the |
364 // database. | 379 // database. |
365 { | 380 { |
366 sql::Connection connection; | 381 sql::Connection connection; |
367 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 382 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
368 } | 383 } |
369 | 384 |
370 // Load the database via the WebDatabase class and migrate the database to | 385 DoMigration(); |
371 // the current version. | |
372 { | |
373 WebDatabase db; | |
374 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
375 } | |
376 | 386 |
377 // Verify post-conditions. These are expectations for current version of the | 387 // Verify post-conditions. These are expectations for current version of the |
378 // database. | 388 // database. |
379 { | 389 { |
380 sql::Connection connection; | 390 sql::Connection connection; |
381 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 391 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
382 | 392 |
383 // Check version. | 393 // Check version. |
384 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 394 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
385 | 395 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 sql::Statement s2(connection.GetUniqueStatement(stmt2.c_str())); | 433 sql::Statement s2(connection.GetUniqueStatement(stmt2.c_str())); |
424 ASSERT_TRUE(s2.Run()); | 434 ASSERT_TRUE(s2.Run()); |
425 | 435 |
426 // |billing_address| is a string. | 436 // |billing_address| is a string. |
427 std::string stmt3 = "SELECT billing_address FROM credit_cards"; | 437 std::string stmt3 = "SELECT billing_address FROM credit_cards"; |
428 sql::Statement s3(connection.GetUniqueStatement(stmt3.c_str())); | 438 sql::Statement s3(connection.GetUniqueStatement(stmt3.c_str())); |
429 ASSERT_TRUE(s3.Step()); | 439 ASSERT_TRUE(s3.Step()); |
430 EXPECT_EQ(s3.ColumnType(0), sql::COLUMN_TYPE_TEXT); | 440 EXPECT_EQ(s3.ColumnType(0), sql::COLUMN_TYPE_TEXT); |
431 } | 441 } |
432 | 442 |
433 // Load the database via the WebDatabase class and migrate the database to | 443 DoMigration(); |
434 // the current version. | |
435 { | |
436 WebDatabase db; | |
437 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
438 } | |
439 | 444 |
440 // Verify post-conditions. These are expectations for current version of the | 445 // Verify post-conditions. These are expectations for current version of the |
441 // database. | 446 // database. |
442 { | 447 { |
443 sql::Connection connection; | 448 sql::Connection connection; |
444 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 449 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
445 | 450 |
446 // Check version. | 451 // Check version. |
447 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 452 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
448 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "billing_address")); | 453 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "billing_address")); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 sql::Statement s2(connection.GetUniqueStatement(stmt2.c_str())); | 498 sql::Statement s2(connection.GetUniqueStatement(stmt2.c_str())); |
494 ASSERT_TRUE(s2.Run()); | 499 ASSERT_TRUE(s2.Run()); |
495 | 500 |
496 // |billing_address| is a string. | 501 // |billing_address| is a string. |
497 std::string stmt3 = "SELECT billing_address FROM credit_cards"; | 502 std::string stmt3 = "SELECT billing_address FROM credit_cards"; |
498 sql::Statement s3(connection.GetUniqueStatement(stmt3.c_str())); | 503 sql::Statement s3(connection.GetUniqueStatement(stmt3.c_str())); |
499 ASSERT_TRUE(s3.Step()); | 504 ASSERT_TRUE(s3.Step()); |
500 EXPECT_EQ(s3.ColumnType(0), sql::COLUMN_TYPE_TEXT); | 505 EXPECT_EQ(s3.ColumnType(0), sql::COLUMN_TYPE_TEXT); |
501 } | 506 } |
502 | 507 |
503 // Load the database via the WebDatabase class and migrate the database to | 508 DoMigration(); |
504 // the current version. | |
505 { | |
506 WebDatabase db; | |
507 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
508 } | |
509 | 509 |
510 // Verify post-conditions. These are expectations for current version of the | 510 // Verify post-conditions. These are expectations for current version of the |
511 // database. | 511 // database. |
512 { | 512 { |
513 sql::Connection connection; | 513 sql::Connection connection; |
514 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 514 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
515 | 515 |
516 // Check version. | 516 // Check version. |
517 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 517 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
518 | 518 |
(...skipping 23 matching lines...) Expand all Loading... | |
542 | 542 |
543 // Verify pre-conditions. These are expectations for version 27 of the | 543 // Verify pre-conditions. These are expectations for version 27 of the |
544 // database. | 544 // database. |
545 { | 545 { |
546 sql::Connection connection; | 546 sql::Connection connection; |
547 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 547 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
548 | 548 |
549 ASSERT_FALSE(connection.DoesColumnExist("keywords", "instant_url")); | 549 ASSERT_FALSE(connection.DoesColumnExist("keywords", "instant_url")); |
550 } | 550 } |
551 | 551 |
552 // Load the database via the WebDatabase class and migrate the database to | 552 DoMigration(); |
553 // the current version. | |
554 { | |
555 WebDatabase db; | |
556 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
557 } | |
558 | 553 |
559 // Verify post-conditions. These are expectations for current version of the | 554 // Verify post-conditions. These are expectations for current version of the |
560 // database. | 555 // database. |
561 { | 556 { |
562 sql::Connection connection; | 557 sql::Connection connection; |
563 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 558 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
564 | 559 |
565 // Check version. | 560 // Check version. |
566 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 561 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
567 | 562 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 { | 610 { |
616 sql::Connection connection; | 611 sql::Connection connection; |
617 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 612 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
618 | 613 |
619 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", | 614 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", |
620 "date_modified")); | 615 "date_modified")); |
621 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", | 616 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", |
622 "date_modified")); | 617 "date_modified")); |
623 } | 618 } |
624 | 619 |
625 // Load the database via the WebDatabase class and migrate the database to | |
626 // the current version. | |
627 Time pre_creation_time = Time::Now(); | 620 Time pre_creation_time = Time::Now(); |
628 { | 621 DoMigration(); |
629 WebDatabase db; | |
630 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
631 } | |
632 Time post_creation_time = Time::Now(); | 622 Time post_creation_time = Time::Now(); |
633 | 623 |
634 // Verify post-conditions. These are expectations for current version of the | 624 // Verify post-conditions. These are expectations for current version of the |
635 // database. | 625 // database. |
636 { | 626 { |
637 sql::Connection connection; | 627 sql::Connection connection; |
638 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 628 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
639 | 629 |
640 // Check version. | 630 // Check version. |
641 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 631 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 // Verify pre-conditions. These are expectations for version 29 of the | 668 // Verify pre-conditions. These are expectations for version 29 of the |
679 // database. | 669 // database. |
680 { | 670 { |
681 sql::Connection connection; | 671 sql::Connection connection; |
682 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 672 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
683 | 673 |
684 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "guid")); | 674 EXPECT_FALSE(connection.DoesColumnExist("autofill_profiles", "guid")); |
685 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); | 675 EXPECT_FALSE(connection.DoesColumnExist("credit_cards", "guid")); |
686 } | 676 } |
687 | 677 |
688 // Load the database via the WebDatabase class and migrate the database to | 678 DoMigration(); |
689 // the current version. | |
690 { | |
691 WebDatabase db; | |
692 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
693 } | |
694 | 679 |
695 // Verify post-conditions. These are expectations for current version of the | 680 // Verify post-conditions. These are expectations for current version of the |
696 // database. | 681 // database. |
697 { | 682 { |
698 sql::Connection connection; | 683 sql::Connection connection; |
699 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 684 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
700 | 685 |
701 // Check version. | 686 // Check version. |
702 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 687 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
703 | 688 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 &credit_card, | 765 &credit_card, |
781 &cc_label, | 766 &cc_label, |
782 &cc_unique_id, | 767 &cc_unique_id, |
783 &cc_number_encrypted, | 768 &cc_number_encrypted, |
784 &cc_date_modified)); | 769 &cc_date_modified)); |
785 | 770 |
786 EXPECT_NE(profile_unique_id, cc_unique_id); | 771 EXPECT_NE(profile_unique_id, cc_unique_id); |
787 EXPECT_NE(profile.guid(), credit_card.guid()); | 772 EXPECT_NE(profile.guid(), credit_card.guid()); |
788 } | 773 } |
789 | 774 |
790 // Load the database via the WebDatabase class and migrate the database to | 775 DoMigration(); |
791 // the current version. | |
792 { | |
793 WebDatabase db; | |
794 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
795 } | |
796 | 776 |
797 // Verify post-conditions. These are expectations for current version of the | 777 // Verify post-conditions. These are expectations for current version of the |
798 // database. | 778 // database. |
799 { | 779 { |
800 sql::Connection connection; | 780 sql::Connection connection; |
801 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 781 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
802 | 782 |
803 // Check version. | 783 // Check version. |
804 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 784 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
805 | 785 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", | 883 EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles", |
904 "date_modified")); | 884 "date_modified")); |
905 | 885 |
906 EXPECT_FALSE(connection.DoesTableExist("autofill_profile_names")); | 886 EXPECT_FALSE(connection.DoesTableExist("autofill_profile_names")); |
907 EXPECT_FALSE(connection.DoesTableExist("autofill_profile_emails")); | 887 EXPECT_FALSE(connection.DoesTableExist("autofill_profile_emails")); |
908 EXPECT_FALSE(connection.DoesTableExist("autofill_profile_phones")); | 888 EXPECT_FALSE(connection.DoesTableExist("autofill_profile_phones")); |
909 | 889 |
910 EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "label")); | 890 EXPECT_TRUE(connection.DoesColumnExist("credit_cards", "label")); |
911 } | 891 } |
912 | 892 |
913 // Load the database via the WebDatabase class and migrate the database to | 893 DoMigration(); |
914 // the current version. | |
915 { | |
916 WebDatabase db; | |
917 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
918 } | |
919 | 894 |
920 // Verify post-conditions. These are expectations for current version of the | 895 // Verify post-conditions. These are expectations for current version of the |
921 // database. | 896 // database. |
922 { | 897 { |
923 sql::Connection connection; | 898 sql::Connection connection; |
924 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 899 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
925 | 900 |
926 // Check version. | 901 // Check version. |
927 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 902 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
928 | 903 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1188 | 1163 |
1189 // Check that the country value is the one we expect. | 1164 // Check that the country value is the one we expect. |
1190 sql::Statement s( | 1165 sql::Statement s( |
1191 connection.GetUniqueStatement("SELECT country FROM autofill_profiles")); | 1166 connection.GetUniqueStatement("SELECT country FROM autofill_profiles")); |
1192 | 1167 |
1193 ASSERT_TRUE(s.Step()); | 1168 ASSERT_TRUE(s.Step()); |
1194 std::string country = s.ColumnString(0); | 1169 std::string country = s.ColumnString(0); |
1195 EXPECT_EQ("United States", country); | 1170 EXPECT_EQ("United States", country); |
1196 } | 1171 } |
1197 | 1172 |
1198 // Load the database via the WebDatabase class and migrate the database to | 1173 DoMigration(); |
1199 // the current version. | |
1200 { | |
1201 WebDatabase db; | |
1202 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1203 } | |
1204 | 1174 |
1205 // Verify post-conditions. These are expectations for current version of the | 1175 // Verify post-conditions. These are expectations for current version of the |
1206 // database. | 1176 // database. |
1207 { | 1177 { |
1208 sql::Connection connection; | 1178 sql::Connection connection; |
1209 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1179 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1210 | 1180 |
1211 // Check version. | 1181 // Check version. |
1212 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1182 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
1213 | 1183 |
(...skipping 30 matching lines...) Expand all Loading... | |
1244 "FROM autofill_profiles")); | 1214 "FROM autofill_profiles")); |
1245 | 1215 |
1246 ASSERT_TRUE(s.Step()); | 1216 ASSERT_TRUE(s.Step()); |
1247 std::string country_code = s.ColumnString(0); | 1217 std::string country_code = s.ColumnString(0); |
1248 EXPECT_EQ("UK", country_code); | 1218 EXPECT_EQ("UK", country_code); |
1249 | 1219 |
1250 // Should have only one. | 1220 // Should have only one. |
1251 ASSERT_FALSE(s.Step()); | 1221 ASSERT_FALSE(s.Step()); |
1252 } | 1222 } |
1253 | 1223 |
1254 // Load the database via the WebDatabase class and migrate the database to | 1224 DoMigration(); |
1255 // the current version. | |
1256 { | |
1257 WebDatabase db; | |
1258 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1259 } | |
1260 | 1225 |
1261 // Verify post-conditions. These are expectations for current version of the | 1226 // Verify post-conditions. These are expectations for current version of the |
1262 // database. | 1227 // database. |
1263 { | 1228 { |
1264 sql::Connection connection; | 1229 sql::Connection connection; |
1265 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1230 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1266 | 1231 |
1267 // Check version. | 1232 // Check version. |
1268 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1233 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
1269 | 1234 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1301 | 1266 |
1302 // Check that there are 6 profiles prior to merge. | 1267 // Check that there are 6 profiles prior to merge. |
1303 sql::Statement s( | 1268 sql::Statement s( |
1304 connection.GetUniqueStatement("SELECT guid FROM autofill_profiles")); | 1269 connection.GetUniqueStatement("SELECT guid FROM autofill_profiles")); |
1305 int i = 0; | 1270 int i = 0; |
1306 while (s.Step()) | 1271 while (s.Step()) |
1307 ++i; | 1272 ++i; |
1308 EXPECT_EQ(6, i); | 1273 EXPECT_EQ(6, i); |
1309 } | 1274 } |
1310 | 1275 |
1311 // Load the database via the WebDatabase class and migrate the database to | 1276 DoMigration(); |
1312 // the current version. | |
1313 { | |
1314 WebDatabase db; | |
1315 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1316 } | |
1317 | 1277 |
1318 // Verify post-conditions. These are expectations for current version of the | 1278 // Verify post-conditions. These are expectations for current version of the |
1319 // database. | 1279 // database. |
1320 { | 1280 { |
1321 sql::Connection connection; | 1281 sql::Connection connection; |
1322 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1282 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1323 | 1283 |
1324 // Check version. | 1284 // Check version. |
1325 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1285 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
1326 | 1286 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1385 // database. | 1345 // database. |
1386 { | 1346 { |
1387 sql::Connection connection; | 1347 sql::Connection connection; |
1388 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1348 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1389 | 1349 |
1390 // Columns existing and not existing before current version. | 1350 // Columns existing and not existing before current version. |
1391 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); | 1351 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); |
1392 ASSERT_FALSE(connection.DoesColumnExist("keywords", "last_modified")); | 1352 ASSERT_FALSE(connection.DoesColumnExist("keywords", "last_modified")); |
1393 } | 1353 } |
1394 | 1354 |
1395 // Load the database via the WebDatabase class and migrate the database to | 1355 DoMigration(); |
1396 // the current version. | |
1397 { | |
1398 WebDatabase db; | |
1399 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1400 } | |
1401 | 1356 |
1402 // Verify post-conditions. These are expectations for current version of the | 1357 // Verify post-conditions. These are expectations for current version of the |
1403 // database. | 1358 // database. |
1404 { | 1359 { |
1405 sql::Connection connection; | 1360 sql::Connection connection; |
1406 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1361 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1407 | 1362 |
1408 // Check version. | 1363 // Check version. |
1409 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1364 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
1410 | 1365 |
(...skipping 14 matching lines...) Expand all Loading... | |
1425 // database. | 1380 // database. |
1426 { | 1381 { |
1427 sql::Connection connection; | 1382 sql::Connection connection; |
1428 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1383 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1429 | 1384 |
1430 // Columns existing and not existing before current version. | 1385 // Columns existing and not existing before current version. |
1431 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); | 1386 ASSERT_TRUE(connection.DoesColumnExist("keywords", "id")); |
1432 ASSERT_FALSE(connection.DoesColumnExist("keywords", "sync_guid")); | 1387 ASSERT_FALSE(connection.DoesColumnExist("keywords", "sync_guid")); |
1433 } | 1388 } |
1434 | 1389 |
1435 // Load the database via the WebDatabase class and migrate the database to | 1390 DoMigration(); |
1436 // the current version. | |
1437 { | |
1438 WebDatabase db; | |
1439 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1440 } | |
1441 | 1391 |
1442 // Verify post-conditions. These are expectations for current version of the | 1392 // Verify post-conditions. These are expectations for current version of the |
1443 // database. | 1393 // database. |
1444 { | 1394 { |
1445 sql::Connection connection; | 1395 sql::Connection connection; |
1446 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1396 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1447 | 1397 |
1448 // Check version. | 1398 // Check version. |
1449 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1399 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
1450 | 1400 |
(...skipping 19 matching lines...) Expand all Loading... | |
1470 sql::MetaTable meta_table; | 1420 sql::MetaTable meta_table; |
1471 ASSERT_TRUE(meta_table.Init(&connection, 39, 39)); | 1421 ASSERT_TRUE(meta_table.Init(&connection, 39, 39)); |
1472 | 1422 |
1473 int64 default_search_provider_id = 0; | 1423 int64 default_search_provider_id = 0; |
1474 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, | 1424 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, |
1475 &default_search_provider_id)); | 1425 &default_search_provider_id)); |
1476 | 1426 |
1477 EXPECT_NO_FATAL_FAILURE(CheckNoBackupData(connection, &meta_table)); | 1427 EXPECT_NO_FATAL_FAILURE(CheckNoBackupData(connection, &meta_table)); |
1478 } | 1428 } |
1479 | 1429 |
1480 // Load the database via the WebDatabase class and migrate the database to | 1430 DoMigration(); |
1481 // the current version. | |
1482 { | |
1483 WebDatabase db; | |
1484 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1485 } | |
1486 | 1431 |
1487 // Verify post-conditions. These are expectations for current version of the | 1432 // Verify post-conditions. These are expectations for current version of the |
1488 // database. | 1433 // database. |
1489 { | 1434 { |
1490 sql::Connection connection; | 1435 sql::Connection connection; |
1491 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1436 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1492 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1437 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1493 | 1438 |
1494 // Check version. | 1439 // Check version. |
1495 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1440 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 25 matching lines...) Expand all Loading... | |
1521 sql::MetaTable meta_table; | 1466 sql::MetaTable meta_table; |
1522 ASSERT_TRUE(meta_table.Init(&connection, 40, 40)); | 1467 ASSERT_TRUE(meta_table.Init(&connection, 40, 40)); |
1523 | 1468 |
1524 int64 default_search_provider_id = 0; | 1469 int64 default_search_provider_id = 0; |
1525 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, | 1470 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, |
1526 &default_search_provider_id)); | 1471 &default_search_provider_id)); |
1527 | 1472 |
1528 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); | 1473 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); |
1529 } | 1474 } |
1530 | 1475 |
1531 // Load the database via the WebDatabase class and migrate the database to | 1476 DoMigration(); |
1532 // the current version. | |
1533 { | |
1534 WebDatabase db; | |
1535 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1536 } | |
1537 | 1477 |
1538 // Verify post-conditions. These are expectations for current version of the | 1478 // Verify post-conditions. These are expectations for current version of the |
1539 // database. | 1479 // database. |
1540 { | 1480 { |
1541 sql::Connection connection; | 1481 sql::Connection connection; |
1542 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1482 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1543 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1483 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1544 | 1484 |
1545 // Check version. | 1485 // Check version. |
1546 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1486 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 25 matching lines...) Expand all Loading... | |
1572 sql::MetaTable meta_table; | 1512 sql::MetaTable meta_table; |
1573 ASSERT_TRUE(meta_table.Init(&connection, 41, 41)); | 1513 ASSERT_TRUE(meta_table.Init(&connection, 41, 41)); |
1574 | 1514 |
1575 int64 default_search_provider_id = 0; | 1515 int64 default_search_provider_id = 0; |
1576 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, | 1516 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, |
1577 &default_search_provider_id)); | 1517 &default_search_provider_id)); |
1578 | 1518 |
1579 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); | 1519 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); |
1580 } | 1520 } |
1581 | 1521 |
1582 // Load the database via the WebDatabase class and migrate the database to | 1522 DoMigration(); |
1583 // the current version. | |
1584 { | |
1585 WebDatabase db; | |
1586 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1587 } | |
1588 | 1523 |
1589 // Verify post-conditions. These are expectations for current version of the | 1524 // Verify post-conditions. These are expectations for current version of the |
1590 // database. | 1525 // database. |
1591 { | 1526 { |
1592 sql::Connection connection; | 1527 sql::Connection connection; |
1593 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1528 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1594 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1529 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1595 | 1530 |
1596 // Check version. | 1531 // Check version. |
1597 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1532 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 27 matching lines...) Expand all Loading... | |
1625 | 1560 |
1626 int64 default_search_provider_id = 0; | 1561 int64 default_search_provider_id = 0; |
1627 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, | 1562 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, |
1628 &default_search_provider_id)); | 1563 &default_search_provider_id)); |
1629 | 1564 |
1630 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); | 1565 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); |
1631 | 1566 |
1632 EXPECT_FALSE(connection.DoesTableExist("keywords_backup")); | 1567 EXPECT_FALSE(connection.DoesTableExist("keywords_backup")); |
1633 } | 1568 } |
1634 | 1569 |
1635 // Load the database via the WebDatabase class and migrate the database to | 1570 DoMigration(); |
1636 // the current version. | |
1637 { | |
1638 WebDatabase db; | |
1639 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1640 } | |
1641 | 1571 |
1642 // Verify post-conditions. These are expectations for current version of the | 1572 // Verify post-conditions. These are expectations for current version of the |
1643 // database. | 1573 // database. |
1644 { | 1574 { |
1645 sql::Connection connection; | 1575 sql::Connection connection; |
1646 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1576 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1647 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1577 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1648 | 1578 |
1649 // Check version. | 1579 // Check version. |
1650 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1580 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 30 matching lines...) Expand all Loading... | |
1681 int64 default_search_provider_id = 0; | 1611 int64 default_search_provider_id = 0; |
1682 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, | 1612 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, |
1683 &default_search_provider_id)); | 1613 &default_search_provider_id)); |
1684 EXPECT_NE(default_search_provider_id, 0); | 1614 EXPECT_NE(default_search_provider_id, 0); |
1685 previous_default_search_provider_id = default_search_provider_id; | 1615 previous_default_search_provider_id = default_search_provider_id; |
1686 | 1616 |
1687 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); | 1617 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); |
1688 EXPECT_TRUE(connection.DoesTableExist("keywords_backup")); | 1618 EXPECT_TRUE(connection.DoesTableExist("keywords_backup")); |
1689 } | 1619 } |
1690 | 1620 |
1691 // Load the database via the WebDatabase class and migrate the database to | 1621 DoMigration(); |
1692 // the current version. | |
1693 { | |
1694 WebDatabase db; | |
1695 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1696 } | |
1697 | 1622 |
1698 // Verify post-conditions. These are expectations for current version of the | 1623 // Verify post-conditions. These are expectations for current version of the |
1699 // database. | 1624 // database. |
1700 { | 1625 { |
1701 sql::Connection connection; | 1626 sql::Connection connection; |
1702 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1627 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1703 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1628 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1704 | 1629 |
1705 // Check version. | 1630 // Check version. |
1706 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1631 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 26 matching lines...) Expand all Loading... | |
1733 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1658 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1734 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1659 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1735 | 1660 |
1736 sql::MetaTable meta_table; | 1661 sql::MetaTable meta_table; |
1737 ASSERT_TRUE(meta_table.Init(&connection, 44, 44)); | 1662 ASSERT_TRUE(meta_table.Init(&connection, 44, 44)); |
1738 | 1663 |
1739 ASSERT_TRUE(connection.DoesColumnExist("keywords", "autogenerate_keyword")); | 1664 ASSERT_TRUE(connection.DoesColumnExist("keywords", "autogenerate_keyword")); |
1740 ASSERT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); | 1665 ASSERT_TRUE(connection.DoesColumnExist("keywords", "logo_id")); |
1741 } | 1666 } |
1742 | 1667 |
1743 // Load the database via the WebDatabase class and migrate the database to | 1668 DoMigration(); |
1744 // the current version. | |
1745 { | |
1746 WebDatabase db; | |
1747 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1748 } | |
1749 | 1669 |
1750 // Verify post-conditions. These are expectations for current version of the | 1670 // Verify post-conditions. These are expectations for current version of the |
1751 // database. | 1671 // database. |
1752 { | 1672 { |
1753 sql::Connection connection; | 1673 sql::Connection connection; |
1754 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1674 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1755 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1675 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1756 | 1676 |
1757 // Check version. | 1677 // Check version. |
1758 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1678 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 30 matching lines...) Expand all Loading... | |
1789 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1709 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1790 | 1710 |
1791 sql::MetaTable meta_table; | 1711 sql::MetaTable meta_table; |
1792 ASSERT_TRUE(meta_table.Init(&connection, 45, 45)); | 1712 ASSERT_TRUE(meta_table.Init(&connection, 45, 45)); |
1793 | 1713 |
1794 ASSERT_FALSE(connection.DoesColumnExist("scheme", "web_intents")); | 1714 ASSERT_FALSE(connection.DoesColumnExist("scheme", "web_intents")); |
1795 ASSERT_FALSE(connection.DoesColumnExist( | 1715 ASSERT_FALSE(connection.DoesColumnExist( |
1796 "scheme", "web_intents_defaults")); | 1716 "scheme", "web_intents_defaults")); |
1797 } | 1717 } |
1798 | 1718 |
1799 // Load the database via the WebDatabase class and migrate the database to | 1719 DoMigration(); |
1800 // the current version. | |
1801 { | |
1802 WebDatabase db; | |
1803 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1804 } | |
1805 | 1720 |
1806 // Verify post-conditions. These are expectations for current version of the | 1721 // Verify post-conditions. These are expectations for current version of the |
1807 // database. | 1722 // database. |
1808 { | 1723 { |
1809 sql::Connection connection; | 1724 sql::Connection connection; |
1810 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1725 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1811 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1726 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1812 | 1727 |
1813 // Check version. | 1728 // Check version. |
1814 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1729 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1870 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1785 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1871 | 1786 |
1872 sql::MetaTable meta_table; | 1787 sql::MetaTable meta_table; |
1873 ASSERT_TRUE(meta_table.Init(&connection, 45, 45)); | 1788 ASSERT_TRUE(meta_table.Init(&connection, 45, 45)); |
1874 | 1789 |
1875 ASSERT_FALSE(connection.DoesColumnExist("scheme", "web_intents")); | 1790 ASSERT_FALSE(connection.DoesColumnExist("scheme", "web_intents")); |
1876 ASSERT_FALSE(connection.DoesColumnExist( | 1791 ASSERT_FALSE(connection.DoesColumnExist( |
1877 "scheme", "web_intents_defaults")); | 1792 "scheme", "web_intents_defaults")); |
1878 } | 1793 } |
1879 | 1794 |
1880 // Load the database via the WebDatabase class and migrate the database to | 1795 DoMigration(); |
1881 // the current version. | |
1882 { | |
1883 WebDatabase db; | |
1884 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1885 } | |
1886 | 1796 |
1887 // Verify post-conditions. These are expectations for current version of the | 1797 // Verify post-conditions. These are expectations for current version of the |
1888 // database. | 1798 // database. |
1889 { | 1799 { |
1890 sql::Connection connection; | 1800 sql::Connection connection; |
1891 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1801 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1892 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1802 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1893 | 1803 |
1894 // Check version. | 1804 // Check version. |
1895 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1805 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1935 { | 1845 { |
1936 sql::Connection connection; | 1846 sql::Connection connection; |
1937 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1847 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1938 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1848 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1939 | 1849 |
1940 sql::MetaTable meta_table; | 1850 sql::MetaTable meta_table; |
1941 // Database is actually version 45 but the version field states 40. | 1851 // Database is actually version 45 but the version field states 40. |
1942 ASSERT_TRUE(meta_table.Init(&connection, 40, 45)); | 1852 ASSERT_TRUE(meta_table.Init(&connection, 40, 45)); |
1943 } | 1853 } |
1944 | 1854 |
1945 // Load the database via the WebDatabase class and migrate the database to | 1855 DoMigration(); |
1946 // the current version. | |
1947 { | |
1948 WebDatabase db; | |
1949 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1950 } | |
1951 | 1856 |
1952 // Verify post-conditions. These are expectations for current version of the | 1857 // Verify post-conditions. These are expectations for current version of the |
1953 // database. | 1858 // database. |
1954 { | 1859 { |
1955 sql::Connection connection; | 1860 sql::Connection connection; |
1956 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1861 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1957 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1862 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1958 | 1863 |
1959 // Check version. | 1864 // Check version. |
1960 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1865 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 15 matching lines...) Expand all Loading... | |
1976 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1881 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1977 | 1882 |
1978 sql::MetaTable meta_table; | 1883 sql::MetaTable meta_table; |
1979 ASSERT_TRUE(meta_table.Init(&connection, 46, 46)); | 1884 ASSERT_TRUE(meta_table.Init(&connection, 46, 46)); |
1980 | 1885 |
1981 ASSERT_FALSE(connection.DoesColumnExist("keywords", "alternate_urls")); | 1886 ASSERT_FALSE(connection.DoesColumnExist("keywords", "alternate_urls")); |
1982 ASSERT_FALSE(connection.DoesColumnExist("keywords_backup", | 1887 ASSERT_FALSE(connection.DoesColumnExist("keywords_backup", |
1983 "alternate_urls")); | 1888 "alternate_urls")); |
1984 } | 1889 } |
1985 | 1890 |
1986 // Load the database via the WebDatabase class and migrate the database to | 1891 DoMigration(); |
1987 // the current version. | |
1988 { | |
1989 WebDatabase db; | |
1990 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
1991 } | |
1992 | 1892 |
1993 // Verify post-conditions. These are expectations for current version of the | 1893 // Verify post-conditions. These are expectations for current version of the |
1994 // database. | 1894 // database. |
1995 { | 1895 { |
1996 sql::Connection connection; | 1896 sql::Connection connection; |
1997 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1897 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
1998 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1898 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
1999 | 1899 |
2000 // Check version. | 1900 // Check version. |
2001 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1901 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 19 matching lines...) Expand all Loading... | |
2021 | 1921 |
2022 int64 default_search_provider_id = 0; | 1922 int64 default_search_provider_id = 0; |
2023 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, | 1923 EXPECT_TRUE(meta_table.GetValue(KeywordTable::kDefaultSearchProviderKey, |
2024 &default_search_provider_id)); | 1924 &default_search_provider_id)); |
2025 EXPECT_NE(0, default_search_provider_id); | 1925 EXPECT_NE(0, default_search_provider_id); |
2026 | 1926 |
2027 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); | 1927 EXPECT_NO_FATAL_FAILURE(CheckHasBackupData(&meta_table)); |
2028 EXPECT_TRUE(connection.DoesTableExist("keywords_backup")); | 1928 EXPECT_TRUE(connection.DoesTableExist("keywords_backup")); |
2029 } | 1929 } |
2030 | 1930 |
2031 // Load the database via the WebDatabase class and migrate the database to | 1931 DoMigration(); |
2032 // the current version. | |
2033 { | |
2034 WebDatabase db; | |
2035 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
2036 } | |
2037 | 1932 |
2038 // Verify post-conditions. These are expectations for current version of the | 1933 // Verify post-conditions. These are expectations for current version of the |
2039 // database. | 1934 // database. |
2040 { | 1935 { |
2041 sql::Connection connection; | 1936 sql::Connection connection; |
2042 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1937 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
2043 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1938 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
2044 | 1939 |
2045 // Check version. | 1940 // Check version. |
2046 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1941 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
(...skipping 24 matching lines...) Expand all Loading... | |
2071 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1966 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
2072 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1967 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
2073 | 1968 |
2074 sql::MetaTable meta_table; | 1969 sql::MetaTable meta_table; |
2075 ASSERT_TRUE(meta_table.Init(&connection, 48, 48)); | 1970 ASSERT_TRUE(meta_table.Init(&connection, 48, 48)); |
2076 | 1971 |
2077 ASSERT_FALSE(connection.DoesColumnExist("keywords", | 1972 ASSERT_FALSE(connection.DoesColumnExist("keywords", |
2078 "search_terms_replacement_key")); | 1973 "search_terms_replacement_key")); |
2079 } | 1974 } |
2080 | 1975 |
2081 // Load the database via the WebDatabase class and migrate the database to | 1976 DoMigration(); |
2082 // the current version. | |
2083 { | |
2084 WebDatabase db; | |
2085 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); | |
2086 } | |
2087 | 1977 |
2088 // Verify post-conditions. These are expectations for current version of the | 1978 // Verify post-conditions. These are expectations for current version of the |
2089 // database. | 1979 // database. |
2090 { | 1980 { |
2091 sql::Connection connection; | 1981 sql::Connection connection; |
2092 ASSERT_TRUE(connection.Open(GetDatabasePath())); | 1982 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
2093 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); | 1983 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); |
2094 | 1984 |
2095 // Check version. | 1985 // Check version. |
2096 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); | 1986 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection)); |
2097 | 1987 |
2098 // A new column should have been created. | 1988 // A new column should have been created. |
2099 EXPECT_TRUE(connection.DoesColumnExist("keywords", | 1989 EXPECT_TRUE(connection.DoesColumnExist("keywords", |
2100 "search_terms_replacement_key")); | 1990 "search_terms_replacement_key")); |
2101 } | 1991 } |
2102 } | 1992 } |
OLD | NEW |