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

Side by Side Diff: components/sync/core/change_record_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 | « components/sync/core/change_record.cc ('k') | components/sync/core/configure_reason.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/internal_api/public/change_record.h" 5 #include "components/sync/core/change_record.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/test/values_test_util.h" 15 #include "base/test/values_test_util.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "sync/protocol/extension_specifics.pb.h" 17 #include "components/sync/protocol/extension_specifics.pb.h"
18 #include "sync/protocol/proto_value_conversions.h" 18 #include "components/sync/protocol/proto_value_conversions.h"
19 #include "sync/protocol/sync.pb.h" 19 #include "components/sync/protocol/sync.pb.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace syncer { 23 namespace syncer {
24 namespace { 24 namespace {
25 25
26 using base::ExpectDictDictionaryValue; 26 using base::ExpectDictDictionaryValue;
27 using base::ExpectDictStringValue; 27 using base::ExpectDictStringValue;
28 using testing::Invoke; 28 using testing::Invoke;
29 using testing::StrictMock; 29 using testing::StrictMock;
(...skipping 14 matching lines...) Expand all
44 break; 44 break;
45 case ChangeRecord::ACTION_DELETE: 45 case ChangeRecord::ACTION_DELETE:
46 EXPECT_EQ("Delete", str_value); 46 EXPECT_EQ("Delete", str_value);
47 break; 47 break;
48 default: 48 default:
49 NOTREACHED(); 49 NOTREACHED();
50 break; 50 break;
51 } 51 }
52 } 52 }
53 53
54 void CheckChangeRecordValue( 54 void CheckChangeRecordValue(const ChangeRecord& record,
55 const ChangeRecord& record, 55 const base::DictionaryValue& value) {
56 const base::DictionaryValue& value) {
57 ExpectChangeRecordActionValue(record.action, value, "action"); 56 ExpectChangeRecordActionValue(record.action, value, "action");
58 ExpectDictStringValue(base::Int64ToString(record.id), value, "id"); 57 ExpectDictStringValue(base::Int64ToString(record.id), value, "id");
59 if (record.action == ChangeRecord::ACTION_DELETE) { 58 if (record.action == ChangeRecord::ACTION_DELETE) {
60 std::unique_ptr<base::DictionaryValue> expected_extra_value; 59 std::unique_ptr<base::DictionaryValue> expected_extra_value;
61 if (record.extra.get()) { 60 if (record.extra.get()) {
62 expected_extra_value = record.extra->ToValue(); 61 expected_extra_value = record.extra->ToValue();
63 } 62 }
64 const base::Value* extra_value = NULL; 63 const base::Value* extra_value = NULL;
65 EXPECT_EQ(record.extra.get() != NULL, 64 EXPECT_EQ(record.extra.get() != NULL, value.Get("extra", &extra_value));
66 value.Get("extra", &extra_value));
67 EXPECT_TRUE(base::Value::Equals(extra_value, expected_extra_value.get())); 65 EXPECT_TRUE(base::Value::Equals(extra_value, expected_extra_value.get()));
68 66
69 std::unique_ptr<base::DictionaryValue> expected_specifics_value( 67 std::unique_ptr<base::DictionaryValue> expected_specifics_value(
70 EntitySpecificsToValue(record.specifics)); 68 EntitySpecificsToValue(record.specifics));
71 ExpectDictDictionaryValue(*expected_specifics_value, 69 ExpectDictDictionaryValue(*expected_specifics_value, value, "specifics");
72 value, "specifics");
73 } 70 }
74 } 71 }
75 72
76 class TestExtraChangeRecordData : public ExtraPasswordChangeRecordData { 73 class TestExtraChangeRecordData : public ExtraPasswordChangeRecordData {
77 public: 74 public:
78 TestExtraChangeRecordData() 75 TestExtraChangeRecordData()
79 : to_value_calls_(0), expected_to_value_calls_(0) {} 76 : to_value_calls_(0), expected_to_value_calls_(0) {}
80 77
81 ~TestExtraChangeRecordData() override { 78 ~TestExtraChangeRecordData() override {
82 EXPECT_EQ(expected_to_value_calls_, to_value_calls_); 79 EXPECT_EQ(expected_to_value_calls_, to_value_calls_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 extra->set_expected_to_value_calls(2U); 154 extra->set_expected_to_value_calls(2U);
158 155
159 record.extra.reset(extra.release()); 156 record.extra.reset(extra.release());
160 std::unique_ptr<base::DictionaryValue> value(record.ToValue()); 157 std::unique_ptr<base::DictionaryValue> value(record.ToValue());
161 CheckChangeRecordValue(record, *value); 158 CheckChangeRecordValue(record, *value);
162 } 159 }
163 } 160 }
164 161
165 } // namespace 162 } // namespace
166 } // namespace syncer 163 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core/change_record.cc ('k') | components/sync/core/configure_reason.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698