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

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

Issue 12066003: Remove TabStripModel wrapper use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 7 years, 10 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) 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_ui.h" 9 #include "chrome/browser/extensions/extension_install_ui.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/extensions/startup_helper.h" 12 #include "chrome/browser/extensions/startup_helper.h"
13 #include "chrome/browser/extensions/webstore_standalone_installer.h" 13 #include "chrome/browser/extensions/webstore_standalone_installer.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/extensions/extension_builder.h" 18 #include "chrome/common/extensions/extension_builder.h"
20 #include "chrome/common/extensions/value_builder.h" 19 #include "chrome/common/extensions/value_builder.h"
21 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
24 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 GURL::Replacements replace_host; 77 GURL::Replacements replace_host;
79 replace_host.SetHostStr(domain); 78 replace_host.SetHostStr(domain);
80 return page_url.ReplaceComponents(replace_host); 79 return page_url.ReplaceComponents(replace_host);
81 } 80 }
82 81
83 void RunTest(const std::string& test_function_name) { 82 void RunTest(const std::string& test_function_name) {
84 bool result = false; 83 bool result = false;
85 std::string script = StringPrintf("%s('%s')", test_function_name.c_str(), 84 std::string script = StringPrintf("%s('%s')", test_function_name.c_str(),
86 test_gallery_url_.c_str()); 85 test_gallery_url_.c_str());
87 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 86 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
88 chrome::GetActiveWebContents(browser()), 87 browser()->tab_strip_model()->GetActiveWebContents(),
89 script, 88 script,
90 &result)); 89 &result));
91 EXPECT_TRUE(result); 90 EXPECT_TRUE(result);
92 } 91 }
93 92
94 std::string test_gallery_url_; 93 std::string test_gallery_url_;
95 }; 94 };
96 95
97 IN_PROC_BROWSER_TEST_F(WebstoreStandaloneInstallTest, Install) { 96 IN_PROC_BROWSER_TEST_F(WebstoreStandaloneInstallTest, Install) {
98 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 97 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 browser(), 142 browser(),
144 GenerateTestServerUrl(kAppDomain, "install_not_supported.html")); 143 GenerateTestServerUrl(kAppDomain, "install_not_supported.html"));
145 144
146 ui_test_utils::WindowedTabAddedNotificationObserver observer( 145 ui_test_utils::WindowedTabAddedNotificationObserver observer(
147 content::NotificationService::AllSources()); 146 content::NotificationService::AllSources());
148 RunTest("runTest"); 147 RunTest("runTest");
149 observer.Wait(); 148 observer.Wait();
150 149
151 // The inline install should fail, and a store-provided URL should be opened 150 // The inline install should fail, and a store-provided URL should be opened
152 // in a new tab. 151 // in a new tab.
153 WebContents* web_contents = chrome::GetActiveWebContents(browser()); 152 WebContents* web_contents =
153 browser()->tab_strip_model()->GetActiveWebContents();
154 EXPECT_EQ(GURL("http://cws.com/show-me-the-money"), web_contents->GetURL()); 154 EXPECT_EQ(GURL("http://cws.com/show-me-the-money"), web_contents->GetURL());
155 } 155 }
156 156
157 // Regression test for http://crbug.com/144991. 157 // Regression test for http://crbug.com/144991.
158 IN_PROC_BROWSER_TEST_F(WebstoreStandaloneInstallTest, InstallFromHostedApp) { 158 IN_PROC_BROWSER_TEST_F(WebstoreStandaloneInstallTest, InstallFromHostedApp) {
159 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 159 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
160 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); 160 switches::kAppsGalleryInstallAutoConfirmForTests, "accept");
161 161
162 const GURL kInstallUrl = GenerateTestServerUrl(kAppDomain, "install.html"); 162 const GURL kInstallUrl = GenerateTestServerUrl(kAppDomain, "install.html");
163 163
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Cancel) { 278 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Cancel) {
279 CommandLine* command_line = CommandLine::ForCurrentProcess(); 279 CommandLine* command_line = CommandLine::ForCurrentProcess();
280 command_line->AppendSwitchASCII( 280 command_line->AppendSwitchASCII(
281 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); 281 switches::kAppsGalleryInstallAutoConfirmForTests, "cancel");
282 extensions::StartupHelper helper; 282 extensions::StartupHelper helper;
283 EXPECT_FALSE(helper.InstallFromWebstore(*command_line, browser()->profile())); 283 EXPECT_FALSE(helper.InstallFromWebstore(*command_line, browser()->profile()));
284 EXPECT_FALSE(saw_install()); 284 EXPECT_FALSE(saw_install());
285 EXPECT_EQ(0, browser_open_count()); 285 EXPECT_EQ(0, browser_open_count());
286 } 286 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/web_contents_browsertest.cc ('k') | chrome/browser/history/history_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698