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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 return false; | 36 return false; |
37 | 37 |
38 if (seen_overrides.find(value) != seen_overrides.end()) | 38 if (seen_overrides.find(value) != seen_overrides.end()) |
39 return false; | 39 return false; |
40 | 40 |
41 seen_overrides.insert(value); | 41 seen_overrides.insert(value); |
42 } | 42 } |
43 | 43 |
44 return true; | 44 return true; |
45 } | 45 } |
46 | |
47 #if defined(USE_VIRTUAL_KEYBOARD) | |
48 // Navigate to the keyboard page, and ensure we have arrived at an | |
49 // extension URL. | |
50 void NavigateToKeyboard() { | |
51 ui_test_utils::NavigateToURL(browser(), GURL("chrome://keyboard/")); | |
52 WebContents* tab = browser()->GetSelectedWebContents(); | |
53 ASSERT_TRUE(tab->GetController().GetActiveEntry()); | |
54 EXPECT_TRUE(tab->GetController().GetActiveEntry()->GetURL(). | |
55 SchemeIs(chrome::kExtensionScheme)); | |
56 } | |
57 #endif | |
58 }; | 46 }; |
59 | 47 |
60 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { | 48 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { |
61 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; | 49 ASSERT_TRUE(RunExtensionTest("override/newtab")) << message_; |
62 { | 50 { |
63 ResultCatcher catcher; | 51 ResultCatcher catcher; |
64 // Navigate to the new tab page. The overridden new tab page | 52 // Navigate to the new tab page. The overridden new tab page |
65 // will call chrome.test.notifyPass() . | 53 // will call chrome.test.notifyPass() . |
66 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); | 54 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab/")); |
67 WebContents* tab = browser()->GetSelectedWebContents(); | 55 WebContents* tab = browser()->GetSelectedWebContents(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 ExtensionWebUI::kExtensionURLOverrides); | 134 ExtensionWebUI::kExtensionURLOverrides); |
147 update.Get()->Set("history", list); | 135 update.Get()->Set("history", list); |
148 } | 136 } |
149 | 137 |
150 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); | 138 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); |
151 | 139 |
152 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); | 140 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); |
153 | 141 |
154 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 142 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
155 } | 143 } |
156 | |
157 #if defined(USE_VIRTUAL_KEYBOARD) | |
158 IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) { | |
159 ASSERT_TRUE(RunExtensionTest("override/keyboard")) << message_; | |
160 { | |
161 ResultCatcher catcher; | |
162 NavigateToKeyboard(); | |
163 ASSERT_TRUE(catcher.GetNextResult()); | |
164 } | |
165 | |
166 // Load the failing version. This should take precedence. | |
167 const extensions::Extension* extension = LoadExtension( | |
168 test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails")); | |
169 ASSERT_TRUE(extension); | |
170 { | |
171 ResultCatcher catcher; | |
172 NavigateToKeyboard(); | |
173 ASSERT_FALSE(catcher.GetNextResult()); | |
174 } | |
175 | |
176 // Unload the failing version. We should be back to passing now. | |
177 UnloadExtension(extension->id()); | |
178 { | |
179 ResultCatcher catcher; | |
180 NavigateToKeyboard(); | |
181 ASSERT_TRUE(catcher.GetNextResult()); | |
182 } | |
183 } | |
184 #endif | |
OLD | NEW |