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

Side by Side Diff: chrome/browser/prefs/pref_hash_filter_unittest.cc

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/prefs/pref_hash_filter.h" 5 #include "chrome/browser/prefs/pref_hash_filter.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 mock_pref_hash_store_->set_stamp_super_mac_result(true); 458 mock_pref_hash_store_->set_stamp_super_mac_result(true);
459 DoFilterOnLoad(true); 459 DoFilterOnLoad(true);
460 // No paths stored, since they all return |UNCHANGED|. The StampSuperMAC 460 // No paths stored, since they all return |UNCHANGED|. The StampSuperMAC
461 // result is the only reason the prefs were considered altered. 461 // result is the only reason the prefs were considered altered.
462 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count()); 462 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count());
463 } 463 }
464 464
465 TEST_P(PrefHashFilterTest, FilterTrackedPrefUpdate) { 465 TEST_P(PrefHashFilterTest, FilterTrackedPrefUpdate) {
466 base::DictionaryValue root_dict; 466 base::DictionaryValue root_dict;
467 // Ownership of |string_value| is transfered to |root_dict|. 467 // Ownership of |string_value| is transfered to |root_dict|.
468 base::Value* string_value = base::Value::CreateStringValue("string value"); 468 base::Value* string_value = new base::StringValue("string value");
469 root_dict.Set(kAtomicPref, string_value); 469 root_dict.Set(kAtomicPref, string_value);
470 470
471 // No path should be stored on FilterUpdate. 471 // No path should be stored on FilterUpdate.
472 pref_hash_filter_->FilterUpdate(kAtomicPref); 472 pref_hash_filter_->FilterUpdate(kAtomicPref);
473 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count()); 473 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count());
474 474
475 // One path should be stored on FilterSerializeData. 475 // One path should be stored on FilterSerializeData.
476 pref_hash_filter_->FilterSerializeData(&root_dict); 476 pref_hash_filter_->FilterSerializeData(&root_dict);
477 ASSERT_EQ(1u, mock_pref_hash_store_->stored_paths_count()); 477 ASSERT_EQ(1u, mock_pref_hash_store_->stored_paths_count());
478 MockPrefHashStore::ValuePtrStrategyPair stored_value = 478 MockPrefHashStore::ValuePtrStrategyPair stored_value =
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 mock_pref_hash_store_->stored_value(kSplitPref); 539 mock_pref_hash_store_->stored_value(kSplitPref);
540 ASSERT_EQ(dict_value, stored_value.first); 540 ASSERT_EQ(dict_value, stored_value.first);
541 ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_value.second); 541 ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, stored_value.second);
542 542
543 ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed()); 543 ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
544 ASSERT_FALSE(RecordedReset()); 544 ASSERT_FALSE(RecordedReset());
545 } 545 }
546 546
547 TEST_P(PrefHashFilterTest, FilterUntrackedPrefUpdate) { 547 TEST_P(PrefHashFilterTest, FilterUntrackedPrefUpdate) {
548 base::DictionaryValue root_dict; 548 base::DictionaryValue root_dict;
549 root_dict.Set("untracked", base::Value::CreateStringValue("some value")); 549 root_dict.Set("untracked", new base::StringValue("some value"));
550 pref_hash_filter_->FilterUpdate("untracked"); 550 pref_hash_filter_->FilterUpdate("untracked");
551 551
552 // No paths should be stored on FilterUpdate. 552 // No paths should be stored on FilterUpdate.
553 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count()); 553 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count());
554 554
555 // Nor on FilterSerializeData. 555 // Nor on FilterSerializeData.
556 pref_hash_filter_->FilterSerializeData(&root_dict); 556 pref_hash_filter_->FilterSerializeData(&root_dict);
557 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count()); 557 ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count());
558 558
559 // No transaction should even be started on FilterSerializeData() if there are 559 // No transaction should even be started on FilterSerializeData() if there are
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 ASSERT_TRUE(pref_store_contents_->Get(kSplitPref, &split_value_in_store)); 724 ASSERT_TRUE(pref_store_contents_->Get(kSplitPref, &split_value_in_store));
725 ASSERT_EQ(dict_value, split_value_in_store); 725 ASSERT_EQ(dict_value, split_value_in_store);
726 ASSERT_EQ(dict_value, stored_split_value.first); 726 ASSERT_EQ(dict_value, stored_split_value.first);
727 727
728 ASSERT_FALSE(RecordedReset()); 728 ASSERT_FALSE(RecordedReset());
729 } 729 }
730 } 730 }
731 731
732 TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) { 732 TEST_P(PrefHashFilterTest, InitialValueTrustedUnknown) {
733 // Ownership of this value is transfered to |pref_store_contents_|. 733 // Ownership of this value is transfered to |pref_store_contents_|.
734 base::Value* string_value = base::Value::CreateStringValue("test"); 734 base::Value* string_value = new base::StringValue("test");
735 pref_store_contents_->Set(kAtomicPref, string_value); 735 pref_store_contents_->Set(kAtomicPref, string_value);
736 736
737 base::DictionaryValue* dict_value = new base::DictionaryValue; 737 base::DictionaryValue* dict_value = new base::DictionaryValue;
738 dict_value->SetString("a", "foo"); 738 dict_value->SetString("a", "foo");
739 dict_value->SetInteger("b", 1234); 739 dict_value->SetInteger("b", 1234);
740 pref_store_contents_->Set(kSplitPref, dict_value); 740 pref_store_contents_->Set(kSplitPref, dict_value);
741 741
742 ASSERT_TRUE(pref_store_contents_->Get(kAtomicPref, NULL)); 742 ASSERT_TRUE(pref_store_contents_->Get(kAtomicPref, NULL));
743 ASSERT_TRUE(pref_store_contents_->Get(kSplitPref, NULL)); 743 ASSERT_TRUE(pref_store_contents_->Get(kSplitPref, NULL));
744 744
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 ASSERT_EQ(NULL, stored_split_value.first); 899 ASSERT_EQ(NULL, stored_split_value.first);
900 ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT, 900 ASSERT_EQ(PrefHashFilter::TRACKING_STRATEGY_SPLIT,
901 stored_split_value.second); 901 stored_split_value.second);
902 } 902 }
903 903
904 TEST_P(PrefHashFilterTest, InitialValueMigrated) { 904 TEST_P(PrefHashFilterTest, InitialValueMigrated) {
905 // Only test atomic prefs, split prefs were introduce after the migration. 905 // Only test atomic prefs, split prefs were introduce after the migration.
906 906
907 // Ownership of this value is transfered to |pref_store_contents_|. 907 // Ownership of this value is transfered to |pref_store_contents_|.
908 base::ListValue* list_value = new base::ListValue; 908 base::ListValue* list_value = new base::ListValue;
909 list_value->Append(base::Value::CreateStringValue("test")); 909 list_value->Append(new base::StringValue("test"));
910 pref_store_contents_->Set(kAtomicPref, list_value); 910 pref_store_contents_->Set(kAtomicPref, list_value);
911 911
912 ASSERT_TRUE(pref_store_contents_->Get(kAtomicPref, NULL)); 912 ASSERT_TRUE(pref_store_contents_->Get(kAtomicPref, NULL));
913 913
914 mock_pref_hash_store_->SetCheckResult(kAtomicPref, 914 mock_pref_hash_store_->SetCheckResult(kAtomicPref,
915 PrefHashStoreTransaction::WEAK_LEGACY); 915 PrefHashStoreTransaction::WEAK_LEGACY);
916 916
917 DoFilterOnLoad(GetParam() >= PrefHashFilter::ENFORCE_ON_LOAD); 917 DoFilterOnLoad(GetParam() >= PrefHashFilter::ENFORCE_ON_LOAD);
918 ASSERT_EQ(arraysize(kTestTrackedPrefs), 918 ASSERT_EQ(arraysize(kTestTrackedPrefs),
919 mock_pref_hash_store_->checked_paths_count()); 919 mock_pref_hash_store_->checked_paths_count());
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 mock_pref_hash_store_->stored_value(kAtomicPref2).first); 1086 mock_pref_hash_store_->stored_value(kAtomicPref2).first);
1087 1087
1088 ASSERT_FALSE(RecordedReset()); 1088 ASSERT_FALSE(RecordedReset());
1089 } 1089 }
1090 } 1090 }
1091 1091
1092 INSTANTIATE_TEST_CASE_P( 1092 INSTANTIATE_TEST_CASE_P(
1093 PrefHashFilterTestInstance, PrefHashFilterTest, 1093 PrefHashFilterTestInstance, PrefHashFilterTest,
1094 testing::Values(PrefHashFilter::NO_ENFORCEMENT, 1094 testing::Values(PrefHashFilter::NO_ENFORCEMENT,
1095 PrefHashFilter::ENFORCE_ON_LOAD)); 1095 PrefHashFilter::ENFORCE_ON_LOAD));
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_hash_calculator_unittest.cc ('k') | chrome/browser/prefs/pref_model_associator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698