| OLD | NEW |
| 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_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
| 6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
| 7 #include "chrome/browser/extensions/extension_web_ui.h" | 7 #include "chrome/browser/extensions/extension_web_ui.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.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/browser_tabstrip.h" | 12 #include "chrome/browser/ui/browser_tabstrip.h" |
| 13 #include "chrome/common/extensions/manifest_url_handler.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
| 18 | 19 |
| 19 using content::WebContents; | 20 using content::WebContents; |
| 20 | 21 |
| 21 class ExtensionOverrideTest : public ExtensionApiTest { | 22 class ExtensionOverrideTest : public ExtensionApiTest { |
| 22 protected: | 23 protected: |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) { | 107 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldNotCreateDuplicateEntries) { |
| 107 const extensions::Extension* extension = | 108 const extensions::Extension* extension = |
| 108 LoadExtension(test_data_dir_.AppendASCII("override/history")); | 109 LoadExtension(test_data_dir_.AppendASCII("override/history")); |
| 109 ASSERT_TRUE(extension); | 110 ASSERT_TRUE(extension); |
| 110 | 111 |
| 111 // Simulate several LoadExtension() calls happening over the lifetime of | 112 // Simulate several LoadExtension() calls happening over the lifetime of |
| 112 // a preferences file without corresponding UnloadExtension() calls. | 113 // a preferences file without corresponding UnloadExtension() calls. |
| 113 for (size_t i = 0; i < 3; ++i) { | 114 for (size_t i = 0; i < 3; ++i) { |
| 114 ExtensionWebUI::RegisterChromeURLOverrides( | 115 ExtensionWebUI::RegisterChromeURLOverrides( |
| 115 browser()->profile(), | 116 browser()->profile(), |
| 116 extension->GetChromeURLOverrides()); | 117 extensions::URLOverrides::GetChromeURLOverrides(extension)); |
| 117 } | 118 } |
| 118 | 119 |
| 119 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 120 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
| 120 } | 121 } |
| 121 | 122 |
| 122 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { | 123 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { |
| 123 // Simulate several LoadExtension() calls happening over the lifetime of | 124 // Simulate several LoadExtension() calls happening over the lifetime of |
| 124 // a preferences file without corresponding UnloadExtension() calls. This is | 125 // a preferences file without corresponding UnloadExtension() calls. This is |
| 125 // 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 |
| 126 // the file already contains dupes when an extension is loaded. | 127 // the file already contains dupes when an extension is loaded. |
| 127 ListValue* list = new ListValue(); | 128 ListValue* list = new ListValue(); |
| 128 for (size_t i = 0; i < 3; ++i) | 129 for (size_t i = 0; i < 3; ++i) |
| 129 list->Append(Value::CreateStringValue("http://www.google.com/")); | 130 list->Append(Value::CreateStringValue("http://www.google.com/")); |
| 130 | 131 |
| 131 { | 132 { |
| 132 DictionaryPrefUpdate update(browser()->profile()->GetPrefs(), | 133 DictionaryPrefUpdate update(browser()->profile()->GetPrefs(), |
| 133 ExtensionWebUI::kExtensionURLOverrides); | 134 ExtensionWebUI::kExtensionURLOverrides); |
| 134 update.Get()->Set("history", list); | 135 update.Get()->Set("history", list); |
| 135 } | 136 } |
| 136 | 137 |
| 137 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); | 138 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); |
| 138 | 139 |
| 139 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); | 140 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); |
| 140 | 141 |
| 141 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 142 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
| 142 } | 143 } |
| OLD | NEW |