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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extension_install_dialog.h" | 9 #include "chrome/browser/extensions/extension_install_dialog.h" |
10 #include "chrome/browser/extensions/extension_install_ui.h" | 10 #include "chrome/browser/extensions/extension_install_ui.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/webstore_inline_installer.h" | 12 #include "chrome/browser/extensions/webstore_inline_installer.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_tabstrip.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
22 #include "net/base/host_port_pair.h" | 23 #include "net/base/host_port_pair.h" |
23 #include "net/base/mock_host_resolver.h" | 24 #include "net/base/mock_host_resolver.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 GURL::Replacements replace_host; | 71 GURL::Replacements replace_host; |
71 replace_host.SetHostStr(domain); | 72 replace_host.SetHostStr(domain); |
72 return page_url.ReplaceComponents(replace_host); | 73 return page_url.ReplaceComponents(replace_host); |
73 } | 74 } |
74 | 75 |
75 void RunInlineInstallTest(const std::string& test_function_name) { | 76 void RunInlineInstallTest(const std::string& test_function_name) { |
76 bool result = false; | 77 bool result = false; |
77 std::string script = StringPrintf("%s('%s')", test_function_name.c_str(), | 78 std::string script = StringPrintf("%s('%s')", test_function_name.c_str(), |
78 test_gallery_url_.c_str()); | 79 test_gallery_url_.c_str()); |
79 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 80 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
80 browser()->GetActiveWebContents()->GetRenderViewHost(), L"", | 81 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), L"", |
81 UTF8ToWide(script), &result)); | 82 UTF8ToWide(script), &result)); |
82 EXPECT_TRUE(result); | 83 EXPECT_TRUE(result); |
83 } | 84 } |
84 | 85 |
85 std::string test_gallery_url_; | 86 std::string test_gallery_url_; |
86 }; | 87 }; |
87 | 88 |
88 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) { | 89 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) { |
89 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 90 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
90 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | 91 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 browser(), | 136 browser(), |
136 GenerateTestServerUrl(kAppDomain, "install_not_supported.html")); | 137 GenerateTestServerUrl(kAppDomain, "install_not_supported.html")); |
137 | 138 |
138 RunInlineInstallTest("runTest"); | 139 RunInlineInstallTest("runTest"); |
139 | 140 |
140 // The inline install should fail, and a store-provided URL should be opened | 141 // The inline install should fail, and a store-provided URL should be opened |
141 // in a new tab. | 142 // in a new tab. |
142 if (browser()->tab_strip_model()->count() == 1) { | 143 if (browser()->tab_strip_model()->count() == 1) { |
143 ui_test_utils::WaitForNewTab(browser()); | 144 ui_test_utils::WaitForNewTab(browser()); |
144 } | 145 } |
145 WebContents* web_contents = browser()->GetActiveWebContents(); | 146 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
146 EXPECT_EQ(GURL("http://cws.com/show-me-the-money"), web_contents->GetURL()); | 147 EXPECT_EQ(GURL("http://cws.com/show-me-the-money"), web_contents->GetURL()); |
147 } | 148 } |
148 | 149 |
149 // The unpack failure test needs to use a different install .crx, which is | 150 // The unpack failure test needs to use a different install .crx, which is |
150 // specified via a command-line flag, so it needs its own test subclass. | 151 // specified via a command-line flag, so it needs its own test subclass. |
151 class WebstoreInlineInstallUnpackFailureTest | 152 class WebstoreInlineInstallUnpackFailureTest |
152 : public WebstoreInlineInstallTest { | 153 : public WebstoreInlineInstallTest { |
153 public: | 154 public: |
154 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 155 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
155 WebstoreInlineInstallTest::SetUpCommandLine(command_line); | 156 WebstoreInlineInstallTest::SetUpCommandLine(command_line); |
(...skipping 13 matching lines...) Expand all Loading... |
169 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest, | 170 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest, |
170 WebstoreInlineInstallUnpackFailureTest) { | 171 WebstoreInlineInstallUnpackFailureTest) { |
171 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 172 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
172 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | 173 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
173 | 174 |
174 ui_test_utils::NavigateToURL(browser(), | 175 ui_test_utils::NavigateToURL(browser(), |
175 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html")); | 176 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html")); |
176 | 177 |
177 RunInlineInstallTest("runTest"); | 178 RunInlineInstallTest("runTest"); |
178 } | 179 } |
OLD | NEW |