| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/example/wm/move_loop.h" | 5 #include "components/mus/example/wm/move_loop.h" |
| 6 | 6 |
| 7 #include "components/mus/public/cpp/tests/test_window.h" | 7 #include "components/mus/public/cpp/tests/test_window.h" |
| 8 #include "mojo/converters/input_events/input_events_type_converters.h" | 8 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| 11 #include "ui/gfx/geometry/point.h" | 11 #include "ui/gfx/geometry/point.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 | 13 |
| 14 using MoveLoopTest = testing::Test; | 14 using MoveLoopTest = testing::Test; |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Sets the client area for |window|. Padding is provided on the top so that | 18 // Sets the client area for |window|. Padding is provided on the top so that |
| 19 // there is a movable region. All other edges are sized to | 19 // there is a movable region. All other edges are sized to |
| 20 // |MoveLoop::kResizeSize|. | 20 // |MoveLoop::kResizeSize|. |
| 21 void SetClientArea(mus::Window* window) { | 21 void SetClientArea(mus::Window* window) { |
| 22 if (window->bounds().IsEmpty()) | 22 if (window->bounds().IsEmpty()) |
| 23 window->SetBounds(gfx::Rect(100, 200, 300, 400)); | 23 window->SetBounds(gfx::Rect(100, 200, 300, 400)); |
| 24 | 24 |
| 25 gfx::Rect client_area(window->bounds().size()); | 25 window->SetClientArea( |
| 26 client_area.Inset(MoveLoop::kResizeSize, MoveLoop::kResizeSize + 10, | 26 gfx::Insets(MoveLoop::kResizeSize + 10, MoveLoop::kResizeSize, |
| 27 MoveLoop::kResizeSize, MoveLoop::kResizeSize); | 27 MoveLoop::kResizeSize, MoveLoop::kResizeSize)); |
| 28 window->SetClientArea(client_area); | |
| 29 } | 28 } |
| 30 | 29 |
| 31 mus::mojom::EventPtr CreatePointerDownEvent(const gfx::Point& location) { | 30 mus::mojom::EventPtr CreatePointerDownEvent(const gfx::Point& location) { |
| 32 const ui::TouchEvent event(ui::ET_TOUCH_PRESSED, location, 1, | 31 const ui::TouchEvent event(ui::ET_TOUCH_PRESSED, location, 1, |
| 33 base::TimeDelta()); | 32 base::TimeDelta()); |
| 34 return mus::mojom::Event::From(static_cast<const ui::Event&>(event)); | 33 return mus::mojom::Event::From(static_cast<const ui::Event&>(event)); |
| 35 } | 34 } |
| 36 | 35 |
| 37 mus::mojom::EventPtr CreatePointerMove(const gfx::Point& location) { | 36 mus::mojom::EventPtr CreatePointerMove(const gfx::Point& location) { |
| 38 const ui::TouchEvent event(ui::ET_TOUCH_MOVED, location, 1, | 37 const ui::TouchEvent event(ui::ET_TOUCH_MOVED, location, 1, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 ASSERT_TRUE(move_loop.get()) << i; | 170 ASSERT_TRUE(move_loop.get()) << i; |
| 172 for (int j = 0; j < data[i].delta_count; ++j) { | 171 for (int j = 0; j < data[i].delta_count; ++j) { |
| 173 pointer_location.Offset(data[i].delta_x[j], data[i].delta_y[j]); | 172 pointer_location.Offset(data[i].delta_x[j], data[i].delta_y[j]); |
| 174 ASSERT_EQ(MoveLoop::MoveResult::CONTINUE, | 173 ASSERT_EQ(MoveLoop::MoveResult::CONTINUE, |
| 175 move_loop->Move(*CreatePointerMove(pointer_location))) | 174 move_loop->Move(*CreatePointerMove(pointer_location))) |
| 176 << i << " " << j; | 175 << i << " " << j; |
| 177 } | 176 } |
| 178 ASSERT_EQ(data[i].expected_bounds, window.bounds()); | 177 ASSERT_EQ(data[i].expected_bounds, window.bounds()); |
| 179 } | 178 } |
| 180 } | 179 } |
| OLD | NEW |