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

Side by Side Diff: ash/display/resolution_notification_controller_unittest.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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/display/resolution_notification_controller.h" 5 #include "ash/display/resolution_notification_controller.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 ~ResolutionNotificationControllerTest() override {} 54 ~ResolutionNotificationControllerTest() override {}
55 55
56 protected: 56 protected:
57 void SetUp() override { 57 void SetUp() override {
58 ash::test::AshTestBase::SetUp(); 58 ash::test::AshTestBase::SetUp();
59 ResolutionNotificationController::SuppressTimerForTest(); 59 ResolutionNotificationController::SuppressTimerForTest();
60 } 60 }
61 61
62 void SetDisplayResolutionAndNotifyWithResolution( 62 void SetDisplayResolutionAndNotifyWithResolution(
63 const gfx::Display& display, 63 const display::Display& display,
64 const gfx::Size& new_resolution, 64 const gfx::Size& new_resolution,
65 const gfx::Size& actual_new_resolution) { 65 const gfx::Size& actual_new_resolution) {
66 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 66 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
67 67
68 const DisplayInfo& info = display_manager->GetDisplayInfo(display.id()); 68 const DisplayInfo& info = display_manager->GetDisplayInfo(display.id());
69 DisplayMode old_mode(info.size_in_pixel(), 69 DisplayMode old_mode(info.size_in_pixel(),
70 60 /* refresh_rate */, 70 60 /* refresh_rate */,
71 false /* interlaced */, 71 false /* interlaced */,
72 false /* native */); 72 false /* native */);
73 DisplayMode new_mode = old_mode; 73 DisplayMode new_mode = old_mode;
(...skipping 18 matching lines...) Expand all
92 gfx::Rect bounds = info.bounds_in_native(); 92 gfx::Rect bounds = info.bounds_in_native();
93 bounds.set_size(actual_new_resolution); 93 bounds.set_size(actual_new_resolution);
94 info.SetBounds(bounds); 94 info.SetBounds(bounds);
95 } 95 }
96 info_list.push_back(info); 96 info_list.push_back(info);
97 } 97 }
98 display_manager->OnNativeDisplaysChanged(info_list); 98 display_manager->OnNativeDisplaysChanged(info_list);
99 RunAllPendingInMessageLoop(); 99 RunAllPendingInMessageLoop();
100 } 100 }
101 101
102 void SetDisplayResolutionAndNotify(const gfx::Display& display, 102 void SetDisplayResolutionAndNotify(const display::Display& display,
103 const gfx::Size& new_resolution) { 103 const gfx::Size& new_resolution) {
104 SetDisplayResolutionAndNotifyWithResolution( 104 SetDisplayResolutionAndNotifyWithResolution(
105 display, new_resolution, new_resolution); 105 display, new_resolution, new_resolution);
106 } 106 }
107 107
108 static base::string16 GetNotificationMessage() { 108 static base::string16 GetNotificationMessage() {
109 const message_center::NotificationList::Notifications& notifications = 109 const message_center::NotificationList::Notifications& notifications =
110 message_center::MessageCenter::Get()->GetVisibleNotifications(); 110 message_center::MessageCenter::Get()->GetVisibleNotifications();
111 for (message_center::NotificationList::Notifications::const_iterator iter = 111 for (message_center::NotificationList::Notifications::const_iterator iter =
112 notifications.begin(); iter != notifications.end(); ++iter) { 112 notifications.begin(); iter != notifications.end(); ++iter) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 227
228 TEST_F(ResolutionNotificationControllerTest, AcceptButton) { 228 TEST_F(ResolutionNotificationControllerTest, AcceptButton) {
229 if (!SupportsMultipleDisplays()) 229 if (!SupportsMultipleDisplays())
230 return; 230 return;
231 231
232 ash::DisplayManager* display_manager = 232 ash::DisplayManager* display_manager =
233 ash::Shell::GetInstance()->display_manager(); 233 ash::Shell::GetInstance()->display_manager();
234 234
235 UpdateDisplay("300x300#300x300%59|200x200%60"); 235 UpdateDisplay("300x300#300x300%59|200x200%60");
236 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 236 const display::Display& display =
237 display::Screen::GetScreen()->GetPrimaryDisplay();
237 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); 238 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
238 EXPECT_TRUE(IsNotificationVisible()); 239 EXPECT_TRUE(IsNotificationVisible());
239 240
240 // If there's a single display only, it will have timeout and the first button 241 // If there's a single display only, it will have timeout and the first button
241 // becomes accept. 242 // becomes accept.
242 EXPECT_TRUE(controller()->DoesNotificationTimeout()); 243 EXPECT_TRUE(controller()->DoesNotificationTimeout());
243 ClickOnNotificationButton(0); 244 ClickOnNotificationButton(0);
244 EXPECT_FALSE(IsNotificationVisible()); 245 EXPECT_FALSE(IsNotificationVisible());
245 EXPECT_EQ(1, accept_count()); 246 EXPECT_EQ(1, accept_count());
246 DisplayMode mode; 247 DisplayMode mode;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 RunAllPendingInMessageLoop(); 292 RunAllPendingInMessageLoop();
292 EXPECT_FALSE(IsNotificationVisible()); 293 EXPECT_FALSE(IsNotificationVisible());
293 EXPECT_EQ(1, accept_count()); 294 EXPECT_EQ(1, accept_count());
294 } 295 }
295 296
296 TEST_F(ResolutionNotificationControllerTest, Timeout) { 297 TEST_F(ResolutionNotificationControllerTest, Timeout) {
297 if (!SupportsMultipleDisplays()) 298 if (!SupportsMultipleDisplays())
298 return; 299 return;
299 300
300 UpdateDisplay("300x300#300x300%59|200x200%60"); 301 UpdateDisplay("300x300#300x300%59|200x200%60");
301 const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 302 const display::Display& display =
303 display::Screen::GetScreen()->GetPrimaryDisplay();
302 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); 304 SetDisplayResolutionAndNotify(display, gfx::Size(200, 200));
303 305
304 for (int i = 0; i < ResolutionNotificationController::kTimeoutInSec; ++i) { 306 for (int i = 0; i < ResolutionNotificationController::kTimeoutInSec; ++i) {
305 EXPECT_TRUE(IsNotificationVisible()) << "notification is closed after " 307 EXPECT_TRUE(IsNotificationVisible()) << "notification is closed after "
306 << i << "-th timer tick"; 308 << i << "-th timer tick";
307 TickTimer(); 309 TickTimer();
308 RunAllPendingInMessageLoop(); 310 RunAllPendingInMessageLoop();
309 } 311 }
310 EXPECT_FALSE(IsNotificationVisible()); 312 EXPECT_FALSE(IsNotificationVisible());
311 EXPECT_EQ(0, accept_count()); 313 EXPECT_EQ(0, accept_count());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ClickOnNotificationButton(0); 416 ClickOnNotificationButton(0);
415 RunAllPendingInMessageLoop(); 417 RunAllPendingInMessageLoop();
416 EXPECT_FALSE(IsNotificationVisible()); 418 EXPECT_FALSE(IsNotificationVisible());
417 EXPECT_EQ(0, accept_count()); 419 EXPECT_EQ(0, accept_count());
418 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode)); 420 EXPECT_TRUE(display_manager->GetSelectedModeForDisplayId(id2, &mode));
419 EXPECT_EQ("250x250", mode.size.ToString()); 421 EXPECT_EQ("250x250", mode.size.ToString());
420 EXPECT_EQ(58.0f, mode.refresh_rate); 422 EXPECT_EQ(58.0f, mode.refresh_rate);
421 } 423 }
422 424
423 } // namespace ash 425 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/resolution_notification_controller.cc ('k') | ash/display/root_window_transformers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698