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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 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
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 "chrome/browser/safe_browsing/incident_reporting/preference_validation_ delegate.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/preference_validation_ delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 protected: 123 protected:
124 void SetUp() override { 124 void SetUp() override {
125 PreferenceValidationDelegateTest::SetUp(); 125 PreferenceValidationDelegateTest::SetUp();
126 value_type_ = std::tr1::get<0>(GetParam()); 126 value_type_ = std::tr1::get<0>(GetParam());
127 expected_value_ = std::tr1::get<1>(GetParam()); 127 expected_value_ = std::tr1::get<1>(GetParam());
128 } 128 }
129 129
130 static std::unique_ptr<base::Value> MakeValue(base::Value::Type value_type) { 130 static std::unique_ptr<base::Value> MakeValue(base::Value::Type value_type) {
131 using base::Value; 131 using base::Value;
132 switch (value_type) { 132 switch (value_type) {
133 case Value::TYPE_NULL: 133 case Value::Type::NONE:
134 return Value::CreateNullValue(); 134 return Value::CreateNullValue();
135 case Value::TYPE_BOOLEAN: 135 case Value::Type::BOOLEAN:
136 return std::unique_ptr<Value>(new base::FundamentalValue(false)); 136 return std::unique_ptr<Value>(new base::FundamentalValue(false));
137 case Value::TYPE_INTEGER: 137 case Value::Type::INTEGER:
138 return std::unique_ptr<Value>(new base::FundamentalValue(47)); 138 return std::unique_ptr<Value>(new base::FundamentalValue(47));
139 case Value::TYPE_DOUBLE: 139 case Value::Type::DOUBLE:
140 return std::unique_ptr<Value>(new base::FundamentalValue(0.47)); 140 return std::unique_ptr<Value>(new base::FundamentalValue(0.47));
141 case Value::TYPE_STRING: 141 case Value::Type::STRING:
142 return std::unique_ptr<Value>(new base::StringValue("i have a spleen")); 142 return std::unique_ptr<Value>(new base::StringValue("i have a spleen"));
143 case Value::TYPE_DICTIONARY: { 143 case Value::Type::DICTIONARY: {
144 std::unique_ptr<base::DictionaryValue> value( 144 std::unique_ptr<base::DictionaryValue> value(
145 new base::DictionaryValue()); 145 new base::DictionaryValue());
146 value->SetInteger("twenty-two", 22); 146 value->SetInteger("twenty-two", 22);
147 value->SetInteger("forty-seven", 47); 147 value->SetInteger("forty-seven", 47);
148 return std::move(value); 148 return std::move(value);
149 } 149 }
150 case Value::TYPE_LIST: { 150 case Value::Type::LIST: {
151 std::unique_ptr<base::ListValue> value(new base::ListValue()); 151 std::unique_ptr<base::ListValue> value(new base::ListValue());
152 value->AppendInteger(22); 152 value->AppendInteger(22);
153 value->AppendInteger(47); 153 value->AppendInteger(47);
154 return std::move(value); 154 return std::move(value);
155 } 155 }
156 default: 156 default:
157 ADD_FAILURE() << "unsupported value type " << value_type; 157 ADD_FAILURE() << "unsupported value type " << value_type;
158 } 158 }
159 return std::unique_ptr<Value>(); 159 return std::unique_ptr<Value>();
160 } 160 }
(...skipping 14 matching lines...) Expand all
175 incident->tracked_preference().atomic_value()); 175 incident->tracked_preference().atomic_value());
176 } 176 }
177 177
178 INSTANTIATE_TEST_CASE_P( 178 INSTANTIATE_TEST_CASE_P(
179 Values, 179 Values,
180 PreferenceValidationDelegateValues, 180 PreferenceValidationDelegateValues,
181 // On Android, make_tuple(..., "null") doesn't compile due to the error: 181 // On Android, make_tuple(..., "null") doesn't compile due to the error:
182 // testing/gtest/include/gtest/internal/gtest-tuple.h:246:48: 182 // testing/gtest/include/gtest/internal/gtest-tuple.h:246:48:
183 // error: array used as initializer 183 // error: array used as initializer
184 testing::Values( 184 testing::Values(
185 std::tr1::make_tuple(base::Value::TYPE_NULL, 185 std::tr1::make_tuple(base::Value::Type::NONE,
186 const_cast<char*>("null")), 186 const_cast<char*>("null")),
187 std::tr1::make_tuple(base::Value::TYPE_BOOLEAN, 187 std::tr1::make_tuple(base::Value::Type::BOOLEAN,
188 const_cast<char*>("false")), 188 const_cast<char*>("false")),
189 std::tr1::make_tuple(base::Value::TYPE_INTEGER, 189 std::tr1::make_tuple(base::Value::Type::INTEGER,
190 const_cast<char*>("47")), 190 const_cast<char*>("47")),
191 std::tr1::make_tuple(base::Value::TYPE_DOUBLE, 191 std::tr1::make_tuple(base::Value::Type::DOUBLE,
192 const_cast<char*>("0.47")), 192 const_cast<char*>("0.47")),
193 std::tr1::make_tuple(base::Value::TYPE_STRING, 193 std::tr1::make_tuple(base::Value::Type::STRING,
194 const_cast<char*>("i have a spleen")), 194 const_cast<char*>("i have a spleen")),
195 std::tr1::make_tuple(base::Value::TYPE_DICTIONARY, 195 std::tr1::make_tuple(base::Value::Type::DICTIONARY,
196 const_cast<char*>("{\"forty-seven\":47,\"twenty-two\":22}")), 196 const_cast<char*>("{\"forty-seven\":47,\"twenty-two\":22}")),
197 std::tr1::make_tuple(base::Value::TYPE_LIST, 197 std::tr1::make_tuple(base::Value::Type::LIST,
198 const_cast<char*>("[22,47]")))); 198 const_cast<char*>("[22,47]"))));
199 199
200 // Tests that no incidents are reported for relevant combinations of ValueState. 200 // Tests that no incidents are reported for relevant combinations of ValueState.
201 class PreferenceValidationDelegateNoIncident 201 class PreferenceValidationDelegateNoIncident
202 : public PreferenceValidationDelegateTest, 202 : public PreferenceValidationDelegateTest,
203 public testing::WithParamInterface< 203 public testing::WithParamInterface<
204 std::tr1::tuple<PrefHashStoreTransaction::ValueState, 204 std::tr1::tuple<PrefHashStoreTransaction::ValueState,
205 PrefHashStoreTransaction::ValueState>> { 205 PrefHashStoreTransaction::ValueState>> {
206 protected: 206 protected:
207 void SetUp() override { 207 void SetUp() override {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 INSTANTIATE_TEST_CASE_P( 342 INSTANTIATE_TEST_CASE_P(
343 WithIncidentIgnoreBypass, 343 WithIncidentIgnoreBypass,
344 PreferenceValidationDelegateWithIncident, 344 PreferenceValidationDelegateWithIncident,
345 testing::Combine( 345 testing::Combine(
346 testing::Values(PrefHashStoreTransaction::CLEARED, 346 testing::Values(PrefHashStoreTransaction::CLEARED,
347 PrefHashStoreTransaction::CHANGED, 347 PrefHashStoreTransaction::CHANGED,
348 PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE), 348 PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE),
349 testing::Values(PrefHashStoreTransaction::CHANGED, 349 testing::Values(PrefHashStoreTransaction::CHANGED,
350 PrefHashStoreTransaction::CLEARED), 350 PrefHashStoreTransaction::CLEARED),
351 testing::Bool())); 351 testing::Bool()));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698