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

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

Issue 20483002: Merge 3 different ways of obtaining first run state into a single one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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 <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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 tab_strip->GetWebContentsAt(3)->GetURL()); 456 tab_strip->GetWebContentsAt(3)->GetURL());
457 } 457 }
458 458
459 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoNoWelcomePage) { 459 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoNoWelcomePage) {
460 #if defined(OS_WIN) && defined(USE_ASH) 460 #if defined(OS_WIN) && defined(USE_ASH)
461 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 461 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
462 if (base::win::GetVersion() >= base::win::VERSION_WIN8) 462 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
463 return; 463 return;
464 #endif 464 #endif
465 465
466 // Trick this test into thinking the promo has been shown for this profile; so
467 // that it will show it again (otherwise it skips showing it since
468 // --no-first-run is specified in browser tests).
469 SyncPromoUI::DidShowSyncPromoAtStartup(browser()->profile());
gab 2013/07/26 15:41:13 This was originally required when I wrote these te
470
471 // Do a simple non-process-startup browser launch. 466 // Do a simple non-process-startup browser launch.
472 CommandLine dummy(CommandLine::NO_PROGRAM); 467 CommandLine dummy(CommandLine::NO_PROGRAM);
473 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, 468 StartupBrowserCreatorImpl launch(base::FilePath(), dummy,
474 chrome::startup::IS_FIRST_RUN); 469 chrome::startup::IS_FIRST_RUN);
475 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, 470 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false,
476 browser()->host_desktop_type())); 471 browser()->host_desktop_type()));
477 472
478 // This should have created a new browser window. 473 // This should have created a new browser window.
479 Browser* new_browser = FindOneOtherBrowser(browser()); 474 Browser* new_browser = FindOneOtherBrowser(browser());
480 ASSERT_TRUE(new_browser); 475 ASSERT_TRUE(new_browser);
481 476
482 TabStripModel* tab_strip = new_browser->tab_strip_model(); 477 TabStripModel* tab_strip = new_browser->tab_strip_model();
483 EXPECT_EQ(1, tab_strip->count()); 478 EXPECT_EQ(1, tab_strip->count());
484 479
485 if (SyncPromoUI::ShouldShowSyncPromoAtStartup(browser()->profile(), true)) { 480 if (SyncPromoUI::ShouldShowSyncPromoAtStartup(browser()->profile(), true)) {
486 EXPECT_EQ("signin", tab_strip->GetWebContentsAt(0)->GetURL().host()); 481 EXPECT_EQ("signin", tab_strip->GetWebContentsAt(0)->GetURL().host());
487 } else { 482 } else {
488 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 483 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
489 tab_strip->GetWebContentsAt(0)->GetURL()); 484 tab_strip->GetWebContentsAt(0)->GetURL());
490 } 485 }
491 } 486 }
492 487
493 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithWelcomePage) { 488 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithWelcomePage) {
494 #if defined(OS_WIN) && defined(USE_ASH) 489 #if defined(OS_WIN) && defined(USE_ASH)
495 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 490 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
496 if (base::win::GetVersion() >= base::win::VERSION_WIN8) 491 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
497 return; 492 return;
498 #endif 493 #endif
499 494
500 // Trick this test into thinking the promo has been shown for this profile; so
501 // that it will show it again (otherwise it skips showing it since
502 // --no-first-run is specified in browser tests).
503 SyncPromoUI::DidShowSyncPromoAtStartup(browser()->profile());
504 first_run::SetShouldShowWelcomePage(); 495 first_run::SetShouldShowWelcomePage();
505 496
506 // Do a simple non-process-startup browser launch. 497 // Do a simple non-process-startup browser launch.
507 CommandLine dummy(CommandLine::NO_PROGRAM); 498 CommandLine dummy(CommandLine::NO_PROGRAM);
508 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, 499 StartupBrowserCreatorImpl launch(base::FilePath(), dummy,
509 chrome::startup::IS_FIRST_RUN); 500 chrome::startup::IS_FIRST_RUN);
510 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, 501 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false,
511 browser()->host_desktop_type())); 502 browser()->host_desktop_type()));
512 503
513 // This should have created a new browser window. 504 // This should have created a new browser window.
(...skipping 16 matching lines...) Expand all
530 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithFirstRunTabs) { 521 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithFirstRunTabs) {
531 #if defined(OS_WIN) && defined(USE_ASH) 522 #if defined(OS_WIN) && defined(USE_ASH)
532 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 523 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
533 if (base::win::GetVersion() >= base::win::VERSION_WIN8) 524 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
534 return; 525 return;
535 #endif 526 #endif
536 527
537 StartupBrowserCreator browser_creator; 528 StartupBrowserCreator browser_creator;
538 browser_creator.AddFirstRunTab(test_server()->GetURL("files/title1.html")); 529 browser_creator.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
539 530
540 // Trick this test into thinking the promo has been shown for this profile; so
541 // that it will show it again (otherwise it skips showing it since
542 // --no-first-run is specified in browser tests).
543 SyncPromoUI::DidShowSyncPromoAtStartup(browser()->profile());
544
545 // The welcome page should not be shown, even if 531 // The welcome page should not be shown, even if
546 // first_run::ShouldShowWelcomePage() says so, when there are already 532 // first_run::ShouldShowWelcomePage() says so, when there are already
547 // more than 2 first run tabs. 533 // more than 2 first run tabs.
548 first_run::SetShouldShowWelcomePage(); 534 first_run::SetShouldShowWelcomePage();
549 535
550 // Do a simple non-process-startup browser launch. 536 // Do a simple non-process-startup browser launch.
551 CommandLine dummy(CommandLine::NO_PROGRAM); 537 CommandLine dummy(CommandLine::NO_PROGRAM);
552 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, 538 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator,
553 chrome::startup::IS_FIRST_RUN); 539 chrome::startup::IS_FIRST_RUN);
554 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, 540 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false,
(...skipping 23 matching lines...) Expand all
578 #if defined(OS_WIN) && defined(USE_ASH) 564 #if defined(OS_WIN) && defined(USE_ASH)
579 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 565 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
580 if (base::win::GetVersion() >= base::win::VERSION_WIN8) 566 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
581 return; 567 return;
582 #endif 568 #endif
583 569
584 StartupBrowserCreator browser_creator; 570 StartupBrowserCreator browser_creator;
585 browser_creator.AddFirstRunTab(test_server()->GetURL("files/title1.html")); 571 browser_creator.AddFirstRunTab(test_server()->GetURL("files/title1.html"));
586 browser_creator.AddFirstRunTab(GURL("http://welcome_page")); 572 browser_creator.AddFirstRunTab(GURL("http://welcome_page"));
587 573
588 // Trick this test into thinking the promo has been shown for this profile; so
589 // that it will show it again (otherwise it skips showing it since
590 // --no-first-run is specified in browser tests).
591 SyncPromoUI::DidShowSyncPromoAtStartup(browser()->profile());
592
593 // Do a simple non-process-startup browser launch. 574 // Do a simple non-process-startup browser launch.
594 CommandLine dummy(CommandLine::NO_PROGRAM); 575 CommandLine dummy(CommandLine::NO_PROGRAM);
595 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, 576 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator,
596 chrome::startup::IS_FIRST_RUN); 577 chrome::startup::IS_FIRST_RUN);
597 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false, 578 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false,
598 browser()->host_desktop_type())); 579 browser()->host_desktop_type()));
599 580
600 // This should have created a new browser window. 581 // This should have created a new browser window.
601 Browser* new_browser = FindOneOtherBrowser(browser()); 582 Browser* new_browser = FindOneOtherBrowser(browser());
602 ASSERT_TRUE(new_browser); 583 ASSERT_TRUE(new_browser);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 ASSERT_EQ(1, tab_strip->count()); 1377 ASSERT_EQ(1, tab_strip->count());
1397 EXPECT_EQ("title1.html", 1378 EXPECT_EQ("title1.html",
1398 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); 1379 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName());
1399 } 1380 }
1400 #endif // defined(ENABLE_CONFIGURATION_POLICY) 1381 #endif // defined(ENABLE_CONFIGURATION_POLICY)
1401 1382
1402 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || 1383 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) ||
1403 // defined(ENABLE_CONFIGURATION_POLICY) 1384 // defined(ENABLE_CONFIGURATION_POLICY)
1404 1385
1405 #endif // !defined(OS_CHROMEOS) 1386 #endif // !defined(OS_CHROMEOS)
OLDNEW
« chrome/browser/first_run/first_run.cc ('K') | « chrome/browser/first_run/first_run.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698