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

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

Issue 1138253003: Notificaiton Message for Unified mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « ash/system/chromeos/tray_display.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 class TrayDisplayTest : public ash::test::AshTestBase { 74 class TrayDisplayTest : public ash::test::AshTestBase {
75 public: 75 public:
76 TrayDisplayTest(); 76 TrayDisplayTest();
77 ~TrayDisplayTest() override; 77 ~TrayDisplayTest() override;
78 78
79 void SetUp() override; 79 void SetUp() override;
80 80
81 protected: 81 protected:
82 SystemTray* tray() { return tray_; } 82 SystemTray* GetTray();
83 TrayDisplay* tray_display() { return tray_display_; } 83 TrayDisplay* GetTrayDisplay();
84 void CheckUpdate();
84 85
85 void CloseNotification(); 86 void CloseNotification();
86 bool IsDisplayVisibleInTray() const; 87 bool IsDisplayVisibleInTray() const;
87 base::string16 GetTrayDisplayText() const; 88 base::string16 GetTrayDisplayText() const;
88 void CheckAccessibleName() const; 89 void CheckAccessibleName() const;
89 base::string16 GetTrayDisplayTooltipText() const; 90 base::string16 GetTrayDisplayTooltipText() const;
90 base::string16 GetDisplayNotificationText() const; 91 base::string16 GetDisplayNotificationText() const;
91 base::string16 GetDisplayNotificationAdditionalText() const; 92 base::string16 GetDisplayNotificationAdditionalText() const;
92 93
93 private: 94 private:
94 const message_center::Notification* GetDisplayNotification() const; 95 const message_center::Notification* GetDisplayNotification() const;
95 96
96 // Weak reference, owned by Shell. 97 // Weak reference, owned by Shell.
97 SystemTray* tray_; 98 SystemTray* tray_;
98 99
99 // Weak reference, owned by |tray_|. 100 // Weak reference, owned by |tray_|.
100 TrayDisplay* tray_display_; 101 TrayDisplay* tray_display_;
101 102
102 DISALLOW_COPY_AND_ASSIGN(TrayDisplayTest); 103 DISALLOW_COPY_AND_ASSIGN(TrayDisplayTest);
103 }; 104 };
104 105
105 TrayDisplayTest::TrayDisplayTest() : tray_(NULL), tray_display_(NULL) { 106 TrayDisplayTest::TrayDisplayTest() : tray_(NULL), tray_display_(NULL) {
106 } 107 }
107 108
108 TrayDisplayTest::~TrayDisplayTest() { 109 TrayDisplayTest::~TrayDisplayTest() {
109 } 110 }
110 111
111 void TrayDisplayTest::SetUp() { 112 void TrayDisplayTest::SetUp() {
112 ash::test::AshTestBase::SetUp(); 113 ash::test::AshTestBase::SetUp();
113 tray_ = Shell::GetPrimaryRootWindowController()->GetSystemTray(); 114 // Populate tray_ and tray_display_.
114 tray_display_ = new TrayDisplay(tray_); 115 CheckUpdate();
115 tray_->AddTrayItem(tray_display_); 116 }
117
118 SystemTray* TrayDisplayTest::GetTray() {
119 CheckUpdate();
120 return tray_;
121 }
122
123 TrayDisplay* TrayDisplayTest::GetTrayDisplay() {
124 CheckUpdate();
125 return tray_display_;
126 }
127
128 void TrayDisplayTest::CheckUpdate() {
129 SystemTray* current =
130 Shell::GetPrimaryRootWindowController()->GetSystemTray();
131 if (tray_ != current) {
132 tray_ = current;
133 tray_display_ = new TrayDisplay(tray_);
134 tray_->AddTrayItem(tray_display_);
135 }
116 } 136 }
117 137
118 void TrayDisplayTest::CloseNotification() { 138 void TrayDisplayTest::CloseNotification() {
119 message_center::MessageCenter::Get()->RemoveNotification( 139 message_center::MessageCenter::Get()->RemoveNotification(
120 TrayDisplay::kNotificationId, false); 140 TrayDisplay::kNotificationId, false);
121 RunAllPendingInMessageLoop(); 141 RunAllPendingInMessageLoop();
122 } 142 }
123 143
124 bool TrayDisplayTest::IsDisplayVisibleInTray() const { 144 bool TrayDisplayTest::IsDisplayVisibleInTray() const {
125 return tray_->HasSystemBubble() && 145 return tray_->HasSystemBubble() &&
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 notifications.begin(); iter != notifications.end(); ++iter) { 187 notifications.begin(); iter != notifications.end(); ++iter) {
168 if ((*iter)->id() == TrayDisplay::kNotificationId) 188 if ((*iter)->id() == TrayDisplay::kNotificationId)
169 return *iter; 189 return *iter;
170 } 190 }
171 191
172 return NULL; 192 return NULL;
173 } 193 }
174 194
175 TEST_F(TrayDisplayTest, NoInternalDisplay) { 195 TEST_F(TrayDisplayTest, NoInternalDisplay) {
176 UpdateDisplay("400x400"); 196 UpdateDisplay("400x400");
177 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 197 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
178 EXPECT_FALSE(IsDisplayVisibleInTray()); 198 EXPECT_FALSE(IsDisplayVisibleInTray());
179 199
180 UpdateDisplay("400x400,200x200"); 200 UpdateDisplay("400x400,200x200");
181 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 201 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
182 EXPECT_TRUE(IsDisplayVisibleInTray()); 202 EXPECT_TRUE(IsDisplayVisibleInTray());
183 base::string16 expected = l10n_util::GetStringUTF16( 203 base::string16 expected = l10n_util::GetStringUTF16(
184 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); 204 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL);
185 base::string16 first_name = GetFirstDisplayName(); 205 base::string16 first_name = GetFirstDisplayName();
186 EXPECT_EQ(expected, GetTrayDisplayText()); 206 EXPECT_EQ(expected, GetTrayDisplayText());
187 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400", 207 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400",
188 GetSecondDisplayName(), "200x200"), 208 GetSecondDisplayName(), "200x200"),
189 GetTrayDisplayTooltipText()); 209 GetTrayDisplayTooltipText());
190 CheckAccessibleName(); 210 CheckAccessibleName();
191 211
192 // mirroring 212 // mirroring
193 Shell::GetInstance()->display_manager()->SetSoftwareMirroring(true); 213 Shell::GetInstance()->display_manager()->SetSoftwareMirroring(true);
194 UpdateDisplay("400x400,200x200"); 214 UpdateDisplay("400x400,200x200");
195 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 215 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
196 EXPECT_TRUE(IsDisplayVisibleInTray()); 216 EXPECT_TRUE(IsDisplayVisibleInTray());
197 expected = l10n_util::GetStringUTF16( 217 expected = l10n_util::GetStringUTF16(
198 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL); 218 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING_NO_INTERNAL);
199 EXPECT_EQ(expected, GetTrayDisplayText()); 219 EXPECT_EQ(expected, GetTrayDisplayText());
200 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "400x400"), 220 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "400x400"),
201 GetTrayDisplayTooltipText()); 221 GetTrayDisplayTooltipText());
202 CheckAccessibleName(); 222 CheckAccessibleName();
203 } 223 }
204 224
205 TEST_F(TrayDisplayTest, InternalDisplay) { 225 TEST_F(TrayDisplayTest, InternalDisplay) {
206 UpdateDisplay("400x400"); 226 UpdateDisplay("400x400");
207 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 227 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
208 gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); 228 gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
209 229
210 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 230 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
211 EXPECT_FALSE(IsDisplayVisibleInTray()); 231 EXPECT_FALSE(IsDisplayVisibleInTray());
212 232
213 // Extended 233 // Extended
214 UpdateDisplay("400x400,200x200"); 234 UpdateDisplay("400x400,200x200");
215 base::string16 expected = l10n_util::GetStringFUTF16( 235 base::string16 expected = l10n_util::GetStringFUTF16(
216 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName()); 236 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName());
217 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 237 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
218 EXPECT_TRUE(IsDisplayVisibleInTray()); 238 EXPECT_TRUE(IsDisplayVisibleInTray());
219 EXPECT_EQ(expected, GetTrayDisplayText()); 239 EXPECT_EQ(expected, GetTrayDisplayText());
220 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400", 240 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400",
221 GetSecondDisplayName(), "200x200"), 241 GetSecondDisplayName(), "200x200"),
222 GetTrayDisplayTooltipText()); 242 GetTrayDisplayTooltipText());
223 CheckAccessibleName(); 243 CheckAccessibleName();
224 244
225 // Mirroring 245 // Mirroring
226 display_manager->SetSoftwareMirroring(true); 246 display_manager->SetSoftwareMirroring(true);
227 UpdateDisplay("400x400,200x200"); 247 UpdateDisplay("400x400,200x200");
228 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 248 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
229 EXPECT_TRUE(IsDisplayVisibleInTray()); 249 EXPECT_TRUE(IsDisplayVisibleInTray());
230 250
231 expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, 251 expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
232 GetMirroringDisplayName()); 252 GetMirroringDisplayName());
233 EXPECT_EQ(expected, GetTrayDisplayText()); 253 EXPECT_EQ(expected, GetTrayDisplayText());
234 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "400x400"), 254 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "400x400"),
235 GetTrayDisplayTooltipText()); 255 GetTrayDisplayTooltipText());
236 CheckAccessibleName(); 256 CheckAccessibleName();
237 } 257 }
238 258
239 TEST_F(TrayDisplayTest, InternalDisplayResized) { 259 TEST_F(TrayDisplayTest, InternalDisplayResized) {
240 UpdateDisplay("400x400@1.5"); 260 UpdateDisplay("400x400@1.5");
241 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 261 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
242 gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); 262 gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
243 263
244 // Shows the tray_display even though there's a single-display. 264 // Shows the tray_display even though there's a single-display.
245 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 265 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
246 EXPECT_TRUE(IsDisplayVisibleInTray()); 266 EXPECT_TRUE(IsDisplayVisibleInTray());
247 base::string16 internal_info = l10n_util::GetStringFUTF16( 267 base::string16 internal_info = l10n_util::GetStringFUTF16(
248 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 268 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
249 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")); 269 GetFirstDisplayName(), base::UTF8ToUTF16("600x600"));
250 EXPECT_EQ(internal_info, GetTrayDisplayText()); 270 EXPECT_EQ(internal_info, GetTrayDisplayText());
251 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600", 271 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
252 base::string16(), std::string()), 272 base::string16(), std::string()),
253 GetTrayDisplayTooltipText()); 273 GetTrayDisplayTooltipText());
254 CheckAccessibleName(); 274 CheckAccessibleName();
255 275
256 // Extended 276 // Extended
257 UpdateDisplay("400x400@1.5,200x200"); 277 UpdateDisplay("400x400@1.5,200x200");
258 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 278 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
259 EXPECT_TRUE(IsDisplayVisibleInTray()); 279 EXPECT_TRUE(IsDisplayVisibleInTray());
260 base::string16 expected = l10n_util::GetStringFUTF16( 280 base::string16 expected = l10n_util::GetStringFUTF16(
261 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName()); 281 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetSecondDisplayName());
262 EXPECT_EQ(expected, GetTrayDisplayText()); 282 EXPECT_EQ(expected, GetTrayDisplayText());
263 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "600x600", 283 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "600x600",
264 GetSecondDisplayName(), "200x200"), 284 GetSecondDisplayName(), "200x200"),
265 GetTrayDisplayTooltipText()); 285 GetTrayDisplayTooltipText());
266 CheckAccessibleName(); 286 CheckAccessibleName();
267 287
268 // Mirroring 288 // Mirroring
269 display_manager->SetSoftwareMirroring(true); 289 display_manager->SetSoftwareMirroring(true);
270 UpdateDisplay("400x400@1.5,200x200"); 290 UpdateDisplay("400x400@1.5,200x200");
271 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 291 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
272 EXPECT_TRUE(IsDisplayVisibleInTray()); 292 EXPECT_TRUE(IsDisplayVisibleInTray());
273 expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, 293 expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
274 GetMirroringDisplayName()); 294 GetMirroringDisplayName());
275 EXPECT_EQ(expected, GetTrayDisplayText()); 295 EXPECT_EQ(expected, GetTrayDisplayText());
276 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "600x600"), 296 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "600x600"),
277 GetTrayDisplayTooltipText()); 297 GetTrayDisplayTooltipText());
278 CheckAccessibleName(); 298 CheckAccessibleName();
279 299
280 // Closed lid mode. 300 // Closed lid mode.
281 display_manager->SetSoftwareMirroring(false); 301 display_manager->SetSoftwareMirroring(false);
282 UpdateDisplay("400x400@1.5,200x200"); 302 UpdateDisplay("400x400@1.5,200x200");
283 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id()); 303 gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id());
284 UpdateDisplay("400x400@1.5"); 304 UpdateDisplay("400x400@1.5");
285 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 305 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
286 EXPECT_TRUE(IsDisplayVisibleInTray()); 306 EXPECT_TRUE(IsDisplayVisibleInTray());
287 expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED); 307 expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED);
288 EXPECT_EQ(expected, GetTrayDisplayText()); 308 EXPECT_EQ(expected, GetTrayDisplayText());
289 EXPECT_EQ( 309 EXPECT_EQ(
290 GetTooltipText( 310 GetTooltipText(
291 expected, GetFirstDisplayName(), "600x600", base::string16(), ""), 311 expected, GetFirstDisplayName(), "600x600", base::string16(), ""),
292 GetTrayDisplayTooltipText()); 312 GetTrayDisplayTooltipText());
293 CheckAccessibleName(); 313 CheckAccessibleName();
314
315 // Unified mode
316 display_manager->SetDefaultMultiDisplayMode(DisplayManager::UNIFIED);
317 display_manager->SetMultiDisplayMode(DisplayManager::UNIFIED);
318 UpdateDisplay("300x200,400x500");
319 // Update the cache variables as the primary root window changed.
320 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
321 EXPECT_TRUE(IsDisplayVisibleInTray());
322 expected = l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_UNIFIED);
323 EXPECT_EQ(expected, GetTrayDisplayText());
294 } 324 }
295 325
296 TEST_F(TrayDisplayTest, ExternalDisplayResized) { 326 TEST_F(TrayDisplayTest, ExternalDisplayResized) {
297 UpdateDisplay("400x400"); 327 UpdateDisplay("400x400");
298 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 328 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
299 gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); 329 gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
300 330
301 // Shows the tray_display even though there's a single-display. 331 // Shows the tray_display even though there's a single-display.
302 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 332 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
303 EXPECT_FALSE(IsDisplayVisibleInTray()); 333 EXPECT_FALSE(IsDisplayVisibleInTray());
304 334
305 // Extended 335 // Extended
306 UpdateDisplay("400x400,200x200@1.5"); 336 UpdateDisplay("400x400,200x200@1.5");
307 const gfx::Display& secondary_display = ScreenUtil::GetSecondaryDisplay(); 337 const gfx::Display& secondary_display = ScreenUtil::GetSecondaryDisplay();
308 338
309 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 339 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
310 EXPECT_TRUE(IsDisplayVisibleInTray()); 340 EXPECT_TRUE(IsDisplayVisibleInTray());
311 base::string16 expected = l10n_util::GetStringFUTF16( 341 base::string16 expected = l10n_util::GetStringFUTF16(
312 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, 342 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
313 l10n_util::GetStringFUTF16( 343 l10n_util::GetStringFUTF16(
314 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, 344 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME,
315 GetSecondDisplayName(), 345 GetSecondDisplayName(),
316 base::UTF8ToUTF16(secondary_display.size().ToString()))); 346 base::UTF8ToUTF16(secondary_display.size().ToString())));
317 EXPECT_EQ(expected, GetTrayDisplayText()); 347 EXPECT_EQ(expected, GetTrayDisplayText());
318 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400", 348 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400",
319 GetSecondDisplayName(), "300x300"), 349 GetSecondDisplayName(), "300x300"),
320 GetTrayDisplayTooltipText()); 350 GetTrayDisplayTooltipText());
321 CheckAccessibleName(); 351 CheckAccessibleName();
322 352
323 // Mirroring 353 // Mirroring
324 display_manager->SetSoftwareMirroring(true); 354 display_manager->SetSoftwareMirroring(true);
325 UpdateDisplay("400x400,200x200@1.5"); 355 UpdateDisplay("400x400,200x200@1.5");
326 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 356 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
327 EXPECT_TRUE(IsDisplayVisibleInTray()); 357 EXPECT_TRUE(IsDisplayVisibleInTray());
328 expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, 358 expected = l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING,
329 GetMirroringDisplayName()); 359 GetMirroringDisplayName());
330 EXPECT_EQ(expected, GetTrayDisplayText()); 360 EXPECT_EQ(expected, GetTrayDisplayText());
331 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "400x400"), 361 EXPECT_EQ(GetMirroredTooltipText(expected, GetFirstDisplayName(), "400x400"),
332 GetTrayDisplayTooltipText()); 362 GetTrayDisplayTooltipText());
333 CheckAccessibleName(); 363 CheckAccessibleName();
334 } 364 }
335 365
336 TEST_F(TrayDisplayTest, OverscanDisplay) { 366 TEST_F(TrayDisplayTest, OverscanDisplay) {
337 UpdateDisplay("400x400,300x300/o"); 367 UpdateDisplay("400x400,300x300/o");
338 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 368 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
339 gfx::Display::SetInternalDisplayId(display_manager->first_display_id()); 369 gfx::Display::SetInternalDisplayId(display_manager->first_display_id());
340 370
341 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 371 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
342 EXPECT_TRUE(IsDisplayVisibleInTray()); 372 EXPECT_TRUE(IsDisplayVisibleInTray());
343 373
344 // /o creates the default overscan, and if overscan is set, the annotation 374 // /o creates the default overscan, and if overscan is set, the annotation
345 // should be the size. 375 // should be the size.
346 base::string16 overscan = l10n_util::GetStringUTF16( 376 base::string16 overscan = l10n_util::GetStringUTF16(
347 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN); 377 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION_OVERSCAN);
348 base::string16 headline = l10n_util::GetStringFUTF16( 378 base::string16 headline = l10n_util::GetStringFUTF16(
349 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, 379 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED,
350 l10n_util::GetStringFUTF16( 380 l10n_util::GetStringFUTF16(
351 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME, 381 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATED_NAME,
(...skipping 15 matching lines...) Expand all
367 GetSecondDisplayName(), overscan)); 397 GetSecondDisplayName(), overscan));
368 second_data = l10n_util::GetStringFUTF8( 398 second_data = l10n_util::GetStringFUTF8(
369 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION, 399 IDS_ASH_STATUS_TRAY_DISPLAY_ANNOTATION,
370 base::UTF8ToUTF16("300x300"), overscan); 400 base::UTF8ToUTF16("300x300"), overscan);
371 EXPECT_EQ(GetTooltipText(headline, GetFirstDisplayName(), "400x400", 401 EXPECT_EQ(GetTooltipText(headline, GetFirstDisplayName(), "400x400",
372 GetSecondDisplayName(), second_data), 402 GetSecondDisplayName(), second_data),
373 GetTrayDisplayTooltipText()); 403 GetTrayDisplayTooltipText());
374 } 404 }
375 405
376 TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) { 406 TEST_F(TrayDisplayTest, UpdateDuringDisplayConfigurationChange) {
377 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 407 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
378 EXPECT_FALSE(IsDisplayVisibleInTray()); 408 EXPECT_FALSE(IsDisplayVisibleInTray());
379 409
380 UpdateDisplay("400x400@1.5"); 410 UpdateDisplay("400x400@1.5");
381 EXPECT_TRUE(tray()->HasSystemBubble()); 411 EXPECT_TRUE(GetTray()->HasSystemBubble());
382 EXPECT_TRUE(IsDisplayVisibleInTray()); 412 EXPECT_TRUE(IsDisplayVisibleInTray());
383 base::string16 internal_info = l10n_util::GetStringFUTF16( 413 base::string16 internal_info = l10n_util::GetStringFUTF16(
384 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY, 414 IDS_ASH_STATUS_TRAY_DISPLAY_SINGLE_DISPLAY,
385 GetFirstDisplayName(), base::UTF8ToUTF16("600x600")); 415 GetFirstDisplayName(), base::UTF8ToUTF16("600x600"));
386 EXPECT_EQ(internal_info, GetTrayDisplayText()); 416 EXPECT_EQ(internal_info, GetTrayDisplayText());
387 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600", 417 EXPECT_EQ(GetTooltipText(base::string16(), GetFirstDisplayName(), "600x600",
388 base::string16(), std::string()), 418 base::string16(), std::string()),
389 GetTrayDisplayTooltipText()); 419 GetTrayDisplayTooltipText());
390 CheckAccessibleName(); 420 CheckAccessibleName();
391 421
392 UpdateDisplay("400x400,200x200"); 422 UpdateDisplay("400x400,200x200");
393 EXPECT_TRUE(tray()->HasSystemBubble()); 423 EXPECT_TRUE(GetTray()->HasSystemBubble());
394 EXPECT_TRUE(IsDisplayVisibleInTray()); 424 EXPECT_TRUE(IsDisplayVisibleInTray());
395 base::string16 expected = l10n_util::GetStringUTF16( 425 base::string16 expected = l10n_util::GetStringUTF16(
396 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL); 426 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL);
397 base::string16 first_name = GetFirstDisplayName(); 427 base::string16 first_name = GetFirstDisplayName();
398 EXPECT_EQ(expected, GetTrayDisplayText()); 428 EXPECT_EQ(expected, GetTrayDisplayText());
399 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400", 429 EXPECT_EQ(GetTooltipText(expected, GetFirstDisplayName(), "400x400",
400 GetSecondDisplayName(), "200x200"), 430 GetSecondDisplayName(), "200x200"),
401 GetTrayDisplayTooltipText()); 431 GetTrayDisplayTooltipText());
402 CheckAccessibleName(); 432 CheckAccessibleName();
403 433
404 UpdateDisplay("400x400@1.5"); 434 UpdateDisplay("400x400@1.5");
405 tray()->ShowDefaultView(BUBBLE_USE_EXISTING); 435 GetTray()->ShowDefaultView(BUBBLE_USE_EXISTING);
406 436
407 // Back to the default state, the display tray item should disappear. 437 // Back to the default state, the display tray item should disappear.
408 UpdateDisplay("400x400"); 438 UpdateDisplay("400x400");
409 EXPECT_TRUE(tray()->HasSystemBubble()); 439 EXPECT_TRUE(GetTray()->HasSystemBubble());
410 EXPECT_FALSE(IsDisplayVisibleInTray()); 440 EXPECT_FALSE(IsDisplayVisibleInTray());
411 } 441 }
412 442
413 TEST_F(TrayDisplayTest, DisplayNotifications) { 443 TEST_F(TrayDisplayTest, DisplayNotifications) {
414 test::TestSystemTrayDelegate* tray_delegate = 444 test::TestSystemTrayDelegate* tray_delegate =
415 static_cast<test::TestSystemTrayDelegate*>( 445 static_cast<test::TestSystemTrayDelegate*>(
416 Shell::GetInstance()->system_tray_delegate()); 446 Shell::GetInstance()->system_tray_delegate());
417 tray_delegate->set_should_show_display_notification(true); 447 tray_delegate->set_should_show_display_notification(true);
418 448
419 UpdateDisplay("400x400"); 449 UpdateDisplay("400x400");
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 557
528 UpdateDisplay("400x400,200x200"); 558 UpdateDisplay("400x400,200x200");
529 EXPECT_EQ( 559 EXPECT_EQ(
530 l10n_util::GetStringUTF16( 560 l10n_util::GetStringUTF16(
531 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 561 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
532 GetDisplayNotificationText()); 562 GetDisplayNotificationText());
533 563
534 // OnDisplayConfigurationChanged() may be called more than once for a single 564 // OnDisplayConfigurationChanged() may be called more than once for a single
535 // update display in case of primary is swapped or recovered from dock mode. 565 // update display in case of primary is swapped or recovered from dock mode.
536 // Should not remove the notification in such case. 566 // Should not remove the notification in such case.
537 tray_display()->OnDisplayConfigurationChanged(); 567 GetTrayDisplay()->OnDisplayConfigurationChanged();
538 EXPECT_EQ( 568 EXPECT_EQ(
539 l10n_util::GetStringUTF16( 569 l10n_util::GetStringUTF16(
540 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL), 570 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED_NO_INTERNAL),
541 GetDisplayNotificationText()); 571 GetDisplayNotificationText());
542 572
543 // Back to the single display. It SHOULD remove the notification since the 573 // Back to the single display. It SHOULD remove the notification since the
544 // information is stale. 574 // information is stale.
545 UpdateDisplay("400x400"); 575 UpdateDisplay("400x400");
546 EXPECT_TRUE(GetDisplayNotificationText().empty()); 576 EXPECT_TRUE(GetDisplayNotificationText().empty());
547 } 577 }
548 578
549 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) { 579 TEST_F(TrayDisplayTest, UpdateAfterSuppressDisplayNotification) {
550 UpdateDisplay("400x400,200x200"); 580 UpdateDisplay("400x400,200x200");
551 581
552 test::TestSystemTrayDelegate* tray_delegate = 582 test::TestSystemTrayDelegate* tray_delegate =
553 static_cast<test::TestSystemTrayDelegate*>( 583 static_cast<test::TestSystemTrayDelegate*>(
554 Shell::GetInstance()->system_tray_delegate()); 584 Shell::GetInstance()->system_tray_delegate());
555 tray_delegate->set_should_show_display_notification(true); 585 tray_delegate->set_should_show_display_notification(true);
556 586
557 // rotate the second. 587 // rotate the second.
558 UpdateDisplay("400x400,200x200/r"); 588 UpdateDisplay("400x400,200x200/r");
559 EXPECT_EQ(l10n_util::GetStringFUTF16( 589 EXPECT_EQ(l10n_util::GetStringFUTF16(
560 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(), 590 IDS_ASH_STATUS_TRAY_DISPLAY_ROTATED, GetSecondDisplayName(),
561 l10n_util::GetStringUTF16( 591 l10n_util::GetStringUTF16(
562 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)), 592 IDS_ASH_STATUS_TRAY_DISPLAY_ORIENTATION_90)),
563 GetDisplayNotificationAdditionalText()); 593 GetDisplayNotificationAdditionalText());
564 } 594 }
565 595
566 } // namespace ash 596 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/tray_display.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698