| Index: sync/api/sync_data_unittest.cc
|
| diff --git a/sync/api/sync_data_unittest.cc b/sync/api/sync_data_unittest.cc
|
| index 19d88d43053732bbe6789ea057b5449bf56ee5ed..bf964c8d19f5f4291342f02a1248f2a02e2c0ee5 100644
|
| --- a/sync/api/sync_data_unittest.cc
|
| +++ b/sync/api/sync_data_unittest.cc
|
| @@ -6,7 +6,14 @@
|
|
|
| #include <string>
|
|
|
| +#include "base/memory/ref_counted_memory.h"
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "base/message_loop/message_loop_proxy.h"
|
| #include "base/time/time.h"
|
| +#include "sync/api/attachments/attachment_id.h"
|
| +#include "sync/api/attachments/attachment_service.h"
|
| +#include "sync/api/attachments/attachment_service_proxy.h"
|
| +#include "sync/api/attachments/fake_attachment_service.h"
|
| #include "sync/protocol/sync.pb.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -22,7 +29,20 @@ const string kNonUniqueTitle = "my preference";
|
| const int64 kId = 439829;
|
| const base::Time kLastModifiedTime = base::Time();
|
|
|
| -typedef testing::Test SyncDataTest;
|
| +class SyncDataTest : public testing::Test {
|
| + protected:
|
| + SyncDataTest()
|
| + : attachment_service(FakeAttachmentService::CreateForTest()),
|
| + attachment_service_weak_ptr_factory(attachment_service.get()),
|
| + attachment_service_proxy(
|
| + base::MessageLoopProxy::current(),
|
| + attachment_service_weak_ptr_factory.GetWeakPtr()) {}
|
| + base::MessageLoop loop;
|
| + sync_pb::EntitySpecifics specifics;
|
| + scoped_ptr<AttachmentService> attachment_service;
|
| + base::WeakPtrFactory<AttachmentService> attachment_service_weak_ptr_factory;
|
| + AttachmentServiceProxy attachment_service_proxy;
|
| +};
|
|
|
| TEST_F(SyncDataTest, NoArgCtor) {
|
| SyncData data;
|
| @@ -38,7 +58,6 @@ TEST_F(SyncDataTest, CreateLocalDelete) {
|
| }
|
|
|
| TEST_F(SyncDataTest, CreateLocalData) {
|
| - sync_pb::EntitySpecifics specifics;
|
| specifics.mutable_preference();
|
| SyncData data =
|
| SyncData::CreateLocalData(kSyncTag, kNonUniqueTitle, specifics);
|
| @@ -50,8 +69,58 @@ TEST_F(SyncDataTest, CreateLocalData) {
|
| EXPECT_TRUE(data.GetSpecifics().has_preference());
|
| }
|
|
|
| +TEST_F(SyncDataTest, CreateLocalDataWithAttachments) {
|
| + specifics.mutable_preference();
|
| + scoped_refptr<base::RefCountedMemory> bytes(new base::RefCountedString);
|
| + AttachmentList attachments;
|
| + attachments.push_back(Attachment::Create(bytes));
|
| + attachments.push_back(Attachment::Create(bytes));
|
| + attachments.push_back(Attachment::Create(bytes));
|
| +
|
| + SyncData data = SyncData::CreateLocalDataWithAttachments(
|
| + kSyncTag, kNonUniqueTitle, specifics, attachments);
|
| + EXPECT_TRUE(data.IsValid());
|
| + EXPECT_TRUE(data.IsLocal());
|
| + EXPECT_EQ(kSyncTag, data.GetTag());
|
| + EXPECT_EQ(kDatatype, data.GetDataType());
|
| + EXPECT_EQ(kNonUniqueTitle, data.GetTitle());
|
| + EXPECT_TRUE(data.GetSpecifics().has_preference());
|
| + AttachmentIdList attachment_ids = data.GetAttachmentIds();
|
| + EXPECT_EQ(3U, attachment_ids.size());
|
| + EXPECT_EQ(3U, data.GetLocalAttachmentsForUpload().size());
|
| +}
|
| +
|
| +TEST_F(SyncDataTest, CreateLocalDataWithAttachments_EmptyListOfAttachments) {
|
| + specifics.mutable_preference();
|
| + AttachmentList attachments;
|
| + SyncData data = SyncData::CreateLocalDataWithAttachments(
|
| + kSyncTag, kNonUniqueTitle, specifics, attachments);
|
| + EXPECT_TRUE(data.IsValid());
|
| + EXPECT_TRUE(data.IsLocal());
|
| + EXPECT_EQ(kSyncTag, data.GetTag());
|
| + EXPECT_EQ(kDatatype, data.GetDataType());
|
| + EXPECT_EQ(kNonUniqueTitle, data.GetTitle());
|
| + EXPECT_TRUE(data.GetSpecifics().has_preference());
|
| + EXPECT_TRUE(data.GetAttachmentIds().empty());
|
| + EXPECT_TRUE(data.GetLocalAttachmentsForUpload().empty());
|
| +}
|
| +
|
| TEST_F(SyncDataTest, CreateRemoteData) {
|
| - sync_pb::EntitySpecifics specifics;
|
| + specifics.mutable_preference();
|
| + SyncData data = SyncData::CreateRemoteData(kId,
|
| + specifics,
|
| + kLastModifiedTime,
|
| + AttachmentIdList(),
|
| + attachment_service_proxy);
|
| + EXPECT_TRUE(data.IsValid());
|
| + EXPECT_FALSE(data.IsLocal());
|
| + EXPECT_EQ(kId, data.GetRemoteId());
|
| + EXPECT_EQ(kLastModifiedTime, data.GetRemoteModifiedTime());
|
| + EXPECT_TRUE(data.GetSpecifics().has_preference());
|
| + EXPECT_TRUE(data.GetAttachmentIds().empty());
|
| +}
|
| +
|
| +TEST_F(SyncDataTest, CreateRemoteData_WithoutAttachmentService) {
|
| specifics.mutable_preference();
|
| SyncData data = SyncData::CreateRemoteData(kId, specifics, kLastModifiedTime);
|
| EXPECT_TRUE(data.IsValid());
|
| @@ -61,6 +130,9 @@ TEST_F(SyncDataTest, CreateRemoteData) {
|
| EXPECT_TRUE(data.GetSpecifics().has_preference());
|
| }
|
|
|
| +// TODO(maniscalco): Add test cases that verify GetLocalAttachmentsForUpload and
|
| +// DropAttachments calls are passed through to the underlying AttachmentService.
|
| +
|
| } // namespace
|
|
|
| } // namespace syncer
|
|
|