| Index: sync/internal_api/attachments/attachment_store_frontend_unittest.cc
|
| diff --git a/sync/internal_api/attachments/attachment_store_handle_unittest.cc b/sync/internal_api/attachments/attachment_store_frontend_unittest.cc
|
| similarity index 73%
|
| rename from sync/internal_api/attachments/attachment_store_handle_unittest.cc
|
| rename to sync/internal_api/attachments/attachment_store_frontend_unittest.cc
|
| index 23c0f09e7a06ecc9a283d7e673835732a132af41..696b43a3d50d71dbd45bb0171e1b72fed0cef358 100644
|
| --- a/sync/internal_api/attachments/attachment_store_handle_unittest.cc
|
| +++ b/sync/internal_api/attachments/attachment_store_frontend_unittest.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "sync/internal_api/public/attachments/attachment_store_handle.h"
|
| +#include "sync/internal_api/public/attachments/attachment_store_frontend.h"
|
|
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| @@ -13,6 +13,7 @@
|
| #include "base/thread_task_runner_handle.h"
|
| #include "sync/api/attachments/attachment.h"
|
| #include "sync/api/attachments/attachment_id.h"
|
| +#include "sync/api/attachments/attachment_store_backend.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace syncer {
|
| @@ -48,12 +49,14 @@ class MockAttachmentStore : public AttachmentStoreBackend {
|
| read_called_.Run();
|
| }
|
|
|
| - void Write(const AttachmentList& attachments,
|
| + void Write(AttachmentStore::AttachmentReferrer referrer,
|
| + const AttachmentList& attachments,
|
| const AttachmentStore::WriteCallback& callback) override {
|
| write_called_.Run();
|
| }
|
|
|
| - void Drop(const AttachmentIdList& ids,
|
| + void Drop(AttachmentStore::AttachmentReferrer referrer,
|
| + const AttachmentIdList& ids,
|
| const AttachmentStore::DropCallback& callback) override {
|
| drop_called_.Run();
|
| }
|
| @@ -65,6 +68,7 @@ class MockAttachmentStore : public AttachmentStoreBackend {
|
| }
|
|
|
| void ReadAllMetadata(
|
| + AttachmentStore::AttachmentReferrer referrer,
|
| const AttachmentStore::ReadMetadataCallback& callback) override {
|
| read_all_metadata_called_.Run();
|
| }
|
| @@ -80,9 +84,9 @@ class MockAttachmentStore : public AttachmentStoreBackend {
|
|
|
| } // namespace
|
|
|
| -class AttachmentStoreHandleTest : public testing::Test {
|
| +class AttachmentStoreFrontendTest : public testing::Test {
|
| protected:
|
| - AttachmentStoreHandleTest()
|
| + AttachmentStoreFrontendTest()
|
| : init_call_count_(0),
|
| read_call_count_(0),
|
| write_call_count_(0),
|
| @@ -93,21 +97,21 @@ class AttachmentStoreHandleTest : public testing::Test {
|
|
|
| void SetUp() override {
|
| scoped_ptr<AttachmentStoreBackend> backend(new MockAttachmentStore(
|
| - base::Bind(&AttachmentStoreHandleTest::InitCalled,
|
| + base::Bind(&AttachmentStoreFrontendTest::InitCalled,
|
| base::Unretained(this)),
|
| - base::Bind(&AttachmentStoreHandleTest::ReadCalled,
|
| + base::Bind(&AttachmentStoreFrontendTest::ReadCalled,
|
| base::Unretained(this)),
|
| - base::Bind(&AttachmentStoreHandleTest::WriteCalled,
|
| + base::Bind(&AttachmentStoreFrontendTest::WriteCalled,
|
| base::Unretained(this)),
|
| - base::Bind(&AttachmentStoreHandleTest::DropCalled,
|
| + base::Bind(&AttachmentStoreFrontendTest::DropCalled,
|
| base::Unretained(this)),
|
| - base::Bind(&AttachmentStoreHandleTest::ReadMetadataCalled,
|
| + base::Bind(&AttachmentStoreFrontendTest::ReadMetadataCalled,
|
| base::Unretained(this)),
|
| - base::Bind(&AttachmentStoreHandleTest::ReadAllMetadataCalled,
|
| + base::Bind(&AttachmentStoreFrontendTest::ReadAllMetadataCalled,
|
| base::Unretained(this)),
|
| - base::Bind(&AttachmentStoreHandleTest::DtorCalled,
|
| + base::Bind(&AttachmentStoreFrontendTest::DtorCalled,
|
| base::Unretained(this))));
|
| - attachment_store_handle_ = new AttachmentStoreHandle(
|
| + attachment_store_frontend_ = new AttachmentStoreFrontend(
|
| backend.Pass(), base::ThreadTaskRunnerHandle::Get());
|
| }
|
|
|
| @@ -146,7 +150,7 @@ class AttachmentStoreHandleTest : public testing::Test {
|
| }
|
|
|
| base::MessageLoop message_loop_;
|
| - scoped_refptr<AttachmentStoreHandle> attachment_store_handle_;
|
| + scoped_refptr<AttachmentStoreFrontend> attachment_store_frontend_;
|
| int init_call_count_;
|
| int read_call_count_;
|
| int write_call_count_;
|
| @@ -157,49 +161,52 @@ class AttachmentStoreHandleTest : public testing::Test {
|
| };
|
|
|
| // Test that method calls are forwarded to backend loop
|
| -TEST_F(AttachmentStoreHandleTest, MethodsCalled) {
|
| +TEST_F(AttachmentStoreFrontendTest, MethodsCalled) {
|
| AttachmentIdList ids;
|
| AttachmentList attachments;
|
|
|
| - attachment_store_handle_->Init(
|
| - base::Bind(&AttachmentStoreHandleTest::DoneWithResult));
|
| + attachment_store_frontend_->Init(
|
| + base::Bind(&AttachmentStoreFrontendTest::DoneWithResult));
|
| EXPECT_EQ(init_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(init_call_count_, 1);
|
|
|
| - attachment_store_handle_->Read(
|
| - ids, base::Bind(&AttachmentStoreHandleTest::ReadDone));
|
| + attachment_store_frontend_->Read(
|
| + ids, base::Bind(&AttachmentStoreFrontendTest::ReadDone));
|
| EXPECT_EQ(read_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(read_call_count_, 1);
|
|
|
| - attachment_store_handle_->Write(
|
| - attachments, base::Bind(&AttachmentStoreHandleTest::DoneWithResult));
|
| + attachment_store_frontend_->Write(
|
| + AttachmentStore::SYNC, attachments,
|
| + base::Bind(&AttachmentStoreFrontendTest::DoneWithResult));
|
| EXPECT_EQ(write_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(write_call_count_, 1);
|
|
|
| - attachment_store_handle_->Drop(
|
| - ids, base::Bind(&AttachmentStoreHandleTest::DoneWithResult));
|
| + attachment_store_frontend_->Drop(
|
| + AttachmentStore::SYNC, ids,
|
| + base::Bind(&AttachmentStoreFrontendTest::DoneWithResult));
|
| EXPECT_EQ(drop_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(drop_call_count_, 1);
|
|
|
| - attachment_store_handle_->ReadMetadata(
|
| - ids, base::Bind(&AttachmentStoreHandleTest::ReadMetadataDone));
|
| + attachment_store_frontend_->ReadMetadata(
|
| + ids, base::Bind(&AttachmentStoreFrontendTest::ReadMetadataDone));
|
| EXPECT_EQ(read_metadata_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(read_metadata_call_count_, 1);
|
|
|
| - attachment_store_handle_->ReadAllMetadata(
|
| - base::Bind(&AttachmentStoreHandleTest::ReadMetadataDone));
|
| + attachment_store_frontend_->ReadAllMetadata(
|
| + AttachmentStore::SYNC,
|
| + base::Bind(&AttachmentStoreFrontendTest::ReadMetadataDone));
|
| EXPECT_EQ(read_all_metadata_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(read_all_metadata_call_count_, 1);
|
|
|
| - // Releasing referehce to AttachmentStoreHandle should result in
|
| + // Releasing referehce to AttachmentStoreFrontend should result in
|
| // MockAttachmentStore being deleted on backend loop.
|
| - attachment_store_handle_ = NULL;
|
| + attachment_store_frontend_ = NULL;
|
| EXPECT_EQ(dtor_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(dtor_call_count_, 1);
|
|
|