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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/profiles/avatar_menu.h" | 8 #include "chrome/browser/profiles/avatar_menu.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/profiles/profile_window.h" |
10 #include "chrome/browser/profiles/profiles_state.h" | 11 #include "chrome/browser/profiles/profiles_state.h" |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_dialogs.h" |
12 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
15 #include "chrome/test/base/test_switches.h" | 17 #include "chrome/test/base/test_switches.h" |
16 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
17 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 // An observer that returns back to test code after a new profile is | 23 // An observer that returns back to test code after a new profile is |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 menu->RebuildMenu(); | 62 menu->RebuildMenu(); |
61 | 63 |
62 BrowserList* browser_list = | 64 BrowserList* browser_list = |
63 BrowserList::GetInstance(chrome::GetActiveDesktop()); | 65 BrowserList::GetInstance(chrome::GetActiveDesktop()); |
64 EXPECT_EQ(1U, browser_list->size()); | 66 EXPECT_EQ(1U, browser_list->size()); |
65 content::WindowedNotificationObserver window_close_observer( | 67 content::WindowedNotificationObserver window_close_observer( |
66 chrome::NOTIFICATION_BROWSER_CLOSED, | 68 chrome::NOTIFICATION_BROWSER_CLOSED, |
67 content::Source<Browser>(browser())); | 69 content::Source<Browser>(browser())); |
68 | 70 |
69 EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index)); | 71 EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index)); |
70 menu->SetLogoutURL("about:blank"); | 72 profiles::LockProfile(current_profile); |
71 menu->BeginSignOut(); | 73 window_close_observer.Wait(); // rely on test time-out for failure indication |
| 74 |
72 EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(index)); | 75 EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(index)); |
| 76 EXPECT_EQ(0U, browser_list->size()); |
73 | 77 |
74 window_close_observer.Wait(); // rely on test time-out for failure indication | 78 // Signing out brings up the User Manager which we should close before exit. |
75 EXPECT_EQ(0U, browser_list->size()); | 79 chrome::HideUserManager(); |
76 } | 80 } |
77 | 81 |
78 IN_PROC_BROWSER_TEST_F(ProfileListDesktopBrowserTest, SwitchToProfile) { | 82 IN_PROC_BROWSER_TEST_F(ProfileListDesktopBrowserTest, SwitchToProfile) { |
79 #if defined(OS_WIN) && defined(USE_ASH) | 83 #if defined(OS_WIN) && defined(USE_ASH) |
80 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 84 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
81 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 85 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
82 return; | 86 return; |
83 #endif | 87 #endif |
84 | 88 |
85 if (!profiles::IsMultipleProfilesEnabled()) | 89 if (!profiles::IsMultipleProfilesEnabled()) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Open a browser window for the second profile. | 122 // Open a browser window for the second profile. |
119 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile2), false); | 123 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile2), false); |
120 EXPECT_EQ(2U, browser_list->size()); | 124 EXPECT_EQ(2U, browser_list->size()); |
121 | 125 |
122 // Switch to the first profile without opening a new window. | 126 // Switch to the first profile without opening a new window. |
123 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), false); | 127 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), false); |
124 EXPECT_EQ(2U, browser_list->size()); | 128 EXPECT_EQ(2U, browser_list->size()); |
125 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 129 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
126 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 130 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
127 } | 131 } |
OLD | NEW |