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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 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
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 "chrome/browser/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 msg += extension_id; 820 msg += extension_id;
821 msg += " "; 821 msg += " ";
822 msg += pref_path; 822 msg += pref_path;
823 msg += " == "; 823 msg += " == ";
824 msg += expected_val ? "true" : "false"; 824 msg += expected_val ? "true" : "false";
825 825
826 PrefService* prefs = profile_->GetPrefs(); 826 PrefService* prefs = profile_->GetPrefs();
827 const DictionaryValue* dict = 827 const DictionaryValue* dict =
828 prefs->GetDictionary("extensions.settings"); 828 prefs->GetDictionary("extensions.settings");
829 ASSERT_TRUE(dict != NULL) << msg; 829 ASSERT_TRUE(dict != NULL) << msg;
830 DictionaryValue* pref = NULL; 830 const DictionaryValue* pref = NULL;
831 ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg; 831 ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg;
832 EXPECT_TRUE(pref != NULL) << msg; 832 EXPECT_TRUE(pref != NULL) << msg;
833 bool val; 833 bool val;
834 ASSERT_TRUE(pref->GetBoolean(pref_path, &val)) << msg; 834 ASSERT_TRUE(pref->GetBoolean(pref_path, &val)) << msg;
835 EXPECT_EQ(expected_val, val) << msg; 835 EXPECT_EQ(expected_val, val) << msg;
836 } 836 }
837 837
838 bool IsPrefExist(const std::string& extension_id, 838 bool IsPrefExist(const std::string& extension_id,
839 const std::string& pref_path) { 839 const std::string& pref_path) {
840 const DictionaryValue* dict = 840 const DictionaryValue* dict =
841 profile_->GetPrefs()->GetDictionary("extensions.settings"); 841 profile_->GetPrefs()->GetDictionary("extensions.settings");
842 if (dict == NULL) return false; 842 if (dict == NULL) return false;
843 DictionaryValue* pref = NULL; 843 const DictionaryValue* pref = NULL;
844 if (!dict->GetDictionary(extension_id, &pref)) { 844 if (!dict->GetDictionary(extension_id, &pref)) {
845 return false; 845 return false;
846 } 846 }
847 if (pref == NULL) { 847 if (pref == NULL) {
848 return false; 848 return false;
849 } 849 }
850 bool val; 850 bool val;
851 if (!pref->GetBoolean(pref_path, &val)) { 851 if (!pref->GetBoolean(pref_path, &val)) {
852 return false; 852 return false;
853 } 853 }
854 return true; 854 return true;
855 } 855 }
856 856
857 void ValidateIntegerPref(const std::string& extension_id, 857 void ValidateIntegerPref(const std::string& extension_id,
858 const std::string& pref_path, 858 const std::string& pref_path,
859 int expected_val) { 859 int expected_val) {
860 std::string msg = " while checking: "; 860 std::string msg = " while checking: ";
861 msg += extension_id; 861 msg += extension_id;
862 msg += " "; 862 msg += " ";
863 msg += pref_path; 863 msg += pref_path;
864 msg += " == "; 864 msg += " == ";
865 msg += base::IntToString(expected_val); 865 msg += base::IntToString(expected_val);
866 866
867 PrefService* prefs = profile_->GetPrefs(); 867 PrefService* prefs = profile_->GetPrefs();
868 const DictionaryValue* dict = 868 const DictionaryValue* dict =
869 prefs->GetDictionary("extensions.settings"); 869 prefs->GetDictionary("extensions.settings");
870 ASSERT_TRUE(dict != NULL) << msg; 870 ASSERT_TRUE(dict != NULL) << msg;
871 DictionaryValue* pref = NULL; 871 const DictionaryValue* pref = NULL;
872 ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg; 872 ASSERT_TRUE(dict->GetDictionary(extension_id, &pref)) << msg;
873 EXPECT_TRUE(pref != NULL) << msg; 873 EXPECT_TRUE(pref != NULL) << msg;
874 int val; 874 int val;
875 ASSERT_TRUE(pref->GetInteger(pref_path, &val)) << msg; 875 ASSERT_TRUE(pref->GetInteger(pref_path, &val)) << msg;
876 EXPECT_EQ(expected_val, val) << msg; 876 EXPECT_EQ(expected_val, val) << msg;
877 } 877 }
878 878
879 void ValidateStringPref(const std::string& extension_id, 879 void ValidateStringPref(const std::string& extension_id,
880 const std::string& pref_path, 880 const std::string& pref_path,
881 const std::string& expected_val) { 881 const std::string& expected_val) {
882 std::string msg = " while checking: "; 882 std::string msg = " while checking: ";
883 msg += extension_id; 883 msg += extension_id;
884 msg += ".manifest."; 884 msg += ".manifest.";
885 msg += pref_path; 885 msg += pref_path;
886 msg += " == "; 886 msg += " == ";
887 msg += expected_val; 887 msg += expected_val;
888 888
889 const DictionaryValue* dict = 889 const DictionaryValue* dict =
890 profile_->GetPrefs()->GetDictionary("extensions.settings"); 890 profile_->GetPrefs()->GetDictionary("extensions.settings");
891 ASSERT_TRUE(dict != NULL) << msg; 891 ASSERT_TRUE(dict != NULL) << msg;
892 DictionaryValue* pref = NULL; 892 const DictionaryValue* pref = NULL;
893 std::string manifest_path = extension_id + ".manifest"; 893 std::string manifest_path = extension_id + ".manifest";
894 ASSERT_TRUE(dict->GetDictionary(manifest_path, &pref)) << msg; 894 ASSERT_TRUE(dict->GetDictionary(manifest_path, &pref)) << msg;
895 EXPECT_TRUE(pref != NULL) << msg; 895 EXPECT_TRUE(pref != NULL) << msg;
896 std::string val; 896 std::string val;
897 ASSERT_TRUE(pref->GetString(pref_path, &val)) << msg; 897 ASSERT_TRUE(pref->GetString(pref_path, &val)) << msg;
898 EXPECT_EQ(expected_val, val) << msg; 898 EXPECT_EQ(expected_val, val) << msg;
899 } 899 }
900 900
901 void SetPref(const std::string& extension_id, 901 void SetPref(const std::string& extension_id,
902 const std::string& pref_path, 902 const std::string& pref_path,
(...skipping 4338 matching lines...) Expand 10 before | Expand all | Expand 10 after
5241 // This should NOT trigger an alert. 5241 // This should NOT trigger an alert.
5242 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0", 5242 provider->UpdateOrAddExtension(hosted_app, "1.0.0.0",
5243 data_dir_.AppendASCII("hosted_app.crx")); 5243 data_dir_.AppendASCII("hosted_app.crx"));
5244 5244
5245 service_->CheckForExternalUpdates(); 5245 service_->CheckForExternalUpdates();
5246 loop_.RunAllPending(); 5246 loop_.RunAllPending();
5247 5247
5248 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get())); 5248 ASSERT_TRUE(service_->PopulateExtensionErrorUI(extension_error_ui.get()));
5249 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size()); 5249 ASSERT_EQ(1u, extension_error_ui->get_external_extension_ids()->size());
5250 } 5250 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/extensions/extension_web_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698