Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / sync / api / attachments / attachment_unittest.cc
blobcd1e3e4ca7c7113f414a02ed256540139c099f7b
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.
5 #include "sync/api/attachments/attachment.h"
7 #include <string>
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/ref_counted_memory.h"
11 #include "sync/internal_api/public/attachments/attachment_util.h"
12 #include "sync/protocol/sync.pb.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace syncer {
17 namespace {
19 const char kAttachmentData[] = "some data";
21 } // namespace
23 class AttachmentTest : public testing::Test {};
25 TEST_F(AttachmentTest, Create_UniqueIdIsUnique) {
26 scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString);
27 some_data->data() = kAttachmentData;
28 Attachment a1 = Attachment::Create(some_data);
29 Attachment a2 = Attachment::Create(some_data);
30 EXPECT_NE(a1.GetId(), a2.GetId());
31 EXPECT_EQ(a1.GetData(), a2.GetData());
34 TEST_F(AttachmentTest, Create_WithEmptyData) {
35 scoped_refptr<base::RefCountedString> empty_data(new base::RefCountedString);
36 Attachment a = Attachment::Create(empty_data);
37 EXPECT_EQ(empty_data, a.GetData());
40 TEST_F(AttachmentTest, CreateFromParts_HappyCase) {
41 scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString);
42 some_data->data() = kAttachmentData;
43 uint32_t crc32c = ComputeCrc32c(some_data);
44 AttachmentId id = AttachmentId::Create(some_data->size(), crc32c);
45 Attachment a = Attachment::CreateFromParts(id, some_data);
46 EXPECT_EQ(id, a.GetId());
47 EXPECT_EQ(some_data, a.GetData());
50 } // namespace syncer