OLD | NEW |
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/root_window_transformers.h" | 5 #include "ash/display/root_window_transformers.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/common/display/display_info.h" | 9 #include "ash/common/display/display_info.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 float touch_radius_y_; | 106 float touch_radius_y_; |
107 float scroll_x_offset_; | 107 float scroll_x_offset_; |
108 float scroll_y_offset_; | 108 float scroll_y_offset_; |
109 float scroll_x_offset_ordinal_; | 109 float scroll_x_offset_ordinal_; |
110 float scroll_y_offset_ordinal_; | 110 float scroll_y_offset_ordinal_; |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 112 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
113 }; | 113 }; |
114 | 114 |
115 float GetStoredUIScale(int64_t id) { | 115 float GetStoredUIScale(int64_t id) { |
116 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). | 116 return Shell::GetInstance() |
117 GetEffectiveUIScale(); | 117 ->display_manager() |
| 118 ->GetDisplayInfo(id) |
| 119 .GetEffectiveUIScale(); |
118 } | 120 } |
119 | 121 |
120 std::unique_ptr<RootWindowTransformer> | 122 std::unique_ptr<RootWindowTransformer> |
121 CreateCurrentRootWindowTransformerForMirroring() { | 123 CreateCurrentRootWindowTransformerForMirroring() { |
122 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 124 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
123 DCHECK(display_manager->IsInMirrorMode()); | 125 DCHECK(display_manager->IsInMirrorMode()); |
124 const DisplayInfo& mirror_display_info = | 126 const DisplayInfo& mirror_display_info = |
125 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); | 127 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); |
126 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 128 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
127 display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 129 display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 magnifier->SetEnabled(true); | 307 magnifier->SetEnabled(true); |
306 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); | 308 EXPECT_FLOAT_EQ(2.0f, magnifier->GetScale()); |
307 magnifier->SetScale(2.5f, false); | 309 magnifier->SetScale(2.5f, false); |
308 EXPECT_FLOAT_EQ(2.5f, magnifier->GetScale()); | 310 EXPECT_FLOAT_EQ(2.5f, magnifier->GetScale()); |
309 generator.PressMoveAndReleaseTouchTo(50, 50); | 311 generator.PressMoveAndReleaseTouchTo(50, 50); |
310 // Default test touches have radius_x/y = 1.0, with device scale | 312 // Default test touches have radius_x/y = 1.0, with device scale |
311 // factor = 2, the scaled radius_x/y should be 0.5. | 313 // factor = 2, the scaled radius_x/y should be 0.5. |
312 EXPECT_FLOAT_EQ(0.2f, event_handler.touch_radius_x()); | 314 EXPECT_FLOAT_EQ(0.2f, event_handler.touch_radius_x()); |
313 EXPECT_FLOAT_EQ(0.2f, event_handler.touch_radius_y()); | 315 EXPECT_FLOAT_EQ(0.2f, event_handler.touch_radius_y()); |
314 | 316 |
315 generator.ScrollSequence(gfx::Point(0,0), | 317 generator.ScrollSequence(gfx::Point(0, 0), |
316 base::TimeDelta::FromMilliseconds(100), | 318 base::TimeDelta::FromMilliseconds(100), 10.0, 1.0, 5, |
317 10.0, 1.0, 5, 1); | 319 1); |
318 | 320 |
319 // ordinal_offset is invariant to the device scale factor. | 321 // ordinal_offset is invariant to the device scale factor. |
320 EXPECT_FLOAT_EQ(event_handler.scroll_x_offset(), | 322 EXPECT_FLOAT_EQ(event_handler.scroll_x_offset(), |
321 event_handler.scroll_x_offset_ordinal()); | 323 event_handler.scroll_x_offset_ordinal()); |
322 EXPECT_FLOAT_EQ(event_handler.scroll_y_offset(), | 324 EXPECT_FLOAT_EQ(event_handler.scroll_y_offset(), |
323 event_handler.scroll_y_offset_ordinal()); | 325 event_handler.scroll_y_offset_ordinal()); |
324 magnifier->SetEnabled(false); | 326 magnifier->SetEnabled(false); |
325 | 327 |
326 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 328 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
327 } | 329 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. | 426 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. |
425 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); | 427 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); |
426 | 428 |
427 UpdateDisplay("200x400,500x500"); | 429 UpdateDisplay("200x400,500x500"); |
428 // The aspect ratio is flipped, so X margin is now 125. | 430 // The aspect ratio is flipped, so X margin is now 125. |
429 transformer = CreateCurrentRootWindowTransformerForMirroring(); | 431 transformer = CreateCurrentRootWindowTransformerForMirroring(); |
430 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); | 432 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); |
431 } | 433 } |
432 | 434 |
433 } // namespace ash | 435 } // namespace ash |
OLD | NEW |