OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/threading/thread_restrictions.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/prefs/session_startup_pref.h" | 13 #include "chrome/browser/prefs/session_startup_pref.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/sessions/session_restore.h" | 15 #include "chrome/browser/sessions/session_restore.h" |
15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 19 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
23 | 24 |
24 typedef InProcessBrowserTest StartupBrowserCreatorTest; | 25 typedef InProcessBrowserTest StartupBrowserCreatorTest; |
25 | 26 |
26 // Chrome OS doesn't support multiprofile. | 27 // Chrome OS doesn't support multiprofile. |
27 // And BrowserWindow::IsActive() always returns false in tests on MAC. | 28 // And BrowserWindow::IsActive() always returns false in tests on MAC. |
28 // And this test is useless without that functionality. | 29 // And this test is useless without that functionality. |
29 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX) | 30 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX) |
30 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, LastUsedProfileActivated) { | 31 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, LastUsedProfileActivated) { |
| 32 base::ThreadRestrictions::ScopedAllowIO allow_io; |
31 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 33 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
32 | 34 |
33 // Create 4 profiles, they will be scheduled for destruction when the last | 35 // Create 4 profiles, they will be scheduled for destruction when the last |
34 // browser window they are associated to will be closed. | 36 // browser window they are associated to will be closed. |
35 Profile* profile_1 = profile_manager->GetProfile( | 37 Profile* profile_1 = profile_manager->GetProfile( |
36 profile_manager->user_data_dir().Append(FILE_PATH_LITERAL( | 38 profile_manager->user_data_dir().Append(FILE_PATH_LITERAL( |
37 "New Profile 1"))); | 39 "New Profile 1"))); |
38 ASSERT_TRUE(profile_1); | 40 ASSERT_TRUE(profile_1); |
39 Profile* profile_2 = profile_manager->GetProfile( | 41 Profile* profile_2 = profile_manager->GetProfile( |
40 profile_manager->user_data_dir().Append(FILE_PATH_LITERAL( | 42 profile_manager->user_data_dir().Append(FILE_PATH_LITERAL( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 new_browser = chrome::FindBrowserWithProfile(profile_3); | 93 new_browser = chrome::FindBrowserWithProfile(profile_3); |
92 ASSERT_TRUE(new_browser); | 94 ASSERT_TRUE(new_browser); |
93 EXPECT_FALSE(new_browser->window()->IsActive()); | 95 EXPECT_FALSE(new_browser->window()->IsActive()); |
94 | 96 |
95 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_4)); | 97 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_4)); |
96 new_browser = chrome::FindBrowserWithProfile(profile_4); | 98 new_browser = chrome::FindBrowserWithProfile(profile_4); |
97 ASSERT_TRUE(new_browser); | 99 ASSERT_TRUE(new_browser); |
98 EXPECT_FALSE(new_browser->window()->IsActive()); | 100 EXPECT_FALSE(new_browser->window()->IsActive()); |
99 } | 101 } |
100 #endif // !OS_MACOSX && !OS_CHROMEOS | 102 #endif // !OS_MACOSX && !OS_CHROMEOS |
OLD | NEW |