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

Side by Side Diff: trunk/src/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm

Issue 17068004: Revert 207755 "Add device policies to control accessibility sett..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/avatar_menu_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h"
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/memory/scoped_nsobject.h"
8 #include "base/message_loop/message_pump_mac.h" 8 #include "base/message_loop/message_pump_mac.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/prefs/pref_service_syncable.h"
11 #include "chrome/browser/profiles/avatar_menu_model.h" 10 #include "chrome/browser/profiles/avatar_menu_model.h"
12 #include "chrome/browser/profiles/avatar_menu_model_observer.h" 11 #include "chrome/browser/profiles/avatar_menu_model_observer.h"
13 #include "chrome/browser/profiles/profile_info_cache.h" 12 #include "chrome/browser/profiles/profile_info_cache.h"
14 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 13 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
15 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" 14 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h"
16 #include "chrome/test/base/testing_browser_process.h" 15 #include "chrome/test/base/testing_browser_process.h"
17 #include "chrome/test/base/testing_profile_manager.h" 16 #include "chrome/test/base/testing_profile_manager.h"
18 #include "testing/gtest_mac.h" 17 #include "testing/gtest_mac.h"
19 #include "ui/base/test/cocoa_test_event_utils.h" 18 #include "ui/base/test/cocoa_test_event_utils.h"
20 19
21 class AvatarMenuBubbleControllerTest : public CocoaTest { 20 class AvatarMenuBubbleControllerTest : public CocoaTest {
22 public: 21 public:
23 AvatarMenuBubbleControllerTest() 22 AvatarMenuBubbleControllerTest()
24 : manager_(TestingBrowserProcess::GetGlobal()) { 23 : manager_(TestingBrowserProcess::GetGlobal()) {
25 } 24 }
26 25
27 virtual void SetUp() { 26 virtual void SetUp() {
28 CocoaTest::SetUp(); 27 CocoaTest::SetUp();
29 ASSERT_TRUE(manager_.SetUp()); 28 ASSERT_TRUE(manager_.SetUp());
30 29
31 manager_.CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(), 30 manager_.CreateTestingProfile("test1", ASCIIToUTF16("Test 1"), 1);
32 ASCIIToUTF16("Test 1"), 1); 31 manager_.CreateTestingProfile("test2", ASCIIToUTF16("Test 2"), 0);
33 manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(),
34 ASCIIToUTF16("Test 2"), 0);
35 32
36 model_ = new AvatarMenuModel(manager_.profile_info_cache(), NULL, NULL); 33 model_ = new AvatarMenuModel(manager_.profile_info_cache(), NULL, NULL);
37 34
38 NSRect frame = [test_window() frame]; 35 NSRect frame = [test_window() frame];
39 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); 36 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame));
40 controller_ = 37 controller_ =
41 [[AvatarMenuBubbleController alloc] initWithModel:model() 38 [[AvatarMenuBubbleController alloc] initWithModel:model()
42 parentWindow:test_window() 39 parentWindow:test_window()
43 anchoredAt:point]; 40 anchoredAt:point];
44 } 41 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 109
113 TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) { 110 TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) {
114 [controller() showWindow:nil]; 111 [controller() showWindow:nil];
115 112
116 NSView* contents = [[controller() window] contentView]; 113 NSView* contents = [[controller() window] contentView];
117 EXPECT_EQ(4U, [[contents subviews] count]); 114 EXPECT_EQ(4U, [[contents subviews] count]);
118 115
119 scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]); 116 scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]);
120 117
121 // Now create a new profile and notify the delegate. 118 // Now create a new profile and notify the delegate.
122 manager()->CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(), 119 manager()->CreateTestingProfile("test3", ASCIIToUTF16("Test 3"), 0);
123 ASCIIToUTF16("Test 3"), 0);
124 120
125 // Testing the bridge is not worth the effort... 121 // Testing the bridge is not worth the effort...
126 [controller() performLayout]; 122 [controller() performLayout];
127 123
128 EXPECT_EQ(5U, [[contents subviews] count]); 124 EXPECT_EQ(5U, [[contents subviews] count]);
129 125
130 // Make sure that none of the old items exit. 126 // Make sure that none of the old items exit.
131 NSArray* newItems = [controller() items]; 127 NSArray* newItems = [controller() items];
132 for (AvatarMenuItemController* oldVC in oldItems.get()) { 128 for (AvatarMenuItemController* oldVC in oldItems.get()) {
133 EXPECT_FALSE([newItems containsObject:oldVC]); 129 EXPECT_FALSE([newItems containsObject:oldVC]);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 [controller() keyDown:event]; 249 [controller() keyDown:event];
254 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem()); 250 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem());
255 251
256 [controller() keyDown:event]; 252 [controller() keyDown:event];
257 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 253 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
258 254
259 // There are no more items now so going up should stay at the first item. 255 // There are no more items now so going up should stay at the first item.
260 [controller() keyDown:event]; 256 [controller() keyDown:event];
261 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 257 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
262 } 258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698