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

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 some DCHECKs and another test case. Created 7 years 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
(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 typedef testing::Test SyncAttachmentTest;
22
23 TEST_F(SyncAttachmentTest, Create_UniqueIdIsUnique) {
24 SyncAttachmentId id;
25 scoped_refptr<base::RefCountedString> bytes(new base::RefCountedString);
26 bytes->data() = "some data";
Nicolas Zea 2013/12/30 19:10:31 nit: make this a anon const variable, and reuse it
maniscalco 2013/12/30 22:17:19 Done.
27 scoped_ptr<SyncAttachment> a1 = SyncAttachment::Create(bytes);
28 scoped_ptr<SyncAttachment> a2 = SyncAttachment::Create(bytes);
29 EXPECT_NE(a1->GetId().unique_id(), a2->GetId().unique_id());
30 EXPECT_EQ(a1->GetBytes(), a2->GetBytes());
31 }
32
33 TEST_F(SyncAttachmentTest, Create_WithEmptyBytes) {
34 SyncAttachmentId id;
35 scoped_refptr<base::RefCountedString> emptyBytes(new base::RefCountedString);
36 scoped_ptr<SyncAttachment> a = SyncAttachment::Create(emptyBytes);
37 EXPECT_EQ(emptyBytes, a->GetBytes());
38 }
39
40 TEST_F(SyncAttachmentTest, CreateWithId_HappyCase) {
41 SyncAttachmentId id;
42 id.set_unique_id("3290482049832");
43 scoped_refptr<base::RefCountedString> bytes(new base::RefCountedString);
44 bytes->data() = "some data";
45 scoped_ptr<SyncAttachment> a = SyncAttachment::CreateWithId(id, bytes);
46 EXPECT_EQ(id.unique_id(), a->GetId().unique_id());
47 EXPECT_EQ(bytes, a->GetBytes());
48 }
49
50 } // namespace
51
52 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698