| Index: sync/internal_api/attachments/attachment_service_proxy_unittest.cc
|
| diff --git a/sync/internal_api/attachments/attachment_service_proxy_unittest.cc b/sync/internal_api/attachments/attachment_service_proxy_unittest.cc
|
| index a946382af65b9060dbf67187483892840f56b50f..545998dd39339fb721d436aff528f4226c7a5868 100644
|
| --- a/sync/internal_api/attachments/attachment_service_proxy_unittest.cc
|
| +++ b/sync/internal_api/attachments/attachment_service_proxy_unittest.cc
|
| @@ -34,8 +34,6 @@
|
|
|
| virtual ~StubAttachmentService() {}
|
|
|
| - virtual AttachmentStore* GetStore() OVERRIDE { return NULL; }
|
| -
|
| virtual void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids,
|
| const GetOrDownloadCallback& callback)
|
| OVERRIDE {
|
| @@ -57,10 +55,12 @@
|
| FROM_HERE, base::Bind(callback, AttachmentService::DROP_SUCCESS));
|
| }
|
|
|
| - virtual void UploadAttachments(
|
| - const AttachmentIdSet& attachments_ids) OVERRIDE {
|
| + virtual void StoreAttachments(const AttachmentList& attachments,
|
| + const StoreCallback& callback) OVERRIDE {
|
| CalledOnValidThread();
|
| Increment();
|
| + base::MessageLoop::current()->PostTask(
|
| + FROM_HERE, base::Bind(callback, AttachmentService::STORE_SUCCESS));
|
| }
|
|
|
| virtual base::WeakPtr<AttachmentService> AsWeakPtr() {
|
| @@ -105,8 +105,11 @@
|
| base::Unretained(this));
|
| callback_drop = base::Bind(&AttachmentServiceProxyTest::IncrementDrop,
|
| base::Unretained(this));
|
| + callback_store = base::Bind(&AttachmentServiceProxyTest::IncrementStore,
|
| + base::Unretained(this));
|
| count_callback_get_or_download = 0;
|
| count_callback_drop = 0;
|
| + count_callback_store = 0;
|
| }
|
|
|
| virtual void TearDown()
|
| @@ -133,6 +136,12 @@
|
| ++count_callback_drop;
|
| }
|
|
|
| + // a StoreCallback
|
| + void IncrementStore(const AttachmentService::StoreResult&) {
|
| + CalledOnValidThread();
|
| + ++count_callback_store;
|
| + }
|
| +
|
| void WaitForStubThread() {
|
| base::WaitableEvent done(false, false);
|
| stub_thread->message_loop()->PostTask(
|
| @@ -148,24 +157,23 @@
|
|
|
| AttachmentService::GetOrDownloadCallback callback_get_or_download;
|
| AttachmentService::DropCallback callback_drop;
|
| + AttachmentService::StoreCallback callback_store;
|
|
|
| // number of times callback_get_or_download was invoked
|
| int count_callback_get_or_download;
|
| // number of times callback_drop was invoked
|
| int count_callback_drop;
|
| + // number of times callback_store was invoked
|
| + int count_callback_store;
|
| };
|
|
|
| -TEST_F(AttachmentServiceProxyTest, GetStore) {
|
| - EXPECT_EQ(NULL, proxy->GetStore());
|
| -}
|
| -
|
| -// Verify that each of AttachmentServiceProxy's methods are invoked on the stub.
|
| -// Verify that the methods that take callbacks invoke passed callbacks on this
|
| -// thread.
|
| -TEST_F(AttachmentServiceProxyTest, MethodsAreProxied) {
|
| +// Verify that each of AttachmentServiceProxy's callback methods (those that
|
| +// take callbacks) are invoked on the stub and that the passed callbacks are
|
| +// invoked in this thread.
|
| +TEST_F(AttachmentServiceProxyTest, MethodsWithCallbacksAreProxied) {
|
| proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download);
|
| proxy->DropAttachments(AttachmentIdList(), callback_drop);
|
| - proxy->UploadAttachments(AttachmentIdSet());
|
| + proxy->StoreAttachments(AttachmentList(), callback_store);
|
| // Wait for the posted calls to execute in the stub thread.
|
| WaitForStubThread();
|
| EXPECT_EQ(3, stub->GetCallCount());
|
| @@ -177,6 +185,7 @@
|
| loop.RunUntilIdle();
|
| EXPECT_EQ(1, count_callback_get_or_download);
|
| EXPECT_EQ(1, count_callback_drop);
|
| + EXPECT_EQ(1, count_callback_store);
|
| }
|
|
|
| // Verify that it's safe to use an AttachmentServiceProxy even after its wrapped
|
|
|