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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/test/histogram_tester.h" | 15 #include "base/test/histogram_tester.h" |
| 16 #include "base/threading/thread_restrictions.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
19 #include "chrome/browser/extensions/extension_browsertest.h" | 20 #include "chrome/browser/extensions/extension_browsertest.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/extension_util.h" | 22 #include "chrome/browser/extensions/extension_util.h" |
22 #include "chrome/browser/extensions/launch_util.h" | 23 #include "chrome/browser/extensions/launch_util.h" |
23 #include "chrome/browser/first_run/first_run.h" | 24 #include "chrome/browser/first_run/first_run.h" |
24 #include "chrome/browser/infobars/infobar_service.h" | 25 #include "chrome/browser/infobars/infobar_service.h" |
25 #include "chrome/browser/lifetime/keep_alive_types.h" | 26 #include "chrome/browser/lifetime/keep_alive_types.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 443 |
443 #if !defined(OS_CHROMEOS) | 444 #if !defined(OS_CHROMEOS) |
444 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, StartupURLsForTwoProfiles) { | 445 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, StartupURLsForTwoProfiles) { |
445 Profile* default_profile = browser()->profile(); | 446 Profile* default_profile = browser()->profile(); |
446 | 447 |
447 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 448 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
448 // Create another profile. | 449 // Create another profile. |
449 base::FilePath dest_path = profile_manager->user_data_dir(); | 450 base::FilePath dest_path = profile_manager->user_data_dir(); |
450 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile 1")); | 451 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile 1")); |
451 | 452 |
452 Profile* other_profile = profile_manager->GetProfile(dest_path); | 453 Profile* other_profile = nullptr; |
| 454 { |
| 455 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 456 other_profile = profile_manager->GetProfile(dest_path); |
| 457 } |
453 ASSERT_TRUE(other_profile); | 458 ASSERT_TRUE(other_profile); |
454 | 459 |
455 // Use a couple arbitrary URLs. | 460 // Use a couple arbitrary URLs. |
456 std::vector<GURL> urls1; | 461 std::vector<GURL> urls1; |
457 urls1.push_back(ui_test_utils::GetTestUrl( | 462 urls1.push_back(ui_test_utils::GetTestUrl( |
458 base::FilePath(base::FilePath::kCurrentDirectory), | 463 base::FilePath(base::FilePath::kCurrentDirectory), |
459 base::FilePath(FILE_PATH_LITERAL("title1.html")))); | 464 base::FilePath(FILE_PATH_LITERAL("title1.html")))); |
460 std::vector<GURL> urls2; | 465 std::vector<GURL> urls2; |
461 urls2.push_back(ui_test_utils::GetTestUrl( | 466 urls2.push_back(ui_test_utils::GetTestUrl( |
462 base::FilePath(base::FilePath::kCurrentDirectory), | 467 base::FilePath(base::FilePath::kCurrentDirectory), |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 // Create 4 more profiles. | 633 // Create 4 more profiles. |
629 base::FilePath dest_path1 = profile_manager->user_data_dir().Append( | 634 base::FilePath dest_path1 = profile_manager->user_data_dir().Append( |
630 FILE_PATH_LITERAL("New Profile 1")); | 635 FILE_PATH_LITERAL("New Profile 1")); |
631 base::FilePath dest_path2 = profile_manager->user_data_dir().Append( | 636 base::FilePath dest_path2 = profile_manager->user_data_dir().Append( |
632 FILE_PATH_LITERAL("New Profile 2")); | 637 FILE_PATH_LITERAL("New Profile 2")); |
633 base::FilePath dest_path3 = profile_manager->user_data_dir().Append( | 638 base::FilePath dest_path3 = profile_manager->user_data_dir().Append( |
634 FILE_PATH_LITERAL("New Profile 3")); | 639 FILE_PATH_LITERAL("New Profile 3")); |
635 base::FilePath dest_path4 = profile_manager->user_data_dir().Append( | 640 base::FilePath dest_path4 = profile_manager->user_data_dir().Append( |
636 FILE_PATH_LITERAL("New Profile 4")); | 641 FILE_PATH_LITERAL("New Profile 4")); |
637 | 642 |
| 643 base::ThreadRestrictions::ScopedAllowIO allow_io; |
638 Profile* profile_home1 = profile_manager->GetProfile(dest_path1); | 644 Profile* profile_home1 = profile_manager->GetProfile(dest_path1); |
639 ASSERT_TRUE(profile_home1); | 645 ASSERT_TRUE(profile_home1); |
640 Profile* profile_home2 = profile_manager->GetProfile(dest_path2); | 646 Profile* profile_home2 = profile_manager->GetProfile(dest_path2); |
641 ASSERT_TRUE(profile_home2); | 647 ASSERT_TRUE(profile_home2); |
642 Profile* profile_last = profile_manager->GetProfile(dest_path3); | 648 Profile* profile_last = profile_manager->GetProfile(dest_path3); |
643 ASSERT_TRUE(profile_last); | 649 ASSERT_TRUE(profile_last); |
644 Profile* profile_urls = profile_manager->GetProfile(dest_path4); | 650 Profile* profile_urls = profile_manager->GetProfile(dest_path4); |
645 ASSERT_TRUE(profile_urls); | 651 ASSERT_TRUE(profile_urls); |
646 | 652 |
647 DisableWelcomePages( | 653 DisableWelcomePages( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 742 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
737 | 743 |
738 // Create 3 profiles. | 744 // Create 3 profiles. |
739 base::FilePath dest_path1 = profile_manager->user_data_dir().Append( | 745 base::FilePath dest_path1 = profile_manager->user_data_dir().Append( |
740 FILE_PATH_LITERAL("New Profile 1")); | 746 FILE_PATH_LITERAL("New Profile 1")); |
741 base::FilePath dest_path2 = profile_manager->user_data_dir().Append( | 747 base::FilePath dest_path2 = profile_manager->user_data_dir().Append( |
742 FILE_PATH_LITERAL("New Profile 2")); | 748 FILE_PATH_LITERAL("New Profile 2")); |
743 base::FilePath dest_path3 = profile_manager->user_data_dir().Append( | 749 base::FilePath dest_path3 = profile_manager->user_data_dir().Append( |
744 FILE_PATH_LITERAL("New Profile 3")); | 750 FILE_PATH_LITERAL("New Profile 3")); |
745 | 751 |
746 Profile* profile_home = profile_manager->GetProfile(dest_path1); | 752 Profile* profile_home = nullptr; |
747 ASSERT_TRUE(profile_home); | 753 Profile* profile_last = nullptr; |
748 Profile* profile_last = profile_manager->GetProfile(dest_path2); | 754 Profile* profile_urls = nullptr; |
749 ASSERT_TRUE(profile_last); | 755 { |
750 Profile* profile_urls = profile_manager->GetProfile(dest_path3); | 756 base::ThreadRestrictions::ScopedAllowIO allow_io; |
751 ASSERT_TRUE(profile_urls); | 757 profile_home = profile_manager->GetProfile(dest_path1); |
| 758 ASSERT_TRUE(profile_home); |
| 759 profile_last = profile_manager->GetProfile(dest_path2); |
| 760 ASSERT_TRUE(profile_last); |
| 761 profile_urls = profile_manager->GetProfile(dest_path3); |
| 762 ASSERT_TRUE(profile_urls); |
| 763 } |
752 | 764 |
753 // Set the profiles to open the home page, last visited pages or URLs. | 765 // Set the profiles to open the home page, last visited pages or URLs. |
754 SessionStartupPref pref_home(SessionStartupPref::DEFAULT); | 766 SessionStartupPref pref_home(SessionStartupPref::DEFAULT); |
755 SessionStartupPref::SetStartupPref(profile_home, pref_home); | 767 SessionStartupPref::SetStartupPref(profile_home, pref_home); |
756 | 768 |
757 SessionStartupPref pref_last(SessionStartupPref::LAST); | 769 SessionStartupPref pref_last(SessionStartupPref::LAST); |
758 SessionStartupPref::SetStartupPref(profile_last, pref_last); | 770 SessionStartupPref::SetStartupPref(profile_last, pref_last); |
759 | 771 |
760 std::vector<GURL> urls; | 772 std::vector<GURL> urls; |
761 urls.push_back(ui_test_utils::GetTestUrl( | 773 urls.push_back(ui_test_utils::GetTestUrl( |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 #define MAYBE_WelcomePages WelcomePages | 1072 #define MAYBE_WelcomePages WelcomePages |
1061 #endif | 1073 #endif |
1062 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, MAYBE_WelcomePages) { | 1074 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, MAYBE_WelcomePages) { |
1063 ASSERT_TRUE(embedded_test_server()->Start()); | 1075 ASSERT_TRUE(embedded_test_server()->Start()); |
1064 | 1076 |
1065 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1077 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1066 | 1078 |
1067 // Open the two profiles. | 1079 // Open the two profiles. |
1068 base::FilePath dest_path = profile_manager->user_data_dir(); | 1080 base::FilePath dest_path = profile_manager->user_data_dir(); |
1069 | 1081 |
1070 Profile* profile1 = Profile::CreateProfile( | 1082 Profile* profile1 = nullptr; |
1071 dest_path.Append(FILE_PATH_LITERAL("New Profile 1")), nullptr, | 1083 { |
1072 Profile::CreateMode::CREATE_MODE_SYNCHRONOUS); | 1084 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 1085 profile1 = Profile::CreateProfile( |
| 1086 dest_path.Append(FILE_PATH_LITERAL("New Profile 1")), nullptr, |
| 1087 Profile::CreateMode::CREATE_MODE_SYNCHRONOUS); |
| 1088 } |
1073 ASSERT_TRUE(profile1); | 1089 ASSERT_TRUE(profile1); |
1074 profile_manager->RegisterTestingProfile(profile1, true, false); | 1090 profile_manager->RegisterTestingProfile(profile1, true, false); |
1075 | 1091 |
1076 Browser* browser = OpenNewBrowser(profile1); | 1092 Browser* browser = OpenNewBrowser(profile1); |
1077 ASSERT_TRUE(browser); | 1093 ASSERT_TRUE(browser); |
1078 | 1094 |
1079 TabStripModel* tab_strip = browser->tab_strip_model(); | 1095 TabStripModel* tab_strip = browser->tab_strip_model(); |
1080 | 1096 |
1081 // Windows 10 has its own Welcome page; the standard Welcome page does not | 1097 // Windows 10 has its own Welcome page; the standard Welcome page does not |
1082 // appear until second run. | 1098 // appear until second run. |
(...skipping 17 matching lines...) Expand all Loading... |
1100 ASSERT_TRUE(browser); | 1116 ASSERT_TRUE(browser); |
1101 tab_strip = browser->tab_strip_model(); | 1117 tab_strip = browser->tab_strip_model(); |
1102 | 1118 |
1103 // Ensure that the new tab page appears on subsequent runs. | 1119 // Ensure that the new tab page appears on subsequent runs. |
1104 ASSERT_EQ(1, tab_strip->count()); | 1120 ASSERT_EQ(1, tab_strip->count()); |
1105 EXPECT_EQ("chrome://newtab/", | 1121 EXPECT_EQ("chrome://newtab/", |
1106 tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec()); | 1122 tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec()); |
1107 } | 1123 } |
1108 | 1124 |
1109 #endif // !defined(OS_CHROMEOS) | 1125 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |