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

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

Issue 102193004: Checkpointing some Sync Attachment work. Added SyncAttachment and SyncAttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing SYNC_EXPORT_PRIVATE modifier (was cause of link error on trybots). Created 6 years, 11 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
« no previous file with comments | « sync/api/sync_attachment.cc ('k') | sync/protocol/attachments.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sync/api/sync_attachment.h"
6
7 #include <string>
8
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/ref_counted_memory.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "sync/protocol/sync.pb.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 using sync_pb::SyncAttachmentId;
16
17 namespace syncer {
18
19 namespace {
20
21 const char kAttachmentData[] = "some data";
22
23 typedef testing::Test SyncAttachmentTest;
24
25 TEST_F(SyncAttachmentTest, Create_UniqueIdIsUnique) {
26 SyncAttachmentId id;
27 scoped_refptr<base::RefCountedString> bytes(new base::RefCountedString);
28 bytes->data() = kAttachmentData;
29 scoped_ptr<SyncAttachment> a1 = SyncAttachment::Create(bytes);
30 scoped_ptr<SyncAttachment> a2 = SyncAttachment::Create(bytes);
31 EXPECT_NE(a1->GetId().unique_id(), a2->GetId().unique_id());
32 EXPECT_EQ(a1->GetBytes(), a2->GetBytes());
33 }
34
35 TEST_F(SyncAttachmentTest, Create_WithEmptyBytes) {
36 SyncAttachmentId id;
37 scoped_refptr<base::RefCountedString> emptyBytes(new base::RefCountedString);
38 scoped_ptr<SyncAttachment> a = SyncAttachment::Create(emptyBytes);
39 EXPECT_EQ(emptyBytes, a->GetBytes());
40 }
41
42 TEST_F(SyncAttachmentTest, CreateWithId_HappyCase) {
43 SyncAttachmentId id;
44 id.set_unique_id("3290482049832");
45 scoped_refptr<base::RefCountedString> bytes(new base::RefCountedString);
46 bytes->data() = kAttachmentData;
47 scoped_ptr<SyncAttachment> a = SyncAttachment::CreateWithId(id, bytes);
48 EXPECT_EQ(id.unique_id(), a->GetId().unique_id());
49 EXPECT_EQ(bytes, a->GetBytes());
50 }
51
52 } // namespace
53
54 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/sync_attachment.cc ('k') | sync/protocol/attachments.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698