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

Side by Side Diff: ash/system/chromeos/tray_display_unittest.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "ash/system/chromeos/tray_display.h" 5 #include "ash/system/chromeos/tray_display.h"
6 6
7 #include "ash/common/system/chromeos/devicetype_utils.h" 7 #include "ash/common/system/chromeos/devicetype_utils.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
(...skipping 19 matching lines...) Expand all
30 base::string16 GetTooltipText(const base::string16& headline, 30 base::string16 GetTooltipText(const base::string16& headline,
31 const base::string16& name1, 31 const base::string16& name1,
32 const std::string& data1, 32 const std::string& data1,
33 const base::string16& name2, 33 const base::string16& name2,
34 const std::string& data2) { 34 const std::string& data2) {
35 std::vector<base::string16> lines; 35 std::vector<base::string16> lines;
36 lines.push_back(headline); 36 lines.push_back(headline);
37 if (data1.empty()) { 37 if (data1.empty()) {
38 lines.push_back(name1); 38 lines.push_back(name1);
39 } else { 39 } else {
40 lines.push_back(l10n_util::GetStringFUTF16( 40 lines.push_back(
41 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 41 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
42 name1, base::UTF8ToUTF16(data1))); 42 name1, base::UTF8ToUTF16(data1)));
43 } 43 }
44 if (!name2.empty()) { 44 if (!name2.empty()) {
45 lines.push_back(l10n_util::GetStringFUTF16( 45 lines.push_back(
46 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 46 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
47 name2, base::UTF8ToUTF16(data2))); 47 name2, base::UTF8ToUTF16(data2)));
48 } 48 }
49 return base::JoinString(lines, base::ASCIIToUTF16("\n")); 49 return base::JoinString(lines, base::ASCIIToUTF16("\n"));
50 } 50 }
51 51
52 base::string16 GetMirroredTooltipText(const base::string16& headline, 52 base::string16 GetMirroredTooltipText(const base::string16& headline,
53 const base::string16& name, 53 const base::string16& name,
54 const std::string& data) { 54 const std::string& data) {
55 return GetTooltipText(headline, name, data, base::string16(), ""); 55 return GetTooltipText(headline, name, data, base::string16(), "");
56 } 56 }
57 57
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 // Weak reference, owned by Shell. 99 // Weak reference, owned by Shell.
100 SystemTray* tray_; 100 SystemTray* tray_;
101 101
102 // Weak reference, owned by |tray_|. 102 // Weak reference, owned by |tray_|.
103 TrayDisplay* tray_display_; 103 TrayDisplay* tray_display_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(TrayDisplayTest); 105 DISALLOW_COPY_AND_ASSIGN(TrayDisplayTest);
106 }; 106 };
107 107
108 TrayDisplayTest::TrayDisplayTest() : tray_(NULL), tray_display_(NULL) { 108 TrayDisplayTest::TrayDisplayTest() : tray_(NULL), tray_display_(NULL) {}
109 }
110 109
111 TrayDisplayTest::~TrayDisplayTest() { 110 TrayDisplayTest::~TrayDisplayTest() {}
112 }
113 111
114 void TrayDisplayTest::SetUp() { 112 void TrayDisplayTest::SetUp() {
115 ash::test::AshTestBase::SetUp(); 113 ash::test::AshTestBase::SetUp();
116 // Populate tray_ and tray_display_. 114 // Populate tray_ and tray_display_.
117 CheckUpdate(); 115 CheckUpdate();
118 } 116 }
119 117
120 SystemTray* TrayDisplayTest::GetTray() { 118 SystemTray* TrayDisplayTest::GetTray() {
121 CheckUpdate(); 119 CheckUpdate();
122 return tray_; 120 return tray_;
(...skipping 14 matching lines...) Expand all
137 } 135 }
138 } 136 }
139 137
140 void TrayDisplayTest::CloseNotification() { 138 void TrayDisplayTest::CloseNotification() {
141 message_center::MessageCenter::Get()->RemoveNotification( 139 message_center::MessageCenter::Get()->RemoveNotification(
142 TrayDisplay::kNotificationId, false); 140 TrayDisplay::kNotificationId, false);
143 RunAllPendingInMessageLoop(); 141 RunAllPendingInMessageLoop();
144 } 142 }
145 143
146 bool TrayDisplayTest::IsDisplayVisibleInTray() const { 144 bool TrayDisplayTest::IsDisplayVisibleInTray() const {
147 return tray_->HasSystemBubble() && 145 return tray_->HasSystemBubble() && tray_display_->default_view() &&
148 tray_display_->default_view() && 146 tray_display_->default_view()->visible();
149 tray_display_->default_view()->visible();
150 } 147 }
151 148
152 base::string16 TrayDisplayTest::GetTrayDisplayText() const { 149 base::string16 TrayDisplayTest::GetTrayDisplayText() const {
153 return tray_display_->GetDefaultViewMessage(); 150 return tray_display_->GetDefaultViewMessage();
154 } 151 }
155 152
156 void TrayDisplayTest::CheckAccessibleName() const { 153 void TrayDisplayTest::CheckAccessibleName() const {
157 ui::AXViewState state; 154 ui::AXViewState state;
158 if (tray_display_->GetAccessibleStateForTesting(&state)) { 155 if (tray_display_->GetAccessibleStateForTesting(&state)) {
159 base::string16 expected = tray_display_->GetDefaultViewMessage(); 156 base::string16 expected = tray_display_->GetDefaultViewMessage();
(...skipping 19 matching lines...) Expand all
179 base::string16 TrayDisplayTest::GetDisplayNotificationAdditionalText() const { 176 base::string16 TrayDisplayTest::GetDisplayNotificationAdditionalText() const {
180 const message_center::Notification* notification = GetDisplayNotification(); 177 const message_center::Notification* notification = GetDisplayNotification();
181 return notification ? notification->message() : base::string16(); 178 return notification ? notification->message() : base::string16();
182 } 179 }
183 180
184 const message_center::Notification* TrayDisplayTest::GetDisplayNotification() 181 const message_center::Notification* TrayDisplayTest::GetDisplayNotification()
185 const { 182 const {
186 const message_center::NotificationList::Notifications notifications = 183 const message_center::NotificationList::Notifications notifications =
187 message_center::MessageCenter::Get()->GetVisibleNotifications(); 184 message_center::MessageCenter::Get()->GetVisibleNotifications();
188 for (message_center::NotificationList::Notifications::const_iterator iter = 185 for (message_center::NotificationList::Notifications::const_iterator iter =
189 notifications.begin(); iter != notifications.end(); ++iter) { 186 notifications.begin();
187 iter != notifications.end(); ++iter) {
190 if ((*iter)->id() == TrayDisplay::kNotificationId) 188 if ((*iter)->id() == TrayDisplay::kNotificationId)
191 return *iter; 189 return *iter;
192 } 190 }
193 191
194 return NULL; 192 return NULL;
195 } 193 }
196 194
197 TEST_F(TrayDisplayTest, NoInternalDisplay) { 195 TEST_F(TrayDisplayTest, NoInternalDisplay) {
198 UpdateDisplay("400x400"); 196 UpdateDisplay("400x400");
199 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 197 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 258
261 TEST_F(TrayDisplayTest, InternalDisplayResized) { 259 TEST_F(TrayDisplayTest, InternalDisplayResized) {
262 UpdateDisplay("400x400@1.5"); 260 UpdateDisplay("400x400@1.5");
263 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 261 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
264 display::Display::SetInternalDisplayId(display_manager->first_display_id()); 262 display::Display::SetInternalDisplayId(display_manager->first_display_id());
265 263
266 // Shows the tray_display even though there's a single-display. 264 // Shows the tray_display even though there's a single-display.
267 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 265 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
268 EXPECT_TRUE(IsDisplayVisibleInTray()); 266 EXPECT_TRUE(IsDisplayVisibleInTray());
269 base::string16 internal_info = l10n_util::GetStringFUTF16( 267 base::string16 internal_info = l10n_util::GetStringFUTF16(
270 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 268 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, GetFirstDisplayName(),
271 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")); 269 base::UTF8ToUTF16("600x600"));
272 EXPECT_EQ(internal_info, GetTrayDisplayText()); 270 EXPECT_EQ(internal_info, GetTrayDisplayText());
273 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600", 271 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
274 base::string16(), std::string()), 272 base::string16(), std::string()),
275 GetTrayDisplayTooltipText()); 273 GetTrayDisplayTooltipText());
276 CheckAccessibleName(); 274 CheckAccessibleName();
277 275
278 // Extended 276 // Extended
279 UpdateDisplay("400x400@1.5,200x200"); 277 UpdateDisplay("400x400@1.5,200x200");
280 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 278 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
281 EXPECT_TRUE(IsDisplayVisibleInTray()); 279 EXPECT_TRUE(IsDisplayVisibleInTray());
(...skipping 20 matching lines...) Expand all
302 // Closed lid mode. 300 // Closed lid mode.
303 display_manager->SetSoftwareMirroring(false); 301 display_manager->SetSoftwareMirroring(false);
304 UpdateDisplay("400x400@1.5,200x200"); 302 UpdateDisplay("400x400@1.5,200x200");
305 display::Display::SetInternalDisplayId( 303 display::Display::SetInternalDisplayId(
306 ScreenUtil::GetSecondaryDisplay().id()); 304 ScreenUtil::GetSecondaryDisplay().id());
307 UpdateDisplay("400x400@1.5"); 305 UpdateDisplay("400x400@1.5");
308 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 306 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
309 EXPECT_TRUE(IsDisplayVisibleInTray()); 307 EXPECT_TRUE(IsDisplayVisibleInTray());
310 expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED); 308 expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED);
311 EXPECT_EQ(expected, GetTrayDisplayText()); 309 EXPECT_EQ(expected, GetTrayDisplayText());
312 EXPECT_EQ( 310 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "600x600",
313 GetTooltipText( 311 base::string16(), ""),
314 expected, GetFirstDisplayName(), "600x600", base::string16(), ""), 312 GetTrayDisplayTooltipText());
315 GetTrayDisplayTooltipText());
316 CheckAccessibleName(); 313 CheckAccessibleName();
317 314
318 // Unified mode 315 // Unified mode
319 display_manager->SetUnifiedDesktopEnabled(true); 316 display_manager->SetUnifiedDesktopEnabled(true);
320 UpdateDisplay("300x200,400x500"); 317 UpdateDisplay("300x200,400x500");
321 // Update the cache variables as the primary root window changed. 318 // Update the cache variables as the primary root window changed.
322 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 319 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
323 EXPECT_TRUE(IsDisplayVisibleInTray()); 320 EXPECT_TRUE(IsDisplayVisibleInTray());
324 expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED); 321 expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED);
325 EXPECT_EQ(expected, GetTrayDisplayText()); 322 EXPECT_EQ(expected, GetTrayDisplayText());
(...skipping 10 matching lines...) Expand all
336 333
337 // Extended 334 // Extended
338 UpdateDisplay("400x400,200x200@1.5"); 335 UpdateDisplay("400x400,200x200@1.5");
339 const display::Display& secondary_display = ScreenUtil::GetSecondaryDisplay(); 336 const display::Display& secondary_display = ScreenUtil::GetSecondaryDisplay();
340 337
341 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 338 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
342 EXPECT_TRUE(IsDisplayVisibleInTray()); 339 EXPECT_TRUE(IsDisplayVisibleInTray());
343 base::string16 expected = l10n_util::GetStringFUTF16( 340 base::string16 expected = l10n_util::GetStringFUTF16(
344 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, 341 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
345 l10n_util::GetStringFUTF16( 342 l10n_util::GetStringFUTF16(
346 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, 343 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, GetSecondDisplayName(),
347 GetSecondDisplayName(),
348 base::UTF8ToUTF16(secondary_display.size().ToString()))); 344 base::UTF8ToUTF16(secondary_display.size().ToString())));
349 EXPECT_EQ(expected, GetTrayDisplayText()); 345 EXPECT_EQ(expected, GetTrayDisplayText());
350 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400", 346 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400",
351 GetSecondDisplayName(), "300x300"), 347 GetSecondDisplayName(), "300x300"),
352 GetTrayDisplayTooltipText()); 348 GetTrayDisplayTooltipText());
353 CheckAccessibleName(); 349 CheckAccessibleName();
354 350
355 // Mirroring 351 // Mirroring
356 display_manager->SetSoftwareMirroring(true); 352 display_manager->SetSoftwareMirroring(true);
357 UpdateDisplay("400x400,200x200@1.5"); 353 UpdateDisplay("400x400,200x200@1.5");
(...skipping 14 matching lines...) Expand all
372 368
373 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 369 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
374 EXPECT_TRUE(IsDisplayVisibleInTray()); 370 EXPECT_TRUE(IsDisplayVisibleInTray());
375 371
376 // /o creates the default overscan, and if overscan is set, the annotation 372 // /o creates the default overscan, and if overscan is set, the annotation
377 // should be the size. 373 // should be the size.
378 base::string16 overscan = l10n_util::GetStringUTF16( 374 base::string16 overscan = l10n_util::GetStringUTF16(
379 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN); 375 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN);
380 base::string16 headline = l10n_util::GetStringFUTF16( 376 base::string16 headline = l10n_util::GetStringFUTF16(
381 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, 377 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
382 l10n_util::GetStringFUTF16( 378 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME,
383 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, 379 GetSecondDisplayName(),
384 GetSecondDisplayName(), base::UTF8ToUTF16("286x286"))); 380 base::UTF8ToUTF16("286x286")));
385 std::string second_data = l10n_util::GetStringFUTF8( 381 std::string second_data =
386 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION, 382 l10n_util::GetStringFUTF8(IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION,
387 base::UTF8ToUTF16("286x286"), overscan); 383 base::UTF8ToUTF16("286x286"), overscan);
388 EXPECT_EQ(GetTooltipText(headline, GetFirstDisplayName(), "400x400", 384 EXPECT_EQ(GetTooltipText(headline, GetFirstDisplayName(), "400x400",
389 GetSecondDisplayName(), second_data), 385 GetSecondDisplayName(), second_data),
390 GetTrayDisplayTooltipText()); 386 GetTrayDisplayTooltipText());
391 387
392 // reset the overscan. 388 // reset the overscan.
393 display_manager->SetOverscanInsets( 389 display_manager->SetOverscanInsets(ScreenUtil::GetSecondaryDisplay().id(),
394 ScreenUtil::GetSecondaryDisplay().id(), gfx::Insets()); 390 gfx::Insets());
395 headline = l10n_util::GetStringFUTF16( 391 headline = l10n_util::GetStringFUTF16(
396 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, 392 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
397 l10n_util::GetStringFUTF16( 393 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME,
398 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, 394 GetSecondDisplayName(), overscan));
399 GetSecondDisplayName(), overscan)); 395 second_data =
400 second_data = l10n_util::GetStringFUTF8( 396 l10n_util::GetStringFUTF8(IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION,
401 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION, 397 base::UTF8ToUTF16("300x300"), overscan);
402 base::UTF8ToUTF16("300x300"), overscan);
403 EXPECT_EQ(GetTooltipText(headline, GetFirstDisplayName(), "400x400", 398 EXPECT_EQ(GetTooltipText(headline, GetFirstDisplayName(), "400x400",
404 GetSecondDisplayName(), second_data), 399 GetSecondDisplayName(), second_data),
405 GetTrayDisplayTooltipText()); 400 GetTrayDisplayTooltipText());
406 } 401 }
407 402
408 TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) { 403 TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) {
409 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING); 404 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
410 EXPECT_FALSE(IsDisplayVisibleInTray()); 405 EXPECT_FALSE(IsDisplayVisibleInTray());
411 406
412 UpdateDisplay("400x400@1.5"); 407 UpdateDisplay("400x400@1.5");
413 EXPECT_TRUE(GetTray()->HasSystemBubble()); 408 EXPECT_TRUE(GetTray()->HasSystemBubble());
414 EXPECT_TRUE(IsDisplayVisibleInTray()); 409 EXPECT_TRUE(IsDisplayVisibleInTray());
415 base::string16 internal_info = l10n_util::GetStringFUTF16( 410 base::string16 internal_info = l10n_util::GetStringFUTF16(
416 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 411 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, GetFirstDisplayName(),
417 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")); 412 base::UTF8ToUTF16("600x600"));
418 EXPECT_EQ(internal_info, GetTrayDisplayText()); 413 EXPECT_EQ(internal_info, GetTrayDisplayText());
419 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600", 414 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
420 base::string16(), std::string()), 415 base::string16(), std::string()),
421 GetTrayDisplayTooltipText()); 416 GetTrayDisplayTooltipText());
422 CheckAccessibleName(); 417 CheckAccessibleName();
423 418
424 UpdateDisplay("400x400,200x200"); 419 UpdateDisplay("400x400,200x200");
425 EXPECT_TRUE(GetTray()->HasSystemBubble()); 420 EXPECT_TRUE(GetTray()->HasSystemBubble());
426 EXPECT_TRUE(IsDisplayVisibleInTray()); 421 EXPECT_TRUE(IsDisplayVisibleInTray());
427 base::string16 expected = l10n_util::GetStringUTF16( 422 base::string16 expected = l10n_util::GetStringUTF16(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 484
490 // No-update 485 // No-update
491 CloseNotification(); 486 CloseNotification();
492 UpdateDisplay("400x400"); 487 UpdateDisplay("400x400");
493 EXPECT_TRUE(GetDisplayNotificationText().empty()); 488 EXPECT_TRUE(GetDisplayNotificationText().empty());
494 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); 489 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
495 490
496 // Extended. 491 // Extended.
497 CloseNotification(); 492 CloseNotification();
498 UpdateDisplay("400x400,200x200"); 493 UpdateDisplay("400x400,200x200");
499 EXPECT_EQ( 494 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
500 l10n_util::GetStringFUTF16( 495 GetSecondDisplayName()),
501 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName()), 496 GetDisplayNotificationText());
502 GetDisplayNotificationText());
503 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); 497 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
504 498
505 // Mirroring. 499 // Mirroring.
506 CloseNotification(); 500 CloseNotification();
507 display_manager->SetSoftwareMirroring(true); 501 display_manager->SetSoftwareMirroring(true);
508 UpdateDisplay("400x400,200x200"); 502 UpdateDisplay("400x400,200x200");
509 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, 503 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
510 GetMirroringDisplayName()), 504 GetMirroringDisplayName()),
511 GetDisplayNotificationText()); 505 GetDisplayNotificationText());
512 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); 506 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
513 507
514 // Back to extended. 508 // Back to extended.
515 CloseNotification(); 509 CloseNotification();
516 display_manager->SetSoftwareMirroring(false); 510 display_manager->SetSoftwareMirroring(false);
517 UpdateDisplay("400x400,200x200"); 511 UpdateDisplay("400x400,200x200");
518 EXPECT_EQ( 512 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
519 l10n_util::GetStringFUTF16( 513 GetSecondDisplayName()),
520 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName()), 514 GetDisplayNotificationText());
521 GetDisplayNotificationText());
522 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty()); 515 EXPECT_TRUE(GetDisplayNotificationAdditionalText().empty());
523 516
524 // Resize the first display. 517 // Resize the first display.
525 UpdateDisplay("400x400@1.5,200x200"); 518 UpdateDisplay("400x400@1.5,200x200");
526 EXPECT_EQ(l10n_util::GetStringFUTF16( 519 EXPECT_EQ(l10n_util::GetStringFUTF16(
527 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED, 520 IDS_ASH_STATUS_TRAY_DISPLAY_RESOLUTION_CHANGED,
528 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")), 521 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")),
529 GetDisplayNotificationAdditionalText()); 522 GetDisplayNotificationAdditionalText());
530 EXPECT_TRUE(GetDisplayNotificationText().empty()); 523 EXPECT_TRUE(GetDisplayNotificationText().empty());
531 524
532 // Rotate the second. 525 // Rotate the second.
533 UpdateDisplay("400x400@1.5,200x200/r"); 526 UpdateDisplay("400x400@1.5,200x200/r");
534 EXPECT_EQ(l10n_util::GetStringFUTF16( 527 EXPECT_EQ(l10n_util::GetStringFUTF16(
535 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(), 528 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(),
536 l10n_util::GetStringUTF16( 529 l10n_util::GetStringUTF16(
537 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), 530 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)),
538 GetDisplayNotificationAdditionalText()); 531 GetDisplayNotificationAdditionalText());
539 EXPECT_TRUE(GetDisplayNotificationText().empty()); 532 EXPECT_TRUE(GetDisplayNotificationText().empty());
540 533
541 // Enters closed lid mode. 534 // Enters closed lid mode.
542 UpdateDisplay("400x400@1.5,200x200"); 535 UpdateDisplay("400x400@1.5,200x200");
543 display::Display::SetInternalDisplayId( 536 display::Display::SetInternalDisplayId(
544 ScreenUtil::GetSecondaryDisplay().id()); 537 ScreenUtil::GetSecondaryDisplay().id());
545 UpdateDisplay("400x400@1.5"); 538 UpdateDisplay("400x400@1.5");
546 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED), 539 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED),
547 GetDisplayNotificationText()); 540 GetDisplayNotificationText());
548 EXPECT_EQ( 541 EXPECT_EQ(ash::SubstituteChromeOSDeviceType(
549 ash::SubstituteChromeOSDeviceType( 542 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION),
550 IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED_DESCRIPTION), 543 GetDisplayNotificationAdditionalText());
551 GetDisplayNotificationAdditionalText());
552 } 544 }
553 545
554 TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) { 546 TEST_F(TrayDisplayTest, DisplayConfigurationChangedTwice) {
555 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate(); 547 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate();
556 tray_delegate->set_should_show_display_notification(true); 548 tray_delegate->set_should_show_display_notification(true);
557 549
558 UpdateDisplay("400x400,200x200"); 550 UpdateDisplay("400x400,200x200");
559 EXPECT_EQ( 551 EXPECT_EQ(l10n_util::GetStringUTF16(
560 l10n_util::GetStringUTF16( 552 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
561 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 553 GetDisplayNotificationText());
562 GetDisplayNotificationText());
563 554
564 // OnDisplayConfigurationChanged() may be called more than once for a single 555 // OnDisplayConfigurationChanged() may be called more than once for a single
565 // update display in case of primary is swapped or recovered from dock mode. 556 // update display in case of primary is swapped or recovered from dock mode.
566 // Should not remove the notification in such case. 557 // Should not remove the notification in such case.
567 GetTrayDisplay()->OnDisplayConfigurationChanged(); 558 GetTrayDisplay()->OnDisplayConfigurationChanged();
568 EXPECT_EQ( 559 EXPECT_EQ(l10n_util::GetStringUTF16(
569 l10n_util::GetStringUTF16( 560 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
570 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 561 GetDisplayNotificationText());
571 GetDisplayNotificationText());
572 562
573 // Back to the single display. It SHOULD remove the notification since the 563 // Back to the single display. It SHOULD remove the notification since the
574 // information is stale. 564 // information is stale.
575 UpdateDisplay("400x400"); 565 UpdateDisplay("400x400");
576 EXPECT_TRUE(GetDisplayNotificationText().empty()); 566 EXPECT_TRUE(GetDisplayNotificationText().empty());
577 } 567 }
578 568
579 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) { 569 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) {
580 UpdateDisplay("400x400,200x200"); 570 UpdateDisplay("400x400,200x200");
581 571
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 display::Display::ROTATION_SOURCE_ACCELEROMETER); 610 display::Display::ROTATION_SOURCE_ACCELEROMETER);
621 EXPECT_FALSE(IsDisplayVisibleInTray()); 611 EXPECT_FALSE(IsDisplayVisibleInTray());
622 612
623 // If a non-rotation setting is changed, display regardless of the source of 613 // If a non-rotation setting is changed, display regardless of the source of
624 // rotation so that the full message is shown. 614 // rotation so that the full message is shown.
625 UpdateDisplay("400x400@1.5"); 615 UpdateDisplay("400x400@1.5");
626 EXPECT_TRUE(IsDisplayVisibleInTray()); 616 EXPECT_TRUE(IsDisplayVisibleInTray());
627 } 617 }
628 618
629 } // namespace ash 619 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/tray_display.cc ('k') | ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698