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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_browsertest.cc

Issue 10704023: Moved ExtensionPrefs and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest-er master merged in Created 8 years, 5 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
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/file_path.h" 6 #include "base/file_path.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ExtensionService* service = browser()->profile()->GetExtensionService(); 60 ExtensionService* service = browser()->profile()->GetExtensionService();
61 *out_app_extension = service->GetExtensionById( 61 *out_app_extension = service->GetExtensionById(
62 last_loaded_extension_id_, false); 62 last_loaded_extension_id_, false);
63 ASSERT_TRUE(*out_app_extension); 63 ASSERT_TRUE(*out_app_extension);
64 64
65 // Code that opens a new browser assumes we start with exactly one. 65 // Code that opens a new browser assumes we start with exactly one.
66 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); 66 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile()));
67 } 67 }
68 68
69 void SetAppLaunchPref(const std::string& app_id, 69 void SetAppLaunchPref(const std::string& app_id,
70 ExtensionPrefs::LaunchType launch_type) { 70 extensions::ExtensionPrefs::LaunchType launch_type) {
71 ExtensionService* service = browser()->profile()->GetExtensionService(); 71 ExtensionService* service = browser()->profile()->GetExtensionService();
72 service->extension_prefs()->SetLaunchType(app_id, launch_type); 72 service->extension_prefs()->SetLaunchType(app_id, launch_type);
73 } 73 }
74 74
75 // Check that there are two browsers. Find the one that is not |browser()|. 75 // Check that there are two browsers. Find the one that is not |browser()|.
76 void FindOneOtherBrowser(Browser** out_other_browser) { 76 void FindOneOtherBrowser(Browser** out_other_browser) {
77 // There should only be one other browser. 77 // There should only be one other browser.
78 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); 78 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile()));
79 79
80 // Find the new browser. 80 // Find the new browser.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 EXPECT_NE( 253 EXPECT_NE(
254 new_browser->app_name_.find(extension_app->id()), 254 new_browser->app_name_.find(extension_app->id()),
255 std::string::npos) << new_browser->app_name_; 255 std::string::npos) << new_browser->app_name_;
256 } 256 }
257 257
258 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutWindowPref) { 258 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutWindowPref) {
259 const Extension* extension_app = NULL; 259 const Extension* extension_app = NULL;
260 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app)); 260 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app));
261 261
262 // Set a pref indicating that the user wants to open this app in a window. 262 // Set a pref indicating that the user wants to open this app in a window.
263 SetAppLaunchPref(extension_app->id(), ExtensionPrefs::LAUNCH_WINDOW); 263 SetAppLaunchPref(extension_app->id(),
264 extensions::ExtensionPrefs::LAUNCH_WINDOW);
264 265
265 CommandLine command_line(CommandLine::NO_PROGRAM); 266 CommandLine command_line(CommandLine::NO_PROGRAM);
266 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); 267 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id());
267 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 268 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
268 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 269 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
269 StartupBrowserCreatorImpl launch(FilePath(), command_line, first_run); 270 StartupBrowserCreatorImpl launch(FilePath(), command_line, first_run);
270 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); 271 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false));
271 272
272 // Pref was set to open in a window, so the app should have opened in a 273 // Pref was set to open in a window, so the app should have opened in a
273 // window. The launch should have created a new browser. Find the new 274 // window. The launch should have created a new browser. Find the new
274 // browser. 275 // browser.
275 Browser* new_browser = NULL; 276 Browser* new_browser = NULL;
276 ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser)); 277 ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
277 278
278 // Expect an app window. 279 // Expect an app window.
279 EXPECT_TRUE(new_browser->is_app()); 280 EXPECT_TRUE(new_browser->is_app());
280 281
281 // The browser's app_name should include the app's ID. 282 // The browser's app_name should include the app's ID.
282 EXPECT_NE( 283 EXPECT_NE(
283 new_browser->app_name_.find(extension_app->id()), 284 new_browser->app_name_.find(extension_app->id()),
284 std::string::npos) << new_browser->app_name_; 285 std::string::npos) << new_browser->app_name_;
285 } 286 }
286 287
287 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutTabPref) { 288 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutTabPref) {
288 // Load an app with launch.container = 'tab'. 289 // Load an app with launch.container = 'tab'.
289 const Extension* extension_app = NULL; 290 const Extension* extension_app = NULL;
290 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app)); 291 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app));
291 292
292 // Set a pref indicating that the user wants to open this app in a window. 293 // Set a pref indicating that the user wants to open this app in a window.
293 SetAppLaunchPref(extension_app->id(), ExtensionPrefs::LAUNCH_REGULAR); 294 SetAppLaunchPref(extension_app->id(),
295 extensions::ExtensionPrefs::LAUNCH_REGULAR);
294 296
295 CommandLine command_line(CommandLine::NO_PROGRAM); 297 CommandLine command_line(CommandLine::NO_PROGRAM);
296 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); 298 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id());
297 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 299 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
298 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 300 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
299 StartupBrowserCreatorImpl launch(FilePath(), command_line, first_run); 301 StartupBrowserCreatorImpl launch(FilePath(), command_line, first_run);
300 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); 302 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false));
301 303
302 // When an app shortcut is open and the pref indicates a tab should 304 // When an app shortcut is open and the pref indicates a tab should
303 // open, the tab is open in a new browser window. Expect a new window. 305 // open, the tab is open in a new browser window. Expect a new window.
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 ASSERT_EQ(1u, browser::GetBrowserCount(profile_urls)); 685 ASSERT_EQ(1u, browser::GetBrowserCount(profile_urls));
684 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); 686 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL);
685 ASSERT_TRUE(new_browser); 687 ASSERT_TRUE(new_browser);
686 ASSERT_EQ(1, new_browser->tab_count()); 688 ASSERT_EQ(1, new_browser->tab_count());
687 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 689 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
688 chrome::GetWebContentsAt(new_browser, 0)->GetURL()); 690 chrome::GetWebContentsAt(new_browser, 0)->GetURL());
689 EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()-> 691 EXPECT_EQ(1U, chrome::GetTabContentsAt(new_browser, 0)->infobar_tab_helper()->
690 infobar_count()); 692 infobar_count());
691 } 693 }
692 #endif // !OS_CHROMEOS 694 #endif // !OS_CHROMEOS
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/application_launch.cc ('k') | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698