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> |
| 8 |
7 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
8 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
9 #include "ash/shell.h" | 11 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
11 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/shell_test_api.h" | 14 #include "ash/test/shell_test_api.h" |
13 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
14 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
15 #include "ui/aura/window_tracker.h" | 17 #include "ui/aura/window_tracker.h" |
16 #include "ui/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
(...skipping 19 matching lines...) Expand all Loading... |
36 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \ | 38 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \ |
37 ConvertToScreenWhileRemovingSecondaryDisplay | 39 ConvertToScreenWhileRemovingSecondaryDisplay |
38 #endif | 40 #endif |
39 | 41 |
40 namespace ash { | 42 namespace ash { |
41 namespace test { | 43 namespace test { |
42 | 44 |
43 namespace { | 45 namespace { |
44 | 46 |
45 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { | 47 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { |
46 scoped_ptr<display::DisplayLayout> layout(Shell::GetInstance() | 48 std::unique_ptr<display::DisplayLayout> layout(Shell::GetInstance() |
47 ->display_manager() | 49 ->display_manager() |
48 ->GetCurrentDisplayLayout() | 50 ->GetCurrentDisplayLayout() |
49 .Copy()); | 51 .Copy()); |
50 layout->placement_list[0].position = position; | 52 layout->placement_list[0].position = position; |
51 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 53 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
52 std::move(layout)); | 54 std::move(layout)); |
53 } | 55 } |
54 | 56 |
55 ScreenPositionController* GetScreenPositionController() { | 57 ScreenPositionController* GetScreenPositionController() { |
56 ShellTestApi test_api(Shell::GetInstance()); | 58 ShellTestApi test_api(Shell::GetInstance()); |
57 return test_api.screen_position_controller(); | 59 return test_api.screen_position_controller(); |
58 } | 60 } |
59 | 61 |
(...skipping 19 matching lines...) Expand all Loading... |
79 // Converts a point (x, y) in host window's coordinate to screen and | 81 // Converts a point (x, y) in host window's coordinate to screen and |
80 // returns its string representation. | 82 // returns its string representation. |
81 std::string ConvertHostPointToScreen(int x, int y) const { | 83 std::string ConvertHostPointToScreen(int x, int y) const { |
82 gfx::Point point(x, y); | 84 gfx::Point point(x, y); |
83 GetScreenPositionController()->ConvertHostPointToScreen( | 85 GetScreenPositionController()->ConvertHostPointToScreen( |
84 window_->GetRootWindow(), &point); | 86 window_->GetRootWindow(), &point); |
85 return point.ToString(); | 87 return point.ToString(); |
86 } | 88 } |
87 | 89 |
88 protected: | 90 protected: |
89 scoped_ptr<aura::Window> window_; | 91 std::unique_ptr<aura::Window> window_; |
90 aura::test::TestWindowDelegate window_delegate_; | 92 aura::test::TestWindowDelegate window_delegate_; |
91 | 93 |
92 private: | 94 private: |
93 DISALLOW_COPY_AND_ASSIGN(ScreenPositionControllerTest); | 95 DISALLOW_COPY_AND_ASSIGN(ScreenPositionControllerTest); |
94 }; | 96 }; |
95 | 97 |
96 } // namespace | 98 } // namespace |
97 | 99 |
98 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { | 100 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { |
99 // 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) |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // We want to check that none of these synthetic events are dispatched after | 336 // We want to check that none of these synthetic events are dispatched after |
335 // ScreenPositionClient has been detached from the root window. | 337 // ScreenPositionClient has been detached from the root window. |
336 GetEventGenerator().MoveMouseTo(800, 200); | 338 GetEventGenerator().MoveMouseTo(800, 200); |
337 EXPECT_TRUE(window_->GetBoundsInScreen().Contains( | 339 EXPECT_TRUE(window_->GetBoundsInScreen().Contains( |
338 aura::Env::GetInstance()->last_mouse_location())); | 340 aura::Env::GetInstance()->last_mouse_location())); |
339 | 341 |
340 aura::Window::Windows root_windows = | 342 aura::Window::Windows root_windows = |
341 Shell::GetInstance()->GetAllRootWindows(); | 343 Shell::GetInstance()->GetAllRootWindows(); |
342 aura::WindowTracker tracker; | 344 aura::WindowTracker tracker; |
343 tracker.Add(root_windows[1]); | 345 tracker.Add(root_windows[1]); |
344 scoped_ptr<ConvertToScreenEventHandler> event_handler( | 346 std::unique_ptr<ConvertToScreenEventHandler> event_handler( |
345 new ConvertToScreenEventHandler); | 347 new ConvertToScreenEventHandler); |
346 | 348 |
347 // Remove the secondary monitor. | 349 // Remove the secondary monitor. |
348 UpdateDisplay("600x600"); | 350 UpdateDisplay("600x600"); |
349 | 351 |
350 // The secondary root window is not immediately destroyed. | 352 // The secondary root window is not immediately destroyed. |
351 EXPECT_TRUE(tracker.Contains(root_windows[1])); | 353 EXPECT_TRUE(tracker.Contains(root_windows[1])); |
352 | 354 |
353 RunAllPendingInMessageLoop(); | 355 RunAllPendingInMessageLoop(); |
354 | 356 |
355 // Check that we waited long enough and that the secondary root window was | 357 // Check that we waited long enough and that the secondary root window was |
356 // destroyed. | 358 // destroyed. |
357 EXPECT_FALSE(tracker.Contains(root_windows[1])); | 359 EXPECT_FALSE(tracker.Contains(root_windows[1])); |
358 | 360 |
359 // 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 |
360 // coordinates. | 362 // coordinates. |
361 EXPECT_TRUE(event_handler->could_convert_to_screen()); | 363 EXPECT_TRUE(event_handler->could_convert_to_screen()); |
362 } | 364 } |
363 | 365 |
364 } // namespace test | 366 } // namespace test |
365 } // namespace ash | 367 } // namespace ash |
OLD | NEW |