| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/events/event_utils.h" | 5 #include "ui/events/event_utils.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/gfx/win/window_impl.h" | 8 #include "ui/gfx/win/window_impl.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class TestWindow : public gfx::WindowImpl { | 14 class TestWindow : public gfx::WindowImpl { |
| 15 public: | 15 public: |
| 16 TestWindow() {} | 16 TestWindow() {} |
| 17 ~TestWindow() override {} | 17 ~TestWindow() override {} |
| 18 | 18 |
| 19 BOOL ProcessWindowMessage(HWND window, | 19 BOOL ProcessWindowMessage(HWND window, |
| 20 UINT message, | 20 UINT message, |
| 21 WPARAM w_param, | 21 WPARAM w_param, |
| 22 LPARAM l_param, | 22 LPARAM l_param, |
| 23 LRESULT& result, | 23 LRESULT& result, |
| 24 DWORD msg_map_id = 0) override { | 24 DWORD msg_map_id = 0) override { |
| 25 return true; | 25 // Handle WM_NCCALCSIZE because the test below assumes there is no |
| 26 // non-client area, affecting EventSystemLocationFromNative's client to |
| 27 // screen coordinate transform. |
| 28 return message == WM_NCCALCSIZE; |
| 26 } | 29 } |
| 27 | 30 |
| 28 private: | 31 private: |
| 29 DISALLOW_COPY_AND_ASSIGN(TestWindow); | 32 DISALLOW_COPY_AND_ASSIGN(TestWindow); |
| 30 }; | 33 }; |
| 31 | 34 |
| 32 MSG CreateEvent(UINT type, WORD x, WORD y, HWND hwnd) { | 35 MSG CreateEvent(UINT type, WORD x, WORD y, HWND hwnd) { |
| 33 MSG event; | 36 MSG event; |
| 34 event.message = type; | 37 event.message = type; |
| 35 event.hwnd = hwnd; | 38 event.hwnd = hwnd; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 57 } | 60 } |
| 58 | 61 |
| 59 MSG event = CreateEvent(WM_LBUTTONDOWN, x_coord, y_coord, test_window.hwnd()); | 62 MSG event = CreateEvent(WM_LBUTTONDOWN, x_coord, y_coord, test_window.hwnd()); |
| 60 EXPECT_EQ(gfx::Point(x_coord + x_window_offset, y_coord + y_window_offset), | 63 EXPECT_EQ(gfx::Point(x_coord + x_window_offset, y_coord + y_window_offset), |
| 61 EventSystemLocationFromNative(event)); | 64 EventSystemLocationFromNative(event)); |
| 62 } | 65 } |
| 63 | 66 |
| 64 } // namespace | 67 } // namespace |
| 65 | 68 |
| 66 } // namespace ui | 69 } // namespace ui |
| OLD | NEW |