OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/profile_menu_controller.h" |
6 | 6 |
7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
8 #include "chrome/browser/profiles/avatar_menu_model.h" | 8 #include "chrome/browser/profiles/avatar_menu_model.h" |
9 #include "chrome/browser/ui/browser_list.h" | 9 #include "chrome/browser/ui/browser_list.h" |
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
11 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 11 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
| 12 #include "chrome/test/base/test_browser_window.h" |
12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
13 #include "testing/gtest_mac.h" | 14 #include "testing/gtest_mac.h" |
14 #include "ui/base/l10n/l10n_util_mac.h" | 15 #include "ui/base/l10n/l10n_util_mac.h" |
15 | 16 |
16 class ProfileMenuControllerTest : public CocoaProfileTest { | 17 class ProfileMenuControllerTest : public CocoaProfileTest { |
17 public: | 18 public: |
18 ProfileMenuControllerTest() { | 19 ProfileMenuControllerTest() { |
19 item_.reset([[NSMenuItem alloc] initWithTitle:@"Users" | 20 item_.reset([[NSMenuItem alloc] initWithTitle:@"Users" |
20 action:nil | 21 action:nil |
21 keyEquivalent:@""]); | 22 keyEquivalent:@""]); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // BrowserWindow::Show() and when a Browser becomes active. We don't need a full | 133 // BrowserWindow::Show() and when a Browser becomes active. We don't need a full |
133 // BrowserWindow, so it is called manually. | 134 // BrowserWindow, so it is called manually. |
134 TEST_F(ProfileMenuControllerTest, SetActiveAndRemove) { | 135 TEST_F(ProfileMenuControllerTest, SetActiveAndRemove) { |
135 NSMenu* menu = [controller() menu]; | 136 NSMenu* menu = [controller() menu]; |
136 TestingProfileManager* manager = testing_profile_manager(); | 137 TestingProfileManager* manager = testing_profile_manager(); |
137 TestingProfile* profile2 = manager->CreateTestingProfile("Profile 2"); | 138 TestingProfile* profile2 = manager->CreateTestingProfile("Profile 2"); |
138 TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3"); | 139 TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3"); |
139 ASSERT_EQ(7, [menu numberOfItems]); | 140 ASSERT_EQ(7, [menu numberOfItems]); |
140 | 141 |
141 // Create a browser and "show" it. | 142 // Create a browser and "show" it. |
142 scoped_ptr<Browser> p2_browser(new Browser(Browser::TYPE_TABBED, profile2)); | 143 scoped_ptr<Browser> p2_browser( |
| 144 chrome::CreateBrowserWithTestWindowForProfile(profile2)); |
143 BrowserList::SetLastActive(p2_browser.get()); | 145 BrowserList::SetLastActive(p2_browser.get()); |
144 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); | 146 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); |
145 | 147 |
146 // Close the browser and make sure it's still active. | 148 // Close the browser and make sure it's still active. |
147 p2_browser.reset(); | 149 p2_browser.reset(); |
148 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); | 150 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); |
149 | 151 |
150 // Open a new browser and make sure it takes effect. | 152 // Open a new browser and make sure it takes effect. |
151 scoped_ptr<Browser> p3_browser(new Browser(Browser::TYPE_TABBED, profile3)); | 153 scoped_ptr<Browser> p3_browser( |
| 154 chrome::CreateBrowserWithTestWindowForProfile(profile3)); |
152 BrowserList::SetLastActive(p3_browser.get()); | 155 BrowserList::SetLastActive(p3_browser.get()); |
153 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); | 156 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); |
154 | 157 |
155 p3_browser.reset(); | 158 p3_browser.reset(); |
156 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); | 159 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); |
157 } | 160 } |
OLD | NEW |