| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "mash/wm/frame/move_loop.h" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 | |
| 9 #include "base/macros.h" | |
| 10 #include "components/mus/public/cpp/tests/test_window.h" | |
| 11 #include "mojo/converters/input_events/input_events_type_converters.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 #include "ui/base/hit_test.h" | |
| 14 #include "ui/events/event.h" | |
| 15 #include "ui/gfx/geometry/point.h" | |
| 16 #include "ui/gfx/geometry/rect.h" | |
| 17 | |
| 18 using MoveLoopTest = testing::Test; | |
| 19 | |
| 20 namespace mash { | |
| 21 namespace wm { | |
| 22 | |
| 23 TEST_F(MoveLoopTest, Move) { | |
| 24 struct TestData { | |
| 25 // One of the HitTestCompat values. | |
| 26 int ht_location; | |
| 27 // Amount to move the mouse by. | |
| 28 int delta_x; | |
| 29 int delta_y; | |
| 30 gfx::Rect expected_bounds; | |
| 31 } data[] = { | |
| 32 // Move. | |
| 33 {HTCAPTION, 1, 2, gfx::Rect(101, 202, 300, 400)}, | |
| 34 | |
| 35 // Resizing | |
| 36 {HTTOPLEFT, 1, 2, gfx::Rect(101, 202, 299, 398)}, | |
| 37 {HTLEFT, 1, 2, gfx::Rect(101, 200, 299, 400)}, | |
| 38 {HTBOTTOMLEFT, -1, -2, gfx::Rect(99, 200, 301, 398)}, | |
| 39 {HTBOTTOM, -1, 4, gfx::Rect(100, 200, 300, 404)}, | |
| 40 {HTBOTTOMRIGHT, -3, 4, gfx::Rect(100, 200, 297, 404)}, | |
| 41 {HTRIGHT, 6, -4, gfx::Rect(100, 200, 306, 400)}, | |
| 42 {HTTOPRIGHT, 6, 5, gfx::Rect(100, 205, 306, 395)}, | |
| 43 }; | |
| 44 | |
| 45 for (size_t i = 0; i < arraysize(data); ++i) { | |
| 46 mus::TestWindow window; | |
| 47 window.SetBounds(gfx::Rect(100, 200, 300, 400)); | |
| 48 gfx::Point pointer_location(51, 52); | |
| 49 ui::PointerEvent pointer_down_event( | |
| 50 ui::ET_POINTER_DOWN, ui::EventPointerType::POINTER_TYPE_TOUCH, | |
| 51 pointer_location, pointer_location, ui::EF_NONE, 1, base::TimeDelta()); | |
| 52 std::unique_ptr<MoveLoop> move_loop = | |
| 53 MoveLoop::Create(&window, data[i].ht_location, pointer_down_event); | |
| 54 ASSERT_TRUE(move_loop.get()) << i; | |
| 55 pointer_location.Offset(data[i].delta_x, data[i].delta_y); | |
| 56 ui::PointerEvent pointer_move_event( | |
| 57 ui::ET_POINTER_MOVED, ui::EventPointerType::POINTER_TYPE_TOUCH, | |
| 58 pointer_location, pointer_location, ui::EF_NONE, 1, base::TimeDelta()); | |
| 59 ASSERT_EQ(MoveLoop::MoveResult::CONTINUE, | |
| 60 move_loop->Move(pointer_move_event)) | |
| 61 << i; | |
| 62 ASSERT_EQ(data[i].expected_bounds, window.bounds()); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 } // namespace wm | |
| 67 } // namespace mash | |
| OLD | NEW |