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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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/avatar_menu_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
6 6
7 #include <memory>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_pump_mac.h" 11 #include "base/message_loop/message_pump_mac.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/profiles/avatar_menu.h" 13 #include "chrome/browser/profiles/avatar_menu.h"
13 #include "chrome/browser/profiles/avatar_menu_observer.h" 14 #include "chrome/browser/profiles/avatar_menu_observer.h"
14 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 15 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
15 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
16 #include "chrome/test/base/testing_profile_manager.h" 17 #include "chrome/test/base/testing_profile_manager.h"
17 #include "components/signin/core/common/profile_management_switches.h" 18 #include "components/signin/core/common/profile_management_switches.h"
18 #include "components/syncable_prefs/pref_service_syncable.h" 19 #include "components/syncable_prefs/pref_service_syncable.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "testing/gtest_mac.h" 21 #include "testing/gtest_mac.h"
21 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" 22 #import "ui/base/cocoa/controls/hyperlink_button_cell.h"
22 #include "ui/events/test/cocoa_test_event_utils.h" 23 #include "ui/events/test/cocoa_test_event_utils.h"
23 24
24 class AvatarMenuBubbleControllerTest : public CocoaTest { 25 class AvatarMenuBubbleControllerTest : public CocoaTest {
25 public: 26 public:
26 AvatarMenuBubbleControllerTest() 27 AvatarMenuBubbleControllerTest()
27 : manager_(TestingBrowserProcess::GetGlobal()) { 28 : manager_(TestingBrowserProcess::GetGlobal()) {
28 } 29 }
29 30
30 void SetUp() override { 31 void SetUp() override {
31 CocoaTest::SetUp(); 32 CocoaTest::SetUp();
32 ASSERT_TRUE(manager_.SetUp()); 33 ASSERT_TRUE(manager_.SetUp());
33 34
34 manager_.CreateTestingProfile( 35 manager_.CreateTestingProfile(
35 "test1", scoped_ptr<syncable_prefs::PrefServiceSyncable>(), 36 "test1", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(),
36 base::ASCIIToUTF16("Test 1"), 1, std::string(), 37 base::ASCIIToUTF16("Test 1"), 1, std::string(),
37 TestingProfile::TestingFactories()); 38 TestingProfile::TestingFactories());
38 manager_.CreateTestingProfile( 39 manager_.CreateTestingProfile(
39 "test2", scoped_ptr<syncable_prefs::PrefServiceSyncable>(), 40 "test2", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(),
40 base::ASCIIToUTF16("Test 2"), 0, std::string(), 41 base::ASCIIToUTF16("Test 2"), 0, std::string(),
41 TestingProfile::TestingFactories()); 42 TestingProfile::TestingFactories());
42 43
43 menu_ = new AvatarMenu(manager_.profile_attributes_storage(), NULL, NULL); 44 menu_ = new AvatarMenu(manager_.profile_attributes_storage(), NULL, NULL);
44 menu_->RebuildMenu(); 45 menu_->RebuildMenu();
45 46
46 NSRect frame = [test_window() frame]; 47 NSRect frame = [test_window() frame];
47 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); 48 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame));
48 controller_ = 49 controller_ =
49 [[AvatarMenuBubbleController alloc] initWithMenu:menu() 50 [[AvatarMenuBubbleController alloc] initWithMenu:menu()
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) { 123 TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) {
123 [controller() showWindow:nil]; 124 [controller() showWindow:nil];
124 125
125 NSView* contents = [[controller() window] contentView]; 126 NSView* contents = [[controller() window] contentView];
126 EXPECT_EQ(4U, [[contents subviews] count]); 127 EXPECT_EQ(4U, [[contents subviews] count]);
127 128
128 base::scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]); 129 base::scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]);
129 130
130 // Now create a new profile and notify the delegate. 131 // Now create a new profile and notify the delegate.
131 manager()->CreateTestingProfile( 132 manager()->CreateTestingProfile(
132 "test3", scoped_ptr<syncable_prefs::PrefServiceSyncable>(), 133 "test3", std::unique_ptr<syncable_prefs::PrefServiceSyncable>(),
133 base::ASCIIToUTF16("Test 3"), 0, std::string(), 134 base::ASCIIToUTF16("Test 3"), 0, std::string(),
134 TestingProfile::TestingFactories()); 135 TestingProfile::TestingFactories());
135 136
136 // Testing the bridge is not worth the effort... 137 // Testing the bridge is not worth the effort...
137 [controller() performLayout]; 138 [controller() performLayout];
138 139
139 EXPECT_EQ(5U, [[contents subviews] count]); 140 EXPECT_EQ(5U, [[contents subviews] count]);
140 141
141 // Make sure that none of the old items exit. 142 // Make sure that none of the old items exit.
142 NSArray* newItems = [controller() items]; 143 NSArray* newItems = [controller() items];
143 for (AvatarMenuItemController* oldVC in oldItems.get()) { 144 for (AvatarMenuItemController* oldVC in oldItems.get()) {
144 EXPECT_FALSE([newItems containsObject:oldVC]); 145 EXPECT_FALSE([newItems containsObject:oldVC]);
145 EXPECT_FALSE([[contents subviews] containsObject:[oldVC view]]); 146 EXPECT_FALSE([[contents subviews] containsObject:[oldVC view]]);
146 } 147 }
147 148
148 [controller() close]; 149 [controller() close];
149 } 150 }
150 151
151 // This subclass is used to inject a delegate into the hide/show edit link 152 // This subclass is used to inject a delegate into the hide/show edit link
152 // animation. 153 // animation.
153 @interface TestingAvatarMenuItemController : AvatarMenuItemController 154 @interface TestingAvatarMenuItemController : AvatarMenuItemController
154 <NSAnimationDelegate> { 155 <NSAnimationDelegate> {
155 @private 156 @private
156 scoped_ptr<base::MessagePumpNSRunLoop> pump_; 157 std::unique_ptr<base::MessagePumpNSRunLoop> pump_;
157 } 158 }
158 // After calling |-highlightForEventType:| an animation will possibly be 159 // After calling |-highlightForEventType:| an animation will possibly be
159 // started. Since the animation is non-blocking, the run loop will need to be 160 // started. Since the animation is non-blocking, the run loop will need to be
160 // spun (via the MessagePump) until the animation has finished. 161 // spun (via the MessagePump) until the animation has finished.
161 - (void)runMessagePump; 162 - (void)runMessagePump;
162 @end 163 @end
163 164
164 @implementation TestingAvatarMenuItemController 165 @implementation TestingAvatarMenuItemController
165 - (void)runMessagePump { 166 - (void)runMessagePump {
166 if (!pump_) 167 if (!pump_)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 [controller() keyDown:event]; 265 [controller() keyDown:event];
265 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem()); 266 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem());
266 267
267 [controller() keyDown:event]; 268 [controller() keyDown:event];
268 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 269 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
269 270
270 // There are no more items now so going up should stay at the first item. 271 // There are no more items now so going up should stay at the first item.
271 [controller() keyDown:event]; 272 [controller() keyDown:event];
272 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 273 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
273 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698