OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "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 29 matching lines...) Expand all Loading... |
40 std::string GetUsername() { | 40 std::string GetUsername() { |
41 return "nick@chromium.org"; | 41 return "nick@chromium.org"; |
42 } | 42 } |
43 | 43 |
44 FilePath GetDatabasePath() { | 44 FilePath GetDatabasePath() { |
45 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename); | 45 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename); |
46 } | 46 } |
47 | 47 |
48 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) { | 48 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) { |
49 MetahandlesIndex metas; | 49 MetahandlesIndex metas; |
| 50 JournalIndex delete_journals;; |
50 STLElementDeleter<MetahandlesIndex> index_deleter(&metas); | 51 STLElementDeleter<MetahandlesIndex> index_deleter(&metas); |
51 Directory::KernelLoadInfo kernel_load_info; | 52 Directory::KernelLoadInfo kernel_load_info; |
52 return dbs->Load(&metas, &kernel_load_info) == OPENED; | 53 return dbs->Load(&metas, &delete_journals, &kernel_load_info) == OPENED; |
53 } | 54 } |
54 | 55 |
55 void SetUpVersion67Database(sql::Connection* connection); | 56 void SetUpVersion67Database(sql::Connection* connection); |
56 void SetUpVersion68Database(sql::Connection* connection); | 57 void SetUpVersion68Database(sql::Connection* connection); |
57 void SetUpVersion69Database(sql::Connection* connection); | 58 void SetUpVersion69Database(sql::Connection* connection); |
58 void SetUpVersion70Database(sql::Connection* connection); | 59 void SetUpVersion70Database(sql::Connection* connection); |
59 void SetUpVersion71Database(sql::Connection* connection); | 60 void SetUpVersion71Database(sql::Connection* connection); |
60 void SetUpVersion72Database(sql::Connection* connection); | 61 void SetUpVersion72Database(sql::Connection* connection); |
61 void SetUpVersion73Database(sql::Connection* connection); | 62 void SetUpVersion73Database(sql::Connection* connection); |
62 void SetUpVersion74Database(sql::Connection* connection); | 63 void SetUpVersion74Database(sql::Connection* connection); |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 "local_external_id bigint default 0" | 2211 "local_external_id bigint default 0" |
2211 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d" | 2212 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d" |
2212 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p" | 2213 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p" |
2213 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa" | 2214 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa" |
2214 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul" | 2215 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul" |
2215 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is" | 2216 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is" |
2216 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0," | 2217 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0," |
2217 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu" | 2218 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu" |
2218 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc" | 2219 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc" |
2219 "har,specifics blob,server_specifics blob, base_server_specifics BLOB" | 2220 "har,specifics blob,server_specifics blob, base_server_specifics BLOB" |
2220 ", server_ordinal_in_parent blob, transaction_verion bigint default 0" | 2221 ", server_ordinal_in_parent blob, transaction_version bigint default " |
2221 ");" | 2222 "0);" |
2222 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" | 2223 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" |
2223 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa" | 2224 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa" |
2224 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips " | 2225 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips " |
2225 "blob);" | 2226 "blob);" |
2226 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," | 2227 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," |
2227 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064," | 2228 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064," |
2228 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);")); | 2229 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);")); |
2229 | 2230 |
2230 const char* insert_stmts[V80_ROW_COUNT] = { | 2231 const char* insert_stmts[V80_ROW_COUNT] = { |
2231 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','" | 2232 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 "local_external_id bigint default 0" | 2333 "local_external_id bigint default 0" |
2333 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d" | 2334 ",mtime bigint default 0,server_mtime bigint default 0,ctime bigint d" |
2334 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p" | 2335 "efault 0,server_ctime bigint default 0,id varchar(255) default 'r',p" |
2335 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa" | 2336 "arent_id varchar(255) default 'r',server_parent_id varchar(255) defa" |
2336 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul" | 2337 "ult 'r',prev_id varchar(255) default 'r',next_id varchar(255) defaul" |
2337 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is" | 2338 "t 'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is" |
2338 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0," | 2339 "_del bit default 0,is_dir bit default 0,server_is_dir bit default 0," |
2339 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu" | 2340 "server_is_del bit default 0,non_unique_name varchar,server_non_uniqu" |
2340 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc" | 2341 "e_name varchar(255),unique_server_tag varchar,unique_client_tag varc" |
2341 "har,specifics blob,server_specifics blob, base_server_specifics BLOB" | 2342 "har,specifics blob,server_specifics blob, base_server_specifics BLOB" |
2342 ", server_ordinal_in_parent blob, transaction_verion bigint default 0" | 2343 ", server_ordinal_in_parent blob, transaction_version bigint default " |
2343 ");" | 2344 "0);" |
2344 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" | 2345 "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda" |
2345 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa" | 2346 "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defa" |
2346 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips " | 2347 "ult -2, cache_guid TEXT , notification_state BLOB, bag_of_chips " |
2347 "blob);" | 2348 "blob);" |
2348 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," | 2349 "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org'," |
2349 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064," | 2350 "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064," |
2350 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);")); | 2351 "-131078,'9010788312004066376x-6609234393368420856x',NULL, NULL);")); |
2351 | 2352 |
2352 const char* insert_stmts[V80_ROW_COUNT] = { | 2353 const char* insert_stmts[V80_ROW_COUNT] = { |
2353 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','" | 2354 "INSERT INTO 'metas' VALUES(1,-1,0,0," META_PROTO_TIMES_VALS(1) ",'r','" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2740 | 2741 |
2741 scoped_ptr<TestDirectoryBackingStore> dbs( | 2742 scoped_ptr<TestDirectoryBackingStore> dbs( |
2742 new TestDirectoryBackingStore(GetUsername(), &connection)); | 2743 new TestDirectoryBackingStore(GetUsername(), &connection)); |
2743 ASSERT_FALSE(dbs->needs_column_refresh_); | 2744 ASSERT_FALSE(dbs->needs_column_refresh_); |
2744 ASSERT_TRUE(dbs->MigrateVersion78To79()); | 2745 ASSERT_TRUE(dbs->MigrateVersion78To79()); |
2745 ASSERT_EQ(79, dbs->GetVersion()); | 2746 ASSERT_EQ(79, dbs->GetVersion()); |
2746 ASSERT_FALSE(dbs->needs_column_refresh_); | 2747 ASSERT_FALSE(dbs->needs_column_refresh_); |
2747 | 2748 |
2748 // Ensure the next_id has been incremented. | 2749 // Ensure the next_id has been incremented. |
2749 MetahandlesIndex entry_bucket; | 2750 MetahandlesIndex entry_bucket; |
| 2751 JournalIndex delete_journals;; |
2750 STLElementDeleter<MetahandlesIndex> deleter(&entry_bucket); | 2752 STLElementDeleter<MetahandlesIndex> deleter(&entry_bucket); |
2751 Directory::KernelLoadInfo load_info; | 2753 Directory::KernelLoadInfo load_info; |
2752 | 2754 |
2753 s.Clear(); | 2755 s.Clear(); |
2754 ASSERT_TRUE(dbs->Load(&entry_bucket, &load_info)); | 2756 ASSERT_TRUE(dbs->Load(&entry_bucket, &delete_journals, &load_info)); |
2755 EXPECT_LE(load_info.kernel_info.next_id, kInitialNextId - 65536); | 2757 EXPECT_LE(load_info.kernel_info.next_id, kInitialNextId - 65536); |
2756 } | 2758 } |
2757 | 2759 |
2758 TEST_F(DirectoryBackingStoreTest, MigrateVersion79To80) { | 2760 TEST_F(DirectoryBackingStoreTest, MigrateVersion79To80) { |
2759 sql::Connection connection; | 2761 sql::Connection connection; |
2760 ASSERT_TRUE(connection.OpenInMemory()); | 2762 ASSERT_TRUE(connection.OpenInMemory()); |
2761 SetUpVersion79Database(&connection); | 2763 SetUpVersion79Database(&connection); |
2762 | 2764 |
2763 scoped_ptr<TestDirectoryBackingStore> dbs( | 2765 scoped_ptr<TestDirectoryBackingStore> dbs( |
2764 new TestDirectoryBackingStore(GetUsername(), &connection)); | 2766 new TestDirectoryBackingStore(GetUsername(), &connection)); |
2765 ASSERT_FALSE(dbs->needs_column_refresh_); | 2767 ASSERT_FALSE(dbs->needs_column_refresh_); |
2766 ASSERT_TRUE(dbs->MigrateVersion79To80()); | 2768 ASSERT_TRUE(dbs->MigrateVersion79To80()); |
2767 ASSERT_EQ(80, dbs->GetVersion()); | 2769 ASSERT_EQ(80, dbs->GetVersion()); |
2768 ASSERT_FALSE(dbs->needs_column_refresh_); | 2770 ASSERT_FALSE(dbs->needs_column_refresh_); |
2769 | 2771 |
2770 // Ensure the bag_of_chips has been set. | 2772 // Ensure the bag_of_chips has been set. |
2771 MetahandlesIndex entry_bucket; | 2773 MetahandlesIndex entry_bucket; |
| 2774 JournalIndex delete_journals;; |
2772 STLElementDeleter<MetahandlesIndex> deleter(&entry_bucket); | 2775 STLElementDeleter<MetahandlesIndex> deleter(&entry_bucket); |
2773 Directory::KernelLoadInfo load_info; | 2776 Directory::KernelLoadInfo load_info; |
2774 | 2777 |
2775 ASSERT_TRUE(dbs->Load(&entry_bucket, &load_info)); | 2778 ASSERT_TRUE(dbs->Load(&entry_bucket, &delete_journals, &load_info)); |
2776 // Check that the initial value is the serialization of an empty ChipBag. | 2779 // Check that the initial value is the serialization of an empty ChipBag. |
2777 sync_pb::ChipBag chip_bag; | 2780 sync_pb::ChipBag chip_bag; |
2778 std::string serialized_chip_bag; | 2781 std::string serialized_chip_bag; |
2779 ASSERT_TRUE(chip_bag.SerializeToString(&serialized_chip_bag)); | 2782 ASSERT_TRUE(chip_bag.SerializeToString(&serialized_chip_bag)); |
2780 EXPECT_EQ(serialized_chip_bag, load_info.kernel_info.bag_of_chips); | 2783 EXPECT_EQ(serialized_chip_bag, load_info.kernel_info.bag_of_chips); |
2781 } | 2784 } |
2782 | 2785 |
2783 TEST_F(DirectoryBackingStoreTest, MigrateVersion80To81) { | 2786 TEST_F(DirectoryBackingStoreTest, MigrateVersion80To81) { |
2784 sql::Connection connection; | 2787 sql::Connection connection; |
2785 ASSERT_TRUE(connection.OpenInMemory()); | 2788 ASSERT_TRUE(connection.OpenInMemory()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 sql::Statement s(connection.GetUniqueStatement( | 2826 sql::Statement s(connection.GetUniqueStatement( |
2824 "INSERT INTO metas " | 2827 "INSERT INTO metas " |
2825 "( id, metahandle, is_dir, ctime, mtime, server_ordinal_in_parent) " | 2828 "( id, metahandle, is_dir, ctime, mtime, server_ordinal_in_parent) " |
2826 "VALUES( \"c-invalid\", 9999, 1, ?, ?, \" \")")); | 2829 "VALUES( \"c-invalid\", 9999, 1, ?, ?, \" \")")); |
2827 s.BindInt64(0, now); | 2830 s.BindInt64(0, now); |
2828 s.BindInt64(1, now); | 2831 s.BindInt64(1, now); |
2829 ASSERT_TRUE(s.Run()); | 2832 ASSERT_TRUE(s.Run()); |
2830 | 2833 |
2831 // Trying to unpack this entry should signal that the DB is corrupted. | 2834 // Trying to unpack this entry should signal that the DB is corrupted. |
2832 MetahandlesIndex entry_bucket; | 2835 MetahandlesIndex entry_bucket; |
| 2836 JournalIndex delete_journals;; |
2833 STLElementDeleter<MetahandlesIndex> deleter(&entry_bucket); | 2837 STLElementDeleter<MetahandlesIndex> deleter(&entry_bucket); |
2834 Directory::KernelLoadInfo kernel_load_info; | 2838 Directory::KernelLoadInfo kernel_load_info; |
2835 ASSERT_EQ(FAILED_DATABASE_CORRUPT, | 2839 ASSERT_EQ(FAILED_DATABASE_CORRUPT, |
2836 dbs->Load(&entry_bucket, &kernel_load_info)); | 2840 dbs->Load(&entry_bucket, &delete_journals, &kernel_load_info)); |
2837 } | 2841 } |
2838 | 2842 |
2839 TEST_F(DirectoryBackingStoreTest, MigrateVersion81To82) { | 2843 TEST_F(DirectoryBackingStoreTest, MigrateVersion81To82) { |
2840 sql::Connection connection; | 2844 sql::Connection connection; |
2841 ASSERT_TRUE(connection.OpenInMemory()); | 2845 ASSERT_TRUE(connection.OpenInMemory()); |
2842 SetUpVersion81Database(&connection); | 2846 SetUpVersion81Database(&connection); |
2843 ASSERT_FALSE(connection.DoesColumnExist("models", "transaction_version")); | 2847 ASSERT_FALSE(connection.DoesColumnExist("models", "transaction_version")); |
2844 | 2848 |
2845 scoped_ptr<TestDirectoryBackingStore> dbs( | 2849 scoped_ptr<TestDirectoryBackingStore> dbs( |
2846 new TestDirectoryBackingStore(GetUsername(), &connection)); | 2850 new TestDirectoryBackingStore(GetUsername(), &connection)); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2966 // 5. Dump this using the sqlite3 command line tool: | 2970 // 5. Dump this using the sqlite3 command line tool: |
2967 // > .output foo_dump.sql | 2971 // > .output foo_dump.sql |
2968 // > .dump | 2972 // > .dump |
2969 // 6. Replace the timestamp columns with META_PROTO_TIMES(x) (or | 2973 // 6. Replace the timestamp columns with META_PROTO_TIMES(x) (or |
2970 // LEGACY_META_PROTO_TIMES(x) if before Version 77). | 2974 // LEGACY_META_PROTO_TIMES(x) if before Version 77). |
2971 FAIL() << "Need to supply database dump for version " << GetParam(); | 2975 FAIL() << "Need to supply database dump for version " << GetParam(); |
2972 } | 2976 } |
2973 | 2977 |
2974 syncable::Directory::KernelLoadInfo dir_info; | 2978 syncable::Directory::KernelLoadInfo dir_info; |
2975 MetahandlesIndex index; | 2979 MetahandlesIndex index; |
| 2980 JournalIndex delete_journals;; |
2976 STLElementDeleter<MetahandlesIndex> index_deleter(&index); | 2981 STLElementDeleter<MetahandlesIndex> index_deleter(&index); |
2977 | 2982 |
2978 { | 2983 { |
2979 scoped_ptr<TestDirectoryBackingStore> dbs( | 2984 scoped_ptr<TestDirectoryBackingStore> dbs( |
2980 new TestDirectoryBackingStore(GetUsername(), &connection)); | 2985 new TestDirectoryBackingStore(GetUsername(), &connection)); |
2981 ASSERT_EQ(OPENED, dbs->Load(&index, &dir_info)); | 2986 ASSERT_EQ(OPENED, dbs->Load(&index, &delete_journals, &dir_info)); |
2982 ASSERT_FALSE(dbs->needs_column_refresh_); | 2987 ASSERT_FALSE(dbs->needs_column_refresh_); |
2983 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion()); | 2988 ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion()); |
2984 } | 2989 } |
2985 | 2990 |
2986 // Columns deleted in Version 67. | 2991 // Columns deleted in Version 67. |
2987 ASSERT_FALSE(connection.DoesColumnExist("metas", "name")); | 2992 ASSERT_FALSE(connection.DoesColumnExist("metas", "name")); |
2988 ASSERT_FALSE(connection.DoesColumnExist("metas", "unsanitized_name")); | 2993 ASSERT_FALSE(connection.DoesColumnExist("metas", "unsanitized_name")); |
2989 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_name")); | 2994 ASSERT_FALSE(connection.DoesColumnExist("metas", "server_name")); |
2990 | 2995 |
2991 // Columns added in Version 68. | 2996 // Columns added in Version 68. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3243 } | 3248 } |
3244 | 3249 |
3245 TEST_F(DirectoryBackingStoreTest, DeleteEntries) { | 3250 TEST_F(DirectoryBackingStoreTest, DeleteEntries) { |
3246 sql::Connection connection; | 3251 sql::Connection connection; |
3247 ASSERT_TRUE(connection.OpenInMemory()); | 3252 ASSERT_TRUE(connection.OpenInMemory()); |
3248 | 3253 |
3249 SetUpCurrentDatabaseAndCheckVersion(&connection); | 3254 SetUpCurrentDatabaseAndCheckVersion(&connection); |
3250 scoped_ptr<TestDirectoryBackingStore> dbs( | 3255 scoped_ptr<TestDirectoryBackingStore> dbs( |
3251 new TestDirectoryBackingStore(GetUsername(), &connection)); | 3256 new TestDirectoryBackingStore(GetUsername(), &connection)); |
3252 MetahandlesIndex index; | 3257 MetahandlesIndex index; |
| 3258 JournalIndex delete_journals; |
3253 Directory::KernelLoadInfo kernel_load_info; | 3259 Directory::KernelLoadInfo kernel_load_info; |
3254 STLElementDeleter<MetahandlesIndex> index_deleter(&index); | 3260 STLElementDeleter<MetahandlesIndex> index_deleter(&index); |
3255 | 3261 |
3256 dbs->Load(&index, &kernel_load_info); | 3262 dbs->Load(&index, &delete_journals, &kernel_load_info); |
3257 size_t initial_size = index.size(); | 3263 size_t initial_size = index.size(); |
3258 ASSERT_LT(0U, initial_size) << "Test requires entries to delete."; | 3264 ASSERT_LT(0U, initial_size) << "Test requires entries to delete."; |
3259 int64 first_to_die = (*index.begin())->ref(META_HANDLE); | 3265 int64 first_to_die = (*index.begin())->ref(META_HANDLE); |
3260 MetahandleSet to_delete; | 3266 MetahandleSet to_delete; |
3261 to_delete.insert(first_to_die); | 3267 to_delete.insert(first_to_die); |
3262 EXPECT_TRUE(dbs->DeleteEntries(to_delete)); | 3268 EXPECT_TRUE(dbs->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE, |
| 3269 to_delete)); |
3263 | 3270 |
3264 STLDeleteElements(&index); | 3271 STLDeleteElements(&index); |
3265 dbs->LoadEntries(&index); | 3272 dbs->LoadEntries(&index); |
3266 | 3273 |
3267 EXPECT_EQ(initial_size - 1, index.size()); | 3274 EXPECT_EQ(initial_size - 1, index.size()); |
3268 bool delete_failed = false; | 3275 bool delete_failed = false; |
3269 for (MetahandlesIndex::iterator it = index.begin(); it != index.end(); | 3276 for (MetahandlesIndex::iterator it = index.begin(); it != index.end(); |
3270 ++it) { | 3277 ++it) { |
3271 if ((*it)->ref(META_HANDLE) == first_to_die) { | 3278 if ((*it)->ref(META_HANDLE) == first_to_die) { |
3272 delete_failed = true; | 3279 delete_failed = true; |
3273 break; | 3280 break; |
3274 } | 3281 } |
3275 } | 3282 } |
3276 EXPECT_FALSE(delete_failed); | 3283 EXPECT_FALSE(delete_failed); |
3277 | 3284 |
3278 to_delete.clear(); | 3285 to_delete.clear(); |
3279 for (MetahandlesIndex::iterator it = index.begin(); it != index.end(); | 3286 for (MetahandlesIndex::iterator it = index.begin(); it != index.end(); |
3280 ++it) { | 3287 ++it) { |
3281 to_delete.insert((*it)->ref(META_HANDLE)); | 3288 to_delete.insert((*it)->ref(META_HANDLE)); |
3282 } | 3289 } |
3283 | 3290 |
3284 EXPECT_TRUE(dbs->DeleteEntries(to_delete)); | 3291 EXPECT_TRUE(dbs->DeleteEntries(TestDirectoryBackingStore::METAS_TABLE, |
| 3292 to_delete)); |
3285 | 3293 |
3286 STLDeleteElements(&index); | 3294 STLDeleteElements(&index); |
3287 dbs->LoadEntries(&index); | 3295 dbs->LoadEntries(&index); |
3288 EXPECT_EQ(0U, index.size()); | 3296 EXPECT_EQ(0U, index.size()); |
3289 } | 3297 } |
3290 | 3298 |
3291 TEST_F(DirectoryBackingStoreTest, GenerateCacheGUID) { | 3299 TEST_F(DirectoryBackingStoreTest, GenerateCacheGUID) { |
3292 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); | 3300 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); |
3293 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); | 3301 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); |
3294 EXPECT_EQ(24U, guid1.size()); | 3302 EXPECT_EQ(24U, guid1.size()); |
3295 EXPECT_EQ(24U, guid2.size()); | 3303 EXPECT_EQ(24U, guid2.size()); |
3296 // In theory this test can fail, but it won't before the universe | 3304 // In theory this test can fail, but it won't before the universe |
3297 // dies of heat death. | 3305 // dies of heat death. |
3298 EXPECT_NE(guid1, guid2); | 3306 EXPECT_NE(guid1, guid2); |
3299 } | 3307 } |
3300 | 3308 |
3301 } // namespace syncable | 3309 } // namespace syncable |
3302 } // namespace syncer | 3310 } // namespace syncer |
OLD | NEW |