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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/extensions/extension_action.h" | 6 #include "chrome/browser/extensions/extension_action.h" |
7 #include "chrome/browser/extensions/extension_action_manager.h" | 7 #include "chrome/browser/extensions/extension_action_manager.h" |
8 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/extensions/extension_tab_util.h" | 11 #include "chrome/browser/extensions/extension_tab_util.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
16 | 17 |
17 namespace extensions { | 18 namespace extensions { |
18 namespace { | 19 namespace { |
19 | 20 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 UnloadExtension(last_loaded_extension_id_); | 110 UnloadExtension(last_loaded_extension_id_); |
110 | 111 |
111 // Make sure the page action goes away when it's unloaded. | 112 // Make sure the page action goes away when it's unloaded. |
112 ASSERT_TRUE(WaitForPageActionCountChangeTo(0)); | 113 ASSERT_TRUE(WaitForPageActionCountChangeTo(0)); |
113 } | 114 } |
114 | 115 |
115 // Tests that we can load page actions in the Omnibox. | 116 // Tests that we can load page actions in the Omnibox. |
116 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) { | 117 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PageActionRefreshCrash) { |
117 base::TimeTicks start_time = base::TimeTicks::Now(); | 118 base::TimeTicks start_time = base::TimeTicks::Now(); |
118 | 119 |
119 ExtensionService* service = browser()->profile()->GetExtensionService(); | 120 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 121 browser()->profile())->extension_service(); |
120 | 122 |
121 size_t size_before = service->extensions()->size(); | 123 size_t size_before = service->extensions()->size(); |
122 | 124 |
123 FilePath base_path = test_data_dir_.AppendASCII("browsertest") | 125 FilePath base_path = test_data_dir_.AppendASCII("browsertest") |
124 .AppendASCII("crash_44415"); | 126 .AppendASCII("crash_44415"); |
125 // Load extension A. | 127 // Load extension A. |
126 const Extension* extensionA = LoadExtension(base_path.AppendASCII("ExtA")); | 128 const Extension* extensionA = LoadExtension(base_path.AppendASCII("ExtA")); |
127 ASSERT_TRUE(extensionA); | 129 ASSERT_TRUE(extensionA); |
128 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); | 130 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); |
129 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 131 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 LOG(INFO) << "Test completed : " | 166 LOG(INFO) << "Test completed : " |
165 << (base::TimeTicks::Now() - start_time).InMilliseconds() | 167 << (base::TimeTicks::Now() - start_time).InMilliseconds() |
166 << " ms" << std::flush; | 168 << " ms" << std::flush; |
167 } | 169 } |
168 | 170 |
169 // Tests that tooltips of a page action icon can be specified using UTF8. | 171 // Tests that tooltips of a page action icon can be specified using UTF8. |
170 // See http://crbug.com/25349. | 172 // See http://crbug.com/25349. |
171 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) { | 173 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) { |
172 ASSERT_TRUE(test_server()->Start()); | 174 ASSERT_TRUE(test_server()->Start()); |
173 | 175 |
174 ExtensionService* service = browser()->profile()->GetExtensionService(); | 176 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 177 browser()->profile())->extension_service(); |
175 const size_t size_before = service->extensions()->size(); | 178 const size_t size_before = service->extensions()->size(); |
176 | 179 |
177 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") | 180 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") |
178 .AppendASCII("title_localized_pa")); | 181 .AppendASCII("title_localized_pa")); |
179 const Extension* extension = LoadExtension(extension_path); | 182 const Extension* extension = LoadExtension(extension_path); |
180 ASSERT_TRUE(extension); | 183 ASSERT_TRUE(extension); |
181 | 184 |
182 // Any navigation prompts the location bar to load the page action. | 185 // Any navigation prompts the location bar to load the page action. |
183 GURL url = test_server()->GetURL(kLocalization); | 186 GURL url = test_server()->GetURL(kLocalization); |
184 ui_test_utils::NavigateToURL(browser(), url); | 187 ui_test_utils::NavigateToURL(browser(), url); |
185 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); | 188 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); |
186 | 189 |
187 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 190 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
188 | 191 |
189 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(), | 192 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(), |
190 extension->description().c_str()); | 193 extension->description().c_str()); |
191 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), | 194 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), |
192 extension->name().c_str()); | 195 extension->name().c_str()); |
193 int tab_id = ExtensionTabUtil::GetTabId( | 196 int tab_id = ExtensionTabUtil::GetTabId( |
194 chrome::GetActiveWebContents(browser())); | 197 chrome::GetActiveWebContents(browser())); |
195 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), | 198 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), |
196 ExtensionActionManager::Get(browser()->profile())-> | 199 ExtensionActionManager::Get(browser()->profile())-> |
197 GetPageAction(*extension)-> | 200 GetPageAction(*extension)-> |
198 GetTitle(tab_id).c_str()); | 201 GetTitle(tab_id).c_str()); |
199 } | 202 } |
200 | 203 |
201 } // namespace | 204 } // namespace |
202 } // namespace extensions | 205 } // namespace extensions |
OLD | NEW |