OLD | NEW |
---|---|
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/command_line.h" | |
7 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/prefs/pref_service_syncable.h" | 12 #include "chrome/browser/prefs/pref_service_syncable.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
15 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 16 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
18 #include "chrome/test/base/test_browser_window.h" | 19 #include "chrome/test/base/test_browser_window.h" |
19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
21 #include "components/signin/core/common/profile_management_switches.h" | |
20 #include "testing/gtest_mac.h" | 22 #include "testing/gtest_mac.h" |
21 #include "ui/base/l10n/l10n_util_mac.h" | 23 #include "ui/base/l10n/l10n_util_mac.h" |
22 | 24 |
23 class ProfileMenuControllerTest : public CocoaProfileTest { | 25 class ProfileMenuControllerTest : public CocoaProfileTest { |
24 public: | 26 public: |
25 ProfileMenuControllerTest() { | 27 ProfileMenuControllerTest() { |
26 item_.reset([[NSMenuItem alloc] initWithTitle:@"Users" | 28 item_.reset([[NSMenuItem alloc] initWithTitle:@"Users" |
27 action:nil | 29 action:nil |
28 keyEquivalent:@""]); | 30 keyEquivalent:@""]); |
29 controller_.reset( | 31 controller_.reset( |
30 [[ProfileMenuController alloc] initWithMainMenuItem:item_]); | 32 [[ProfileMenuController alloc] initWithMainMenuItem:item_]); |
31 } | 33 } |
32 | 34 |
33 void SetUp() override { | 35 void SetUp() override { |
36 switches::DisableNewAvatarMenuForTesting( | |
noms (inactive)
2015/03/09 19:26:17
Why are we disabling the flag? This is the os menu
Mike Lerman
2015/03/10 15:58:58
Is it? Oh. Trying to count the numbers of items in
noms (inactive)
2015/03/17 14:26:30
At the moment for one profile, it's showing up in
Mike Lerman
2015/03/18 19:29:48
Okay, good. I'll leave it Enabled then.
| |
37 base::CommandLine::ForCurrentProcess()); | |
34 CocoaProfileTest::SetUp(); | 38 CocoaProfileTest::SetUp(); |
35 ASSERT_TRUE(profile()); | 39 ASSERT_TRUE(profile()); |
36 | 40 |
37 // Spin the runloop so |-initializeMenu| gets called. | 41 // Spin the runloop so |-initializeMenu| gets called. |
38 chrome::testing::NSRunLoopRunAllPending(); | 42 chrome::testing::NSRunLoopRunAllPending(); |
39 } | 43 } |
40 | 44 |
41 void TestBottomItems() { | 45 void TestBottomItems() { |
42 NSMenu* menu = [controller() menu]; | 46 NSMenu* menu = [controller() menu]; |
43 NSInteger count = [menu numberOfItems]; | 47 NSInteger count = [menu numberOfItems]; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 EXPECT_FALSE([controller() validateMenuItem:item]); | 285 EXPECT_FALSE([controller() validateMenuItem:item]); |
282 | 286 |
283 item = [menu itemAtIndex:1]; | 287 item = [menu itemAtIndex:1]; |
284 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); | 288 ASSERT_EQ(@selector(switchToProfileFromMenu:), [item action]); |
285 EXPECT_TRUE([controller() validateMenuItem:item]); | 289 EXPECT_TRUE([controller() validateMenuItem:item]); |
286 | 290 |
287 item = [menu itemAtIndex:5]; | 291 item = [menu itemAtIndex:5]; |
288 ASSERT_EQ(@selector(newProfile:), [item action]); | 292 ASSERT_EQ(@selector(newProfile:), [item action]); |
289 EXPECT_FALSE([controller() validateMenuItem:item]); | 293 EXPECT_FALSE([controller() validateMenuItem:item]); |
290 } | 294 } |
OLD | NEW |