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

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

Issue 16915006: Convert most of extensions and some other random stuff to using the base namespace for Values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 (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 "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_web_ui.h" 8 #include "chrome/browser/extensions/extension_web_ui.h"
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" 9 #include "chrome/browser/prefs/scoped_user_pref_update.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/common/extensions/manifest_url_handler.h" 13 #include "chrome/common/extensions/manifest_url_handler.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
19 19
20 using content::WebContents; 20 using content::WebContents;
21 21
22 class ExtensionOverrideTest : public ExtensionApiTest { 22 class ExtensionOverrideTest : public ExtensionApiTest {
23 protected: 23 protected:
24 bool CheckHistoryOverridesContainsNoDupes() { 24 bool CheckHistoryOverridesContainsNoDupes() {
25 // There should be no duplicate entries in the preferences. 25 // There should be no duplicate entries in the preferences.
26 const DictionaryValue* overrides = 26 const DictionaryValue* overrides =
27 browser()->profile()->GetPrefs()->GetDictionary( 27 browser()->profile()->GetPrefs()->GetDictionary(
28 ExtensionWebUI::kExtensionURLOverrides); 28 ExtensionWebUI::kExtensionURLOverrides);
29 29
30 const ListValue* values = NULL; 30 const base::ListValue* values = NULL;
31 if (!overrides->GetList("history", &values)) 31 if (!overrides->GetList("history", &values))
32 return false; 32 return false;
33 33
34 std::set<std::string> seen_overrides; 34 std::set<std::string> seen_overrides;
35 for (size_t i = 0; i < values->GetSize(); ++i) { 35 for (size_t i = 0; i < values->GetSize(); ++i) {
36 std::string value; 36 std::string value;
37 if (!values->GetString(i, &value)) 37 if (!values->GetString(i, &value))
38 return false; 38 return false;
39 39
40 if (seen_overrides.find(value) != seen_overrides.end()) 40 if (seen_overrides.find(value) != seen_overrides.end())
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); 120 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes());
121 } 121 }
122 122
123 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { 123 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) {
124 // Simulate several LoadExtension() calls happening over the lifetime of 124 // Simulate several LoadExtension() calls happening over the lifetime of
125 // a preferences file without corresponding UnloadExtension() calls. This is 125 // a preferences file without corresponding UnloadExtension() calls. This is
126 // the same as the above test, except for that it is testing the case where 126 // the same as the above test, except for that it is testing the case where
127 // the file already contains dupes when an extension is loaded. 127 // the file already contains dupes when an extension is loaded.
128 ListValue* list = new ListValue(); 128 base::ListValue* list = new base::ListValue();
129 for (size_t i = 0; i < 3; ++i) 129 for (size_t i = 0; i < 3; ++i)
130 list->Append(Value::CreateStringValue("http://www.google.com/")); 130 list->Append(Value::CreateStringValue("http://www.google.com/"));
131 131
132 { 132 {
133 DictionaryPrefUpdate update(browser()->profile()->GetPrefs(), 133 DictionaryPrefUpdate update(browser()->profile()->GetPrefs(),
134 ExtensionWebUI::kExtensionURLOverrides); 134 ExtensionWebUI::kExtensionURLOverrides);
135 update.Get()->Set("history", list); 135 update.Get()->Set("history", list);
136 } 136 }
137 137
138 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); 138 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes());
139 139
140 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); 140 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history")));
141 141
142 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); 142 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes());
143 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698