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

Side by Side Diff: ui/message_center/cocoa/notification_controller_unittest.mm

Issue 117983002: Prefix string16 with base:: in ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/message_center/cocoa/notification_controller.h" 5 #import "ui/message_center/cocoa/notification_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 }; 108 };
109 109
110 TEST_F(NotificationControllerTest, BasicLayout) { 110 TEST_F(NotificationControllerTest, BasicLayout) {
111 scoped_ptr<message_center::Notification> notification( 111 scoped_ptr<message_center::Notification> notification(
112 new message_center::Notification( 112 new message_center::Notification(
113 message_center::NOTIFICATION_TYPE_SIMPLE, 113 message_center::NOTIFICATION_TYPE_SIMPLE,
114 "", 114 "",
115 ASCIIToUTF16("Added to circles"), 115 ASCIIToUTF16("Added to circles"),
116 ASCIIToUTF16("Jonathan and 5 others"), 116 ASCIIToUTF16("Jonathan and 5 others"),
117 gfx::Image(), 117 gfx::Image(),
118 string16(), 118 base::string16(),
119 DummyNotifierId(), 119 DummyNotifierId(),
120 message_center::RichNotificationData(), 120 message_center::RichNotificationData(),
121 NULL)); 121 NULL));
122 notification->set_icon(gfx::Image([TestIcon() retain])); 122 notification->set_icon(gfx::Image([TestIcon() retain]));
123 123
124 base::scoped_nsobject<MCNotificationController> controller( 124 base::scoped_nsobject<MCNotificationController> controller(
125 [[MCNotificationController alloc] initWithNotification:notification.get() 125 [[MCNotificationController alloc] initWithNotification:notification.get()
126 messageCenter:NULL]); 126 messageCenter:NULL]);
127 [controller view]; 127 [controller view];
128 128
129 EXPECT_EQ(TestIcon(), [[controller iconView] image]); 129 EXPECT_EQ(TestIcon(), [[controller iconView] image]);
130 EXPECT_EQ(base::SysNSStringToUTF16([[controller titleView] string]), 130 EXPECT_EQ(base::SysNSStringToUTF16([[controller titleView] string]),
131 notification->title()); 131 notification->title());
132 EXPECT_EQ(base::SysNSStringToUTF16([[controller messageView] string]), 132 EXPECT_EQ(base::SysNSStringToUTF16([[controller messageView] string]),
133 notification->message()); 133 notification->message());
134 EXPECT_EQ(controller.get(), [[controller closeButton] target]); 134 EXPECT_EQ(controller.get(), [[controller closeButton] target]);
135 } 135 }
136 136
137 TEST_F(NotificationControllerTest, OverflowText) { 137 TEST_F(NotificationControllerTest, OverflowText) {
138 scoped_ptr<message_center::Notification> notification( 138 scoped_ptr<message_center::Notification> notification(
139 new message_center::Notification( 139 new message_center::Notification(
140 message_center::NOTIFICATION_TYPE_SIMPLE, 140 message_center::NOTIFICATION_TYPE_SIMPLE,
141 "", 141 "",
142 ASCIIToUTF16("This is a much longer title that should wrap " 142 ASCIIToUTF16("This is a much longer title that should wrap "
143 "multiple lines."), 143 "multiple lines."),
144 ASCIIToUTF16("And even the message is long. This sure is a wordy " 144 ASCIIToUTF16("And even the message is long. This sure is a wordy "
145 "notification. Are you really going to read this " 145 "notification. Are you really going to read this "
146 "entire thing?"), 146 "entire thing?"),
147 gfx::Image(), 147 gfx::Image(),
148 string16(), 148 base::string16(),
149 DummyNotifierId(), 149 DummyNotifierId(),
150 message_center::RichNotificationData(), 150 message_center::RichNotificationData(),
151 NULL)); 151 NULL));
152 base::scoped_nsobject<MCNotificationController> controller( 152 base::scoped_nsobject<MCNotificationController> controller(
153 [[MCNotificationController alloc] initWithNotification:notification.get() 153 [[MCNotificationController alloc] initWithNotification:notification.get()
154 messageCenter:NULL]); 154 messageCenter:NULL]);
155 [controller view]; 155 [controller view];
156 156
157 EXPECT_GT(NSHeight([[controller view] frame]), 157 EXPECT_GT(NSHeight([[controller view] frame]),
158 message_center::kNotificationIconSize); 158 message_center::kNotificationIconSize);
159 } 159 }
160 160
161 TEST_F(NotificationControllerTest, Close) { 161 TEST_F(NotificationControllerTest, Close) {
162 scoped_ptr<message_center::Notification> notification( 162 scoped_ptr<message_center::Notification> notification(
163 new message_center::Notification( 163 new message_center::Notification(
164 message_center::NOTIFICATION_TYPE_SIMPLE, 164 message_center::NOTIFICATION_TYPE_SIMPLE,
165 "an_id", 165 "an_id",
166 string16(), 166 base::string16(),
167 string16(), 167 base::string16(),
168 gfx::Image(), 168 gfx::Image(),
169 string16(), 169 base::string16(),
170 DummyNotifierId(), 170 DummyNotifierId(),
171 message_center::RichNotificationData(), 171 message_center::RichNotificationData(),
172 NULL)); 172 NULL));
173 MockMessageCenter message_center; 173 MockMessageCenter message_center;
174 174
175 base::scoped_nsobject<MCNotificationController> controller( 175 base::scoped_nsobject<MCNotificationController> controller(
176 [[MCNotificationController alloc] initWithNotification:notification.get() 176 [[MCNotificationController alloc] initWithNotification:notification.get()
177 messageCenter:&message_center]); 177 messageCenter:&message_center]);
178 [controller view]; 178 [controller view];
179 179
180 [[controller closeButton] performClick:nil]; 180 [[controller closeButton] performClick:nil];
181 181
182 EXPECT_EQ(1, message_center.remove_count()); 182 EXPECT_EQ(1, message_center.remove_count());
183 EXPECT_EQ("an_id", message_center.last_removed_id()); 183 EXPECT_EQ("an_id", message_center.last_removed_id());
184 EXPECT_TRUE(message_center.last_removed_by_user()); 184 EXPECT_TRUE(message_center.last_removed_by_user());
185 } 185 }
186 186
187 TEST_F(NotificationControllerTest, Update) { 187 TEST_F(NotificationControllerTest, Update) {
188 scoped_ptr<message_center::Notification> notification( 188 scoped_ptr<message_center::Notification> notification(
189 new message_center::Notification( 189 new message_center::Notification(
190 message_center::NOTIFICATION_TYPE_SIMPLE, 190 message_center::NOTIFICATION_TYPE_SIMPLE,
191 "", 191 "",
192 ASCIIToUTF16("A simple title"), 192 ASCIIToUTF16("A simple title"),
193 ASCIIToUTF16("This message isn't too long and should fit in the" 193 ASCIIToUTF16("This message isn't too long and should fit in the"
194 "default bounds."), 194 "default bounds."),
195 gfx::Image(), 195 gfx::Image(),
196 string16(), 196 base::string16(),
197 DummyNotifierId(), 197 DummyNotifierId(),
198 message_center::RichNotificationData(), 198 message_center::RichNotificationData(),
199 NULL)); 199 NULL));
200 base::scoped_nsobject<MCNotificationController> controller( 200 base::scoped_nsobject<MCNotificationController> controller(
201 [[MCNotificationController alloc] initWithNotification:notification.get() 201 [[MCNotificationController alloc] initWithNotification:notification.get()
202 messageCenter:NULL]); 202 messageCenter:NULL]);
203 203
204 // Set up the default layout. 204 // Set up the default layout.
205 [controller view]; 205 [controller view];
206 EXPECT_EQ(NSHeight([[controller view] frame]), 206 EXPECT_EQ(NSHeight([[controller view] frame]),
(...skipping 12 matching lines...) Expand all
219 message_center::RichNotificationData optional; 219 message_center::RichNotificationData optional;
220 message_center::ButtonInfo button1(UTF8ToUTF16("button1")); 220 message_center::ButtonInfo button1(UTF8ToUTF16("button1"));
221 optional.buttons.push_back(button1); 221 optional.buttons.push_back(button1);
222 message_center::ButtonInfo button2(UTF8ToUTF16("button2")); 222 message_center::ButtonInfo button2(UTF8ToUTF16("button2"));
223 optional.buttons.push_back(button2); 223 optional.buttons.push_back(button2);
224 224
225 scoped_ptr<message_center::Notification> notification( 225 scoped_ptr<message_center::Notification> notification(
226 new message_center::Notification( 226 new message_center::Notification(
227 message_center::NOTIFICATION_TYPE_BASE_FORMAT, 227 message_center::NOTIFICATION_TYPE_BASE_FORMAT,
228 "an_id", 228 "an_id",
229 string16(), 229 base::string16(),
230 string16(), 230 base::string16(),
231 gfx::Image(), 231 gfx::Image(),
232 string16(), 232 base::string16(),
233 DummyNotifierId(), 233 DummyNotifierId(),
234 optional, 234 optional,
235 NULL)); 235 NULL));
236 MockMessageCenter message_center; 236 MockMessageCenter message_center;
237 237
238 base::scoped_nsobject<MCNotificationController> controller( 238 base::scoped_nsobject<MCNotificationController> controller(
239 [[MCNotificationController alloc] initWithNotification:notification.get() 239 [[MCNotificationController alloc] initWithNotification:notification.get()
240 messageCenter:&message_center]); 240 messageCenter:&message_center]);
241 [controller view]; 241 [controller view];
242 242
243 [[controller secondButton] performClick:nil]; 243 [[controller secondButton] performClick:nil];
244 244
245 EXPECT_EQ("an_id", message_center.last_clicked_id()); 245 EXPECT_EQ("an_id", message_center.last_clicked_id());
246 EXPECT_EQ(1, message_center.last_clicked_index()); 246 EXPECT_EQ(1, message_center.last_clicked_index());
247 } 247 }
248 248
249 TEST_F(NotificationControllerTest, Image) { 249 TEST_F(NotificationControllerTest, Image) {
250 scoped_ptr<message_center::Notification> notification( 250 scoped_ptr<message_center::Notification> notification(
251 new message_center::Notification( 251 new message_center::Notification(
252 message_center::NOTIFICATION_TYPE_BASE_FORMAT, 252 message_center::NOTIFICATION_TYPE_BASE_FORMAT,
253 "an_id", 253 "an_id",
254 string16(), 254 base::string16(),
255 string16(), 255 base::string16(),
256 gfx::Image(), 256 gfx::Image(),
257 string16(), 257 base::string16(),
258 DummyNotifierId(), 258 DummyNotifierId(),
259 message_center::RichNotificationData(), 259 message_center::RichNotificationData(),
260 NULL)); 260 NULL));
261 NSImage* image = [NSImage imageNamed:NSImageNameFolder]; 261 NSImage* image = [NSImage imageNamed:NSImageNameFolder];
262 notification->set_image(gfx::Image([image retain])); 262 notification->set_image(gfx::Image([image retain]));
263 263
264 MockMessageCenter message_center; 264 MockMessageCenter message_center;
265 265
266 base::scoped_nsobject<MCNotificationController> controller( 266 base::scoped_nsobject<MCNotificationController> controller(
267 [[MCNotificationController alloc] initWithNotification:notification.get() 267 [[MCNotificationController alloc] initWithNotification:notification.get()
(...skipping 22 matching lines...) Expand all
290 optional.items.push_back(item3); 290 optional.items.push_back(item3);
291 optional.context_message = UTF8ToUTF16("Context Message"); 291 optional.context_message = UTF8ToUTF16("Context Message");
292 292
293 scoped_ptr<message_center::Notification> notification( 293 scoped_ptr<message_center::Notification> notification(
294 new message_center::Notification( 294 new message_center::Notification(
295 message_center::NOTIFICATION_TYPE_BASE_FORMAT, 295 message_center::NOTIFICATION_TYPE_BASE_FORMAT,
296 "an_id", 296 "an_id",
297 UTF8ToUTF16("Notification Title"), 297 UTF8ToUTF16("Notification Title"),
298 UTF8ToUTF16("Notification Message - should be hidden"), 298 UTF8ToUTF16("Notification Message - should be hidden"),
299 gfx::Image(), 299 gfx::Image(),
300 string16(), 300 base::string16(),
301 DummyNotifierId(), 301 DummyNotifierId(),
302 optional, 302 optional,
303 NULL)); 303 NULL));
304 304
305 MockMessageCenter message_center; 305 MockMessageCenter message_center;
306 base::scoped_nsobject<MCNotificationController> controller( 306 base::scoped_nsobject<MCNotificationController> controller(
307 [[MCNotificationController alloc] initWithNotification:notification.get() 307 [[MCNotificationController alloc] initWithNotification:notification.get()
308 messageCenter:&message_center]); 308 messageCenter:&message_center]);
309 [controller view]; 309 [controller view];
310 310
311 EXPECT_FALSE([[controller titleView] isHidden]); 311 EXPECT_FALSE([[controller titleView] isHidden]);
312 EXPECT_TRUE([[controller messageView] isHidden]); 312 EXPECT_TRUE([[controller messageView] isHidden]);
313 EXPECT_FALSE([[controller contextMessageView] isHidden]); 313 EXPECT_FALSE([[controller contextMessageView] isHidden]);
314 314
315 EXPECT_EQ(3u, [[[controller listView] subviews] count]); 315 EXPECT_EQ(3u, [[[controller listView] subviews] count]);
316 EXPECT_LT(NSMaxY([[controller listView] frame]), 316 EXPECT_LT(NSMaxY([[controller listView] frame]),
317 NSMinY([[controller titleView] frame])); 317 NSMinY([[controller titleView] frame]));
318 } 318 }
319 319
320 } // namespace message_center 320 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/cocoa/notification_controller.mm ('k') | ui/message_center/cocoa/popup_collection_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698