OLD | NEW |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 class AttachmentServiceProxyTest : public testing::Test, | 78 class AttachmentServiceProxyTest : public testing::Test, |
79 public base::NonThreadSafe { | 79 public base::NonThreadSafe { |
80 protected: | 80 protected: |
81 AttachmentServiceProxyTest() {} | 81 AttachmentServiceProxyTest() {} |
82 | 82 |
83 void SetUp() override { | 83 void SetUp() override { |
84 CalledOnValidThread(); | 84 CalledOnValidThread(); |
85 stub_thread.reset(new base::Thread("attachment service stub thread")); | 85 stub_thread.reset(new base::Thread("attachment service stub thread")); |
86 stub_thread->Start(); | 86 stub_thread->Start(); |
87 stub.reset(new StubAttachmentService); | 87 stub.reset(new StubAttachmentService); |
88 proxy.reset(new AttachmentServiceProxy(stub_thread->message_loop_proxy(), | 88 proxy.reset(new AttachmentServiceProxy(stub_thread->task_runner(), |
89 stub->AsWeakPtr())); | 89 stub->AsWeakPtr())); |
90 | 90 |
91 callback_get_or_download = | 91 callback_get_or_download = |
92 base::Bind(&AttachmentServiceProxyTest::IncrementGetOrDownload, | 92 base::Bind(&AttachmentServiceProxyTest::IncrementGetOrDownload, |
93 base::Unretained(this)); | 93 base::Unretained(this)); |
94 count_callback_get_or_download = 0; | 94 count_callback_get_or_download = 0; |
95 } | 95 } |
96 | 96 |
97 void TearDown() override { | 97 void TearDown() override { |
98 // We must take care to call the stub's destructor on the stub_thread | 98 // We must take care to call the stub's destructor on the stub_thread |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |