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

Side by Side Diff: chrome/browser/sync/syncable/directory_backing_store_unittest.cc

Issue 8770032: [Sync] Implement encryption-aware conflict resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 9 years 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
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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 void SetUpVersion67Database(); 46 void SetUpVersion67Database();
47 void SetUpVersion68Database(); 47 void SetUpVersion68Database();
48 void SetUpVersion69Database(); 48 void SetUpVersion69Database();
49 void SetUpVersion70Database(); 49 void SetUpVersion70Database();
50 void SetUpVersion71Database(); 50 void SetUpVersion71Database();
51 void SetUpVersion72Database(); 51 void SetUpVersion72Database();
52 void SetUpVersion73Database(); 52 void SetUpVersion73Database();
53 void SetUpVersion74Database(); 53 void SetUpVersion74Database();
54 void SetUpVersion75Database(); 54 void SetUpVersion75Database();
55 void SetUpVersion76Database(); 55 void SetUpVersion76Database();
56 void SetUpVersion77Database();
56 57
57 void SetUpCurrentDatabaseAndCheckVersion() { 58 void SetUpCurrentDatabaseAndCheckVersion() {
58 SetUpVersion70Database(); // Prepopulates data. 59 SetUpVersion70Database(); // Prepopulates data.
59 scoped_ptr<DirectoryBackingStore> dbs( 60 scoped_ptr<DirectoryBackingStore> dbs(
60 new DirectoryBackingStore(GetUsername(), GetDatabasePath())); 61 new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
61 62
62 dbs->BeginLoad(); 63 dbs->BeginLoad();
63 ASSERT_EQ(OPENED, dbs->InitializeTables()); 64 ASSERT_EQ(OPENED, dbs->InitializeTables());
64 ASSERT_FALSE(dbs->needs_column_refresh_); 65 ASSERT_FALSE(dbs->needs_column_refresh_);
65 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion()); 66 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 #define META_PROTO_TIMES_STR_12 "1263522151000" 200 #define META_PROTO_TIMES_STR_12 "1263522151000"
200 #define META_PROTO_TIMES_STR_13 "1263522198000" 201 #define META_PROTO_TIMES_STR_13 "1263522198000"
201 #define META_PROTO_TIMES_STR_14 "1263522238000" 202 #define META_PROTO_TIMES_STR_14 "1263522238000"
202 203
203 #endif 204 #endif
204 205
205 // Helper macros for the database dumps in the SetUpVersion*Database 206 // Helper macros for the database dumps in the SetUpVersion*Database
206 // functions. 207 // functions.
207 #define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x 208 #define LEGACY_META_PROTO_TIMES(x) LEGACY_META_PROTO_TIMES_##x
208 #define LEGACY_META_PROTO_TIMES_STR(x) LEGACY_META_PROTO_TIMES_STR_##x 209 #define LEGACY_META_PROTO_TIMES_STR(x) LEGACY_META_PROTO_TIMES_STR_##x
209 #define META_PROTO_TIMES(x) META_PROTO_TIMES_##x
210 #define LEGACY_PROTO_TIME_VALS(x) \ 210 #define LEGACY_PROTO_TIME_VALS(x) \
211 LEGACY_META_PROTO_TIMES_STR(x) "," \ 211 LEGACY_META_PROTO_TIMES_STR(x) "," \
212 LEGACY_META_PROTO_TIMES_STR(x) "," \ 212 LEGACY_META_PROTO_TIMES_STR(x) "," \
213 LEGACY_META_PROTO_TIMES_STR(x) "," \ 213 LEGACY_META_PROTO_TIMES_STR(x) "," \
214 LEGACY_META_PROTO_TIMES_STR(x) 214 LEGACY_META_PROTO_TIMES_STR(x)
215 #define META_PROTO_TIMES(x) META_PROTO_TIMES_##x
216 #define META_PROTO_TIMES_STR(x) META_PROTO_TIMES_STR_##x
217 #define META_PROTO_TIMES_VALS(x) \
218 META_PROTO_TIMES_STR(x) "," \
219 META_PROTO_TIMES_STR(x) "," \
220 META_PROTO_TIMES_STR(x) "," \
221 META_PROTO_TIMES_STR(x)
215 222
216 namespace { 223 namespace {
217 224
218 // Helper functions for testing. 225 // Helper functions for testing.
219 226
220 // Returns a map from metahandle -> expected legacy time (in proto 227 // Returns a map from metahandle -> expected legacy time (in proto
221 // format). 228 // format).
222 std::map<int64, int64> GetExpectedLegacyMetaProtoTimes() { 229 std::map<int64, int64> GetExpectedLegacyMetaProtoTimes() {
223 std::map<int64, int64> expected_legacy_meta_proto_times; 230 std::map<int64, int64> expected_legacy_meta_proto_times;
224 expected_legacy_meta_proto_times[1] = LEGACY_META_PROTO_TIMES(1); 231 expected_legacy_meta_proto_times[1] = LEGACY_META_PROTO_TIMES(1);
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" 1434 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1428 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa" 1435 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1429 "ult -2, cache_guid TEXT , notification_state BLOB);" 1436 "ult -2, cache_guid TEXT , notification_state BLOB);"
1430 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," 1437 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1431 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'" 1438 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1432 "9010788312004066376x-6609234393368420856x',NULL);" 1439 "9010788312004066376x-6609234393368420856x',NULL);"
1433 )); 1440 ));
1434 ASSERT_TRUE(connection.CommitTransaction()); 1441 ASSERT_TRUE(connection.CommitTransaction());
1435 } 1442 }
1436 1443
1444 void MigrationTest::SetUpVersion77Database() {
1445 sql::Connection connection;
1446 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1447 ASSERT_TRUE(connection.BeginTransaction());
1448 ASSERT_TRUE(connection.Execute(
1449 "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
1450 "INSERT INTO 'share_version' VALUES('nick@chromium.org',77);"
1451 "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB, in"
1452 "itial_sync_ended BOOLEAN default 0);"
1453 "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1);"
1454 "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
1455 "_version bigint default -1,server_version bigint default 0,server_po"
1456 "sition_in_parent bigint default 0,local_external_id bigint default 0"
1457 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d"
1458 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p"
1459 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa"
1460 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul"
1461 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is"
1462 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0,"
1463 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu"
1464 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc"
1465 "har,specifics blob,server_specifics blob);"
1466 "INSERT INTO 'metas' VALUES(1,-1,0,0,0," META_PROTO_TIMES_VALS(1)
1467 ",'r','r','r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X'',X'');"
1468 "INSERT INTO 'metas' VALUES(2,669,669,-2097152,4,"
1469 META_PROTO_TIMES_VALS(2) ",'s_ID_2','s_ID_9','s_ID_9','s_ID_2','s_ID_"
1470 "2',0,0,1,0,0,1,'Deleted Item','Deleted Item',NULL,NULL,X'C28810220A1"
1471 "6687474703A2F2F7777772E676F6F676C652E636F6D2F12084141534741534741',X"
1472 "'C28810260A17687474703A2F2F7777772E676F6F676C652E636F6D2F32120B41534"
1473 "14447414447414447');"
1474 "INSERT INTO 'metas' VALUES(4,681,681,-3145728,3,"
1475 META_PROTO_TIMES_VALS(4) ",'s_ID_4','s_ID_9','s_ID_9','s_ID_4','s_ID_"
1476 "4',0,0,1,0,0,1,'Welcome to Chromium','Welcome to Chromium',NULL,NULL"
1477 ",X'C28810350A31687474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6"
1478 "D652F696E746C2F656E2F77656C636F6D652E68746D6C1200',X'C28810350A31687"
1479 "474703A2F2F7777772E676F6F676C652E636F6D2F6368726F6D652F696E746C2F656"
1480 "E2F77656C636F6D652E68746D6C1200');"
1481 "INSERT INTO 'metas' VALUES(5,677,677,1048576,7," META_PROTO_TIMES_VALS(5)
1482 ",'s_ID_5','s_ID_9','s_ID_9','s_ID_5','s_ID_5',0,0,1,0,0,1,'Google','"
1483 "Google',NULL,NULL,X'C28810220A16687474703A2F2F7777772E676F6F676C652E"
1484 "636F6D2F12084147415347415347',X'C28810220A16687474703A2F2F7777772E67"
1485 "6F6F676C652E636F6D2F12084147464447415347');"
1486 "INSERT INTO 'metas' VALUES(6,694,694,-4194304,6,"
1487 META_PROTO_TIMES_VALS(6) ",'s_ID_6','s_ID_9','s_ID_9','r','r',0,0,0,1"
1488 ",1,0,'The Internet','The Internet',NULL,NULL,X'C2881000',X'C2881000'"
1489 ");"
1490 "INSERT INTO 'metas' VALUES(7,663,663,1048576,0," META_PROTO_TIMES_VALS(7)
1491 ",'s_ID_7','r','r','r','r',0,0,0,1,1,0,'Google Chrome','Goo"
1492 "gle Chrome','google_chrome',NULL,NULL,NULL);"
1493 "INSERT INTO 'metas' VALUES(8,664,664,1048576,0," META_PROTO_TIMES_VALS(8)
1494 ",'s_ID_8','s_ID_7','s_ID_7','r','r',0,0,0,1,1,0,'Bookmarks','Bookmar"
1495 "ks','google_chrome_bookmarks',NULL,X'C2881000',X'C2881000');"
1496 "INSERT INTO 'metas' VALUES(9,665,665,1048576,1," META_PROTO_TIMES_VALS(9)
1497 ",'s_ID_9','s_ID_8','s_ID_8','r','s_ID_10',0,0,0,1,1,0,'Bookmark Bar'"
1498 ",'Bookmark Bar','bookmark_bar',NULL,X'C2881000',X'C2881000');"
1499 "INSERT INTO 'metas' VALUES(10,666,666,2097152,2,"
1500 META_PROTO_TIMES_VALS(10) ",'s_ID_10','s_ID_8','s_ID_8','s_ID_9','r',"
1501 "0,0,0,1,1,0,'Other Bookmarks','Other Bookmarks','other_bookmarks',NU"
1502 "LL,X'C2881000',X'C2881000');"
1503 "INSERT INTO 'metas' VALUES(11,683,683,-1048576,8,"
1504 META_PROTO_TIMES_VALS(11) ",'s_ID_11','s_ID_6','s_ID_6','r','s_ID_13'"
1505 ",0,0,0,0,0,0,'Home (The Chromium Projects)','Home (The Chromium Proj"
1506 "ects)',NULL,NULL,X'C28810220A18687474703A2F2F6465762E6368726F6D69756"
1507 "D2E6F72672F1206414741545741',X'C28810290A1D687474703A2F2F6465762E636"
1508 "8726F6D69756D2E6F72672F6F7468657212084146414756415346');"
1509 "INSERT INTO 'metas' VALUES(12,685,685,0,9," META_PROTO_TIMES_VALS(12)
1510 ",'s_ID_12','s_ID_6','s_"
1511 "ID_6','s_ID_13','s_ID_14',0,0,0,1,1,0,'Extra Bookmarks','Extra Bookm"
1512 "arks',NULL,NULL,X'C2881000',X'C2881000');"
1513 "INSERT INTO 'metas' VALUES(13,687,687,-917504,10,"
1514 META_PROTO_TIMES_VALS(13) ",'s_ID_13','s_ID_6','s_ID_6','s_ID_11','s_"
1515 "ID_12',0,0,0,0,0,0,'ICANN | Internet Corporation for Assigned Names "
1516 "and Numbers','ICANN | Internet Corporation for Assigned Names and Nu"
1517 "mbers',NULL,NULL,X'C28810240A15687474703A2F2F7777772E6963616E6E2E636"
1518 "F6D2F120B504E474158463041414646',X'C28810200A15687474703A2F2F7777772"
1519 "E6963616E6E2E636F6D2F120744414146415346');"
1520 "INSERT INTO 'metas' VALUES(14,692,692,1048576,11,"
1521 META_PROTO_TIMES_VALS(14) ",'s_ID_14','s_ID_6','s_ID_6','s_ID_12','r'"
1522 ",0,0,0,0,0,0,'The WebKit Open Source Project','The WebKit Open Sourc"
1523 "e Project',NULL,NULL,X'C288101A0A12687474703A2F2F7765626B69742E6F726"
1524 "72F1204504E4758',X'C288101C0A13687474703A2F2F7765626B69742E6F72672F7"
1525 "81205504E473259');"
1526 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
1527 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa"
1528 "ult -2, cache_guid TEXT , notification_state BLOB);"
1529 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
1530 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-65542,'"
1531 "9010788312004066376x-6609234393368420856x',NULL);"
1532 ));
1533 ASSERT_TRUE(connection.CommitTransaction());
1534 }
1535
1437 TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) { 1536 TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) {
1438 SetUpVersion67Database(); 1537 SetUpVersion67Database();
1439 1538
1440 { 1539 {
1441 sql::Connection connection; 1540 sql::Connection connection;
1442 ASSERT_TRUE(connection.Open(GetDatabasePath())); 1541 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1443 1542
1444 // Columns existing before version 67. 1543 // Columns existing before version 67.
1445 ASSERT_TRUE(connection.DoesColumnExist("metas", "name")); 1544 ASSERT_TRUE(connection.DoesColumnExist("metas", "name"));
1446 ASSERT_TRUE(connection.DoesColumnExist("metas", "unsanitized_name")); 1545 ASSERT_TRUE(connection.DoesColumnExist("metas", "unsanitized_name"));
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 ASSERT_TRUE(connection.DoesColumnExist("share_info", 1824 ASSERT_TRUE(connection.DoesColumnExist("share_info",
1726 "autofill_profiles_added_during_migration")); 1825 "autofill_profiles_added_during_migration"));
1727 } 1826 }
1728 1827
1729 scoped_ptr<DirectoryBackingStore> dbs( 1828 scoped_ptr<DirectoryBackingStore> dbs(
1730 new DirectoryBackingStore(GetUsername(), GetDatabasePath())); 1829 new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
1731 dbs->BeginLoad(); 1830 dbs->BeginLoad();
1732 ASSERT_FALSE(dbs->needs_column_refresh_); 1831 ASSERT_FALSE(dbs->needs_column_refresh_);
1733 ASSERT_TRUE(dbs->MigrateVersion75To76()); 1832 ASSERT_TRUE(dbs->MigrateVersion75To76());
1734 ASSERT_EQ(76, dbs->GetVersion()); 1833 ASSERT_EQ(76, dbs->GetVersion());
1834 dbs->EndLoad();
1735 ASSERT_TRUE(dbs->needs_column_refresh_); 1835 ASSERT_TRUE(dbs->needs_column_refresh_);
1736 dbs->RefreshColumns(); 1836 // Cannot actual refresh columns due to version 76 not containing all
1737 dbs->EndLoad(); 1837 // necessary columns.
1738
1739 sql::Connection connection;
1740 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1741 ASSERT_FALSE(
1742 connection.DoesColumnExist("share_info", "autofill_migration_state"));
1743 ASSERT_FALSE(
1744 connection.DoesColumnExist("share_info",
1745 "bookmarks_added_during_autofill_migration"));
1746 ASSERT_FALSE(
1747 connection.DoesColumnExist("share_info", "autofill_migration_time"));
1748 ASSERT_FALSE(
1749 connection.DoesColumnExist("share_info",
1750 "autofill_entries_added_during_migration"));
1751 ASSERT_FALSE(
1752 connection.DoesColumnExist("share_info",
1753 "autofill_profiles_added_during_migration"));
1754 } 1838 }
1755 1839
1756 TEST_F(DirectoryBackingStoreTest, MigrateVersion76To77) { 1840 TEST_F(DirectoryBackingStoreTest, MigrateVersion76To77) {
1757 SetUpVersion76Database(); 1841 SetUpVersion76Database();
1758 1842
1759 scoped_ptr<DirectoryBackingStore> dbs( 1843 scoped_ptr<DirectoryBackingStore> dbs(
1760 new DirectoryBackingStore(GetUsername(), GetDatabasePath())); 1844 new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
1761 dbs->BeginLoad(); 1845 dbs->BeginLoad();
1762 ASSERT_FALSE(dbs->needs_column_refresh_); 1846 ASSERT_FALSE(dbs->needs_column_refresh_);
1763 1847
1764 EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(), 1848 EXPECT_EQ(GetExpectedLegacyMetaProtoTimes(),
1765 GetMetaProtoTimes(dbs->load_dbhandle_)); 1849 GetMetaProtoTimes(dbs->load_dbhandle_));
1766 // Since we the proto times are expected to be in a legacy format, 1850 // Since the proto times are expected to be in a legacy format, they may not
1767 // they may not be compatible with ProtoTimeToTime, so we don't call 1851 // be compatible with ProtoTimeToTime, so we don't call ExpectTimes().
1768 // ExpectTimes().
1769 1852
1770 ASSERT_TRUE(dbs->MigrateVersion76To77()); 1853 ASSERT_TRUE(dbs->MigrateVersion76To77());
1771 ASSERT_EQ(77, dbs->GetVersion()); 1854 ASSERT_EQ(77, dbs->GetVersion());
1772 1855
1773 EXPECT_EQ(GetExpectedMetaProtoTimes(), 1856 EXPECT_EQ(GetExpectedMetaProtoTimes(),
1774 GetMetaProtoTimes(dbs->load_dbhandle_)); 1857 GetMetaProtoTimes(dbs->load_dbhandle_));
1775 1858 // Cannot actually load entries due to version 77 not having all required
1776 { 1859 // columns.
1777 MetahandlesIndex index;
1778 STLElementDeleter<MetahandlesIndex> index_deleter(&index);
1779 dbs->LoadEntries(&index);
1780 ExpectTimes(index, GetExpectedMetaTimes());
1781 }
1782
1783 dbs->EndLoad(); 1860 dbs->EndLoad();
1784 ASSERT_FALSE(dbs->needs_column_refresh_); 1861 ASSERT_FALSE(dbs->needs_column_refresh_);
1785 } 1862 }
1786 1863
1864 TEST_F(DirectoryBackingStoreTest, MigrateVersion77To78) {
1865 SetUpVersion77Database();
1866 {
1867 sql::Connection connection;
1868 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1869 ASSERT_FALSE(
1870 connection.DoesColumnExist("metas", "BASE_SERVER_SPECIFICS"));
1871 }
1872
1873 scoped_ptr<DirectoryBackingStore> dbs(
1874 new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
1875 dbs->BeginLoad();
1876 ASSERT_FALSE(dbs->needs_column_refresh_);
1877 ASSERT_TRUE(dbs->MigrateVersion77To78());
1878 ASSERT_EQ(78, dbs->GetVersion());
1879 dbs->EndLoad();
1880 ASSERT_FALSE(dbs->needs_column_refresh_);
1881
1882 sql::Connection connection;
1883 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1884 ASSERT_TRUE(
1885 connection.DoesColumnExist("metas", "base_server_specifics"));
1886 }
1887
1787 TEST_P(MigrationTest, ToCurrentVersion) { 1888 TEST_P(MigrationTest, ToCurrentVersion) {
1788 switch (GetParam()) { 1889 switch (GetParam()) {
1789 case 67: 1890 case 67:
1790 SetUpVersion67Database(); 1891 SetUpVersion67Database();
1791 break; 1892 break;
1792 case 68: 1893 case 68:
1793 SetUpVersion68Database(); 1894 SetUpVersion68Database();
1794 break; 1895 break;
1795 case 69: 1896 case 69:
1796 SetUpVersion69Database(); 1897 SetUpVersion69Database();
(...skipping 12 matching lines...) Expand all
1809 break; 1910 break;
1810 case 74: 1911 case 74:
1811 SetUpVersion74Database(); 1912 SetUpVersion74Database();
1812 break; 1913 break;
1813 case 75: 1914 case 75:
1814 SetUpVersion75Database(); 1915 SetUpVersion75Database();
1815 break; 1916 break;
1816 case 76: 1917 case 76:
1817 SetUpVersion76Database(); 1918 SetUpVersion76Database();
1818 break; 1919 break;
1920 case 77:
1921 SetUpVersion77Database();
1922 break;
1819 default: 1923 default:
1820 // If you see this error, it may mean that you've increased the 1924 // If you see this error, it may mean that you've increased the
1821 // database version number but you haven't finished adding unit tests 1925 // database version number but you haven't finished adding unit tests
1822 // for the database migration code. You need to need to supply a 1926 // for the database migration code. You need to need to supply a
1823 // SetUpVersionXXDatabase function with a dump of the test database 1927 // SetUpVersionXXDatabase function with a dump of the test database
1824 // at the old schema. Here's one way to do that: 1928 // at the old schema. Here's one way to do that:
1825 // 1. Start on a clean tree (with none of your pending schema changes). 1929 // 1. Start on a clean tree (with none of your pending schema changes).
1826 // 2. Set a breakpoint in this function and run the unit test. 1930 // 2. Set a breakpoint in this function and run the unit test.
1827 // 3. Allow this test to run to completion (step out of the call), 1931 // 3. Allow this test to run to completion (step out of the call),
1828 // without allowing ~MigrationTest to execute. 1932 // without allowing ~MigrationTest to execute.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 ASSERT_FALSE( 1990 ASSERT_FALSE(
1887 connection.DoesColumnExist("share_info", "autofill_migration_state")); 1991 connection.DoesColumnExist("share_info", "autofill_migration_state"));
1888 ASSERT_FALSE(connection.DoesColumnExist("share_info", 1992 ASSERT_FALSE(connection.DoesColumnExist("share_info",
1889 "bookmarks_added_during_autofill_migration")); 1993 "bookmarks_added_during_autofill_migration"));
1890 ASSERT_FALSE( 1994 ASSERT_FALSE(
1891 connection.DoesColumnExist("share_info", "autofill_migration_time")); 1995 connection.DoesColumnExist("share_info", "autofill_migration_time"));
1892 ASSERT_FALSE(connection.DoesColumnExist("share_info", 1996 ASSERT_FALSE(connection.DoesColumnExist("share_info",
1893 "autofill_entries_added_during_migration")); 1997 "autofill_entries_added_during_migration"));
1894 ASSERT_FALSE(connection.DoesColumnExist("share_info", 1998 ASSERT_FALSE(connection.DoesColumnExist("share_info",
1895 "autofill_profiles_added_during_migration")); 1999 "autofill_profiles_added_during_migration"));
2000
2001 // Column added in version 78
2002 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics"));
1896 } 2003 }
1897 { 2004 {
1898 syncable::Directory::KernelLoadInfo dir_info; 2005 syncable::Directory::KernelLoadInfo dir_info;
1899 dbs->LoadInfo(&dir_info); 2006 dbs->LoadInfo(&dir_info);
1900 2007
1901 // Check download_progress state (v75 migration) 2008 // Check download_progress state (v75 migration)
1902 ASSERT_EQ(694, 2009 ASSERT_EQ(694,
1903 dir_info.kernel_info.download_progress[syncable::BOOKMARKS] 2010 dir_info.kernel_info.download_progress[syncable::BOOKMARKS]
1904 .timestamp_token_for_migration()); 2011 .timestamp_token_for_migration());
1905 ASSERT_FALSE( 2012 ASSERT_FALSE(
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 2232
2126 STLDeleteElements(&index); 2233 STLDeleteElements(&index);
2127 dbs->LoadEntries(&index); 2234 dbs->LoadEntries(&index);
2128 EXPECT_EQ(0U, index.size()); 2235 EXPECT_EQ(0U, index.size());
2129 2236
2130 dbs->EndLoad(); 2237 dbs->EndLoad();
2131 dbs->EndSave(); 2238 dbs->EndSave();
2132 } 2239 }
2133 2240
2134 } // namespace syncable 2241 } // namespace syncable
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/directory_backing_store.cc ('k') | chrome/browser/sync/syncable/syncable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698