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

Side by Side Diff: sync/internal_api/attachments/on_disk_attachment_store_unittest.cc

Issue 986743004: [Sync] Refactor AttachmentStore classes. Introduce concept of referrer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 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 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 "sync/internal_api/public/attachments/on_disk_attachment_store.h" 5 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 } // namespace 32 } // namespace
33 33
34 // Instantiation of common attachment store tests. 34 // Instantiation of common attachment store tests.
35 class OnDiskAttachmentStoreFactory { 35 class OnDiskAttachmentStoreFactory {
36 public: 36 public:
37 OnDiskAttachmentStoreFactory() {} 37 OnDiskAttachmentStoreFactory() {}
38 ~OnDiskAttachmentStoreFactory() {} 38 ~OnDiskAttachmentStoreFactory() {}
39 39
40 scoped_refptr<AttachmentStore> CreateAttachmentStore() { 40 scoped_ptr<AttachmentStore> CreateAttachmentStore() {
41 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 41 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
42 scoped_refptr<AttachmentStore> store; 42 scoped_ptr<AttachmentStore> store;
43 AttachmentStore::Result result = AttachmentStore::UNSPECIFIED_ERROR; 43 AttachmentStore::Result result = AttachmentStore::UNSPECIFIED_ERROR;
44 store = AttachmentStore::CreateOnDiskStore( 44 store = AttachmentStore::CreateOnDiskStore(
45 temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), 45 temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(),
46 base::Bind(&AttachmentStoreCreated, &result)); 46 base::Bind(&AttachmentStoreCreated, &result));
47 base::RunLoop run_loop; 47 base::RunLoop run_loop;
48 run_loop.RunUntilIdle(); 48 run_loop.RunUntilIdle();
49 EXPECT_EQ(AttachmentStore::SUCCESS, result); 49 EXPECT_EQ(AttachmentStore::SUCCESS, result);
50 return store; 50 return store;
51 } 51 }
52 52
53 private: 53 private:
54 base::ScopedTempDir temp_dir_; 54 base::ScopedTempDir temp_dir_;
55 }; 55 };
56 56
57 INSTANTIATE_TYPED_TEST_CASE_P(OnDisk, 57 INSTANTIATE_TYPED_TEST_CASE_P(OnDisk,
58 AttachmentStoreTest, 58 AttachmentStoreTest,
59 OnDiskAttachmentStoreFactory); 59 OnDiskAttachmentStoreFactory);
60 60
61 // Tests specific to OnDiskAttachmentStore. 61 // Tests specific to OnDiskAttachmentStore.
62 class OnDiskAttachmentStoreSpecificTest : public testing::Test { 62 class OnDiskAttachmentStoreSpecificTest : public testing::Test {
63 public: 63 public:
64 base::ScopedTempDir temp_dir_; 64 base::ScopedTempDir temp_dir_;
65 base::FilePath db_path_; 65 base::FilePath db_path_;
66 base::MessageLoop message_loop_; 66 base::MessageLoop message_loop_;
67 scoped_refptr<AttachmentStore> store_; 67 scoped_ptr<AttachmentStore> store_;
68 68
69 OnDiskAttachmentStoreSpecificTest() {} 69 OnDiskAttachmentStoreSpecificTest() {}
70 70
71 void SetUp() override { 71 void SetUp() override {
72 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 72 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
73 db_path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("leveldb")); 73 db_path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("leveldb"));
74 base::CreateDirectory(db_path_); 74 base::CreateDirectory(db_path_);
75 } 75 }
76 76
77 void CopyResult(AttachmentStore::Result* destination_result, 77 void CopyResult(AttachmentStore::Result* destination_result,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 store_->ReadAllMetadata( 468 store_->ReadAllMetadata(
469 base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResultMetadata, 469 base::Bind(&OnDiskAttachmentStoreSpecificTest::CopyResultMetadata,
470 base::Unretained(this), &metadata_result, &metadata_list)); 470 base::Unretained(this), &metadata_result, &metadata_list));
471 RunLoop(); 471 RunLoop();
472 EXPECT_EQ(AttachmentStore::SUCCESS, create_result); 472 EXPECT_EQ(AttachmentStore::SUCCESS, create_result);
473 EXPECT_EQ(AttachmentStore::UNSPECIFIED_ERROR, metadata_result); 473 EXPECT_EQ(AttachmentStore::UNSPECIFIED_ERROR, metadata_result);
474 EXPECT_EQ(2U, metadata_list->size()); 474 EXPECT_EQ(2U, metadata_list->size());
475 } 475 }
476 476
477 } // namespace syncer 477 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/on_disk_attachment_store.cc ('k') | sync/internal_api/public/attachments/attachment_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698