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

Unified Diff: components/user_prefs/tracked/pref_hash_calculator_unittest.cc

Issue 1227973003: Componentize //chrome/browser/prefs/tracked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/user_prefs/tracked/pref_hash_calculator_unittest.cc
diff --git a/chrome/browser/prefs/tracked/pref_hash_calculator_unittest.cc b/components/user_prefs/tracked/pref_hash_calculator_unittest.cc
similarity index 76%
rename from chrome/browser/prefs/tracked/pref_hash_calculator_unittest.cc
rename to components/user_prefs/tracked/pref_hash_calculator_unittest.cc
index 71f9a44dd3a60ff77110042f3004c3a48b60ef32..4fc1ff6f2b57c82ceeb192f25639e565e9985554 100644
--- a/chrome/browser/prefs/tracked/pref_hash_calculator_unittest.cc
+++ b/components/user_prefs/tracked/pref_hash_calculator_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/prefs/tracked/pref_hash_calculator.h"
+#include "components/user_prefs/tracked/pref_hash_calculator.h"
#include <string>
@@ -31,19 +31,15 @@ TEST(PrefHashCalculatorTest, TestCurrentAlgorithm) {
ASSERT_EQ(calc1.Calculate("pref_path", &string_value_1),
calc1_dup.Calculate("pref_path", &string_value_1));
ASSERT_EQ(PrefHashCalculator::VALID,
- calc1_dup.Validate(
- "pref_path",
- &string_value_1,
- calc1.Calculate("pref_path", &string_value_1)));
+ calc1_dup.Validate("pref_path", &string_value_1,
+ calc1.Calculate("pref_path", &string_value_1)));
// Different seeds, different hashes.
ASSERT_NE(calc1.Calculate("pref_path", &string_value_1),
calc2.Calculate("pref_path", &string_value_1));
ASSERT_EQ(PrefHashCalculator::INVALID,
- calc2.Validate(
- "pref_path",
- &string_value_1,
- calc1.Calculate("pref_path", &string_value_1)));
+ calc2.Validate("pref_path", &string_value_1,
+ calc1.Calculate("pref_path", &string_value_1)));
// Different device IDs, different hashes.
ASSERT_NE(calc1.Calculate("pref_path", &string_value_1),
@@ -92,8 +88,7 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) {
new base::DictionaryValue);
nested_empty_dict->Set("a", new base::DictionaryValue);
nested_empty_dict->Set("b", new base::ListValue);
- scoped_ptr<base::ListValue> nested_empty_list(
- new base::ListValue);
+ scoped_ptr<base::ListValue> nested_empty_list(new base::ListValue);
nested_empty_list->Append(new base::DictionaryValue);
nested_empty_list->Append(new base::ListValue);
nested_empty_list->Append(nested_empty_dict->DeepCopy());
@@ -126,44 +121,47 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) {
static const char kExpectedNullValue[] =
"82A9F3BBC7F9FF84C76B033C854E79EEB162783FA7B3E99FF9372FA8E12C44F7";
EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", null_value.get(), kExpectedNullValue));
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", null_value.get(), kExpectedNullValue));
static const char kExpectedBooleanValue[] =
"A520D8F43EA307B0063736DC9358C330539D0A29417580514C8B9862632C4CCC";
- EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", bool_value.get(), kExpectedBooleanValue));
+ EXPECT_EQ(
+ PrefHashCalculator::VALID,
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", bool_value.get(), kExpectedBooleanValue));
static const char kExpectedIntegerValue[] =
"8D60DA1F10BF5AA29819D2D66D7CCEF9AABC5DA93C11A0D2BD21078D63D83682";
EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", int_value.get(), kExpectedIntegerValue));
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", int_value.get(), kExpectedIntegerValue));
static const char kExpectedDoubleValue[] =
"C9D94772516125BEEDAE68C109D44BC529E719EE020614E894CC7FB4098C545D";
- EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", double_value.get(), kExpectedDoubleValue));
+ EXPECT_EQ(
+ PrefHashCalculator::VALID,
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", double_value.get(), kExpectedDoubleValue));
static const char kExpectedStringValue[] =
"05ACCBD3B05C45C36CD06190F63EC577112311929D8380E26E5F13182EB68318";
- EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", string_value.get(), kExpectedStringValue));
+ EXPECT_EQ(
+ PrefHashCalculator::VALID,
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", string_value.get(), kExpectedStringValue));
static const char kExpectedDictValue[] =
"7A84DCC710D796C771F789A4DA82C952095AA956B6F1667EE42D0A19ECAA3C4A";
EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", dict_value.get(), kExpectedDictValue));
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", dict_value.get(), kExpectedDictValue));
static const char kExpectedListValue[] =
"8D5A25972DF5AE20D041C780E7CA54E40F614AD53513A0724EE8D62D4F992740";
EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", list_value.get(), kExpectedListValue));
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", list_value.get(), kExpectedListValue));
// Also test every value type together in the same dictionary.
base::DictionaryValue everything;
@@ -177,21 +175,18 @@ TEST(PrefHashCalculatorTest, CatchHashChanges) {
static const char kExpectedEverythingValue[] =
"B97D09BE7005693574DCBDD03D8D9E44FB51F4008B73FB56A49A9FA671A1999B";
EXPECT_EQ(PrefHashCalculator::VALID,
- PrefHashCalculator(kSeed, kDeviceId).Validate(
- "pref.path", &everything, kExpectedEverythingValue));
+ PrefHashCalculator(kSeed, kDeviceId)
+ .Validate("pref.path", &everything, kExpectedEverythingValue));
}
TEST(PrefHashCalculatorTest, TestCompatibilityWithLegacyPrefMetricsServiceId) {
static const char kSeed[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
- };
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
+ 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
+ 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
+ 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
static const char kDeviceId[] =
"D730D9CBD98C734A4FB097A1922275FE9F7E026A4EA1BE0E84";
static const char kExpectedValue[] =
@@ -200,7 +195,8 @@ TEST(PrefHashCalculatorTest, TestCompatibilityWithLegacyPrefMetricsServiceId) {
base::ListValue startup_urls;
startup_urls.Set(0, new base::StringValue("http://www.chromium.org/"));
- EXPECT_EQ(PrefHashCalculator::VALID_SECURE_LEGACY,
- PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId).
- Validate("session.startup_urls", &startup_urls, kExpectedValue));
+ EXPECT_EQ(
+ PrefHashCalculator::VALID_SECURE_LEGACY,
+ PrefHashCalculator(std::string(kSeed, arraysize(kSeed)), kDeviceId)
+ .Validate("session.startup_urls", &startup_urls, kExpectedValue));
}
« no previous file with comments | « components/user_prefs/tracked/pref_hash_calculator.cc ('k') | components/user_prefs/tracked/pref_hash_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698