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

Side by Side Diff: chrome/browser/ui/cocoa/profile_menu_controller_unittest.mm

Issue 16174003: Make all tests use GetActiveDesktop() instead of hardcoding HOST_DESKTOP_TYPE_NATIVE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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) 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 "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "chrome/browser/profiles/avatar_menu_model.h" 9 #include "chrome/browser/profiles/avatar_menu_model.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // BrowserWindow::Show() and when a Browser becomes active. We don't need a full 190 // BrowserWindow::Show() and when a Browser becomes active. We don't need a full
191 // BrowserWindow, so it is called manually. 191 // BrowserWindow, so it is called manually.
192 TEST_F(ProfileMenuControllerTest, SetActiveAndRemove) { 192 TEST_F(ProfileMenuControllerTest, SetActiveAndRemove) {
193 NSMenu* menu = [controller() menu]; 193 NSMenu* menu = [controller() menu];
194 TestingProfileManager* manager = testing_profile_manager(); 194 TestingProfileManager* manager = testing_profile_manager();
195 TestingProfile* profile2 = manager->CreateTestingProfile("Profile 2"); 195 TestingProfile* profile2 = manager->CreateTestingProfile("Profile 2");
196 TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3"); 196 TestingProfile* profile3 = manager->CreateTestingProfile("Profile 3");
197 ASSERT_EQ(7, [menu numberOfItems]); 197 ASSERT_EQ(7, [menu numberOfItems]);
198 198
199 // Create a browser and "show" it. 199 // Create a browser and "show" it.
200 Browser::CreateParams profile2_params(profile2, 200 Browser::CreateParams profile2_params(profile2, chrome::GetActiveDesktop());
201 chrome::HOST_DESKTOP_TYPE_NATIVE);
202 scoped_ptr<Browser> p2_browser( 201 scoped_ptr<Browser> p2_browser(
203 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); 202 chrome::CreateBrowserWithTestWindowForParams(&profile2_params));
204 BrowserList::SetLastActive(p2_browser.get()); 203 BrowserList::SetLastActive(p2_browser.get());
205 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); 204 VerifyProfileNamedIsActive(@"Profile 2", __LINE__);
206 205
207 // Close the browser and make sure it's still active. 206 // Close the browser and make sure it's still active.
208 p2_browser.reset(); 207 p2_browser.reset();
209 VerifyProfileNamedIsActive(@"Profile 2", __LINE__); 208 VerifyProfileNamedIsActive(@"Profile 2", __LINE__);
210 209
211 // Open a new browser and make sure it takes effect. 210 // Open a new browser and make sure it takes effect.
212 Browser::CreateParams profile3_params(profile3, 211 Browser::CreateParams profile3_params(profile3, chrome::GetActiveDesktop());
213 chrome::HOST_DESKTOP_TYPE_NATIVE);
214 scoped_ptr<Browser> p3_browser( 212 scoped_ptr<Browser> p3_browser(
215 chrome::CreateBrowserWithTestWindowForParams(&profile3_params)); 213 chrome::CreateBrowserWithTestWindowForParams(&profile3_params));
216 BrowserList::SetLastActive(p3_browser.get()); 214 BrowserList::SetLastActive(p3_browser.get());
217 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); 215 VerifyProfileNamedIsActive(@"Profile 3", __LINE__);
218 216
219 p3_browser.reset(); 217 p3_browser.reset();
220 VerifyProfileNamedIsActive(@"Profile 3", __LINE__); 218 VerifyProfileNamedIsActive(@"Profile 3", __LINE__);
221 } 219 }
222 220
223 TEST_F(ProfileMenuControllerTest, DeleteActiveProfile) { 221 TEST_F(ProfileMenuControllerTest, DeleteActiveProfile) {
(...skipping 12 matching lines...) Expand all
236 local_state->SetString(prefs::kProfileLastUsed, 234 local_state->SetString(prefs::kProfileLastUsed,
237 profile3_path.BaseName().MaybeAsASCII()); 235 profile3_path.BaseName().MaybeAsASCII());
238 236
239 // Simulate the active browser changing to NULL and ensure a profile doesn't 237 // Simulate the active browser changing to NULL and ensure a profile doesn't
240 // get created by disallowing IO operations temporarily. 238 // get created by disallowing IO operations temporarily.
241 const bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(false); 239 const bool io_was_allowed = base::ThreadRestrictions::SetIOAllowed(false);
242 [controller() activeBrowserChangedTo:NULL]; 240 [controller() activeBrowserChangedTo:NULL];
243 base::ThreadRestrictions::SetIOAllowed(io_was_allowed); 241 base::ThreadRestrictions::SetIOAllowed(io_was_allowed);
244 } 242 }
245 243
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698