| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 browser()->host_desktop_type())); | 273 browser()->host_desktop_type())); |
| 274 | 274 |
| 275 // This should have created a new browser window. | 275 // This should have created a new browser window. |
| 276 Browser* new_browser = FindOneOtherBrowser(browser()); | 276 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 277 ASSERT_TRUE(new_browser); | 277 ASSERT_TRUE(new_browser); |
| 278 | 278 |
| 279 // The new browser should have exactly one tab (not the startup URLs). | 279 // The new browser should have exactly one tab (not the startup URLs). |
| 280 ASSERT_EQ(1, new_browser->tab_strip_model()->count()); | 280 ASSERT_EQ(1, new_browser->tab_strip_model()->count()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 #if defined(OS_WIN) | |
| 284 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ActivateExistingBrowser) { | |
| 285 // Initially, there should only be one browser open. | |
| 286 ASSERT_TRUE(browser()); | |
| 287 EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | |
| 288 browser()->host_desktop_type())); | |
| 289 | |
| 290 // Add --activate-existing-profile-browser to the command line and | |
| 291 // start a new process. | |
| 292 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | |
| 293 dummy.AppendSwitch(switches::kActivateExistingProfileBrowser); | |
| 294 | |
| 295 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | |
| 296 dummy, base::FilePath(), browser()->profile()->GetPath()); | |
| 297 | |
| 298 // This should not have created a new browser window, and should have | |
| 299 // activated the existing browser. | |
| 300 EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | |
| 301 browser()->host_desktop_type())); | |
| 302 } | |
| 303 #endif | |
| 304 | |
| 305 // App shortcuts are not implemented on mac os. | 283 // App shortcuts are not implemented on mac os. |
| 306 #if !defined(OS_MACOSX) | 284 #if !defined(OS_MACOSX) |
| 307 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutNoPref) { | 285 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutNoPref) { |
| 308 // Load an app with launch.container = 'tab'. | 286 // Load an app with launch.container = 'tab'. |
| 309 const Extension* extension_app = NULL; | 287 const Extension* extension_app = NULL; |
| 310 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app)); | 288 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app)); |
| 311 | 289 |
| 312 // Add --app-id=<extension->id()> to the command line. | 290 // Add --app-id=<extension->id()> to the command line. |
| 313 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 291 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 314 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); | 292 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 ASSERT_EQ(1, tab_strip->count()); | 1466 ASSERT_EQ(1, tab_strip->count()); |
| 1489 EXPECT_EQ("title1.html", | 1467 EXPECT_EQ("title1.html", |
| 1490 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1468 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1491 } | 1469 } |
| 1492 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1470 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
| 1493 | 1471 |
| 1494 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | 1472 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || |
| 1495 // defined(ENABLE_CONFIGURATION_POLICY) | 1473 // defined(ENABLE_CONFIGURATION_POLICY) |
| 1496 | 1474 |
| 1497 #endif // !defined(OS_CHROMEOS) | 1475 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |