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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc

Issue 527163002: [SyncFS] Retry initialization of MetadataDatabase on failure of loading ServiceMetadata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Retry initialization Created 6 years, 3 months 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.h" 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 int64 next_tracker_id_; 633 int64 next_tracker_id_;
634 int64 next_file_id_number_; 634 int64 next_file_id_number_;
635 int64 next_md5_sequence_number_; 635 int64 next_md5_sequence_number_;
636 636
637 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseTest); 637 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseTest);
638 }; 638 };
639 639
640 TEST_F(MetadataDatabaseTest, InitializationTest_Empty) { 640 TEST_F(MetadataDatabaseTest, InitializationTest_Empty) {
641 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase()); 641 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
642 DropDatabase(); 642 DropDatabase();
643 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase()); 643 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
nhiroki 2014/09/03 04:30:06 This init->drop-init sequence might not make sense
peria 2014/09/03 09:24:21 It works well as long as we use |in_memory_env_|.
nhiroki 2014/09/03 09:52:20 I see. I wrongly assumed |in_memory_env_| is recre
644
645 DropDatabase();
646 scoped_ptr<LevelDBWrapper> db = InitializeLevelDB();
647 db->Put(kServiceMetadataKey, "Unparsable string");
648 db->Commit();
649 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
644 } 650 }
645 651
646 TEST_F(MetadataDatabaseTest, InitializationTest_SimpleTree) { 652 TEST_F(MetadataDatabaseTest, InitializationTest_SimpleTree) {
647 TrackedFile sync_root(CreateTrackedSyncRoot()); 653 TrackedFile sync_root(CreateTrackedSyncRoot());
648 TrackedFile app_root(CreateTrackedFolder(sync_root, "app_id")); 654 TrackedFile app_root(CreateTrackedFolder(sync_root, "app_id"));
649 app_root.tracker.set_app_id(app_root.metadata.details().title()); 655 app_root.tracker.set_app_id(app_root.metadata.details().title());
650 app_root.tracker.set_tracker_kind(TRACKER_KIND_APP_ROOT); 656 app_root.tracker.set_tracker_kind(TRACKER_KIND_APP_ROOT);
651 657
652 TrackedFile file(CreateTrackedFile(app_root, "file")); 658 TrackedFile file(CreateTrackedFile(app_root, "file"));
653 TrackedFile folder(CreateTrackedFolder(app_root, "folder")); 659 TrackedFile folder(CreateTrackedFolder(app_root, "folder"));
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 EXPECT_TRUE(file->HasKey("details")); 1164 EXPECT_TRUE(file->HasKey("details"));
1159 1165
1160 ASSERT_TRUE(files->GetDictionary(1, &file)); 1166 ASSERT_TRUE(files->GetDictionary(1, &file));
1161 EXPECT_TRUE(file->GetString("title", &str) && str == "file_0"); 1167 EXPECT_TRUE(file->GetString("title", &str) && str == "file_0");
1162 EXPECT_TRUE(file->GetString("type", &str) && str == "file"); 1168 EXPECT_TRUE(file->GetString("type", &str) && str == "file");
1163 EXPECT_TRUE(file->HasKey("details")); 1169 EXPECT_TRUE(file->HasKey("details"));
1164 } 1170 }
1165 1171
1166 } // namespace drive_backend 1172 } // namespace drive_backend
1167 } // namespace sync_file_system 1173 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698