Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: chrome/browser/extensions/webstore_inline_install_browsertest.cc

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tabs/tab_strip_model.h" 13 #include "chrome/browser/tabs/tab_strip_model.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/browser/tab_contents/tab_contents.h"
20 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
20 #include "content/public/browser/web_contents.h"
21 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
22 #include "net/base/host_port_pair.h" 22 #include "net/base/host_port_pair.h"
23 #include "net/base/mock_host_resolver.h" 23 #include "net/base/mock_host_resolver.h"
24 24
25 using content::WebContents;
26
25 const char kWebstoreDomain[] = "cws.com"; 27 const char kWebstoreDomain[] = "cws.com";
26 const char kAppDomain[] = "app.com"; 28 const char kAppDomain[] = "app.com";
27 const char kNonAppDomain[] = "nonapp.com"; 29 const char kNonAppDomain[] = "nonapp.com";
28 30
29 class WebstoreInlineInstallTest : public InProcessBrowserTest { 31 class WebstoreInlineInstallTest : public InProcessBrowserTest {
30 public: 32 public:
31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 33 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
32 EnableDOMAutomation(); 34 EnableDOMAutomation();
33 35
34 // We start the test server now instead of in 36 // We start the test server now instead of in
(...skipping 29 matching lines...) Expand all
64 GURL::Replacements replace_host; 66 GURL::Replacements replace_host;
65 replace_host.SetHostStr(domain); 67 replace_host.SetHostStr(domain);
66 return page_url.ReplaceComponents(replace_host); 68 return page_url.ReplaceComponents(replace_host);
67 } 69 }
68 70
69 void RunInlineInstallTest(const std::string& test_function_name) { 71 void RunInlineInstallTest(const std::string& test_function_name) {
70 bool result = false; 72 bool result = false;
71 std::string script = StringPrintf("%s('%s')", test_function_name.c_str(), 73 std::string script = StringPrintf("%s('%s')", test_function_name.c_str(),
72 test_gallery_url_.c_str()); 74 test_gallery_url_.c_str());
73 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 75 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
74 browser()->GetSelectedTabContents()->GetRenderViewHost(), L"", 76 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
75 UTF8ToWide(script), &result)); 77 UTF8ToWide(script), &result));
76 EXPECT_TRUE(result); 78 EXPECT_TRUE(result);
77 } 79 }
78 80
79 std::string test_gallery_url_; 81 std::string test_gallery_url_;
80 }; 82 };
81 83
82 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) { 84 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallTest, Install) {
83 SetExtensionInstallDialogAutoConfirmForTests(true); 85 SetExtensionInstallDialogAutoConfirmForTests(true);
84 86
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 browser(), 126 browser(),
125 GenerateTestServerUrl(kAppDomain, "install_not_supported.html")); 127 GenerateTestServerUrl(kAppDomain, "install_not_supported.html"));
126 128
127 RunInlineInstallTest("runTest"); 129 RunInlineInstallTest("runTest");
128 130
129 // The inline install should fail, and a store-provided URL should be opened 131 // The inline install should fail, and a store-provided URL should be opened
130 // in a new tab. 132 // in a new tab.
131 if (browser()->tabstrip_model()->count() == 1) { 133 if (browser()->tabstrip_model()->count() == 1) {
132 ui_test_utils::WaitForNewTab(browser()); 134 ui_test_utils::WaitForNewTab(browser());
133 } 135 }
134 TabContents* tab_contents = browser()->GetSelectedTabContents(); 136 WebContents* web_contents = browser()->GetSelectedWebContents();
135 EXPECT_EQ(GURL("http://cws.com/show-me-the-money"), tab_contents->GetURL()); 137 EXPECT_EQ(GURL("http://cws.com/show-me-the-money"), web_contents->GetURL());
136 } 138 }
137 139
138 // The unpack failure test needs to use a different install .crx, which is 140 // The unpack failure test needs to use a different install .crx, which is
139 // specified via a command-line flag, so it needs its own test subclass. 141 // specified via a command-line flag, so it needs its own test subclass.
140 class WebstoreInlineInstallUnpackFailureTest 142 class WebstoreInlineInstallUnpackFailureTest
141 : public WebstoreInlineInstallTest { 143 : public WebstoreInlineInstallTest {
142 public: 144 public:
143 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 145 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
144 WebstoreInlineInstallTest::SetUpCommandLine(command_line); 146 WebstoreInlineInstallTest::SetUpCommandLine(command_line);
145 147
(...skipping 10 matching lines...) Expand all
156 }; 158 };
157 159
158 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest, Test) { 160 IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallUnpackFailureTest, Test) {
159 SetExtensionInstallDialogAutoConfirmForTests(true); 161 SetExtensionInstallDialogAutoConfirmForTests(true);
160 162
161 ui_test_utils::NavigateToURL(browser(), 163 ui_test_utils::NavigateToURL(browser(),
162 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html")); 164 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html"));
163 165
164 RunInlineInstallTest("runTest"); 166 RunInlineInstallTest("runTest");
165 } 167 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/page_action_apitest.cc ('k') | chrome/browser/external_tab_container_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698