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

Side by Side Diff: ash/system/web_notification/ash_popup_alignment_delegate_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 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 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" 5 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
11 #include "ash/display/window_tree_host_manager.h" 11 #include "ash/display/window_tree_host_manager.h"
12 #include "ash/screen_util.h" 12 #include "ash/screen_util.h"
13 #include "ash/shelf/shelf.h" 13 #include "ash/shelf/shelf.h"
14 #include "ash/shelf/shelf_layout_manager.h" 14 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_types.h" 15 #include "ash/shelf/shelf_types.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_window_ids.h" 17 #include "ash/shell_window_ids.h"
18 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
21 #include "ui/display/screen.h"
21 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
22 #include "ui/gfx/screen.h"
23 #include "ui/keyboard/keyboard_switches.h" 23 #include "ui/keyboard/keyboard_switches.h"
24 #include "ui/keyboard/keyboard_util.h" 24 #include "ui/keyboard/keyboard_util.h"
25 #include "ui/message_center/message_center_style.h" 25 #include "ui/message_center/message_center_style.h"
26 26
27 namespace ash { 27 namespace ash {
28 28
29 class AshPopupAlignmentDelegateTest : public test::AshTestBase { 29 class AshPopupAlignmentDelegateTest : public test::AshTestBase {
30 public: 30 public:
31 AshPopupAlignmentDelegateTest() {} 31 AshPopupAlignmentDelegateTest() {}
32 ~AshPopupAlignmentDelegateTest() override {} 32 ~AshPopupAlignmentDelegateTest() override {}
(...skipping 24 matching lines...) Expand all
57 BOTTOM_LEFT, 57 BOTTOM_LEFT,
58 BOTTOM_RIGHT, 58 BOTTOM_RIGHT,
59 OUTSIDE 59 OUTSIDE
60 }; 60 };
61 61
62 AshPopupAlignmentDelegate* alignment_delegate() { 62 AshPopupAlignmentDelegate* alignment_delegate() {
63 return alignment_delegate_.get(); 63 return alignment_delegate_.get();
64 } 64 }
65 65
66 void UpdateWorkArea(AshPopupAlignmentDelegate* alignment_delegate, 66 void UpdateWorkArea(AshPopupAlignmentDelegate* alignment_delegate,
67 const gfx::Display& display) { 67 const display::Display& display) {
68 alignment_delegate->StartObserving(gfx::Screen::GetScreen(), display); 68 alignment_delegate->StartObserving(display::Screen::GetScreen(), display);
69 // Update the layout 69 // Update the layout
70 alignment_delegate->OnDisplayWorkAreaInsetsChanged(); 70 alignment_delegate->OnDisplayWorkAreaInsetsChanged();
71 } 71 }
72 72
73 void SetAlignmentDelegate( 73 void SetAlignmentDelegate(
74 std::unique_ptr<AshPopupAlignmentDelegate> delegate) { 74 std::unique_ptr<AshPopupAlignmentDelegate> delegate) {
75 if (!delegate.get()) { 75 if (!delegate.get()) {
76 alignment_delegate_.reset(); 76 alignment_delegate_.reset();
77 return; 77 return;
78 } 78 }
79 alignment_delegate_ = std::move(delegate); 79 alignment_delegate_ = std::move(delegate);
80 UpdateWorkArea(alignment_delegate_.get(), 80 UpdateWorkArea(alignment_delegate_.get(),
81 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 81 display::Screen::GetScreen()->GetPrimaryDisplay());
82 } 82 }
83 83
84 Position GetPositionInDisplay(const gfx::Point& point) { 84 Position GetPositionInDisplay(const gfx::Point& point) {
85 const gfx::Rect& work_area = 85 const gfx::Rect& work_area =
86 gfx::Screen::GetScreen()->GetPrimaryDisplay().work_area(); 86 display::Screen::GetScreen()->GetPrimaryDisplay().work_area();
87 const gfx::Point center_point = work_area.CenterPoint(); 87 const gfx::Point center_point = work_area.CenterPoint();
88 if (work_area.x() > point.x() || work_area.y() > point.y() || 88 if (work_area.x() > point.x() || work_area.y() > point.y() ||
89 work_area.right() < point.x() || work_area.bottom() < point.y()) { 89 work_area.right() < point.x() || work_area.bottom() < point.y()) {
90 return OUTSIDE; 90 return OUTSIDE;
91 } 91 }
92 92
93 if (center_point.x() < point.x()) 93 if (center_point.x() < point.x())
94 return (center_point.y() < point.y()) ? BOTTOM_RIGHT : TOP_RIGHT; 94 return (center_point.y() < point.y()) ? BOTTOM_RIGHT : TOP_RIGHT;
95 else 95 else
96 return (center_point.y() < point.y()) ? BOTTOM_LEFT : TOP_LEFT; 96 return (center_point.y() < point.y()) ? BOTTOM_LEFT : TOP_LEFT;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 alignment_delegate()->GetBaseLine()); 267 alignment_delegate()->GetBaseLine());
268 } 268 }
269 269
270 TEST_F(AshPopupAlignmentDelegateTest, Extended) { 270 TEST_F(AshPopupAlignmentDelegateTest, Extended) {
271 if (!SupportsMultipleDisplays()) 271 if (!SupportsMultipleDisplays())
272 return; 272 return;
273 UpdateDisplay("600x600,800x800"); 273 UpdateDisplay("600x600,800x800");
274 SetAlignmentDelegate(base::WrapUnique(new AshPopupAlignmentDelegate( 274 SetAlignmentDelegate(base::WrapUnique(new AshPopupAlignmentDelegate(
275 Shelf::ForPrimaryDisplay()->shelf_layout_manager()))); 275 Shelf::ForPrimaryDisplay()->shelf_layout_manager())));
276 276
277 gfx::Display second_display = ScreenUtil::GetSecondaryDisplay(); 277 display::Display second_display = ScreenUtil::GetSecondaryDisplay();
278 aura::Window* second_root = 278 aura::Window* second_root =
279 Shell::GetInstance() 279 Shell::GetInstance()
280 ->window_tree_host_manager() 280 ->window_tree_host_manager()
281 ->GetRootWindowForDisplayId(second_display.id()); 281 ->GetRootWindowForDisplayId(second_display.id());
282 AshPopupAlignmentDelegate for_2nd_display( 282 AshPopupAlignmentDelegate for_2nd_display(
283 Shelf::ForWindow(second_root)->shelf_layout_manager()); 283 Shelf::ForWindow(second_root)->shelf_layout_manager());
284 UpdateWorkArea(&for_2nd_display, second_display); 284 UpdateWorkArea(&for_2nd_display, second_display);
285 // Make sure that the toast position on the secondary display is 285 // Make sure that the toast position on the secondary display is
286 // positioned correctly. 286 // positioned correctly.
287 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10))); 287 EXPECT_LT(1300, for_2nd_display.GetToastOriginX(gfx::Rect(0, 0, 10, 10)));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 SetKeyboardBounds(keyboard_bounds); 325 SetKeyboardBounds(keyboard_bounds);
326 int keyboard_baseline = alignment_delegate()->GetBaseLine(); 326 int keyboard_baseline = alignment_delegate()->GetBaseLine();
327 EXPECT_NE(baseline, keyboard_baseline); 327 EXPECT_NE(baseline, keyboard_baseline);
328 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline); 328 EXPECT_GT(keyboard_bounds.y(), keyboard_baseline);
329 329
330 SetKeyboardBounds(gfx::Rect()); 330 SetKeyboardBounds(gfx::Rect());
331 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); 331 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine());
332 } 332 }
333 333
334 } // namespace ash 334 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/ash_popup_alignment_delegate.cc ('k') | ash/system/web_notification/web_notification_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698