OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/user_prefs/tracked/pref_hash_store_impl.h" | 5 #include "components/user_prefs/tracked/pref_hash_store_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 private: | 24 private: |
25 base::DictionaryValue pref_store_contents_; | 25 base::DictionaryValue pref_store_contents_; |
26 // Must be declared after |pref_store_contents_| as it needs to be outlived | 26 // Must be declared after |pref_store_contents_| as it needs to be outlived |
27 // by it. | 27 // by it. |
28 DictionaryHashStoreContents contents_; | 28 DictionaryHashStoreContents contents_; |
29 | 29 |
30 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImplTest); | 30 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreImplTest); |
31 }; | 31 }; |
32 | 32 |
33 TEST_F(PrefHashStoreImplTest, ComputeMac) { | 33 TEST_F(PrefHashStoreImplTest, ComputeMac) { |
34 base::StringValue string_1("string1"); | 34 base::Value string_1("string1"); |
35 base::StringValue string_2("string2"); | 35 base::Value string_2("string2"); |
36 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); | 36 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
37 | 37 |
38 std::string computed_mac_1 = pref_hash_store.ComputeMac("path1", &string_1); | 38 std::string computed_mac_1 = pref_hash_store.ComputeMac("path1", &string_1); |
39 std::string computed_mac_2 = pref_hash_store.ComputeMac("path1", &string_2); | 39 std::string computed_mac_2 = pref_hash_store.ComputeMac("path1", &string_2); |
40 std::string computed_mac_3 = pref_hash_store.ComputeMac("path2", &string_1); | 40 std::string computed_mac_3 = pref_hash_store.ComputeMac("path2", &string_1); |
41 | 41 |
42 // Quick sanity checks here, see pref_hash_calculator_unittest.cc for more | 42 // Quick sanity checks here, see pref_hash_calculator_unittest.cc for more |
43 // complete tests. | 43 // complete tests. |
44 EXPECT_EQ(computed_mac_1, pref_hash_store.ComputeMac("path1", &string_1)); | 44 EXPECT_EQ(computed_mac_1, pref_hash_store.ComputeMac("path1", &string_1)); |
45 EXPECT_NE(computed_mac_1, computed_mac_2); | 45 EXPECT_NE(computed_mac_1, computed_mac_2); |
46 EXPECT_NE(computed_mac_1, computed_mac_3); | 46 EXPECT_NE(computed_mac_1, computed_mac_3); |
47 EXPECT_EQ(64U, computed_mac_1.size()); | 47 EXPECT_EQ(64U, computed_mac_1.size()); |
48 } | 48 } |
49 | 49 |
50 TEST_F(PrefHashStoreImplTest, ComputeSplitMacs) { | 50 TEST_F(PrefHashStoreImplTest, ComputeSplitMacs) { |
51 base::DictionaryValue dict; | 51 base::DictionaryValue dict; |
52 dict.Set("a", new base::StringValue("string1")); | 52 dict.Set("a", new base::Value("string1")); |
53 dict.Set("b", new base::StringValue("string2")); | 53 dict.Set("b", new base::Value("string2")); |
54 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); | 54 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
55 | 55 |
56 std::unique_ptr<base::DictionaryValue> computed_macs = | 56 std::unique_ptr<base::DictionaryValue> computed_macs = |
57 pref_hash_store.ComputeSplitMacs("foo.bar", &dict); | 57 pref_hash_store.ComputeSplitMacs("foo.bar", &dict); |
58 | 58 |
59 std::string mac_1; | 59 std::string mac_1; |
60 std::string mac_2; | 60 std::string mac_2; |
61 ASSERT_TRUE(computed_macs->GetString("a", &mac_1)); | 61 ASSERT_TRUE(computed_macs->GetString("a", &mac_1)); |
62 ASSERT_TRUE(computed_macs->GetString("b", &mac_2)); | 62 ASSERT_TRUE(computed_macs->GetString("b", &mac_2)); |
63 | 63 |
64 EXPECT_EQ(2U, computed_macs->size()); | 64 EXPECT_EQ(2U, computed_macs->size()); |
65 | 65 |
66 base::StringValue string_1("string1"); | 66 base::Value string_1("string1"); |
67 base::StringValue string_2("string2"); | 67 base::Value string_2("string2"); |
68 EXPECT_EQ(pref_hash_store.ComputeMac("foo.bar.a", &string_1), mac_1); | 68 EXPECT_EQ(pref_hash_store.ComputeMac("foo.bar.a", &string_1), mac_1); |
69 EXPECT_EQ(pref_hash_store.ComputeMac("foo.bar.b", &string_2), mac_2); | 69 EXPECT_EQ(pref_hash_store.ComputeMac("foo.bar.b", &string_2), mac_2); |
70 } | 70 } |
71 | 71 |
72 TEST_F(PrefHashStoreImplTest, AtomicHashStoreAndCheck) { | 72 TEST_F(PrefHashStoreImplTest, AtomicHashStoreAndCheck) { |
73 base::StringValue string_1("string1"); | 73 base::Value string_1("string1"); |
74 base::StringValue string_2("string2"); | 74 base::Value string_2("string2"); |
75 | 75 |
76 { | 76 { |
77 // 32 NULL bytes is the seed that was used to generate the legacy hash. | 77 // 32 NULL bytes is the seed that was used to generate the legacy hash. |
78 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); | 78 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
79 std::unique_ptr<PrefHashStoreTransaction> transaction( | 79 std::unique_ptr<PrefHashStoreTransaction> transaction( |
80 pref_hash_store.BeginTransaction(GetHashStoreContents())); | 80 pref_hash_store.BeginTransaction(GetHashStoreContents())); |
81 | 81 |
82 // Only NULL should be trusted in the absence of a hash. | 82 // Only NULL should be trusted in the absence of a hash. |
83 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, | 83 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, |
84 transaction->CheckValue("path1", &string_1)); | 84 transaction->CheckValue("path1", &string_1)); |
85 EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_NULL_VALUE, | 85 EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_NULL_VALUE, |
86 transaction->CheckValue("path1", NULL)); | 86 transaction->CheckValue("path1", NULL)); |
87 | 87 |
88 transaction->StoreHash("path1", &string_1); | 88 transaction->StoreHash("path1", &string_1); |
89 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, | 89 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
90 transaction->CheckValue("path1", &string_1)); | 90 transaction->CheckValue("path1", &string_1)); |
91 EXPECT_EQ(PrefHashStoreTransaction::CLEARED, | 91 EXPECT_EQ(PrefHashStoreTransaction::CLEARED, |
92 transaction->CheckValue("path1", NULL)); | 92 transaction->CheckValue("path1", NULL)); |
93 transaction->StoreHash("path1", NULL); | 93 transaction->StoreHash("path1", NULL); |
94 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, | 94 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
95 transaction->CheckValue("path1", NULL)); | 95 transaction->CheckValue("path1", NULL)); |
96 EXPECT_EQ(PrefHashStoreTransaction::CHANGED, | 96 EXPECT_EQ(PrefHashStoreTransaction::CHANGED, |
97 transaction->CheckValue("path1", &string_2)); | 97 transaction->CheckValue("path1", &string_2)); |
98 | 98 |
99 base::DictionaryValue dict; | 99 base::DictionaryValue dict; |
100 dict.Set("a", new base::StringValue("foo")); | 100 dict.Set("a", new base::Value("foo")); |
101 dict.Set("d", new base::StringValue("bad")); | 101 dict.Set("d", new base::Value("bad")); |
102 dict.Set("b", new base::StringValue("bar")); | 102 dict.Set("b", new base::Value("bar")); |
103 dict.Set("c", new base::StringValue("baz")); | 103 dict.Set("c", new base::Value("baz")); |
104 | 104 |
105 transaction->StoreHash("path1", &dict); | 105 transaction->StoreHash("path1", &dict); |
106 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, | 106 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
107 transaction->CheckValue("path1", &dict)); | 107 transaction->CheckValue("path1", &dict)); |
108 } | 108 } |
109 | 109 |
110 ASSERT_FALSE(GetHashStoreContents()->GetSuperMac().empty()); | 110 ASSERT_FALSE(GetHashStoreContents()->GetSuperMac().empty()); |
111 | 111 |
112 { | 112 { |
113 // |pref_hash_store2| should trust its initial hashes dictionary and thus | 113 // |pref_hash_store2| should trust its initial hashes dictionary and thus |
(...skipping 21 matching lines...) Expand all Loading... |
135 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, | 135 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, |
136 transaction->CheckValue("new_path", &string_1)); | 136 transaction->CheckValue("new_path", &string_1)); |
137 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, | 137 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, |
138 transaction->CheckValue("new_path", &string_2)); | 138 transaction->CheckValue("new_path", &string_2)); |
139 EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_NULL_VALUE, | 139 EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_NULL_VALUE, |
140 transaction->CheckValue("new_path", NULL)); | 140 transaction->CheckValue("new_path", NULL)); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 TEST_F(PrefHashStoreImplTest, ImportExportOperations) { | 144 TEST_F(PrefHashStoreImplTest, ImportExportOperations) { |
145 base::StringValue string_1("string1"); | 145 base::Value string_1("string1"); |
146 base::StringValue string_2("string2"); | 146 base::Value string_2("string2"); |
147 | 147 |
148 // Initial state: no super MAC. | 148 // Initial state: no super MAC. |
149 { | 149 { |
150 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); | 150 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
151 std::unique_ptr<PrefHashStoreTransaction> transaction( | 151 std::unique_ptr<PrefHashStoreTransaction> transaction( |
152 pref_hash_store.BeginTransaction(GetHashStoreContents())); | 152 pref_hash_store.BeginTransaction(GetHashStoreContents())); |
153 ASSERT_FALSE(transaction->IsSuperMACValid()); | 153 ASSERT_FALSE(transaction->IsSuperMACValid()); |
154 | 154 |
155 ASSERT_FALSE(transaction->HasHash("path1")); | 155 ASSERT_FALSE(transaction->HasHash("path1")); |
156 | 156 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 pref_hash_store.BeginTransaction(GetHashStoreContents())); | 283 pref_hash_store.BeginTransaction(GetHashStoreContents())); |
284 ASSERT_TRUE(transaction->IsSuperMACValid()); | 284 ASSERT_TRUE(transaction->IsSuperMACValid()); |
285 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, | 285 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
286 transaction->CheckValue("path1", &string_1)); | 286 transaction->CheckValue("path1", &string_1)); |
287 EXPECT_EQ(PrefHashStoreTransaction::CHANGED, | 287 EXPECT_EQ(PrefHashStoreTransaction::CHANGED, |
288 transaction->CheckValue("path1", &string_2)); | 288 transaction->CheckValue("path1", &string_2)); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 TEST_F(PrefHashStoreImplTest, SuperMACDisabled) { | 292 TEST_F(PrefHashStoreImplTest, SuperMACDisabled) { |
293 base::StringValue string_1("string1"); | 293 base::Value string_1("string1"); |
294 base::StringValue string_2("string2"); | 294 base::Value string_2("string2"); |
295 | 295 |
296 { | 296 { |
297 // Pass |use_super_mac| => false. | 297 // Pass |use_super_mac| => false. |
298 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", false); | 298 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", false); |
299 std::unique_ptr<PrefHashStoreTransaction> transaction( | 299 std::unique_ptr<PrefHashStoreTransaction> transaction( |
300 pref_hash_store.BeginTransaction(GetHashStoreContents())); | 300 pref_hash_store.BeginTransaction(GetHashStoreContents())); |
301 | 301 |
302 transaction->StoreHash("path1", &string_2); | 302 transaction->StoreHash("path1", &string_2); |
303 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, | 303 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
304 transaction->CheckValue("path1", &string_2)); | 304 transaction->CheckValue("path1", &string_2)); |
305 } | 305 } |
306 | 306 |
307 ASSERT_TRUE(GetHashStoreContents()->GetSuperMac().empty()); | 307 ASSERT_TRUE(GetHashStoreContents()->GetSuperMac().empty()); |
308 | 308 |
309 { | 309 { |
310 PrefHashStoreImpl pref_hash_store2(std::string(32, 0), "device_id", false); | 310 PrefHashStoreImpl pref_hash_store2(std::string(32, 0), "device_id", false); |
311 std::unique_ptr<PrefHashStoreTransaction> transaction( | 311 std::unique_ptr<PrefHashStoreTransaction> transaction( |
312 pref_hash_store2.BeginTransaction(GetHashStoreContents())); | 312 pref_hash_store2.BeginTransaction(GetHashStoreContents())); |
313 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, | 313 EXPECT_EQ(PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE, |
314 transaction->CheckValue("new_path", &string_1)); | 314 transaction->CheckValue("new_path", &string_1)); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 TEST_F(PrefHashStoreImplTest, SplitHashStoreAndCheck) { | 318 TEST_F(PrefHashStoreImplTest, SplitHashStoreAndCheck) { |
319 base::DictionaryValue dict; | 319 base::DictionaryValue dict; |
320 dict.Set("a", new base::StringValue("to be replaced")); | 320 dict.Set("a", new base::Value("to be replaced")); |
321 dict.Set("b", new base::StringValue("same")); | 321 dict.Set("b", new base::Value("same")); |
322 dict.Set("o", new base::StringValue("old")); | 322 dict.Set("o", new base::Value("old")); |
323 | 323 |
324 base::DictionaryValue modified_dict; | 324 base::DictionaryValue modified_dict; |
325 modified_dict.Set("a", new base::StringValue("replaced")); | 325 modified_dict.Set("a", new base::Value("replaced")); |
326 modified_dict.Set("b", new base::StringValue("same")); | 326 modified_dict.Set("b", new base::Value("same")); |
327 modified_dict.Set("c", new base::StringValue("new")); | 327 modified_dict.Set("c", new base::Value("new")); |
328 | 328 |
329 base::DictionaryValue empty_dict; | 329 base::DictionaryValue empty_dict; |
330 | 330 |
331 std::vector<std::string> invalid_keys; | 331 std::vector<std::string> invalid_keys; |
332 | 332 |
333 { | 333 { |
334 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); | 334 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
335 std::unique_ptr<PrefHashStoreTransaction> transaction( | 335 std::unique_ptr<PrefHashStoreTransaction> transaction( |
336 pref_hash_store.BeginTransaction(GetHashStoreContents())); | 336 pref_hash_store.BeginTransaction(GetHashStoreContents())); |
337 | 337 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 std::vector<std::string> invalid_keys; | 430 std::vector<std::string> invalid_keys; |
431 | 431 |
432 { | 432 { |
433 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); | 433 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
434 std::unique_ptr<PrefHashStoreTransaction> transaction( | 434 std::unique_ptr<PrefHashStoreTransaction> transaction( |
435 pref_hash_store.BeginTransaction(GetHashStoreContents())); | 435 pref_hash_store.BeginTransaction(GetHashStoreContents())); |
436 | 436 |
437 // Store hashes for a random dict to be overwritten below. | 437 // Store hashes for a random dict to be overwritten below. |
438 base::DictionaryValue initial_dict; | 438 base::DictionaryValue initial_dict; |
439 initial_dict.Set("a", new base::StringValue("foo")); | 439 initial_dict.Set("a", new base::Value("foo")); |
440 transaction->StoreSplitHash("path1", &initial_dict); | 440 transaction->StoreSplitHash("path1", &initial_dict); |
441 | 441 |
442 // Verify stored empty dictionary matches NULL and empty dictionary back. | 442 // Verify stored empty dictionary matches NULL and empty dictionary back. |
443 transaction->StoreSplitHash("path1", &empty_dict); | 443 transaction->StoreSplitHash("path1", &empty_dict); |
444 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, | 444 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
445 transaction->CheckSplitValue("path1", NULL, &invalid_keys)); | 445 transaction->CheckSplitValue("path1", NULL, &invalid_keys)); |
446 EXPECT_TRUE(invalid_keys.empty()); | 446 EXPECT_TRUE(invalid_keys.empty()); |
447 EXPECT_EQ( | 447 EXPECT_EQ( |
448 PrefHashStoreTransaction::UNCHANGED, | 448 PrefHashStoreTransaction::UNCHANGED, |
449 transaction->CheckSplitValue("path1", &empty_dict, &invalid_keys)); | 449 transaction->CheckSplitValue("path1", &empty_dict, &invalid_keys)); |
(...skipping 14 matching lines...) Expand all Loading... |
464 // |pref_hash_store2| should trust its initial hashes dictionary (and thus | 464 // |pref_hash_store2| should trust its initial hashes dictionary (and thus |
465 // trust new unknown values) even though the last action done was to clear | 465 // trust new unknown values) even though the last action done was to clear |
466 // the hashes for path1 by setting its value to NULL (this is a regression | 466 // the hashes for path1 by setting its value to NULL (this is a regression |
467 // test ensuring that the internal action of clearing some hashes does | 467 // test ensuring that the internal action of clearing some hashes does |
468 // update the stored hash of hashes). | 468 // update the stored hash of hashes). |
469 PrefHashStoreImpl pref_hash_store2(std::string(32, 0), "device_id", true); | 469 PrefHashStoreImpl pref_hash_store2(std::string(32, 0), "device_id", true); |
470 std::unique_ptr<PrefHashStoreTransaction> transaction( | 470 std::unique_ptr<PrefHashStoreTransaction> transaction( |
471 pref_hash_store2.BeginTransaction(GetHashStoreContents())); | 471 pref_hash_store2.BeginTransaction(GetHashStoreContents())); |
472 | 472 |
473 base::DictionaryValue tested_dict; | 473 base::DictionaryValue tested_dict; |
474 tested_dict.Set("a", new base::StringValue("foo")); | 474 tested_dict.Set("a", new base::Value("foo")); |
475 tested_dict.Set("b", new base::StringValue("bar")); | 475 tested_dict.Set("b", new base::Value("bar")); |
476 EXPECT_EQ( | 476 EXPECT_EQ( |
477 PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE, | 477 PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE, |
478 transaction->CheckSplitValue("new_path", &tested_dict, &invalid_keys)); | 478 transaction->CheckSplitValue("new_path", &tested_dict, &invalid_keys)); |
479 EXPECT_TRUE(invalid_keys.empty()); | 479 EXPECT_TRUE(invalid_keys.empty()); |
480 } | 480 } |
481 } | 481 } |
482 | 482 |
483 // Test that the PrefHashStore returns TRUSTED_UNKNOWN_VALUE when checking for | 483 // Test that the PrefHashStore returns TRUSTED_UNKNOWN_VALUE when checking for |
484 // a split preference even if there is an existing atomic preference's hash | 484 // a split preference even if there is an existing atomic preference's hash |
485 // stored. There is no point providing a migration path for preferences | 485 // stored. There is no point providing a migration path for preferences |
486 // switching strategies after their initial release as split preferences are | 486 // switching strategies after their initial release as split preferences are |
487 // turned into split preferences specifically because the atomic hash isn't | 487 // turned into split preferences specifically because the atomic hash isn't |
488 // considered useful. | 488 // considered useful. |
489 TEST_F(PrefHashStoreImplTest, TrustedUnknownSplitValueFromExistingAtomic) { | 489 TEST_F(PrefHashStoreImplTest, TrustedUnknownSplitValueFromExistingAtomic) { |
490 base::StringValue string("string1"); | 490 base::Value string("string1"); |
491 | 491 |
492 base::DictionaryValue dict; | 492 base::DictionaryValue dict; |
493 dict.Set("a", new base::StringValue("foo")); | 493 dict.Set("a", new base::Value("foo")); |
494 dict.Set("d", new base::StringValue("bad")); | 494 dict.Set("d", new base::Value("bad")); |
495 dict.Set("b", new base::StringValue("bar")); | 495 dict.Set("b", new base::Value("bar")); |
496 dict.Set("c", new base::StringValue("baz")); | 496 dict.Set("c", new base::Value("baz")); |
497 | 497 |
498 { | 498 { |
499 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); | 499 PrefHashStoreImpl pref_hash_store(std::string(32, 0), "device_id", true); |
500 std::unique_ptr<PrefHashStoreTransaction> transaction( | 500 std::unique_ptr<PrefHashStoreTransaction> transaction( |
501 pref_hash_store.BeginTransaction(GetHashStoreContents())); | 501 pref_hash_store.BeginTransaction(GetHashStoreContents())); |
502 | 502 |
503 transaction->StoreHash("path1", &string); | 503 transaction->StoreHash("path1", &string); |
504 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, | 504 EXPECT_EQ(PrefHashStoreTransaction::UNCHANGED, |
505 transaction->CheckValue("path1", &string)); | 505 transaction->CheckValue("path1", &string)); |
506 } | 506 } |
507 | 507 |
508 { | 508 { |
509 // Load a new |pref_hash_store2| in which the hashes dictionary is trusted. | 509 // Load a new |pref_hash_store2| in which the hashes dictionary is trusted. |
510 PrefHashStoreImpl pref_hash_store2(std::string(32, 0), "device_id", true); | 510 PrefHashStoreImpl pref_hash_store2(std::string(32, 0), "device_id", true); |
511 std::unique_ptr<PrefHashStoreTransaction> transaction( | 511 std::unique_ptr<PrefHashStoreTransaction> transaction( |
512 pref_hash_store2.BeginTransaction(GetHashStoreContents())); | 512 pref_hash_store2.BeginTransaction(GetHashStoreContents())); |
513 std::vector<std::string> invalid_keys; | 513 std::vector<std::string> invalid_keys; |
514 EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE, | 514 EXPECT_EQ(PrefHashStoreTransaction::TRUSTED_UNKNOWN_VALUE, |
515 transaction->CheckSplitValue("path1", &dict, &invalid_keys)); | 515 transaction->CheckSplitValue("path1", &dict, &invalid_keys)); |
516 EXPECT_TRUE(invalid_keys.empty()); | 516 EXPECT_TRUE(invalid_keys.empty()); |
517 } | 517 } |
518 } | 518 } |
OLD | NEW |