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/fake_attachment_store.h" | 5 #include "sync/internal_api/public/attachments/fake_attachment_store.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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/thread_task_runner_handle.h" |
11 #include "sync/api/attachments/attachment.h" | 12 #include "sync/api/attachments/attachment.h" |
12 #include "sync/protocol/sync.pb.h" | 13 #include "sync/protocol/sync.pb.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace syncer { | 16 namespace syncer { |
16 | 17 |
17 const char kTestData1[] = "test data 1"; | 18 const char kTestData1[] = "test data 1"; |
18 const char kTestData2[] = "test data 2"; | 19 const char kTestData2[] = "test data 2"; |
19 | 20 |
20 class FakeAttachmentStoreTest : public testing::Test { | 21 class FakeAttachmentStoreTest : public testing::Test { |
21 protected: | 22 protected: |
22 base::MessageLoop message_loop; | 23 base::MessageLoop message_loop; |
23 FakeAttachmentStore store; | 24 FakeAttachmentStore store; |
24 AttachmentStore::Result result; | 25 AttachmentStore::Result result; |
25 scoped_ptr<AttachmentMap> attachments; | 26 scoped_ptr<AttachmentMap> attachments; |
26 scoped_ptr<AttachmentIdList> failed_attachment_ids; | 27 scoped_ptr<AttachmentIdList> failed_attachment_ids; |
27 | 28 |
28 AttachmentStore::ReadCallback read_callback; | 29 AttachmentStore::ReadCallback read_callback; |
29 AttachmentStore::WriteCallback write_callback; | 30 AttachmentStore::WriteCallback write_callback; |
30 AttachmentStore::DropCallback drop_callback; | 31 AttachmentStore::DropCallback drop_callback; |
31 | 32 |
32 scoped_refptr<base::RefCountedString> some_data1; | 33 scoped_refptr<base::RefCountedString> some_data1; |
33 scoped_refptr<base::RefCountedString> some_data2; | 34 scoped_refptr<base::RefCountedString> some_data2; |
34 | 35 |
35 FakeAttachmentStoreTest() : store(base::MessageLoopProxy::current()) {} | 36 FakeAttachmentStoreTest() : store(base::ThreadTaskRunnerHandle::Get()) {} |
36 | 37 |
37 virtual void SetUp() { | 38 virtual void SetUp() { |
38 Clear(); | 39 Clear(); |
39 read_callback = base::Bind(&FakeAttachmentStoreTest::CopyResultAttachments, | 40 read_callback = base::Bind(&FakeAttachmentStoreTest::CopyResultAttachments, |
40 base::Unretained(this), | 41 base::Unretained(this), |
41 &result, | 42 &result, |
42 &attachments, | 43 &attachments, |
43 &failed_attachment_ids); | 44 &failed_attachment_ids); |
44 write_callback = base::Bind( | 45 write_callback = base::Bind( |
45 &FakeAttachmentStoreTest::CopyResult, base::Unretained(this), &result); | 46 &FakeAttachmentStoreTest::CopyResult, base::Unretained(this), &result); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 247 |
247 // Drop again, see that no error occurs. | 248 // Drop again, see that no error occurs. |
248 ids.clear(); | 249 ids.clear(); |
249 ids.push_back(attachment1.GetId()); | 250 ids.push_back(attachment1.GetId()); |
250 store.Drop(ids, drop_callback); | 251 store.Drop(ids, drop_callback); |
251 ClearAndPumpLoop(); | 252 ClearAndPumpLoop(); |
252 EXPECT_EQ(result, AttachmentStore::SUCCESS); | 253 EXPECT_EQ(result, AttachmentStore::SUCCESS); |
253 } | 254 } |
254 | 255 |
255 } // namespace syncer | 256 } // namespace syncer |
OLD | NEW |