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

Side by Side Diff: sync/api/sync_data_unittest.cc

Issue 213003004: Replace calls to 3-arg SyncData::CreateLocalData with 5-arg version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Forgot a class keyword. Created 6 years, 8 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/api/sync_data.h" 5 #include "sync/api/sync_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 16 matching lines...) Expand all
27 const ModelType kDatatype = syncer::PREFERENCES; 27 const ModelType kDatatype = syncer::PREFERENCES;
28 const string kNonUniqueTitle = "my preference"; 28 const string kNonUniqueTitle = "my preference";
29 const int64 kId = 439829; 29 const int64 kId = 439829;
30 const base::Time kLastModifiedTime = base::Time(); 30 const base::Time kLastModifiedTime = base::Time();
31 31
32 class SyncDataTest : public testing::Test { 32 class SyncDataTest : public testing::Test {
33 protected: 33 protected:
34 SyncDataTest() 34 SyncDataTest()
35 : attachment_service(FakeAttachmentService::CreateForTest()), 35 : attachment_service(FakeAttachmentService::CreateForTest()),
36 attachment_service_weak_ptr_factory(attachment_service.get()), 36 attachment_service_weak_ptr_factory(attachment_service.get()),
37 attachment_service_proxy( 37 attachment_service_proxy(new AttachmentServiceProxy(
38 base::MessageLoopProxy::current(), 38 base::MessageLoopProxy::current(),
39 attachment_service_weak_ptr_factory.GetWeakPtr()) {} 39 attachment_service_weak_ptr_factory.GetWeakPtr())) {}
40 base::MessageLoop loop; 40 base::MessageLoop loop;
41 sync_pb::EntitySpecifics specifics; 41 sync_pb::EntitySpecifics specifics;
42 scoped_ptr<AttachmentService> attachment_service; 42 scoped_ptr<AttachmentService> attachment_service;
43 base::WeakPtrFactory<AttachmentService> attachment_service_weak_ptr_factory; 43 base::WeakPtrFactory<AttachmentService> attachment_service_weak_ptr_factory;
44 AttachmentServiceProxy attachment_service_proxy; 44 scoped_refptr<AttachmentServiceProxy> attachment_service_proxy;
45 }; 45 };
46 46
47 TEST_F(SyncDataTest, NoArgCtor) { 47 TEST_F(SyncDataTest, NoArgCtor) {
48 SyncData data; 48 SyncData data;
49 EXPECT_FALSE(data.IsValid()); 49 EXPECT_FALSE(data.IsValid());
50 } 50 }
51 51
52 TEST_F(SyncDataTest, CreateLocalDelete) { 52 TEST_F(SyncDataTest, CreateLocalDelete) {
53 SyncData data = SyncData::CreateLocalDelete(kSyncTag, kDatatype); 53 SyncData data = SyncData::CreateLocalDelete(kSyncTag, kDatatype);
54 EXPECT_TRUE(data.IsValid()); 54 EXPECT_TRUE(data.IsValid());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 AttachmentIdList(), 113 AttachmentIdList(),
114 attachment_service_proxy); 114 attachment_service_proxy);
115 EXPECT_TRUE(data.IsValid()); 115 EXPECT_TRUE(data.IsValid());
116 EXPECT_FALSE(data.IsLocal()); 116 EXPECT_FALSE(data.IsLocal());
117 EXPECT_EQ(kId, SyncDataRemote(data).GetId()); 117 EXPECT_EQ(kId, SyncDataRemote(data).GetId());
118 EXPECT_EQ(kLastModifiedTime, SyncDataRemote(data).GetModifiedTime()); 118 EXPECT_EQ(kLastModifiedTime, SyncDataRemote(data).GetModifiedTime());
119 EXPECT_TRUE(data.GetSpecifics().has_preference()); 119 EXPECT_TRUE(data.GetSpecifics().has_preference());
120 EXPECT_TRUE(data.GetAttachmentIds().empty()); 120 EXPECT_TRUE(data.GetAttachmentIds().empty());
121 } 121 }
122 122
123 TEST_F(SyncDataTest, CreateRemoteData_WithoutAttachmentService) {
124 specifics.mutable_preference();
125 SyncData data = SyncData::CreateRemoteData(kId, specifics, kLastModifiedTime);
126 EXPECT_TRUE(data.IsValid());
127 EXPECT_FALSE(data.IsLocal());
128 EXPECT_EQ(kId, SyncDataRemote(data).GetId());
129 EXPECT_EQ(kLastModifiedTime, SyncDataRemote(data).GetModifiedTime());
130 EXPECT_TRUE(data.GetSpecifics().has_preference());
131 }
132
133 // TODO(maniscalco): Add test cases that verify GetLocalAttachmentsForUpload and 123 // TODO(maniscalco): Add test cases that verify GetLocalAttachmentsForUpload and
134 // DropAttachments calls are passed through to the underlying AttachmentService. 124 // DropAttachments calls are passed through to the underlying AttachmentService.
135 125
136 } // namespace 126 } // namespace
137 127
138 } // namespace syncer 128 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698