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

Side by Side Diff: chrome/browser/webdata/web_database_migration_unittest.cc

Issue 8502019: Added internal Protector key to official build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added check for DSP Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/webdata/web_database.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void MigrateVersion28Assertions(); 189 void MigrateVersion28Assertions();
190 190
191 private: 191 private:
192 MessageLoopForUI message_loop_for_ui_; 192 MessageLoopForUI message_loop_for_ui_;
193 content::TestBrowserThread ui_thread_; 193 content::TestBrowserThread ui_thread_;
194 ScopedTempDir temp_dir_; 194 ScopedTempDir temp_dir_;
195 195
196 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 196 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
197 }; 197 };
198 198
199 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 40; 199 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 41;
200 200
201 void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) { 201 void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
202 std::string contents; 202 std::string contents;
203 ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents)); 203 ASSERT_TRUE(GetWebDatabaseData(FilePath(file), &contents));
204 204
205 sql::Connection connection; 205 sql::Connection connection;
206 ASSERT_TRUE(connection.Open(GetDatabasePath())); 206 ASSERT_TRUE(connection.Open(GetDatabasePath()));
207 ASSERT_TRUE(connection.Execute(contents.data())); 207 ASSERT_TRUE(connection.Execute(contents.data()));
208 } 208 }
209 209
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 1499
1500 // |keywords| |sync_guid| column should have been added. 1500 // |keywords| |sync_guid| column should have been added.
1501 EXPECT_TRUE(connection.DoesColumnExist("keywords", "id")); 1501 EXPECT_TRUE(connection.DoesColumnExist("keywords", "id"));
1502 EXPECT_TRUE(connection.DoesColumnExist("keywords", "sync_guid")); 1502 EXPECT_TRUE(connection.DoesColumnExist("keywords", "sync_guid"));
1503 } 1503 }
1504 } 1504 }
1505 1505
1506 // Tests that the backup field for the default search provider gets added to 1506 // Tests that the backup field for the default search provider gets added to
1507 // the meta table of a version 39 database. 1507 // the meta table of a version 39 database.
1508 TEST_F(WebDatabaseMigrationTest, MigrateVersion39ToCurrent) { 1508 TEST_F(WebDatabaseMigrationTest, MigrateVersion39ToCurrent) {
1509 // This schema is taken from a build prior to the addition of the defaul 1509 // This schema is taken from a build prior to the addition of the default
1510 // search provider backup field to the meta table. 1510 // search provider backup field to the meta table.
1511 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_39.sql"))); 1511 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_39.sql")));
1512 1512
1513 // Verify pre-conditions. These are expectations for version 39 of the 1513 // Verify pre-conditions. These are expectations for version 39 of the
1514 // database. 1514 // database.
1515 { 1515 {
1516 sql::Connection connection; 1516 sql::Connection connection;
1517 ASSERT_TRUE(connection.Open(GetDatabasePath())); 1517 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1518 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection)); 1518 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1519 1519
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 &default_search_provider_id_backup)); 1570 &default_search_provider_id_backup));
1571 EXPECT_EQ(default_search_provider_id, default_search_provider_id_backup); 1571 EXPECT_EQ(default_search_provider_id, default_search_provider_id_backup);
1572 1572
1573 std::string default_search_provider_id_backup_signature; 1573 std::string default_search_provider_id_backup_signature;
1574 EXPECT_TRUE(meta_table.GetValue( 1574 EXPECT_TRUE(meta_table.GetValue(
1575 "Default Search Provider ID Backup Signature", 1575 "Default Search Provider ID Backup Signature",
1576 &default_search_provider_id_backup_signature)); 1576 &default_search_provider_id_backup_signature));
1577 } 1577 }
1578 } 1578 }
1579 1579
1580 // Tests that the backup field for the default search provider is rewritten
1581 // despite any value in the old version.
1582 TEST_F(WebDatabaseMigrationTest, MigrateVersion40ToCurrent) {
1583 // This schema is taken from a build after the addition of the default
1584 // search provider backup field to the meta table. Due to crbug.com/101815
1585 // the signature was empty in all build between revisions 106214 and 108111.
1586 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_40.sql")));
1587
1588 // Verify pre-conditions. These are expectations for version 40 of the
1589 // database.
1590 {
1591 sql::Connection connection;
1592 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1593 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1594
1595 sql::MetaTable meta_table;
1596 ASSERT_TRUE(meta_table.Init(&connection, 40, 40));
1597
1598 int64 default_search_provider_id = 0;
1599 EXPECT_TRUE(meta_table.GetValue(
1600 "Default Search Provider ID",
1601 &default_search_provider_id));
1602
1603 int64 default_search_provider_id_backup = 0;
1604 EXPECT_TRUE(meta_table.GetValue(
1605 "Default Search Provider ID Backup",
1606 &default_search_provider_id_backup));
1607
1608 std::string default_search_provider_id_backup_signature;
1609 EXPECT_TRUE(meta_table.GetValue(
1610 "Default Search Provider ID Backup Signature",
1611 &default_search_provider_id_backup_signature));
1612 EXPECT_TRUE(default_search_provider_id_backup_signature.empty());
1613 }
1614
1615 // Load the database via the WebDatabase class and migrate the database to
1616 // the current version.
1617 {
1618 WebDatabase db;
1619 ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
1620 }
1621
1622 // Verify post-conditions. These are expectations for current version of the
1623 // database.
1624 {
1625 sql::Connection connection;
1626 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1627 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1628
1629 // Check version.
1630 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
1631
1632 sql::MetaTable meta_table;
1633 ASSERT_TRUE(meta_table.Init(
1634 &connection,
1635 kCurrentTestedVersionNumber,
1636 kCurrentTestedVersionNumber));
1637
1638 int64 default_search_provider_id = 0;
1639 EXPECT_TRUE(meta_table.GetValue(
1640 "Default Search Provider ID",
1641 &default_search_provider_id));
1642 EXPECT_NE(0, default_search_provider_id);
1643
1644 int64 default_search_provider_id_backup = 0;
1645 EXPECT_TRUE(meta_table.GetValue(
1646 "Default Search Provider ID Backup",
1647 &default_search_provider_id_backup));
1648 EXPECT_EQ(default_search_provider_id, default_search_provider_id_backup);
1649
1650 std::string default_search_provider_id_backup_signature;
1651 EXPECT_TRUE(meta_table.GetValue(
1652 "Default Search Provider ID Backup Signature",
1653 &default_search_provider_id_backup_signature));
1654 EXPECT_FALSE(default_search_provider_id_backup_signature.empty());
1655 }
1656 }
1657
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698