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

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

Issue 982883002: [Sync] Add size and crc32c to AttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix argument evaluation order bug. Created 5 years, 9 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/attachments/attachment.h" 5 #include "sync/api/attachments/attachment.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
(...skipping 20 matching lines...) Expand all
31 EXPECT_EQ(a1.GetData(), a2.GetData()); 31 EXPECT_EQ(a1.GetData(), a2.GetData());
32 } 32 }
33 33
34 TEST_F(AttachmentTest, Create_WithEmptyData) { 34 TEST_F(AttachmentTest, Create_WithEmptyData) {
35 scoped_refptr<base::RefCountedString> empty_data(new base::RefCountedString); 35 scoped_refptr<base::RefCountedString> empty_data(new base::RefCountedString);
36 Attachment a = Attachment::Create(empty_data); 36 Attachment a = Attachment::Create(empty_data);
37 EXPECT_EQ(empty_data, a.GetData()); 37 EXPECT_EQ(empty_data, a.GetData());
38 } 38 }
39 39
40 TEST_F(AttachmentTest, CreateFromParts_HappyCase) { 40 TEST_F(AttachmentTest, CreateFromParts_HappyCase) {
41 AttachmentId id = AttachmentId::Create();
42 scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString); 41 scoped_refptr<base::RefCountedString> some_data(new base::RefCountedString);
43 some_data->data() = kAttachmentData; 42 some_data->data() = kAttachmentData;
44 uint32_t crc32c = ComputeCrc32c(some_data); 43 uint32_t crc32c = ComputeCrc32c(some_data);
45 Attachment a = Attachment::CreateFromParts(id, some_data, crc32c); 44 AttachmentId id = AttachmentId::Create(some_data->size(), crc32c);
45 Attachment a = Attachment::CreateFromParts(id, some_data);
46 EXPECT_EQ(id, a.GetId()); 46 EXPECT_EQ(id, a.GetId());
47 EXPECT_EQ(some_data, a.GetData()); 47 EXPECT_EQ(some_data, a.GetData());
48 } 48 }
49 49
50 } // namespace syncer 50 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698