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

Side by Side Diff: sync/api/attachments/attachment_unittest.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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/attachments/attachment_store_backend.cc ('k') | sync/api/conflict_resolution.h » ('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 2014 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/attachments/attachment.h"
6
7 #include <stdint.h>
8
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/ref_counted_memory.h"
13 #include "sync/internal_api/public/attachments/attachment_util.h"
14 #include "sync/protocol/sync.pb.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace syncer {
18
19 namespace {
20
21 const char kAttachmentData[] = "some data";
22
23 } // namespace
24
25 class AttachmentTest : public testing::Test {};
26
27 TEST_F(AttachmentTest, Create_UniqueIdIsUnique) {
28 scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString);
29 some_data->data() = kAttachmentData;
30 Attachment a1 = Attachment::Create(some_data);
31 Attachment a2 = Attachment::Create(some_data);
32 EXPECT_NE(a1.GetId(), a2.GetId());
33 EXPECT_EQ(a1.GetData(), a2.GetData());
34 }
35
36 TEST_F(AttachmentTest, Create_WithEmptyData) {
37 scoped_refptr<base::RefCountedString> empty_data(new base::RefCountedString);
38 Attachment a = Attachment::Create(empty_data);
39 EXPECT_EQ(empty_data, a.GetData());
40 }
41
42 TEST_F(AttachmentTest, CreateFromParts_HappyCase) {
43 scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString);
44 some_data->data() = kAttachmentData;
45 uint32_t crc32c = ComputeCrc32c(some_data);
46 AttachmentId id = AttachmentId::Create(some_data->size(), crc32c);
47 Attachment a = Attachment::CreateFromParts(id, some_data);
48 EXPECT_EQ(id, a.GetId());
49 EXPECT_EQ(some_data, a.GetData());
50 }
51
52 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/attachment_store_backend.cc ('k') | sync/api/conflict_resolution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698