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

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

Issue 1035573002: [Sync] Replace AttachmentIdSet with AttachmentIdList in interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/attachment_service_proxy.h" 5 #include "sync/internal_api/public/attachments/attachment_service_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 28 matching lines...) Expand all
39 CalledOnValidThread(); 39 CalledOnValidThread();
40 Increment(); 40 Increment();
41 scoped_ptr<AttachmentMap> attachments(new AttachmentMap()); 41 scoped_ptr<AttachmentMap> attachments(new AttachmentMap());
42 base::MessageLoop::current()->PostTask( 42 base::MessageLoop::current()->PostTask(
43 FROM_HERE, 43 FROM_HERE,
44 base::Bind(callback, 44 base::Bind(callback,
45 AttachmentService::GET_UNSPECIFIED_ERROR, 45 AttachmentService::GET_UNSPECIFIED_ERROR,
46 base::Passed(&attachments))); 46 base::Passed(&attachments)));
47 } 47 }
48 48
49 void UploadAttachments(const AttachmentIdSet& attachments_ids) override { 49 void UploadAttachments(const AttachmentIdList& attachments_ids) override {
50 CalledOnValidThread(); 50 CalledOnValidThread();
51 Increment(); 51 Increment();
52 } 52 }
53 53
54 virtual base::WeakPtr<AttachmentService> AsWeakPtr() { 54 virtual base::WeakPtr<AttachmentService> AsWeakPtr() {
55 return weak_ptr_factory_.GetWeakPtr(); 55 return weak_ptr_factory_.GetWeakPtr();
56 } 56 }
57 57
58 // Return the number of method invocations. 58 // Return the number of method invocations.
59 int GetCallCount() const { 59 int GetCallCount() const {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 // number of times callback_get_or_download was invoked 129 // number of times callback_get_or_download was invoked
130 int count_callback_get_or_download; 130 int count_callback_get_or_download;
131 }; 131 };
132 132
133 // Verify that each of AttachmentServiceProxy's methods are invoked on the stub. 133 // Verify that each of AttachmentServiceProxy's methods are invoked on the stub.
134 // Verify that the methods that take callbacks invoke passed callbacks on this 134 // Verify that the methods that take callbacks invoke passed callbacks on this
135 // thread. 135 // thread.
136 TEST_F(AttachmentServiceProxyTest, MethodsAreProxied) { 136 TEST_F(AttachmentServiceProxyTest, MethodsAreProxied) {
137 proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download); 137 proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download);
138 proxy->UploadAttachments(AttachmentIdSet()); 138 proxy->UploadAttachments(AttachmentIdList());
139 // Wait for the posted calls to execute in the stub thread. 139 // Wait for the posted calls to execute in the stub thread.
140 WaitForStubThread(); 140 WaitForStubThread();
141 EXPECT_EQ(2, stub->GetCallCount()); 141 EXPECT_EQ(2, stub->GetCallCount());
142 // At this point the stub thread has finished executed the calls. However, the 142 // At this point the stub thread has finished executed the calls. However, the
143 // result callbacks it has posted may not have executed yet. Wait a second 143 // result callbacks it has posted may not have executed yet. Wait a second
144 // time to ensure the stub thread has executed the posted result callbacks. 144 // time to ensure the stub thread has executed the posted result callbacks.
145 WaitForStubThread(); 145 WaitForStubThread();
146 146
147 base::RunLoop().RunUntilIdle(); 147 base::RunLoop().RunUntilIdle();
148 EXPECT_EQ(1, count_callback_get_or_download); 148 EXPECT_EQ(1, count_callback_get_or_download);
(...skipping 20 matching lines...) Expand all
169 // Now that the wrapped object has been destroyed, call again and see that we 169 // Now that the wrapped object has been destroyed, call again and see that we
170 // don't crash and the count remains the same. 170 // don't crash and the count remains the same.
171 proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download); 171 proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download);
172 WaitForStubThread(); 172 WaitForStubThread();
173 WaitForStubThread(); 173 WaitForStubThread();
174 base::RunLoop().RunUntilIdle(); 174 base::RunLoop().RunUntilIdle();
175 EXPECT_EQ(1, count_callback_get_or_download); 175 EXPECT_EQ(1, count_callback_get_or_download);
176 } 176 }
177 177
178 } // namespace syncer 178 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698