| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/screen_position_controller.h" | 5 #include "ash/display/screen_position_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Make sure that the point is in host coordinates. (crbug.com/521919) | 101 // Make sure that the point is in host coordinates. (crbug.com/521919) |
| 102 UpdateDisplay("100+100-200x200,100+300-200x200"); | 102 UpdateDisplay("100+100-200x200,100+300-200x200"); |
| 103 // The point 150,210 should be in host coords, and detected as outside. | 103 // The point 150,210 should be in host coords, and detected as outside. |
| 104 EXPECT_EQ("350,10", ConvertHostPointToScreen(150, 210)); | 104 EXPECT_EQ("350,10", ConvertHostPointToScreen(150, 210)); |
| 105 | 105 |
| 106 UpdateDisplay("100+100-200x200,100+500-200x200"); | 106 UpdateDisplay("100+100-200x200,100+500-200x200"); |
| 107 | 107 |
| 108 aura::Window::Windows root_windows = | 108 aura::Window::Windows root_windows = |
| 109 Shell::GetInstance()->GetAllRootWindows(); | 109 Shell::GetInstance()->GetAllRootWindows(); |
| 110 EXPECT_EQ("100,100", | 110 EXPECT_EQ("100,100", |
| 111 root_windows[0]->GetHost()->GetBounds().origin().ToString()); | 111 root_windows[0]->GetHost()->GetBoundsInPixel().origin().ToString()); |
| 112 EXPECT_EQ("200x200", | 112 EXPECT_EQ("200x200", |
| 113 root_windows[0]->GetHost()->GetBounds().size().ToString()); | 113 root_windows[0]->GetHost()->GetBoundsInPixel().size().ToString()); |
| 114 EXPECT_EQ("100,500", | 114 EXPECT_EQ("100,500", |
| 115 root_windows[1]->GetHost()->GetBounds().origin().ToString()); | 115 root_windows[1]->GetHost()->GetBoundsInPixel().origin().ToString()); |
| 116 EXPECT_EQ("200x200", | 116 EXPECT_EQ("200x200", |
| 117 root_windows[1]->GetHost()->GetBounds().size().ToString()); | 117 root_windows[1]->GetHost()->GetBoundsInPixel().size().ToString()); |
| 118 | 118 |
| 119 const gfx::Point window_pos(100, 100); | 119 const gfx::Point window_pos(100, 100); |
| 120 window_->SetBoundsInScreen( | 120 window_->SetBoundsInScreen( |
| 121 gfx::Rect(window_pos, gfx::Size(100, 100)), | 121 gfx::Rect(window_pos, gfx::Size(100, 100)), |
| 122 display::Screen::GetScreen()->GetDisplayNearestPoint(window_pos)); | 122 display::Screen::GetScreen()->GetDisplayNearestPoint(window_pos)); |
| 123 SetSecondaryDisplayLayout(display::DisplayPlacement::RIGHT); | 123 SetSecondaryDisplayLayout(display::DisplayPlacement::RIGHT); |
| 124 // The point is on the primary root window. | 124 // The point is on the primary root window. |
| 125 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); | 125 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); |
| 126 // The point is out of the all root windows. | 126 // The point is out of the all root windows. |
| 127 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); | 127 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // The point is on the primary root window. | 188 // The point is on the primary root window. |
| 189 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); | 189 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { | 192 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { |
| 193 UpdateDisplay("50+50-200x200*2,50+300-300x300"); | 193 UpdateDisplay("50+50-200x200*2,50+300-300x300"); |
| 194 | 194 |
| 195 aura::Window::Windows root_windows = | 195 aura::Window::Windows root_windows = |
| 196 Shell::GetInstance()->GetAllRootWindows(); | 196 Shell::GetInstance()->GetAllRootWindows(); |
| 197 EXPECT_EQ("50,50 200x200", | 197 EXPECT_EQ("50,50 200x200", |
| 198 root_windows[0]->GetHost()->GetBounds().ToString()); | 198 root_windows[0]->GetHost()->GetBoundsInPixel().ToString()); |
| 199 EXPECT_EQ("50,300 300x300", | 199 EXPECT_EQ("50,300 300x300", |
| 200 root_windows[1]->GetHost()->GetBounds().ToString()); | 200 root_windows[1]->GetHost()->GetBoundsInPixel().ToString()); |
| 201 | 201 |
| 202 // Put |window_| to the primary 2x display. | 202 // Put |window_| to the primary 2x display. |
| 203 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), | 203 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), |
| 204 display::Screen::GetScreen()->GetPrimaryDisplay()); | 204 display::Screen::GetScreen()->GetPrimaryDisplay()); |
| 205 // (30, 30) means the host coordinate, so the point is still on the primary | 205 // (30, 30) means the host coordinate, so the point is still on the primary |
| 206 // root window. Since it's 2x, the specified native point was halved. | 206 // root window. Since it's 2x, the specified native point was halved. |
| 207 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); | 207 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); |
| 208 // Similar to above but the point is out of the all root windows. | 208 // Similar to above but the point is out of the all root windows. |
| 209 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); | 209 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); |
| 210 // Similar to above but the point is on the secondary display. | 210 // Similar to above but the point is on the secondary display. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // destroyed. | 358 // destroyed. |
| 359 EXPECT_FALSE(tracker.Contains(root_windows[1])); | 359 EXPECT_FALSE(tracker.Contains(root_windows[1])); |
| 360 | 360 |
| 361 // Check that we could convert all of the mouse events we got to screen | 361 // Check that we could convert all of the mouse events we got to screen |
| 362 // coordinates. | 362 // coordinates. |
| 363 EXPECT_TRUE(event_handler->could_convert_to_screen()); | 363 EXPECT_TRUE(event_handler->could_convert_to_screen()); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace test | 366 } // namespace test |
| 367 } // namespace ash | 367 } // namespace ash |
| OLD | NEW |