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

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

Issue 1078713002: Supervised users: Re-check ManagementPolicy when ProfileIsSupervised changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shaving the yak Created 5 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/profiles/profile_menu_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 TEST_F(ProfileMenuControllerTest, SupervisedProfile) { 247 TEST_F(ProfileMenuControllerTest, SupervisedProfile) {
248 TestingProfileManager* manager = testing_profile_manager(); 248 TestingProfileManager* manager = testing_profile_manager();
249 TestingProfile* supervised_profile = 249 TestingProfile* supervised_profile =
250 manager->CreateTestingProfile("test1", 250 manager->CreateTestingProfile("test1",
251 scoped_ptr<PrefServiceSyncable>(), 251 scoped_ptr<PrefServiceSyncable>(),
252 base::ASCIIToUTF16("Supervised User"), 252 base::ASCIIToUTF16("Supervised User"),
253 0, 253 0,
254 "TEST_ID", 254 "TEST_ID",
255 TestingProfile::TestingFactories()); 255 TestingProfile::TestingFactories());
256 // The supervised profile is initially marked as omitted from the avatar menu
257 // (in non-test code, until we have confirmation that it has actually been
258 // created on the server). For the test, just tell the cache to un-hide it.
259 ProfileInfoCache* cache = manager->profile_info_cache();
260 size_t index =
261 cache->GetIndexOfProfileWithPath(supervised_profile->GetPath());
262 cache->SetIsOmittedProfileAtIndex(index, false);
263
256 BrowserList::SetLastActive(browser()); 264 BrowserList::SetLastActive(browser());
257 265
258 NSMenu* menu = [controller() menu]; 266 NSMenu* menu = [controller() menu];
267 // Person 1, Supervised User, <sep>, Edit, <sep>, New.
259 ASSERT_EQ(6, [menu numberOfItems]); 268 ASSERT_EQ(6, [menu numberOfItems]);
269
260 NSMenuItem* item = [menu itemAtIndex:0]; 270 NSMenuItem* item = [menu itemAtIndex:0];
261 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); 271 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]);
262 EXPECT_TRUE([controller() validateMenuItem:item]); 272 EXPECT_TRUE([controller() validateMenuItem:item]);
263 273
264 item = [menu itemAtIndex:1]; 274 item = [menu itemAtIndex:1];
265 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); 275 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]);
266 EXPECT_TRUE([controller() validateMenuItem:item]); 276 EXPECT_TRUE([controller() validateMenuItem:item]);
267 277
268 item = [menu itemAtIndex:5]; 278 item = [menu itemAtIndex:5];
269 ASSERT_EQ(@selector(newProfile:), [item action]); 279 ASSERT_EQ(@selector(newProfile:), [item action]);
(...skipping 11 matching lines...) Expand all
281 EXPECT_FALSE([controller() validateMenuItem:item]); 291 EXPECT_FALSE([controller() validateMenuItem:item]);
282 292
283 item = [menu itemAtIndex:1]; 293 item = [menu itemAtIndex:1];
284 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); 294 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]);
285 EXPECT_TRUE([controller() validateMenuItem:item]); 295 EXPECT_TRUE([controller() validateMenuItem:item]);
286 296
287 item = [menu itemAtIndex:5]; 297 item = [menu itemAtIndex:5];
288 ASSERT_EQ(@selector(newProfile:), [item action]); 298 ASSERT_EQ(@selector(newProfile:), [item action]);
289 EXPECT_FALSE([controller() validateMenuItem:item]); 299 EXPECT_FALSE([controller() validateMenuItem:item]);
290 } 300 }
OLDNEW
« no previous file with comments | « chrome/browser/supervised_user/supervised_user_service.cc ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698