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
3 // found in the LICENSE file.
8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/histogram_tester.h"
13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/extension_browsertest.h"
15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_util.h"
17 #include "chrome/browser/extensions/launch_util.h"
18 #include "chrome/browser/first_run/first_run.h"
19 #include "chrome/browser/infobars/infobar_service.h"
20 #include "chrome/browser/prefs/session_startup_pref.h"
21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_impl.h"
23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/sessions/session_restore.h"
25 #include "chrome/browser/signin/signin_promo.h"
26 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_commands.h"
28 #include "chrome/browser/ui/browser_finder.h"
29 #include "chrome/browser/ui/browser_iterator.h"
30 #include "chrome/browser/ui/browser_list.h"
31 #include "chrome/browser/ui/browser_list_observer.h"
32 #include "chrome/browser/ui/browser_window.h"
33 #include "chrome/browser/ui/host_desktop.h"
34 #include "chrome/browser/ui/startup/startup_browser_creator.h"
35 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
36 #include "chrome/browser/ui/tabs/tab_strip_model.h"
37 #include "chrome/common/chrome_switches.h"
38 #include "chrome/common/extensions/extension_constants.h"
39 #include "chrome/common/pref_names.h"
40 #include "chrome/common/url_constants.h"
41 #include "chrome/test/base/in_process_browser_test.h"
42 #include "chrome/test/base/test_switches.h"
43 #include "chrome/test/base/ui_test_utils.h"
44 #include "content/public/browser/web_contents.h"
45 #include "extensions/browser/extension_system.h"
46 #include "testing/gtest/include/gtest/gtest.h"
49 #if defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS)
50 #include "base/callback.h"
51 #include "base/run_loop.h"
52 #include "base/values.h"
53 #include "components/policy/core/browser/browser_policy_connector.h"
54 #include "components/policy/core/common/external_data_fetcher.h"
55 #include "components/policy/core/common/mock_configuration_policy_provider.h"
56 #include "components/policy/core/common/policy_map.h"
57 #include "components/policy/core/common/policy_types.h"
58 #include "policy/policy_constants.h"
59 #include "testing/gmock/include/gmock/gmock.h"
62 using testing::Return
;
63 #endif // defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS)
65 #if defined(ENABLE_SUPERVISED_USERS)
66 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
67 #include "chrome/browser/supervised_user/supervised_user_service.h"
68 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
71 using extensions::Extension
;
75 // Check that there are two browsers. Find the one that is not |browser|.
76 Browser
* FindOneOtherBrowser(Browser
* browser
) {
77 // There should only be one other browser.
78 EXPECT_EQ(2u, chrome::GetBrowserCount(browser
->profile(),
79 browser
->host_desktop_type()));
81 // Find the new browser.
82 Browser
* other_browser
= NULL
;
83 for (chrome::BrowserIterator it
; !it
.done() && !other_browser
; it
.Next()) {
92 class StartupBrowserCreatorTest
: public ExtensionBrowserTest
{
94 StartupBrowserCreatorTest() {}
96 bool SetUpUserDataDirectory() override
{
97 return ExtensionBrowserTest::SetUpUserDataDirectory();
100 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
101 ExtensionBrowserTest::SetUpCommandLine(command_line
);
102 command_line
->AppendSwitch(switches::kEnablePanels
);
103 command_line
->AppendSwitchASCII(switches::kHomePage
, url::kAboutBlankURL
);
104 #if defined(OS_CHROMEOS)
105 // TODO(nkostylev): Investigate if we can remove this switch.
106 command_line
->AppendSwitch(switches::kCreateBrowserOnStartupForTests
);
110 // Helper functions return void so that we can ASSERT*().
111 // Use ASSERT_NO_FATAL_FAILURE around calls to these functions to stop the
112 // test if an assert fails.
113 void LoadApp(const std::string
& app_name
,
114 const Extension
** out_app_extension
) {
115 ASSERT_TRUE(LoadExtension(test_data_dir_
.AppendASCII(app_name
.c_str())));
117 ExtensionService
* service
= extensions::ExtensionSystem::Get(
118 browser()->profile())->extension_service();
119 *out_app_extension
= service
->GetExtensionById(
120 last_loaded_extension_id(), false);
121 ASSERT_TRUE(*out_app_extension
);
123 // Code that opens a new browser assumes we start with exactly one.
124 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(),
125 browser()->host_desktop_type()));
128 void SetAppLaunchPref(const std::string
& app_id
,
129 extensions::LaunchType launch_type
) {
130 ExtensionService
* service
= extensions::ExtensionSystem::Get(
131 browser()->profile())->extension_service();
132 extensions::SetLaunchType(service
, app_id
, launch_type
);
135 Browser
* FindOneOtherBrowserForProfile(Profile
* profile
,
136 Browser
* not_this_browser
) {
137 for (chrome::BrowserIterator it
; !it
.done(); it
.Next()) {
138 if (*it
!= not_this_browser
&& it
->profile() == profile
)
144 // A helper function that checks the session restore UI (infobar) is shown
145 // when Chrome starts up after crash.
146 void EnsureRestoreUIWasShown(content::WebContents
* web_contents
) {
147 #if defined(OS_MACOSX)
148 InfoBarService
* infobar_service
=
149 InfoBarService::FromWebContents(web_contents
);
150 EXPECT_EQ(1U, infobar_service
->infobar_count());
151 #endif // defined(OS_MACOSX)
155 DISALLOW_COPY_AND_ASSIGN(StartupBrowserCreatorTest
);
158 class OpenURLsPopupObserver
: public chrome::BrowserListObserver
{
160 OpenURLsPopupObserver() : added_browser_(NULL
) { }
162 void OnBrowserAdded(Browser
* browser
) override
{ added_browser_
= browser
; }
164 void OnBrowserRemoved(Browser
* browser
) override
{}
166 Browser
* added_browser_
;
169 // Test that when there is a popup as the active browser any requests to
170 // StartupBrowserCreatorImpl::OpenURLsInBrowser don't crash because there's no
171 // explicit profile given.
172 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, OpenURLsPopup
) {
173 std::vector
<GURL
> urls
;
174 urls
.push_back(GURL("http://localhost"));
176 // Note that in our testing we do not ever query the BrowserList for the "last
177 // active" browser. That's because the browsers are set as "active" by
178 // platform UI toolkit messages, and those messages are not sent during unit
181 OpenURLsPopupObserver observer
;
182 BrowserList::AddObserver(&observer
);
184 Browser
* popup
= new Browser(
185 Browser::CreateParams(Browser::TYPE_POPUP
, browser()->profile(),
186 browser()->host_desktop_type()));
187 ASSERT_TRUE(popup
->is_type_popup());
188 ASSERT_EQ(popup
, observer
.added_browser_
);
190 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
191 chrome::startup::IsFirstRun first_run
= first_run::IsChromeFirstRun() ?
192 chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN
;
193 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, first_run
);
194 // This should create a new window, but re-use the profile from |popup|. If
195 // it used a NULL or invalid profile, it would crash.
196 launch
.OpenURLsInBrowser(popup
, false, urls
, chrome::GetActiveDesktop());
197 ASSERT_NE(popup
, observer
.added_browser_
);
198 BrowserList::RemoveObserver(&observer
);
201 // We don't do non-process-startup browser launches on ChromeOS.
202 // Session restore for process-startup browser launches is tested
203 // in session_restore_uitest.
204 #if !defined(OS_CHROMEOS)
205 // Verify that startup URLs are honored when the process already exists but has
206 // no tabbed browser windows (eg. as if the process is running only due to a
207 // background application.
208 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
,
209 StartupURLsOnNewWindowWithNoTabbedBrowsers
) {
210 // Use a couple same-site HTTP URLs.
211 ASSERT_TRUE(test_server()->Start());
212 std::vector
<GURL
> urls
;
213 urls
.push_back(test_server()->GetURL("files/title1.html"));
214 urls
.push_back(test_server()->GetURL("files/title2.html"));
216 // Set the startup preference to open these URLs.
217 SessionStartupPref
pref(SessionStartupPref::URLS
);
219 SessionStartupPref::SetStartupPref(browser()->profile(), pref
);
221 // Close the browser.
222 browser()->window()->Close();
224 // Do a simple non-process-startup browser launch.
225 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
226 chrome::startup::IsFirstRun first_run
= first_run::IsChromeFirstRun() ?
227 chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN
;
228 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, first_run
);
229 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
230 browser()->host_desktop_type()));
232 // This should have created a new browser window. |browser()| is still
233 // around at this point, even though we've closed its window.
234 Browser
* new_browser
= FindOneOtherBrowser(browser());
235 ASSERT_TRUE(new_browser
);
237 // The new browser should have one tab for each URL.
238 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
239 ASSERT_EQ(static_cast<int>(urls
.size()), tab_strip
->count());
240 for (size_t i
=0; i
< urls
.size(); i
++) {
241 EXPECT_EQ(urls
[i
], tab_strip
->GetWebContentsAt(i
)->GetURL());
244 // The two tabs, despite having the same site, should be in different
246 EXPECT_NE(tab_strip
->GetWebContentsAt(0)->GetSiteInstance(),
247 tab_strip
->GetWebContentsAt(1)->GetSiteInstance());
250 // Verify that startup URLs aren't used when the process already exists
251 // and has other tabbed browser windows. This is the common case of starting a
253 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
,
254 StartupURLsOnNewWindow
) {
255 // Use a couple arbitrary URLs.
256 std::vector
<GURL
> urls
;
257 urls
.push_back(ui_test_utils::GetTestUrl(
258 base::FilePath(base::FilePath::kCurrentDirectory
),
259 base::FilePath(FILE_PATH_LITERAL("title1.html"))));
260 urls
.push_back(ui_test_utils::GetTestUrl(
261 base::FilePath(base::FilePath::kCurrentDirectory
),
262 base::FilePath(FILE_PATH_LITERAL("title2.html"))));
264 // Set the startup preference to open these URLs.
265 SessionStartupPref
pref(SessionStartupPref::URLS
);
267 SessionStartupPref::SetStartupPref(browser()->profile(), pref
);
269 // Do a simple non-process-startup browser launch.
270 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
271 chrome::startup::IsFirstRun first_run
= first_run::IsChromeFirstRun() ?
272 chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN
;
273 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, first_run
);
274 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
275 browser()->host_desktop_type()));
277 // This should have created a new browser window.
278 Browser
* new_browser
= FindOneOtherBrowser(browser());
279 ASSERT_TRUE(new_browser
);
281 // The new browser should have exactly one tab (not the startup URLs).
282 ASSERT_EQ(1, new_browser
->tab_strip_model()->count());
286 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, ActivateExistingBrowser
) {
287 // Initially, there should only be one browser open.
288 ASSERT_TRUE(browser());
289 EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(),
290 browser()->host_desktop_type()));
292 // Add --activate-existing-profile-browser to the command line and
293 // start a new process.
294 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
295 dummy
.AppendSwitch(switches::kActivateExistingProfileBrowser
);
297 StartupBrowserCreator::ProcessCommandLineAlreadyRunning(
298 dummy
, base::FilePath(), browser()->profile()->GetPath());
300 // This should not have created a new browser window, and should have
301 // activated the existing browser.
302 EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(),
303 browser()->host_desktop_type()));
307 // App shortcuts are not implemented on mac os.
308 #if !defined(OS_MACOSX)
309 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, OpenAppShortcutNoPref
) {
310 // Load an app with launch.container = 'tab'.
311 const Extension
* extension_app
= NULL
;
312 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app
));
314 // Add --app-id=<extension->id()> to the command line.
315 base::CommandLine
command_line(base::CommandLine::NO_PROGRAM
);
316 command_line
.AppendSwitchASCII(switches::kAppId
, extension_app
->id());
318 chrome::startup::IsFirstRun first_run
= first_run::IsChromeFirstRun() ?
319 chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN
;
320 StartupBrowserCreatorImpl
launch(base::FilePath(), command_line
, first_run
);
321 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
322 browser()->host_desktop_type()));
324 // No pref was set, so the app should have opened in a tab in a new window.
325 // The launch should have created a new browser.
326 Browser
* new_browser
= FindOneOtherBrowser(browser());
327 ASSERT_TRUE(new_browser
);
329 // If new bookmark apps are enabled, it should be a standard tabbed window,
330 // not an app window; otherwise the reverse should be true.
331 bool new_bookmark_apps_enabled
=
332 extensions::util::IsStreamlinedHostedAppsEnabled();
333 EXPECT_EQ(!new_bookmark_apps_enabled
, new_browser
->is_app());
334 EXPECT_EQ(new_bookmark_apps_enabled
, new_browser
->is_type_tabbed());
337 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, OpenAppShortcutWindowPref
) {
338 const Extension
* extension_app
= NULL
;
339 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app
));
341 // Set a pref indicating that the user wants to open this app in a window.
342 SetAppLaunchPref(extension_app
->id(), extensions::LAUNCH_TYPE_WINDOW
);
344 base::CommandLine
command_line(base::CommandLine::NO_PROGRAM
);
345 command_line
.AppendSwitchASCII(switches::kAppId
, extension_app
->id());
346 chrome::startup::IsFirstRun first_run
= first_run::IsChromeFirstRun() ?
347 chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN
;
348 StartupBrowserCreatorImpl
launch(base::FilePath(), command_line
, first_run
);
349 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
350 browser()->host_desktop_type()));
352 // Pref was set to open in a window, so the app should have opened in a
353 // window. The launch should have created a new browser. Find the new
355 Browser
* new_browser
= FindOneOtherBrowser(browser());
356 ASSERT_TRUE(new_browser
);
358 // Expect an app window.
359 EXPECT_TRUE(new_browser
->is_app());
361 // The browser's app_name should include the app's ID.
363 new_browser
->app_name_
.find(extension_app
->id()),
364 std::string::npos
) << new_browser
->app_name_
;
367 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, OpenAppShortcutTabPref
) {
368 // Load an app with launch.container = 'tab'.
369 const Extension
* extension_app
= NULL
;
370 ASSERT_NO_FATAL_FAILURE(LoadApp("app_with_tab_container", &extension_app
));
372 // Set a pref indicating that the user wants to open this app in a window.
373 SetAppLaunchPref(extension_app
->id(), extensions::LAUNCH_TYPE_REGULAR
);
375 base::CommandLine
command_line(base::CommandLine::NO_PROGRAM
);
376 command_line
.AppendSwitchASCII(switches::kAppId
, extension_app
->id());
377 chrome::startup::IsFirstRun first_run
= first_run::IsChromeFirstRun() ?
378 chrome::startup::IS_FIRST_RUN
: chrome::startup::IS_NOT_FIRST_RUN
;
379 StartupBrowserCreatorImpl
launch(base::FilePath(), command_line
, first_run
);
380 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
381 browser()->host_desktop_type()));
383 // When an app shortcut is open and the pref indicates a tab should
384 // open, the tab is open in a new browser window. Expect a new window.
385 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
386 browser()->host_desktop_type()));
388 Browser
* new_browser
= FindOneOtherBrowser(browser());
389 ASSERT_TRUE(new_browser
);
391 // The tab should be in a tabbed window.
392 EXPECT_TRUE(new_browser
->is_type_tabbed());
394 // The browser's app_name should not include the app's ID: It is in a
397 new_browser
->app_name_
.find(extension_app
->id()),
398 std::string::npos
) << new_browser
->app_name_
;
401 #endif // !defined(OS_MACOSX)
403 #endif // !defined(OS_CHROMEOS)
405 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
,
406 ReadingWasRestartedAfterRestart
) {
407 // Tests that StartupBrowserCreator::WasRestarted reads and resets the
408 // preference kWasRestarted correctly.
409 StartupBrowserCreator::was_restarted_read_
= false;
410 PrefService
* pref_service
= g_browser_process
->local_state();
411 pref_service
->SetBoolean(prefs::kWasRestarted
, true);
412 EXPECT_TRUE(StartupBrowserCreator::WasRestarted());
413 EXPECT_FALSE(pref_service
->GetBoolean(prefs::kWasRestarted
));
414 EXPECT_TRUE(StartupBrowserCreator::WasRestarted());
417 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
,
418 ReadingWasRestartedAfterNormalStart
) {
419 // Tests that StartupBrowserCreator::WasRestarted reads and resets the
420 // preference kWasRestarted correctly.
421 StartupBrowserCreator::was_restarted_read_
= false;
422 PrefService
* pref_service
= g_browser_process
->local_state();
423 pref_service
->SetBoolean(prefs::kWasRestarted
, false);
424 EXPECT_FALSE(StartupBrowserCreator::WasRestarted());
425 EXPECT_FALSE(pref_service
->GetBoolean(prefs::kWasRestarted
));
426 EXPECT_FALSE(StartupBrowserCreator::WasRestarted());
429 // Fails on official builds. See http://crbug.com/313856
430 #if defined(GOOGLE_CHROME_BUILD)
431 #define MAYBE_AddFirstRunTab DISABLED_AddFirstRunTab
433 #define MAYBE_AddFirstRunTab AddFirstRunTab
435 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, MAYBE_AddFirstRunTab
) {
436 StartupBrowserCreator browser_creator
;
437 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
438 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title2.html"));
440 // Do a simple non-process-startup browser launch.
441 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
442 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
443 chrome::startup::IS_FIRST_RUN
);
444 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
445 browser()->host_desktop_type()));
447 // This should have created a new browser window.
448 Browser
* new_browser
= FindOneOtherBrowser(browser());
449 ASSERT_TRUE(new_browser
);
451 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
452 EXPECT_EQ(2, tab_strip
->count());
454 EXPECT_EQ("title1.html",
455 tab_strip
->GetWebContentsAt(0)->GetURL().ExtractFileName());
456 EXPECT_EQ("title2.html",
457 tab_strip
->GetWebContentsAt(1)->GetURL().ExtractFileName());
460 // Test hard-coded special first run tabs (defined in
461 // StartupBrowserCreatorImpl::AddStartupURLs()).
462 // Fails on official builds. See http://crbug.com/313856
463 #if defined(GOOGLE_CHROME_BUILD)
464 #define MAYBE_AddCustomFirstRunTab DISABLED_AddCustomFirstRunTab
466 #define MAYBE_AddCustomFirstRunTab AddCustomFirstRunTab
468 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, MAYBE_AddCustomFirstRunTab
) {
469 StartupBrowserCreator browser_creator
;
470 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
471 browser_creator
.AddFirstRunTab(GURL("http://new_tab_page"));
472 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title2.html"));
473 browser_creator
.AddFirstRunTab(GURL("http://welcome_page"));
475 // Do a simple non-process-startup browser launch.
476 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
477 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
478 chrome::startup::IS_FIRST_RUN
);
479 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
480 browser()->host_desktop_type()));
482 // This should have created a new browser window.
483 Browser
* new_browser
= FindOneOtherBrowser(browser());
484 ASSERT_TRUE(new_browser
);
486 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
487 EXPECT_EQ(4, tab_strip
->count());
489 EXPECT_EQ("title1.html",
490 tab_strip
->GetWebContentsAt(0)->GetURL().ExtractFileName());
491 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
),
492 tab_strip
->GetWebContentsAt(1)->GetURL());
493 EXPECT_EQ("title2.html",
494 tab_strip
->GetWebContentsAt(2)->GetURL().ExtractFileName());
495 EXPECT_EQ(internals::GetWelcomePageURL(),
496 tab_strip
->GetWebContentsAt(3)->GetURL());
499 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, SyncPromoNoWelcomePage
) {
500 // Do a simple non-process-startup browser launch.
501 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
502 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
,
503 chrome::startup::IS_FIRST_RUN
);
504 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
505 browser()->host_desktop_type()));
507 // This should have created a new browser window.
508 Browser
* new_browser
= FindOneOtherBrowser(browser());
509 ASSERT_TRUE(new_browser
);
511 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
512 EXPECT_EQ(1, tab_strip
->count());
514 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) {
515 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
516 tab_strip
->GetWebContentsAt(0)->GetURL());
518 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
),
519 tab_strip
->GetWebContentsAt(0)->GetURL());
523 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, SyncPromoWithWelcomePage
) {
524 first_run::SetShouldShowWelcomePage();
526 // Do a simple non-process-startup browser launch.
527 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
528 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
,
529 chrome::startup::IS_FIRST_RUN
);
530 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
531 browser()->host_desktop_type()));
533 // This should have created a new browser window.
534 Browser
* new_browser
= FindOneOtherBrowser(browser());
535 ASSERT_TRUE(new_browser
);
537 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
538 EXPECT_EQ(2, tab_strip
->count());
540 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) {
541 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
542 tab_strip
->GetWebContentsAt(0)->GetURL());
544 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
),
545 tab_strip
->GetWebContentsAt(0)->GetURL());
547 EXPECT_EQ(internals::GetWelcomePageURL(),
548 tab_strip
->GetWebContentsAt(1)->GetURL());
551 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, SyncPromoWithFirstRunTabs
) {
552 StartupBrowserCreator browser_creator
;
553 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
555 // The welcome page should not be shown, even if
556 // first_run::ShouldShowWelcomePage() says so, when there are already
557 // more than 2 first run tabs.
558 first_run::SetShouldShowWelcomePage();
560 // Do a simple non-process-startup browser launch.
561 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
562 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
563 chrome::startup::IS_FIRST_RUN
);
564 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
565 browser()->host_desktop_type()));
567 // This should have created a new browser window.
568 Browser
* new_browser
= FindOneOtherBrowser(browser());
569 ASSERT_TRUE(new_browser
);
571 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
572 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) {
573 EXPECT_EQ(2, tab_strip
->count());
574 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
575 tab_strip
->GetWebContentsAt(0)->GetURL());
576 EXPECT_EQ("title1.html",
577 tab_strip
->GetWebContentsAt(1)->GetURL().ExtractFileName());
579 EXPECT_EQ(1, tab_strip
->count());
580 EXPECT_EQ("title1.html",
581 tab_strip
->GetWebContentsAt(0)->GetURL().ExtractFileName());
585 // The welcome page should still be shown if there are more than 2 first run
586 // tabs, but the welcome page was explcitly added to the first run tabs.
587 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
,
588 SyncPromoWithFirstRunTabsIncludingWelcomePage
) {
589 StartupBrowserCreator browser_creator
;
590 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
591 browser_creator
.AddFirstRunTab(GURL("http://welcome_page"));
593 // Do a simple non-process-startup browser launch.
594 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
595 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
596 chrome::startup::IS_FIRST_RUN
);
597 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
598 browser()->host_desktop_type()));
600 // This should have created a new browser window.
601 Browser
* new_browser
= FindOneOtherBrowser(browser());
602 ASSERT_TRUE(new_browser
);
604 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
605 if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) {
606 EXPECT_EQ(3, tab_strip
->count());
607 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
608 tab_strip
->GetWebContentsAt(0)->GetURL());
609 EXPECT_EQ("title1.html",
610 tab_strip
->GetWebContentsAt(1)->GetURL().ExtractFileName());
611 EXPECT_EQ(internals::GetWelcomePageURL(),
612 tab_strip
->GetWebContentsAt(2)->GetURL());
614 EXPECT_EQ(2, tab_strip
->count());
615 EXPECT_EQ("title1.html",
616 tab_strip
->GetWebContentsAt(0)->GetURL().ExtractFileName());
617 EXPECT_EQ(internals::GetWelcomePageURL(),
618 tab_strip
->GetWebContentsAt(1)->GetURL());
622 #if !defined(OS_CHROMEOS)
623 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, StartupURLsForTwoProfiles
) {
624 #if defined(OS_WIN) && defined(USE_ASH)
625 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
626 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
627 switches::kAshBrowserTests
))
631 Profile
* default_profile
= browser()->profile();
633 ProfileManager
* profile_manager
= g_browser_process
->profile_manager();
634 // Create another profile.
635 base::FilePath dest_path
= profile_manager
->user_data_dir();
636 dest_path
= dest_path
.Append(FILE_PATH_LITERAL("New Profile 1"));
638 Profile
* other_profile
= profile_manager
->GetProfile(dest_path
);
639 ASSERT_TRUE(other_profile
);
641 // Use a couple arbitrary URLs.
642 std::vector
<GURL
> urls1
;
643 urls1
.push_back(ui_test_utils::GetTestUrl(
644 base::FilePath(base::FilePath::kCurrentDirectory
),
645 base::FilePath(FILE_PATH_LITERAL("title1.html"))));
646 std::vector
<GURL
> urls2
;
647 urls2
.push_back(ui_test_utils::GetTestUrl(
648 base::FilePath(base::FilePath::kCurrentDirectory
),
649 base::FilePath(FILE_PATH_LITERAL("title2.html"))));
651 // Set different startup preferences for the 2 profiles.
652 SessionStartupPref
pref1(SessionStartupPref::URLS
);
654 SessionStartupPref::SetStartupPref(default_profile
, pref1
);
655 SessionStartupPref
pref2(SessionStartupPref::URLS
);
657 SessionStartupPref::SetStartupPref(other_profile
, pref2
);
659 // Close the browser.
660 browser()->window()->Close();
662 // Do a simple non-process-startup browser launch.
663 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
666 StartupBrowserCreator browser_creator
;
667 std::vector
<Profile
*> last_opened_profiles
;
668 last_opened_profiles
.push_back(default_profile
);
669 last_opened_profiles
.push_back(other_profile
);
670 browser_creator
.Start(dummy
, profile_manager
->user_data_dir(),
671 default_profile
, last_opened_profiles
, &return_code
);
673 // urls1 were opened in a browser for default_profile, and urls2 were opened
674 // in a browser for other_profile.
675 Browser
* new_browser
= NULL
;
676 // |browser()| is still around at this point, even though we've closed its
677 // window. Thus the browser count for default_profile is 2.
678 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile
,
679 browser()->host_desktop_type()));
680 new_browser
= FindOneOtherBrowserForProfile(default_profile
, browser());
681 ASSERT_TRUE(new_browser
);
682 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
683 ASSERT_EQ(1, tab_strip
->count());
684 EXPECT_EQ(urls1
[0], tab_strip
->GetWebContentsAt(0)->GetURL());
686 ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile
,
687 browser()->host_desktop_type()));
688 new_browser
= FindOneOtherBrowserForProfile(other_profile
, NULL
);
689 ASSERT_TRUE(new_browser
);
690 tab_strip
= new_browser
->tab_strip_model();
691 ASSERT_EQ(1, tab_strip
->count());
692 EXPECT_EQ(urls2
[0], tab_strip
->GetWebContentsAt(0)->GetURL());
695 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, PRE_UpdateWithTwoProfiles
) {
696 // Simulate a browser restart by creating the profiles in the PRE_ part.
697 ProfileManager
* profile_manager
= g_browser_process
->profile_manager();
699 ASSERT_TRUE(test_server()->Start());
701 // Create two profiles.
702 base::FilePath dest_path
= profile_manager
->user_data_dir();
704 Profile
* profile1
= profile_manager
->GetProfile(
705 dest_path
.Append(FILE_PATH_LITERAL("New Profile 1")));
706 ASSERT_TRUE(profile1
);
708 Profile
* profile2
= profile_manager
->GetProfile(
709 dest_path
.Append(FILE_PATH_LITERAL("New Profile 2")));
710 ASSERT_TRUE(profile2
);
712 // Open some urls with the browsers, and close them.
713 Browser
* browser1
= new Browser(
714 Browser::CreateParams(Browser::TYPE_TABBED
, profile1
,
715 browser()->host_desktop_type()));
716 chrome::NewTab(browser1
);
717 ui_test_utils::NavigateToURL(browser1
,
718 test_server()->GetURL("files/empty.html"));
719 browser1
->window()->Close();
721 Browser
* browser2
= new Browser(
722 Browser::CreateParams(Browser::TYPE_TABBED
, profile2
,
723 browser()->host_desktop_type()));
724 chrome::NewTab(browser2
);
725 ui_test_utils::NavigateToURL(browser2
,
726 test_server()->GetURL("files/form.html"));
727 browser2
->window()->Close();
729 // Set different startup preferences for the 2 profiles.
730 std::vector
<GURL
> urls1
;
731 urls1
.push_back(ui_test_utils::GetTestUrl(
732 base::FilePath(base::FilePath::kCurrentDirectory
),
733 base::FilePath(FILE_PATH_LITERAL("title1.html"))));
734 std::vector
<GURL
> urls2
;
735 urls2
.push_back(ui_test_utils::GetTestUrl(
736 base::FilePath(base::FilePath::kCurrentDirectory
),
737 base::FilePath(FILE_PATH_LITERAL("title2.html"))));
739 // Set different startup preferences for the 2 profiles.
740 SessionStartupPref
pref1(SessionStartupPref::URLS
);
742 SessionStartupPref::SetStartupPref(profile1
, pref1
);
743 SessionStartupPref
pref2(SessionStartupPref::URLS
);
745 SessionStartupPref::SetStartupPref(profile2
, pref2
);
747 profile1
->GetPrefs()->CommitPendingWrite();
748 profile2
->GetPrefs()->CommitPendingWrite();
751 // See crbug.com/376184 about improvements to this test on Mac.
752 // Disabled because it's flaky. http://crbug.com/379579
753 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
,
754 DISABLED_UpdateWithTwoProfiles
) {
755 #if defined(OS_WIN) && defined(USE_ASH)
756 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
757 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
758 switches::kAshBrowserTests
))
762 // Make StartupBrowserCreator::WasRestarted() return true.
763 StartupBrowserCreator::was_restarted_read_
= false;
764 PrefService
* pref_service
= g_browser_process
->local_state();
765 pref_service
->SetBoolean(prefs::kWasRestarted
, true);
767 ProfileManager
* profile_manager
= g_browser_process
->profile_manager();
769 // Open the two profiles.
770 base::FilePath dest_path
= profile_manager
->user_data_dir();
772 Profile
* profile1
= profile_manager
->GetProfile(
773 dest_path
.Append(FILE_PATH_LITERAL("New Profile 1")));
774 ASSERT_TRUE(profile1
);
776 Profile
* profile2
= profile_manager
->GetProfile(
777 dest_path
.Append(FILE_PATH_LITERAL("New Profile 2")));
778 ASSERT_TRUE(profile2
);
780 // Simulate a launch after a browser update.
781 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
783 StartupBrowserCreator browser_creator
;
784 std::vector
<Profile
*> last_opened_profiles
;
785 last_opened_profiles
.push_back(profile1
);
786 last_opened_profiles
.push_back(profile2
);
787 browser_creator
.Start(dummy
, profile_manager
->user_data_dir(), profile1
,
788 last_opened_profiles
, &return_code
);
790 while (SessionRestore::IsRestoring(profile1
) ||
791 SessionRestore::IsRestoring(profile2
))
792 base::MessageLoop::current()->RunUntilIdle();
794 // The startup URLs are ignored, and instead the last open sessions are
796 EXPECT_TRUE(profile1
->restored_last_session());
797 EXPECT_TRUE(profile2
->restored_last_session());
799 Browser
* new_browser
= NULL
;
800 ASSERT_EQ(1u, chrome::GetBrowserCount(profile1
,
801 browser()->host_desktop_type()));
802 new_browser
= FindOneOtherBrowserForProfile(profile1
, NULL
);
803 ASSERT_TRUE(new_browser
);
804 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
805 ASSERT_EQ(1, tab_strip
->count());
806 EXPECT_EQ("/files/empty.html",
807 tab_strip
->GetWebContentsAt(0)->GetURL().path());
809 ASSERT_EQ(1u, chrome::GetBrowserCount(profile2
,
810 browser()->host_desktop_type()));
811 new_browser
= FindOneOtherBrowserForProfile(profile2
, NULL
);
812 ASSERT_TRUE(new_browser
);
813 tab_strip
= new_browser
->tab_strip_model();
814 ASSERT_EQ(1, tab_strip
->count());
815 EXPECT_EQ("/files/form.html",
816 tab_strip
->GetWebContentsAt(0)->GetURL().path());
819 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
,
820 ProfilesWithoutPagesNotLaunched
) {
821 #if defined(OS_WIN) && defined(USE_ASH)
822 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
823 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
824 switches::kAshBrowserTests
))
828 Profile
* default_profile
= browser()->profile();
830 ProfileManager
* profile_manager
= g_browser_process
->profile_manager();
832 // Create 4 more profiles.
833 base::FilePath dest_path1
= profile_manager
->user_data_dir().Append(
834 FILE_PATH_LITERAL("New Profile 1"));
835 base::FilePath dest_path2
= profile_manager
->user_data_dir().Append(
836 FILE_PATH_LITERAL("New Profile 2"));
837 base::FilePath dest_path3
= profile_manager
->user_data_dir().Append(
838 FILE_PATH_LITERAL("New Profile 3"));
839 base::FilePath dest_path4
= profile_manager
->user_data_dir().Append(
840 FILE_PATH_LITERAL("New Profile 4"));
842 Profile
* profile_home1
= profile_manager
->GetProfile(dest_path1
);
843 ASSERT_TRUE(profile_home1
);
844 Profile
* profile_home2
= profile_manager
->GetProfile(dest_path2
);
845 ASSERT_TRUE(profile_home2
);
846 Profile
* profile_last
= profile_manager
->GetProfile(dest_path3
);
847 ASSERT_TRUE(profile_last
);
848 Profile
* profile_urls
= profile_manager
->GetProfile(dest_path4
);
849 ASSERT_TRUE(profile_urls
);
851 // Set the profiles to open urls, open last visited pages or display the home
853 SessionStartupPref
pref_home(SessionStartupPref::DEFAULT
);
854 SessionStartupPref::SetStartupPref(profile_home1
, pref_home
);
855 SessionStartupPref::SetStartupPref(profile_home2
, pref_home
);
857 SessionStartupPref
pref_last(SessionStartupPref::LAST
);
858 SessionStartupPref::SetStartupPref(profile_last
, pref_last
);
860 std::vector
<GURL
> urls
;
861 urls
.push_back(ui_test_utils::GetTestUrl(
862 base::FilePath(base::FilePath::kCurrentDirectory
),
863 base::FilePath(FILE_PATH_LITERAL("title1.html"))));
865 SessionStartupPref
pref_urls(SessionStartupPref::URLS
);
866 pref_urls
.urls
= urls
;
867 SessionStartupPref::SetStartupPref(profile_urls
, pref_urls
);
869 // Open a page with profile_last.
870 Browser
* browser_last
= new Browser(
871 Browser::CreateParams(Browser::TYPE_TABBED
, profile_last
,
872 browser()->host_desktop_type()));
873 chrome::NewTab(browser_last
);
874 ui_test_utils::NavigateToURL(browser_last
,
875 test_server()->GetURL("files/empty.html"));
876 browser_last
->window()->Close();
878 // Close the main browser.
879 chrome::HostDesktopType original_desktop_type
=
880 browser()->host_desktop_type();
881 browser()->window()->Close();
883 // Do a simple non-process-startup browser launch.
884 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
887 StartupBrowserCreator browser_creator
;
888 std::vector
<Profile
*> last_opened_profiles
;
889 last_opened_profiles
.push_back(profile_home1
);
890 last_opened_profiles
.push_back(profile_home2
);
891 last_opened_profiles
.push_back(profile_last
);
892 last_opened_profiles
.push_back(profile_urls
);
893 browser_creator
.Start(dummy
, profile_manager
->user_data_dir(), profile_home1
,
894 last_opened_profiles
, &return_code
);
896 while (SessionRestore::IsRestoring(default_profile
) ||
897 SessionRestore::IsRestoring(profile_home1
) ||
898 SessionRestore::IsRestoring(profile_home2
) ||
899 SessionRestore::IsRestoring(profile_last
) ||
900 SessionRestore::IsRestoring(profile_urls
))
901 base::MessageLoop::current()->RunUntilIdle();
903 Browser
* new_browser
= NULL
;
904 // The last open profile (the profile_home1 in this case) will always be
905 // launched, even if it will open just the home page.
906 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1
, original_desktop_type
));
907 new_browser
= FindOneOtherBrowserForProfile(profile_home1
, NULL
);
908 ASSERT_TRUE(new_browser
);
909 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
910 ASSERT_EQ(1, tab_strip
->count());
911 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
),
912 tab_strip
->GetWebContentsAt(0)->GetURL());
914 // profile_urls opened the urls.
915 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls
, original_desktop_type
));
916 new_browser
= FindOneOtherBrowserForProfile(profile_urls
, NULL
);
917 ASSERT_TRUE(new_browser
);
918 tab_strip
= new_browser
->tab_strip_model();
919 ASSERT_EQ(1, tab_strip
->count());
920 EXPECT_EQ(urls
[0], tab_strip
->GetWebContentsAt(0)->GetURL());
922 // profile_last opened the last open pages.
923 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last
, original_desktop_type
));
924 new_browser
= FindOneOtherBrowserForProfile(profile_last
, NULL
);
925 ASSERT_TRUE(new_browser
);
926 tab_strip
= new_browser
->tab_strip_model();
927 ASSERT_EQ(1, tab_strip
->count());
928 EXPECT_EQ("/files/empty.html",
929 tab_strip
->GetWebContentsAt(0)->GetURL().path());
931 // profile_home2 was not launched since it would've only opened the home page.
932 ASSERT_EQ(0u, chrome::GetBrowserCount(profile_home2
, original_desktop_type
));
935 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest
, ProfilesLaunchedAfterCrash
) {
936 #if defined(OS_WIN) && defined(USE_ASH)
937 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
938 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
939 switches::kAshBrowserTests
))
943 // After an unclean exit, all profiles will be launched. However, they won't
944 // open any pages automatically.
946 ProfileManager
* profile_manager
= g_browser_process
->profile_manager();
948 // Create 3 profiles.
949 base::FilePath dest_path1
= profile_manager
->user_data_dir().Append(
950 FILE_PATH_LITERAL("New Profile 1"));
951 base::FilePath dest_path2
= profile_manager
->user_data_dir().Append(
952 FILE_PATH_LITERAL("New Profile 2"));
953 base::FilePath dest_path3
= profile_manager
->user_data_dir().Append(
954 FILE_PATH_LITERAL("New Profile 3"));
956 Profile
* profile_home
= profile_manager
->GetProfile(dest_path1
);
957 ASSERT_TRUE(profile_home
);
958 Profile
* profile_last
= profile_manager
->GetProfile(dest_path2
);
959 ASSERT_TRUE(profile_last
);
960 Profile
* profile_urls
= profile_manager
->GetProfile(dest_path3
);
961 ASSERT_TRUE(profile_urls
);
963 // Set the profiles to open the home page, last visited pages or URLs.
964 SessionStartupPref
pref_home(SessionStartupPref::DEFAULT
);
965 SessionStartupPref::SetStartupPref(profile_home
, pref_home
);
967 SessionStartupPref
pref_last(SessionStartupPref::LAST
);
968 SessionStartupPref::SetStartupPref(profile_last
, pref_last
);
970 std::vector
<GURL
> urls
;
971 urls
.push_back(ui_test_utils::GetTestUrl(
972 base::FilePath(base::FilePath::kCurrentDirectory
),
973 base::FilePath(FILE_PATH_LITERAL("title1.html"))));
975 SessionStartupPref
pref_urls(SessionStartupPref::URLS
);
976 pref_urls
.urls
= urls
;
977 SessionStartupPref::SetStartupPref(profile_urls
, pref_urls
);
979 // Simulate a launch after an unclear exit.
980 browser()->window()->Close();
981 static_cast<ProfileImpl
*>(profile_home
)->last_session_exit_type_
=
982 Profile::EXIT_CRASHED
;
983 static_cast<ProfileImpl
*>(profile_last
)->last_session_exit_type_
=
984 Profile::EXIT_CRASHED
;
985 static_cast<ProfileImpl
*>(profile_urls
)->last_session_exit_type_
=
986 Profile::EXIT_CRASHED
;
988 #if !defined(OS_MACOSX) && !defined(GOOGLE_CHROME_BUILD)
989 // Use HistogramTester to make sure a bubble is shown when it's not on
990 // platform Mac OS X and it's not official Chrome build.
992 // On Mac OS X, an infobar is shown to restore the previous session, which
993 // is tested by function EnsureRestoreUIWasShown.
995 // Under a Google Chrome build, it is not tested because a task is posted to
996 // the file thread before the bubble is shown. It is difficult to make sure
997 // that the histogram check runs after all threads have finished their tasks.
998 base::HistogramTester histogram_tester
;
999 #endif // !defined(OS_MACOSX) && !defined(GOOGLE_CHROME_BUILD)
1001 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1002 dummy
.AppendSwitchASCII(switches::kTestType
, "browser");
1004 StartupBrowserCreator browser_creator
;
1005 std::vector
<Profile
*> last_opened_profiles
;
1006 last_opened_profiles
.push_back(profile_home
);
1007 last_opened_profiles
.push_back(profile_last
);
1008 last_opened_profiles
.push_back(profile_urls
);
1009 browser_creator
.Start(dummy
, profile_manager
->user_data_dir(), profile_home
,
1010 last_opened_profiles
, &return_code
);
1012 // No profiles are getting restored, since they all display the crash info
1014 EXPECT_FALSE(SessionRestore::IsRestoring(profile_home
));
1015 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last
));
1016 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls
));
1018 // The profile which normally opens the home page displays the new tab page.
1019 Browser
* new_browser
= NULL
;
1020 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home
,
1021 browser()->host_desktop_type()));
1022 new_browser
= FindOneOtherBrowserForProfile(profile_home
, NULL
);
1023 ASSERT_TRUE(new_browser
);
1024 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1025 ASSERT_EQ(1, tab_strip
->count());
1026 content::WebContents
* web_contents
= tab_strip
->GetWebContentsAt(0);
1027 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
), web_contents
->GetURL());
1028 EnsureRestoreUIWasShown(web_contents
);
1030 // The profile which normally opens last open pages displays the new tab page.
1031 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last
,
1032 browser()->host_desktop_type()));
1033 new_browser
= FindOneOtherBrowserForProfile(profile_last
, NULL
);
1034 ASSERT_TRUE(new_browser
);
1035 tab_strip
= new_browser
->tab_strip_model();
1036 ASSERT_EQ(1, tab_strip
->count());
1037 web_contents
= tab_strip
->GetWebContentsAt(0);
1038 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
), web_contents
->GetURL());
1039 EnsureRestoreUIWasShown(web_contents
);
1041 // The profile which normally opens URLs displays the new tab page.
1042 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls
,
1043 browser()->host_desktop_type()));
1044 new_browser
= FindOneOtherBrowserForProfile(profile_urls
, NULL
);
1045 ASSERT_TRUE(new_browser
);
1046 tab_strip
= new_browser
->tab_strip_model();
1047 ASSERT_EQ(1, tab_strip
->count());
1048 web_contents
= tab_strip
->GetWebContentsAt(0);
1049 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
), web_contents
->GetURL());
1050 EnsureRestoreUIWasShown(web_contents
);
1052 #if !defined(OS_MACOSX) && !defined(GOOGLE_CHROME_BUILD)
1053 // Each profile should have one session restore bubble shown, so we should
1054 // observe count 3 in bucket 0 (which represents bubble shown).
1055 histogram_tester
.ExpectBucketCount("SessionCrashed.Bubble", 0, 3);
1056 #endif // !defined(OS_MACOSX) && !defined(GOOGLE_CHROME_BUILD)
1059 class SupervisedUserBrowserCreatorTest
: public InProcessBrowserTest
{
1061 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
1062 InProcessBrowserTest::SetUpCommandLine(command_line
);
1063 command_line
->AppendSwitchASCII(switches::kSupervisedUserId
, "asdf");
1067 IN_PROC_BROWSER_TEST_F(SupervisedUserBrowserCreatorTest
,
1068 StartupSupervisedUserProfile
) {
1069 StartupBrowserCreator browser_creator
;
1071 // Do a simple non-process-startup browser launch.
1072 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1073 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1074 chrome::startup::IS_FIRST_RUN
);
1075 content::WindowedNotificationObserver
observer(
1076 content::NOTIFICATION_LOAD_STOP
,
1077 content::NotificationService::AllSources());
1078 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), false,
1079 browser()->host_desktop_type()));
1081 // This should have created a new browser window.
1082 Browser
* new_browser
= FindOneOtherBrowser(browser());
1083 ASSERT_TRUE(new_browser
);
1085 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1086 // There should be only one tab.
1087 EXPECT_EQ(1, tab_strip
->count());
1090 #endif // !defined(OS_CHROMEOS)
1092 // These tests are not applicable to Chrome OS as neither master_preferences nor
1093 // the sync promo exist there.
1094 #if !defined(OS_CHROMEOS)
1096 // On a branded Linux build, policy is required to suppress the first-run
1098 #if !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || \
1099 defined(ENABLE_CONFIGURATION_POLICY)
1101 class StartupBrowserCreatorFirstRunTest
: public InProcessBrowserTest
{
1103 void SetUpCommandLine(base::CommandLine
* command_line
) override
;
1104 void SetUpInProcessBrowserTestFixture() override
;
1106 #if defined(ENABLE_CONFIGURATION_POLICY)
1107 policy::MockConfigurationPolicyProvider provider_
;
1108 policy::PolicyMap policy_map_
;
1109 #endif // defined(ENABLE_CONFIGURATION_POLICY)
1112 void StartupBrowserCreatorFirstRunTest::SetUpCommandLine(
1113 base::CommandLine
* command_line
) {
1114 command_line
->AppendSwitch(switches::kForceFirstRun
);
1117 void StartupBrowserCreatorFirstRunTest::SetUpInProcessBrowserTestFixture() {
1118 #if defined(ENABLE_CONFIGURATION_POLICY)
1119 #if defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD)
1120 // Set a policy that prevents the first-run dialog from being shown.
1121 policy_map_
.Set(policy::key::kMetricsReportingEnabled
,
1122 policy::POLICY_LEVEL_MANDATORY
,
1123 policy::POLICY_SCOPE_USER
,
1124 new base::FundamentalValue(false),
1126 provider_
.UpdateChromePolicy(policy_map_
);
1127 #endif // defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD)
1129 EXPECT_CALL(provider_
, IsInitializationComplete(_
))
1130 .WillRepeatedly(Return(true));
1131 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_
);
1132 #endif // defined(ENABLE_CONFIGURATION_POLICY)
1135 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1136 // http://crbug.com/314819
1137 #define MAYBE_SyncPromoForbidden DISABLED_SyncPromoForbidden
1139 #define MAYBE_SyncPromoForbidden SyncPromoForbidden
1141 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1142 MAYBE_SyncPromoForbidden
) {
1143 // Consistently enable the welcome page on all platforms.
1144 first_run::SetShouldShowWelcomePage();
1146 // Simulate the following master_preferences:
1149 // "show_on_first_run_allowed": false
1152 StartupBrowserCreator browser_creator
;
1153 browser()->profile()->GetPrefs()->SetBoolean(
1154 prefs::kSignInPromoShowOnFirstRunAllowed
, false);
1156 // Do a process-startup browser launch.
1157 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1158 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1159 chrome::startup::IS_FIRST_RUN
);
1160 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1161 browser()->host_desktop_type()));
1163 // This should have created a new browser window.
1164 Browser
* new_browser
= FindOneOtherBrowser(browser());
1165 ASSERT_TRUE(new_browser
);
1167 // Verify that the NTP and the welcome page are shown.
1168 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1169 ASSERT_EQ(2, tab_strip
->count());
1170 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
),
1171 tab_strip
->GetWebContentsAt(0)->GetURL());
1172 EXPECT_EQ(internals::GetWelcomePageURL(),
1173 tab_strip
->GetWebContentsAt(1)->GetURL());
1176 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1177 // http://crbug.com/314819
1178 #define MAYBE_SyncPromoAllowed DISABLED_SyncPromoAllowed
1180 #define MAYBE_SyncPromoAllowed SyncPromoAllowed
1182 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1183 MAYBE_SyncPromoAllowed
) {
1184 // Consistently enable the welcome page on all platforms.
1185 first_run::SetShouldShowWelcomePage();
1187 // Simulate the following master_preferences:
1190 // "show_on_first_run_allowed": true
1193 StartupBrowserCreator browser_creator
;
1194 browser()->profile()->GetPrefs()->SetBoolean(
1195 prefs::kSignInPromoShowOnFirstRunAllowed
, true);
1197 // Do a process-startup browser launch.
1198 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1199 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1200 chrome::startup::IS_FIRST_RUN
);
1201 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1202 browser()->host_desktop_type()));
1204 // This should have created a new browser window.
1205 Browser
* new_browser
= FindOneOtherBrowser(browser());
1206 ASSERT_TRUE(new_browser
);
1208 // Verify that the sync promo and the welcome page are shown.
1209 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1210 ASSERT_EQ(2, tab_strip
->count());
1211 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
1212 tab_strip
->GetWebContentsAt(0)->GetURL());
1213 EXPECT_EQ(internals::GetWelcomePageURL(),
1214 tab_strip
->GetWebContentsAt(1)->GetURL());
1217 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1218 // http://crbug.com/314819
1219 #define MAYBE_FirstRunTabsPromoAllowed DISABLED_FirstRunTabsPromoAllowed
1221 #define MAYBE_FirstRunTabsPromoAllowed FirstRunTabsPromoAllowed
1223 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1224 MAYBE_FirstRunTabsPromoAllowed
) {
1225 // Simulate the following master_preferences:
1227 // "first_run_tabs" : [
1228 // "files/title1.html"
1231 // "show_on_first_run_allowed": true
1234 StartupBrowserCreator browser_creator
;
1235 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
1236 browser()->profile()->GetPrefs()->SetBoolean(
1237 prefs::kSignInPromoShowOnFirstRunAllowed
, true);
1239 // Do a process-startup browser launch.
1240 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1241 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1242 chrome::startup::IS_FIRST_RUN
);
1243 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1244 browser()->host_desktop_type()));
1246 // This should have created a new browser window.
1247 Browser
* new_browser
= FindOneOtherBrowser(browser());
1248 ASSERT_TRUE(new_browser
);
1250 // Verify that the first-run tab is shown and the sync promo has been added.
1251 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1252 ASSERT_EQ(2, tab_strip
->count());
1253 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
1254 tab_strip
->GetWebContentsAt(0)->GetURL());
1255 EXPECT_EQ("title1.html",
1256 tab_strip
->GetWebContentsAt(1)->GetURL().ExtractFileName());
1259 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1260 // http://crbug.com/314819
1261 #define MAYBE_FirstRunTabsContainSyncPromo \
1262 DISABLED_FirstRunTabsContainSyncPromo
1264 #define MAYBE_FirstRunTabsContainSyncPromo FirstRunTabsContainSyncPromo
1266 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1267 MAYBE_FirstRunTabsContainSyncPromo
) {
1268 // Simulate the following master_preferences:
1270 // "first_run_tabs" : [
1271 // "files/title1.html",
1272 // "chrome://signin/?source=0&next_page=chrome%3A%2F%2Fnewtab%2F"
1275 // "show_on_first_run_allowed": true
1278 ASSERT_TRUE(test_server()->Start());
1279 StartupBrowserCreator browser_creator
;
1280 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
1281 browser_creator
.AddFirstRunTab(
1282 signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false));
1283 browser()->profile()->GetPrefs()->SetBoolean(
1284 prefs::kSignInPromoShowOnFirstRunAllowed
, true);
1286 // Do a process-startup browser launch.
1287 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1288 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1289 chrome::startup::IS_FIRST_RUN
);
1290 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1291 browser()->host_desktop_type()));
1293 // This should have created a new browser window.
1294 Browser
* new_browser
= FindOneOtherBrowser(browser());
1295 ASSERT_TRUE(new_browser
);
1297 // Verify that the first-run tabs are shown and no sync promo has been added
1298 // as the first-run tabs contain it already.
1299 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1300 ASSERT_EQ(2, tab_strip
->count());
1301 EXPECT_EQ("title1.html",
1302 tab_strip
->GetWebContentsAt(0)->GetURL().ExtractFileName());
1303 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
1304 tab_strip
->GetWebContentsAt(1)->GetURL());
1307 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1308 // http://crbug.com/314819
1309 #define MAYBE_FirstRunTabsContainNTPSyncPromoAllowed \
1310 DISABLED_FirstRunTabsContainNTPSyncPromoAllowed
1312 #define MAYBE_FirstRunTabsContainNTPSyncPromoAllowed \
1313 FirstRunTabsContainNTPSyncPromoAllowed
1315 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1316 MAYBE_FirstRunTabsContainNTPSyncPromoAllowed
) {
1317 // Simulate the following master_preferences:
1319 // "first_run_tabs" : [
1321 // "files/title1.html"
1324 // "show_on_first_run_allowed": true
1327 StartupBrowserCreator browser_creator
;
1328 browser_creator
.AddFirstRunTab(GURL("http://new_tab_page"));
1329 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
1330 browser()->profile()->GetPrefs()->SetBoolean(
1331 prefs::kSignInPromoShowOnFirstRunAllowed
, true);
1333 // Do a process-startup browser launch.
1334 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1335 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1336 chrome::startup::IS_FIRST_RUN
);
1337 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1338 browser()->host_desktop_type()));
1340 // This should have created a new browser window.
1341 Browser
* new_browser
= FindOneOtherBrowser(browser());
1342 ASSERT_TRUE(new_browser
);
1344 // Verify that the first-run tabs are shown but the NTP that they contain has
1345 // been replaced by the sync promo.
1346 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1347 ASSERT_EQ(2, tab_strip
->count());
1348 EXPECT_EQ(signin::GetPromoURL(signin_metrics::SOURCE_START_PAGE
, false),
1349 tab_strip
->GetWebContentsAt(0)->GetURL());
1350 EXPECT_EQ("title1.html",
1351 tab_strip
->GetWebContentsAt(1)->GetURL().ExtractFileName());
1354 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1355 // http://crbug.com/314819
1356 #define MAYBE_FirstRunTabsContainNTPSyncPromoForbidden \
1357 DISABLED_FirstRunTabsContainNTPSyncPromoForbidden
1359 #define MAYBE_FirstRunTabsContainNTPSyncPromoForbidden \
1360 FirstRunTabsContainNTPSyncPromoForbidden
1362 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1363 MAYBE_FirstRunTabsContainNTPSyncPromoForbidden
) {
1364 // Simulate the following master_preferences:
1366 // "first_run_tabs" : [
1368 // "files/title1.html"
1371 // "show_on_first_run_allowed": false
1374 StartupBrowserCreator browser_creator
;
1375 browser_creator
.AddFirstRunTab(GURL("http://new_tab_page"));
1376 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
1377 browser()->profile()->GetPrefs()->SetBoolean(
1378 prefs::kSignInPromoShowOnFirstRunAllowed
, false);
1380 // Do a process-startup browser launch.
1381 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1382 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1383 chrome::startup::IS_FIRST_RUN
);
1384 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1385 browser()->host_desktop_type()));
1387 // This should have created a new browser window.
1388 Browser
* new_browser
= FindOneOtherBrowser(browser());
1389 ASSERT_TRUE(new_browser
);
1391 // Verify that the first-run tabs are shown, the NTP that they contain has not
1392 // not been replaced by the sync promo and no sync promo has been added.
1393 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1394 ASSERT_EQ(2, tab_strip
->count());
1395 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL
),
1396 tab_strip
->GetWebContentsAt(0)->GetURL());
1397 EXPECT_EQ("title1.html",
1398 tab_strip
->GetWebContentsAt(1)->GetURL().ExtractFileName());
1401 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1402 // http://crbug.com/314819
1403 #define MAYBE_FirstRunTabsSyncPromoForbidden \
1404 DISABLED_FirstRunTabsSyncPromoForbidden
1406 #define MAYBE_FirstRunTabsSyncPromoForbidden FirstRunTabsSyncPromoForbidden
1408 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1409 MAYBE_FirstRunTabsSyncPromoForbidden
) {
1410 // Simulate the following master_preferences:
1412 // "first_run_tabs" : [
1413 // "files/title1.html"
1416 // "show_on_first_run_allowed": false
1419 StartupBrowserCreator browser_creator
;
1420 browser_creator
.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
1421 browser()->profile()->GetPrefs()->SetBoolean(
1422 prefs::kSignInPromoShowOnFirstRunAllowed
, false);
1424 // Do a process-startup browser launch.
1425 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1426 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1427 chrome::startup::IS_FIRST_RUN
);
1428 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1429 browser()->host_desktop_type()));
1431 // This should have created a new browser window.
1432 Browser
* new_browser
= FindOneOtherBrowser(browser());
1433 ASSERT_TRUE(new_browser
);
1435 // Verify that the first-run tab is shown and no sync promo has been added.
1436 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1437 ASSERT_EQ(1, tab_strip
->count());
1438 EXPECT_EQ("title1.html",
1439 tab_strip
->GetWebContentsAt(0)->GetURL().ExtractFileName());
1442 #if defined(ENABLE_CONFIGURATION_POLICY)
1443 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
1444 // http://crbug.com/314819
1445 #define MAYBE_RestoreOnStartupURLsPolicySpecified \
1446 DISABLED_RestoreOnStartupURLsPolicySpecified
1448 #define MAYBE_RestoreOnStartupURLsPolicySpecified \
1449 RestoreOnStartupURLsPolicySpecified
1451 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest
,
1452 MAYBE_RestoreOnStartupURLsPolicySpecified
) {
1453 // Simulate the following master_preferences:
1456 // "show_on_first_run_allowed": true
1459 StartupBrowserCreator browser_creator
;
1460 browser()->profile()->GetPrefs()->SetBoolean(
1461 prefs::kSignInPromoShowOnFirstRunAllowed
, true);
1463 // Set the following user policies:
1464 // * RestoreOnStartup = RestoreOnStartupIsURLs
1465 // * RestoreOnStartupURLs = [ "files/title1.html" ]
1467 policy::key::kRestoreOnStartup
,
1468 policy::POLICY_LEVEL_MANDATORY
,
1469 policy::POLICY_SCOPE_USER
,
1470 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs
),
1472 base::ListValue startup_urls
;
1473 startup_urls
.Append(
1474 new base::StringValue(test_server()->GetURL("files/title1.html").spec()));
1475 policy_map_
.Set(policy::key::kRestoreOnStartupURLs
,
1476 policy::POLICY_LEVEL_MANDATORY
, policy::POLICY_SCOPE_USER
,
1477 startup_urls
.DeepCopy(), NULL
);
1478 provider_
.UpdateChromePolicy(policy_map_
);
1479 base::RunLoop().RunUntilIdle();
1481 // Do a process-startup browser launch.
1482 base::CommandLine
dummy(base::CommandLine::NO_PROGRAM
);
1483 StartupBrowserCreatorImpl
launch(base::FilePath(), dummy
, &browser_creator
,
1484 chrome::startup::IS_FIRST_RUN
);
1485 ASSERT_TRUE(launch
.Launch(browser()->profile(), std::vector
<GURL
>(), true,
1486 browser()->host_desktop_type()));
1488 // This should have created a new browser window.
1489 Browser
* new_browser
= FindOneOtherBrowser(browser());
1490 ASSERT_TRUE(new_browser
);
1492 // Verify that the URL specified through policy is shown and no sync promo has
1494 TabStripModel
* tab_strip
= new_browser
->tab_strip_model();
1495 ASSERT_EQ(1, tab_strip
->count());
1496 EXPECT_EQ("title1.html",
1497 tab_strip
->GetWebContentsAt(0)->GetURL().ExtractFileName());
1499 #endif // defined(ENABLE_CONFIGURATION_POLICY)
1501 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) ||
1502 // defined(ENABLE_CONFIGURATION_POLICY)
1504 #endif // !defined(OS_CHROMEOS)