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_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
| 7 #include "chrome/browser/extensions/extension_system.h" |
7 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
15 | 16 |
16 using extensions::Extension; | 17 using extensions::Extension; |
17 | 18 |
18 // Used to simulate a click on the first button named 'Options'. | 19 // Used to simulate a click on the first button named 'Options'. |
19 static const wchar_t* jscript_click_option_button = | 20 static const wchar_t* jscript_click_option_button = |
20 L"(function() { " | 21 L"(function() { " |
21 L" var button = document.evaluate(\"//button[text()='Options']\"," | 22 L" var button = document.evaluate(\"//button[text()='Options']\"," |
22 L" document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE," | 23 L" document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE," |
23 L" null).snapshotItem(0);" | 24 L" null).snapshotItem(0);" |
24 L" button.click();" | 25 L" button.click();" |
25 L"})();"; | 26 L"})();"; |
26 | 27 |
27 // Test that an extension with an options page makes an 'Options' button appear | 28 // Test that an extension with an options page makes an 'Options' button appear |
28 // on chrome://extensions, and that clicking the button opens a new tab with the | 29 // on chrome://extensions, and that clicking the button opens a new tab with the |
29 // extension's options page. | 30 // extension's options page. |
30 // Disabled. See http://crbug.com/26948 for details. | 31 // Disabled. See http://crbug.com/26948 for details. |
31 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) { | 32 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) { |
32 // Install an extension with an options page. | 33 // Install an extension with an options page. |
33 const Extension* extension = | 34 const Extension* extension = |
34 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1); | 35 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1); |
35 ASSERT_TRUE(extension); | 36 ASSERT_TRUE(extension); |
36 ExtensionService* service = browser()->profile()->GetExtensionService(); | 37 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 38 browser()->profile())->extension_service(); |
37 ASSERT_EQ(1u, service->extensions()->size()); | 39 ASSERT_EQ(1u, service->extensions()->size()); |
38 | 40 |
39 // Go to the Extension Settings page and click the Options button. | 41 // Go to the Extension Settings page and click the Options button. |
40 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); | 42 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); |
41 TabStripModel* tab_strip = browser()->tab_strip_model(); | 43 TabStripModel* tab_strip = browser()->tab_strip_model(); |
42 ASSERT_TRUE(content::ExecuteJavaScript( | 44 ASSERT_TRUE(content::ExecuteJavaScript( |
43 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", | 45 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
44 jscript_click_option_button)); | 46 jscript_click_option_button)); |
45 | 47 |
46 // If the options page hasn't already come up, wait for it. | 48 // If the options page hasn't already come up, wait for it. |
47 if (tab_strip->count() == 1) { | 49 if (tab_strip->count() == 1) { |
48 ui_test_utils::WaitForNewTab(browser()); | 50 ui_test_utils::WaitForNewTab(browser()); |
49 } | 51 } |
50 ASSERT_EQ(2, tab_strip->count()); | 52 ASSERT_EQ(2, tab_strip->count()); |
51 | 53 |
52 EXPECT_EQ(extension->GetResourceURL("options.html"), | 54 EXPECT_EQ(extension->GetResourceURL("options.html"), |
53 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL()); | 55 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL()); |
54 } | 56 } |
OLD | NEW |