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