OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
on_disk.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
on_disk.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 | 10 |
9 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
10 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
11 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" | 13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" |
12 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.
h" | 14 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.
h" |
13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" | 15 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" |
14 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" | 16 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" |
15 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 17 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 19 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
18 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 20 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
19 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 21 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
20 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 22 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
21 | 23 |
22 namespace sync_file_system { | 24 namespace sync_file_system { |
23 namespace drive_backend { | 25 namespace drive_backend { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 const int64 kSyncRootTrackerID = 1; | 29 const int64_t kSyncRootTrackerID = 1; |
28 const int64 kAppRootTrackerID = 2; | 30 const int64_t kAppRootTrackerID = 2; |
29 const int64 kFileTrackerID = 3; | 31 const int64_t kFileTrackerID = 3; |
30 const int64 kPlaceholderTrackerID = 4; | 32 const int64_t kPlaceholderTrackerID = 4; |
31 | 33 |
32 } // namespace | 34 } // namespace |
33 | 35 |
34 class MetadataDatabaseIndexOnDiskTest : public testing::Test { | 36 class MetadataDatabaseIndexOnDiskTest : public testing::Test { |
35 public: | 37 public: |
36 ~MetadataDatabaseIndexOnDiskTest() override {} | 38 ~MetadataDatabaseIndexOnDiskTest() override {} |
37 | 39 |
38 void SetUp() override { | 40 void SetUp() override { |
39 ASSERT_TRUE(database_dir_.CreateUniqueTempDir()); | 41 ASSERT_TRUE(database_dir_.CreateUniqueTempDir()); |
40 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 42 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 149 |
148 FileMetadata metadata; | 150 FileMetadata metadata; |
149 EXPECT_FALSE(index()->GetFileMetadata(std::string(), nullptr)); | 151 EXPECT_FALSE(index()->GetFileMetadata(std::string(), nullptr)); |
150 ASSERT_TRUE(index()->GetFileMetadata("file_id", &metadata)); | 152 ASSERT_TRUE(index()->GetFileMetadata("file_id", &metadata)); |
151 EXPECT_EQ("file_id", metadata.file_id()); | 153 EXPECT_EQ("file_id", metadata.file_id()); |
152 } | 154 } |
153 | 155 |
154 TEST_F(MetadataDatabaseIndexOnDiskTest, SetEntryTest) { | 156 TEST_F(MetadataDatabaseIndexOnDiskTest, SetEntryTest) { |
155 CreateTestDatabase(false, nullptr); | 157 CreateTestDatabase(false, nullptr); |
156 | 158 |
157 const int64 tracker_id = 10; | 159 const int64_t tracker_id = 10; |
158 scoped_ptr<FileMetadata> metadata = | 160 scoped_ptr<FileMetadata> metadata = |
159 test_util::CreateFileMetadata("test_file_id", "test_title", "test_md5"); | 161 test_util::CreateFileMetadata("test_file_id", "test_title", "test_md5"); |
160 FileTracker root_tracker; | 162 FileTracker root_tracker; |
161 EXPECT_TRUE(index()->GetFileTracker(kSyncRootTrackerID, &root_tracker)); | 163 EXPECT_TRUE(index()->GetFileTracker(kSyncRootTrackerID, &root_tracker)); |
162 scoped_ptr<FileTracker> tracker = | 164 scoped_ptr<FileTracker> tracker = |
163 test_util::CreateTracker(*metadata, tracker_id, &root_tracker); | 165 test_util::CreateTracker(*metadata, tracker_id, &root_tracker); |
164 | 166 |
165 index()->StoreFileMetadata(metadata.Pass()); | 167 index()->StoreFileMetadata(metadata.Pass()); |
166 index()->StoreFileTracker(tracker.Pass()); | 168 index()->StoreFileTracker(tracker.Pass()); |
167 | 169 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 225 |
224 EXPECT_TRUE(index_on_disk->GetFileTracker(kSyncRootTrackerID, nullptr)); | 226 EXPECT_TRUE(index_on_disk->GetFileTracker(kSyncRootTrackerID, nullptr)); |
225 EXPECT_TRUE(index_on_disk->GetFileTracker(kAppRootTrackerID, nullptr)); | 227 EXPECT_TRUE(index_on_disk->GetFileTracker(kAppRootTrackerID, nullptr)); |
226 EXPECT_TRUE(index_on_disk->GetFileTracker(kFileTrackerID, nullptr)); | 228 EXPECT_TRUE(index_on_disk->GetFileTracker(kFileTrackerID, nullptr)); |
227 } | 229 } |
228 | 230 |
229 TEST_F(MetadataDatabaseIndexOnDiskTest, SyncRootInvalidation) { | 231 TEST_F(MetadataDatabaseIndexOnDiskTest, SyncRootInvalidation) { |
230 CreateTestDatabase(true, nullptr); | 232 CreateTestDatabase(true, nullptr); |
231 EXPECT_NE(kInvalidTrackerID, index()->GetAppRootTracker("app_id")); | 233 EXPECT_NE(kInvalidTrackerID, index()->GetAppRootTracker("app_id")); |
232 | 234 |
233 const int64 kNewSyncRootTrackerID = 10; | 235 const int64_t kNewSyncRootTrackerID = 10; |
234 scoped_ptr<FileMetadata> new_sync_root_metadata = | 236 scoped_ptr<FileMetadata> new_sync_root_metadata = |
235 test_util::CreateFolderMetadata("new_sync_root_folder_id", | 237 test_util::CreateFolderMetadata("new_sync_root_folder_id", |
236 kSyncRootFolderTitle); | 238 kSyncRootFolderTitle); |
237 scoped_ptr<FileTracker> new_sync_root_tracker = | 239 scoped_ptr<FileTracker> new_sync_root_tracker = |
238 test_util::CreateTracker(*new_sync_root_metadata, kNewSyncRootTrackerID, | 240 test_util::CreateTracker(*new_sync_root_metadata, kNewSyncRootTrackerID, |
239 nullptr); | 241 nullptr); |
240 | 242 |
241 // Override SyncRoot with a new one. | 243 // Override SyncRoot with a new one. |
242 index()->StoreFileMetadata(new_sync_root_metadata.Pass()); | 244 index()->StoreFileMetadata(new_sync_root_metadata.Pass()); |
243 index()->StoreFileTracker(new_sync_root_tracker.Pass()); | 245 index()->StoreFileTracker(new_sync_root_tracker.Pass()); |
(...skipping 29 matching lines...) Expand all Loading... |
273 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); | 275 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); |
274 tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( | 276 tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( |
275 kAppRootTrackerID, "file"); | 277 kAppRootTrackerID, "file"); |
276 EXPECT_EQ(1U, tracker_ids.size()); | 278 EXPECT_EQ(1U, tracker_ids.size()); |
277 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); | 279 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); |
278 EXPECT_EQ(1U, index()->CountDirtyTracker()); | 280 EXPECT_EQ(1U, index()->CountDirtyTracker()); |
279 } | 281 } |
280 | 282 |
281 TEST_F(MetadataDatabaseIndexOnDiskTest, BuildAndDeleteIndexTest) { | 283 TEST_F(MetadataDatabaseIndexOnDiskTest, BuildAndDeleteIndexTest) { |
282 CreateTestDatabase(false, nullptr); | 284 CreateTestDatabase(false, nullptr); |
283 int64 answer = index()->BuildTrackerIndexes(); | 285 int64_t answer = index()->BuildTrackerIndexes(); |
284 WriteToDB(); | 286 WriteToDB(); |
285 ASSERT_EQ(16, answer); | 287 ASSERT_EQ(16, answer); |
286 EXPECT_EQ(answer, index()->DeleteTrackerIndexes()); | 288 EXPECT_EQ(answer, index()->DeleteTrackerIndexes()); |
287 WriteToDB(); | 289 WriteToDB(); |
288 EXPECT_EQ(answer, index()->BuildTrackerIndexes()); | 290 EXPECT_EQ(answer, index()->BuildTrackerIndexes()); |
289 WriteToDB(); | 291 WriteToDB(); |
290 } | 292 } |
291 | 293 |
292 TEST_F(MetadataDatabaseIndexOnDiskTest, AllEntriesTest) { | 294 TEST_F(MetadataDatabaseIndexOnDiskTest, AllEntriesTest) { |
293 CreateTestDatabase(true, nullptr); | 295 CreateTestDatabase(true, nullptr); |
294 | 296 |
295 EXPECT_EQ(3U, index()->CountFileMetadata()); | 297 EXPECT_EQ(3U, index()->CountFileMetadata()); |
296 std::vector<std::string> file_ids(index()->GetAllMetadataIDs()); | 298 std::vector<std::string> file_ids(index()->GetAllMetadataIDs()); |
297 ASSERT_EQ(3U, file_ids.size()); | 299 ASSERT_EQ(3U, file_ids.size()); |
298 std::sort(file_ids.begin(), file_ids.end()); | 300 std::sort(file_ids.begin(), file_ids.end()); |
299 EXPECT_EQ("app_root_folder_id", file_ids[0]); | 301 EXPECT_EQ("app_root_folder_id", file_ids[0]); |
300 EXPECT_EQ("file_id", file_ids[1]); | 302 EXPECT_EQ("file_id", file_ids[1]); |
301 EXPECT_EQ("sync_root_folder_id", file_ids[2]); | 303 EXPECT_EQ("sync_root_folder_id", file_ids[2]); |
302 | 304 |
303 EXPECT_EQ(4U, index()->CountFileTracker()); | 305 EXPECT_EQ(4U, index()->CountFileTracker()); |
304 std::vector<int64> tracker_ids = index()->GetAllTrackerIDs(); | 306 std::vector<int64_t> tracker_ids = index()->GetAllTrackerIDs(); |
305 ASSERT_EQ(4U, tracker_ids.size()); | 307 ASSERT_EQ(4U, tracker_ids.size()); |
306 std::sort(tracker_ids.begin(), tracker_ids.end()); | 308 std::sort(tracker_ids.begin(), tracker_ids.end()); |
307 EXPECT_EQ(kSyncRootTrackerID, tracker_ids[0]); | 309 EXPECT_EQ(kSyncRootTrackerID, tracker_ids[0]); |
308 EXPECT_EQ(kAppRootTrackerID, tracker_ids[1]); | 310 EXPECT_EQ(kAppRootTrackerID, tracker_ids[1]); |
309 EXPECT_EQ(kFileTrackerID, tracker_ids[2]); | 311 EXPECT_EQ(kFileTrackerID, tracker_ids[2]); |
310 EXPECT_EQ(kPlaceholderTrackerID, tracker_ids[3]); | 312 EXPECT_EQ(kPlaceholderTrackerID, tracker_ids[3]); |
311 } | 313 } |
312 | 314 |
313 TEST_F(MetadataDatabaseIndexOnDiskTest, IndexAppRootIDByAppIDTest) { | 315 TEST_F(MetadataDatabaseIndexOnDiskTest, IndexAppRootIDByAppIDTest) { |
314 CreateTestDatabase(true, nullptr); | 316 CreateTestDatabase(true, nullptr); |
315 | 317 |
316 std::vector<std::string> app_ids = index()->GetRegisteredAppIDs(); | 318 std::vector<std::string> app_ids = index()->GetRegisteredAppIDs(); |
317 ASSERT_EQ(1U, app_ids.size()); | 319 ASSERT_EQ(1U, app_ids.size()); |
318 EXPECT_EQ("app_id", app_ids[0]); | 320 EXPECT_EQ("app_id", app_ids[0]); |
319 | 321 |
320 EXPECT_EQ(kInvalidTrackerID, index()->GetAppRootTracker("")); | 322 EXPECT_EQ(kInvalidTrackerID, index()->GetAppRootTracker("")); |
321 EXPECT_EQ(kAppRootTrackerID, index()->GetAppRootTracker("app_id")); | 323 EXPECT_EQ(kAppRootTrackerID, index()->GetAppRootTracker("app_id")); |
322 | 324 |
323 const int64 kAppRootTrackerID2 = 12; | 325 const int64_t kAppRootTrackerID2 = 12; |
324 FileTracker sync_root_tracker; | 326 FileTracker sync_root_tracker; |
325 index()->GetFileTracker(kSyncRootTrackerID, &sync_root_tracker); | 327 index()->GetFileTracker(kSyncRootTrackerID, &sync_root_tracker); |
326 scoped_ptr<FileMetadata> app_root_metadata = | 328 scoped_ptr<FileMetadata> app_root_metadata = |
327 test_util::CreateFolderMetadata("app_root_folder_id_2", "app_title_2"); | 329 test_util::CreateFolderMetadata("app_root_folder_id_2", "app_title_2"); |
328 | 330 |
329 // Testing AddToAppIDIndex | 331 // Testing AddToAppIDIndex |
330 scoped_ptr<FileTracker> app_root_tracker = | 332 scoped_ptr<FileTracker> app_root_tracker = |
331 test_util::CreateTracker(*app_root_metadata, kAppRootTrackerID2, | 333 test_util::CreateTracker(*app_root_metadata, kAppRootTrackerID2, |
332 &sync_root_tracker); | 334 &sync_root_tracker); |
333 app_root_tracker->set_app_id("app_id_2"); | 335 app_root_tracker->set_app_id("app_id_2"); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 FileTracker app_root_tracker; | 378 FileTracker app_root_tracker; |
377 EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root_tracker)); | 379 EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root_tracker)); |
378 FileMetadata metadata; | 380 FileMetadata metadata; |
379 EXPECT_TRUE(index()->GetFileMetadata("file_id", &metadata)); | 381 EXPECT_TRUE(index()->GetFileMetadata("file_id", &metadata)); |
380 | 382 |
381 // Testing GetFileTrackerIDsByFileID | 383 // Testing GetFileTrackerIDsByFileID |
382 TrackerIDSet tracker_ids = index()->GetFileTrackerIDsByFileID("file_id"); | 384 TrackerIDSet tracker_ids = index()->GetFileTrackerIDsByFileID("file_id"); |
383 EXPECT_EQ(1U, tracker_ids.size()); | 385 EXPECT_EQ(1U, tracker_ids.size()); |
384 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); | 386 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); |
385 | 387 |
386 const int64 tracker_id = 21; | 388 const int64_t tracker_id = 21; |
387 // Testing AddToFileIDIndexes | 389 // Testing AddToFileIDIndexes |
388 scoped_ptr<FileTracker> file_tracker = | 390 scoped_ptr<FileTracker> file_tracker = |
389 test_util::CreateTracker(metadata, tracker_id, &app_root_tracker); | 391 test_util::CreateTracker(metadata, tracker_id, &app_root_tracker); |
390 | 392 |
391 index()->StoreFileTracker(file_tracker.Pass()); | 393 index()->StoreFileTracker(file_tracker.Pass()); |
392 WriteToDB(); | 394 WriteToDB(); |
393 tracker_ids = index()->GetFileTrackerIDsByFileID("file_id"); | 395 tracker_ids = index()->GetFileTrackerIDsByFileID("file_id"); |
394 EXPECT_EQ(2U, tracker_ids.size()); | 396 EXPECT_EQ(2U, tracker_ids.size()); |
395 EXPECT_EQ(tracker_id, tracker_ids.active_tracker()); | 397 EXPECT_EQ(tracker_id, tracker_ids.active_tracker()); |
396 | 398 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // Testing GetFileTrackerIDsByFileID | 447 // Testing GetFileTrackerIDsByFileID |
446 TrackerIDSet tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( | 448 TrackerIDSet tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( |
447 kAppRootTrackerID, "file"); | 449 kAppRootTrackerID, "file"); |
448 EXPECT_EQ(1U, tracker_ids.size()); | 450 EXPECT_EQ(1U, tracker_ids.size()); |
449 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); | 451 EXPECT_EQ(kFileTrackerID, tracker_ids.active_tracker()); |
450 | 452 |
451 tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( | 453 tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( |
452 kAppRootTrackerID, "file2"); | 454 kAppRootTrackerID, "file2"); |
453 EXPECT_TRUE(tracker_ids.empty()); | 455 EXPECT_TRUE(tracker_ids.empty()); |
454 | 456 |
455 const int64 tracker_id = 72; | 457 const int64_t tracker_id = 72; |
456 // Testing AddToFileIDIndexes | 458 // Testing AddToFileIDIndexes |
457 scoped_ptr<FileTracker> file_tracker = | 459 scoped_ptr<FileTracker> file_tracker = |
458 test_util::CreateTracker(metadata, tracker_id, &app_root_tracker); | 460 test_util::CreateTracker(metadata, tracker_id, &app_root_tracker); |
459 | 461 |
460 index()->StoreFileTracker(file_tracker.Pass()); | 462 index()->StoreFileTracker(file_tracker.Pass()); |
461 WriteToDB(); | 463 WriteToDB(); |
462 tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( | 464 tracker_ids = index()->GetFileTrackerIDsByParentAndTitle( |
463 kAppRootTrackerID, "file"); | 465 kAppRootTrackerID, "file"); |
464 EXPECT_EQ(2U, tracker_ids.size()); | 466 EXPECT_EQ(2U, tracker_ids.size()); |
465 EXPECT_EQ(tracker_id, tracker_ids.active_tracker()); | 467 EXPECT_EQ(tracker_id, tracker_ids.active_tracker()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 510 |
509 multi_backing = index()->PickMultiBackingFilePath(); | 511 multi_backing = index()->PickMultiBackingFilePath(); |
510 EXPECT_EQ(kInvalidTrackerID, multi_backing.parent_id); | 512 EXPECT_EQ(kInvalidTrackerID, multi_backing.parent_id); |
511 EXPECT_TRUE(multi_backing.title.empty()) << multi_backing.title; | 513 EXPECT_TRUE(multi_backing.title.empty()) << multi_backing.title; |
512 } | 514 } |
513 | 515 |
514 TEST_F(MetadataDatabaseIndexOnDiskTest, | 516 TEST_F(MetadataDatabaseIndexOnDiskTest, |
515 TrackerIDSetByParentIDAndTitleTest_EmptyTitle) { | 517 TrackerIDSetByParentIDAndTitleTest_EmptyTitle) { |
516 CreateTestDatabase(true, nullptr); | 518 CreateTestDatabase(true, nullptr); |
517 | 519 |
518 const int64 kFolderTrackerID = 23; | 520 const int64_t kFolderTrackerID = 23; |
519 const int64 kNewFileTrackerID = 42; | 521 const int64_t kNewFileTrackerID = 42; |
520 { | 522 { |
521 FileTracker app_root_tracker; | 523 FileTracker app_root_tracker; |
522 EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root_tracker)); | 524 EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root_tracker)); |
523 scoped_ptr<FileMetadata> folder_metadata = | 525 scoped_ptr<FileMetadata> folder_metadata = |
524 test_util::CreateFolderMetadata("folder_id", "folder_name"); | 526 test_util::CreateFolderMetadata("folder_id", "folder_name"); |
525 scoped_ptr<FileTracker> folder_tracker = | 527 scoped_ptr<FileTracker> folder_tracker = |
526 test_util::CreateTracker(*folder_metadata, kFolderTrackerID, | 528 test_util::CreateTracker(*folder_metadata, kFolderTrackerID, |
527 &app_root_tracker); | 529 &app_root_tracker); |
528 index()->StoreFileMetadata(folder_metadata.Pass()); | 530 index()->StoreFileMetadata(folder_metadata.Pass()); |
529 index()->StoreFileTracker(folder_tracker.Pass()); | 531 index()->StoreFileTracker(folder_tracker.Pass()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 multi_backing = index()->PickMultiBackingFilePath(); | 570 multi_backing = index()->PickMultiBackingFilePath(); |
569 EXPECT_EQ(kInvalidTrackerID, multi_backing.parent_id); | 571 EXPECT_EQ(kInvalidTrackerID, multi_backing.parent_id); |
570 } | 572 } |
571 | 573 |
572 TEST_F(MetadataDatabaseIndexOnDiskTest, TrackerIDSetDetailsTest) { | 574 TEST_F(MetadataDatabaseIndexOnDiskTest, TrackerIDSetDetailsTest) { |
573 CreateTestDatabase(true, nullptr); | 575 CreateTestDatabase(true, nullptr); |
574 | 576 |
575 FileTracker app_root; | 577 FileTracker app_root; |
576 EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root)); | 578 EXPECT_TRUE(index()->GetFileTracker(kAppRootTrackerID, &app_root)); |
577 | 579 |
578 const int64 kFileTrackerID2 = 123; | 580 const int64_t kFileTrackerID2 = 123; |
579 const int64 kFileTrackerID3 = 124; | 581 const int64_t kFileTrackerID3 = 124; |
580 scoped_ptr<FileMetadata> file_metadata = | 582 scoped_ptr<FileMetadata> file_metadata = |
581 test_util::CreateFileMetadata("file_id2", "file_2", "file_md5_2"); | 583 test_util::CreateFileMetadata("file_id2", "file_2", "file_md5_2"); |
582 scoped_ptr<FileTracker> file_tracker = | 584 scoped_ptr<FileTracker> file_tracker = |
583 test_util::CreateTracker(*file_metadata, kFileTrackerID2, &app_root); | 585 test_util::CreateTracker(*file_metadata, kFileTrackerID2, &app_root); |
584 file_tracker->set_active(false); | 586 file_tracker->set_active(false); |
585 scoped_ptr<FileTracker> file_tracker2 = | 587 scoped_ptr<FileTracker> file_tracker2 = |
586 test_util::CreateTracker(*file_metadata, kFileTrackerID3, &app_root); | 588 test_util::CreateTracker(*file_metadata, kFileTrackerID3, &app_root); |
587 file_tracker2->set_active(false); | 589 file_tracker2->set_active(false); |
588 | 590 |
589 // Add 2 trackers related to one file metadata. | 591 // Add 2 trackers related to one file metadata. |
(...skipping 22 matching lines...) Expand all Loading... |
612 | 614 |
613 // Testing public methods | 615 // Testing public methods |
614 EXPECT_EQ(1U, index()->CountDirtyTracker()); | 616 EXPECT_EQ(1U, index()->CountDirtyTracker()); |
615 EXPECT_FALSE(index()->HasDemotedDirtyTracker()); | 617 EXPECT_FALSE(index()->HasDemotedDirtyTracker()); |
616 EXPECT_EQ(kPlaceholderTrackerID, index()->PickDirtyTracker()); | 618 EXPECT_EQ(kPlaceholderTrackerID, index()->PickDirtyTracker()); |
617 index()->DemoteDirtyTracker(kPlaceholderTrackerID); | 619 index()->DemoteDirtyTracker(kPlaceholderTrackerID); |
618 WriteToDB(); | 620 WriteToDB(); |
619 EXPECT_TRUE(index()->HasDemotedDirtyTracker()); | 621 EXPECT_TRUE(index()->HasDemotedDirtyTracker()); |
620 EXPECT_EQ(0U, index()->CountDirtyTracker()); | 622 EXPECT_EQ(0U, index()->CountDirtyTracker()); |
621 | 623 |
622 const int64 tracker_id = 13; | 624 const int64_t tracker_id = 13; |
623 scoped_ptr<FileTracker> app_root_tracker(new FileTracker); | 625 scoped_ptr<FileTracker> app_root_tracker(new FileTracker); |
624 index()->GetFileTracker(kAppRootTrackerID, app_root_tracker.get()); | 626 index()->GetFileTracker(kAppRootTrackerID, app_root_tracker.get()); |
625 | 627 |
626 // Testing AddDirtyTrackerIndexes | 628 // Testing AddDirtyTrackerIndexes |
627 scoped_ptr<FileTracker> tracker = | 629 scoped_ptr<FileTracker> tracker = |
628 test_util::CreatePlaceholderTracker("placeholder", | 630 test_util::CreatePlaceholderTracker("placeholder", |
629 tracker_id, | 631 tracker_id, |
630 app_root_tracker.get()); | 632 app_root_tracker.get()); |
631 index()->StoreFileTracker(tracker.Pass()); | 633 index()->StoreFileTracker(tracker.Pass()); |
632 WriteToDB(); | 634 WriteToDB(); |
(...skipping 25 matching lines...) Expand all Loading... |
658 EXPECT_EQ(kInvalidTrackerID, index()->PickDirtyTracker()); | 660 EXPECT_EQ(kInvalidTrackerID, index()->PickDirtyTracker()); |
659 | 661 |
660 // Demoted trackers | 662 // Demoted trackers |
661 EXPECT_TRUE(index()->HasDemotedDirtyTracker()); | 663 EXPECT_TRUE(index()->HasDemotedDirtyTracker()); |
662 EXPECT_TRUE(index()->PromoteDemotedDirtyTrackers()); | 664 EXPECT_TRUE(index()->PromoteDemotedDirtyTrackers()); |
663 EXPECT_FALSE(index()->HasDemotedDirtyTracker()); | 665 EXPECT_FALSE(index()->HasDemotedDirtyTracker()); |
664 } | 666 } |
665 | 667 |
666 } // namespace drive_backend | 668 } // namespace drive_backend |
667 } // namespace sync_file_system | 669 } // namespace sync_file_system |
OLD | NEW |