| Index: sync/internal_api/attachments/attachment_store_handle_unittest.cc
|
| diff --git a/sync/internal_api/attachments/attachment_store_handle_unittest.cc b/sync/internal_api/attachments/attachment_store_handle_unittest.cc
|
| index a282c607977ab5719acf04bba0ab6175f255056f..31c1f464dbb66a4bc6f1d5ae6ebcec499bf510ee 100644
|
| --- a/sync/internal_api/attachments/attachment_store_handle_unittest.cc
|
| +++ b/sync/internal_api/attachments/attachment_store_handle_unittest.cc
|
| @@ -21,11 +21,13 @@ namespace {
|
|
|
| class MockAttachmentStore : public AttachmentStoreBase {
|
| public:
|
| - MockAttachmentStore(const base::Closure& read_called,
|
| + MockAttachmentStore(const base::Closure& load_called,
|
| + const base::Closure& read_called,
|
| const base::Closure& write_called,
|
| const base::Closure& drop_called,
|
| const base::Closure& dtor_called)
|
| - : read_called_(read_called),
|
| + : load_called_(load_called),
|
| + read_called_(read_called),
|
| write_called_(write_called),
|
| drop_called_(drop_called),
|
| dtor_called_(dtor_called) {}
|
| @@ -34,6 +36,10 @@ class MockAttachmentStore : public AttachmentStoreBase {
|
| dtor_called_.Run();
|
| }
|
|
|
| + virtual void Load(const LoadCallback& callback) override {
|
| + load_called_.Run();
|
| + }
|
| +
|
| virtual void Read(const AttachmentIdList& ids,
|
| const ReadCallback& callback) override {
|
| read_called_.Run();
|
| @@ -49,6 +55,7 @@ class MockAttachmentStore : public AttachmentStoreBase {
|
| drop_called_.Run();
|
| }
|
|
|
| + base::Closure load_called_;
|
| base::Closure read_called_;
|
| base::Closure write_called_;
|
| base::Closure drop_called_;
|
| @@ -60,13 +67,16 @@ class MockAttachmentStore : public AttachmentStoreBase {
|
| class AttachmentStoreHandleTest : public testing::Test {
|
| protected:
|
| AttachmentStoreHandleTest()
|
| - : read_call_count_(0),
|
| + : load_call_count_(0),
|
| + read_call_count_(0),
|
| write_call_count_(0),
|
| drop_call_count_(0),
|
| dtor_call_count_(0) {}
|
|
|
| virtual void SetUp() {
|
| scoped_ptr<AttachmentStoreBase> backend(new MockAttachmentStore(
|
| + base::Bind(&AttachmentStoreHandleTest::LoadCalled,
|
| + base::Unretained(this)),
|
| base::Bind(&AttachmentStoreHandleTest::ReadCalled,
|
| base::Unretained(this)),
|
| base::Bind(&AttachmentStoreHandleTest::WriteCalled,
|
| @@ -79,19 +89,17 @@ class AttachmentStoreHandleTest : public testing::Test {
|
| backend.Pass(), base::ThreadTaskRunnerHandle::Get());
|
| }
|
|
|
| - static void ReadDone(const AttachmentStore::Result& result,
|
| - scoped_ptr<AttachmentMap> attachments,
|
| - scoped_ptr<AttachmentIdList> unavailable_attachments) {
|
| + static void DoneWithResult(const AttachmentStore::Result& result) {
|
| NOTREACHED();
|
| }
|
|
|
| - static void WriteDone(const AttachmentStore::Result& result) {
|
| + static void ReadDone(const AttachmentStore::Result& result,
|
| + scoped_ptr<AttachmentMap> attachments,
|
| + scoped_ptr<AttachmentIdList> unavailable_attachments) {
|
| NOTREACHED();
|
| }
|
|
|
| - static void DropDone(const AttachmentStore::Result& result) {
|
| - NOTREACHED();
|
| - }
|
| + void LoadCalled() { ++load_call_count_; }
|
|
|
| void ReadCalled() { ++read_call_count_; }
|
|
|
| @@ -108,6 +116,7 @@ class AttachmentStoreHandleTest : public testing::Test {
|
|
|
| base::MessageLoop message_loop_;
|
| scoped_refptr<AttachmentStoreHandle> attachment_store_handle_;
|
| + int load_call_count_;
|
| int read_call_count_;
|
| int write_call_count_;
|
| int drop_call_count_;
|
| @@ -119,6 +128,12 @@ TEST_F(AttachmentStoreHandleTest, MethodsCalled) {
|
| AttachmentIdList ids;
|
| AttachmentList attachments;
|
|
|
| + attachment_store_handle_->Load(
|
| + base::Bind(&AttachmentStoreHandleTest::DoneWithResult));
|
| + EXPECT_EQ(load_call_count_, 0);
|
| + RunMessageLoop();
|
| + EXPECT_EQ(load_call_count_, 1);
|
| +
|
| attachment_store_handle_->Read(
|
| ids, base::Bind(&AttachmentStoreHandleTest::ReadDone));
|
| EXPECT_EQ(read_call_count_, 0);
|
| @@ -126,13 +141,13 @@ TEST_F(AttachmentStoreHandleTest, MethodsCalled) {
|
| EXPECT_EQ(read_call_count_, 1);
|
|
|
| attachment_store_handle_->Write(
|
| - attachments, base::Bind(&AttachmentStoreHandleTest::WriteDone));
|
| + attachments, base::Bind(&AttachmentStoreHandleTest::DoneWithResult));
|
| EXPECT_EQ(write_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(write_call_count_, 1);
|
|
|
| attachment_store_handle_->Drop(
|
| - ids, base::Bind(&AttachmentStoreHandleTest::DropDone));
|
| + ids, base::Bind(&AttachmentStoreHandleTest::DoneWithResult));
|
| EXPECT_EQ(drop_call_count_, 0);
|
| RunMessageLoop();
|
| EXPECT_EQ(drop_call_count_, 1);
|
|
|