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

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

Issue 2524873002: Rename WindowTreeHost G|SetBounds to indicate they are in pixels. (Closed)
Patch Set: rebase Created 4 years 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/display/screen_position_controller.cc ('k') | ash/display/unified_mouse_warp_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { 100 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) {
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(
111 root_windows[0]->GetHost()->GetBounds().origin().ToString()); 111 "100,100",
112 root_windows[0]->GetHost()->GetBoundsInPixels().origin().ToString());
112 EXPECT_EQ("200x200", 113 EXPECT_EQ("200x200",
113 root_windows[0]->GetHost()->GetBounds().size().ToString()); 114 root_windows[0]->GetHost()->GetBoundsInPixels().size().ToString());
114 EXPECT_EQ("100,500", 115 EXPECT_EQ(
115 root_windows[1]->GetHost()->GetBounds().origin().ToString()); 116 "100,500",
117 root_windows[1]->GetHost()->GetBoundsInPixels().origin().ToString());
116 EXPECT_EQ("200x200", 118 EXPECT_EQ("200x200",
117 root_windows[1]->GetHost()->GetBounds().size().ToString()); 119 root_windows[1]->GetHost()->GetBoundsInPixels().size().ToString());
118 120
119 const gfx::Point window_pos(100, 100); 121 const gfx::Point window_pos(100, 100);
120 window_->SetBoundsInScreen( 122 window_->SetBoundsInScreen(
121 gfx::Rect(window_pos, gfx::Size(100, 100)), 123 gfx::Rect(window_pos, gfx::Size(100, 100)),
122 display::Screen::GetScreen()->GetDisplayNearestPoint(window_pos)); 124 display::Screen::GetScreen()->GetDisplayNearestPoint(window_pos));
123 SetSecondaryDisplayLayout(display::DisplayPlacement::RIGHT); 125 SetSecondaryDisplayLayout(display::DisplayPlacement::RIGHT);
124 // The point is on the primary root window. 126 // The point is on the primary root window.
125 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); 127 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50));
126 // The point is out of the all root windows. 128 // The point is out of the all root windows.
127 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); 129 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // The point is on the primary root window. 190 // The point is on the primary root window.
189 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); 191 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400));
190 } 192 }
191 193
192 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { 194 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) {
193 UpdateDisplay("50+50-200x200*2,50+300-300x300"); 195 UpdateDisplay("50+50-200x200*2,50+300-300x300");
194 196
195 aura::Window::Windows root_windows = 197 aura::Window::Windows root_windows =
196 Shell::GetInstance()->GetAllRootWindows(); 198 Shell::GetInstance()->GetAllRootWindows();
197 EXPECT_EQ("50,50 200x200", 199 EXPECT_EQ("50,50 200x200",
198 root_windows[0]->GetHost()->GetBounds().ToString()); 200 root_windows[0]->GetHost()->GetBoundsInPixels().ToString());
199 EXPECT_EQ("50,300 300x300", 201 EXPECT_EQ("50,300 300x300",
200 root_windows[1]->GetHost()->GetBounds().ToString()); 202 root_windows[1]->GetHost()->GetBoundsInPixels().ToString());
201 203
202 // Put |window_| to the primary 2x display. 204 // Put |window_| to the primary 2x display.
203 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), 205 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50),
204 display::Screen::GetScreen()->GetPrimaryDisplay()); 206 display::Screen::GetScreen()->GetPrimaryDisplay());
205 // (30, 30) means the host coordinate, so the point is still on the primary 207 // (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. 208 // root window. Since it's 2x, the specified native point was halved.
207 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); 209 EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30));
208 // Similar to above but the point is out of the all root windows. 210 // Similar to above but the point is out of the all root windows.
209 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400)); 211 EXPECT_EQ("200,200", ConvertHostPointToScreen(400, 400));
210 // Similar to above but the point is on the secondary display. 212 // Similar to above but the point is on the secondary display.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // destroyed. 360 // destroyed.
359 EXPECT_FALSE(tracker.Contains(root_windows[1])); 361 EXPECT_FALSE(tracker.Contains(root_windows[1]));
360 362
361 // Check that we could convert all of the mouse events we got to screen 363 // Check that we could convert all of the mouse events we got to screen
362 // coordinates. 364 // coordinates.
363 EXPECT_TRUE(event_handler->could_convert_to_screen()); 365 EXPECT_TRUE(event_handler->could_convert_to_screen());
364 } 366 }
365 367
366 } // namespace test 368 } // namespace test
367 } // namespace ash 369 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/screen_position_controller.cc ('k') | ash/display/unified_mouse_warp_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698