| 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 "ui/display/win/screen_win.h" | 5 #include "ui/display/win/screen_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <inttypes.h> | 8 #include <inttypes.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 namespace display { | 29 namespace display { |
| 30 namespace win { | 30 namespace win { |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 class TestScreenWin : public ScreenWin { | 33 class TestScreenWin : public ScreenWin { |
| 34 public: | 34 public: |
| 35 TestScreenWin(const std::vector<DisplayInfo>& display_infos, | 35 TestScreenWin(const std::vector<DisplayInfo>& display_infos, |
| 36 const std::vector<MONITORINFOEX>& monitor_infos, | 36 const std::vector<MONITORINFOEX>& monitor_infos, |
| 37 const std::unordered_map<HWND, gfx::Rect>& hwnd_map) | 37 const std::unordered_map<HWND, gfx::Rect>& hwnd_map) |
| 38 : monitor_infos_(monitor_infos), | 38 : ScreenWin(false), monitor_infos_(monitor_infos), hwnd_map_(hwnd_map) { |
| 39 hwnd_map_(hwnd_map) { | |
| 40 UpdateFromDisplayInfos(display_infos); | 39 UpdateFromDisplayInfos(display_infos); |
| 41 } | 40 } |
| 42 | 41 |
| 43 ~TestScreenWin() override = default; | 42 ~TestScreenWin() override = default; |
| 44 | 43 |
| 45 protected: | 44 protected: |
| 46 // win::ScreenWin: | 45 // win::ScreenWin: |
| 47 HWND GetHWNDFromNativeView(gfx::NativeView window) const override { | 46 HWND GetHWNDFromNativeView(gfx::NativeView window) const override { |
| 48 // NativeView is only used as an identifier in this tests, so interchange | 47 // NativeView is only used as an identifier in this tests, so interchange |
| 49 // NativeView with an HWND for convenience. | 48 // NativeView with an HWND for convenience. |
| 50 return reinterpret_cast<HWND>(window); | 49 return reinterpret_cast<HWND>(window); |
| 51 } | 50 } |
| 52 | 51 |
| 53 gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const override { | 52 gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const override { |
| 54 // NativeWindow is only used as an identifier in this tests, so interchange | 53 // NativeWindow is only used as an identifier in this tests, so interchange |
| 55 // an HWND for a NativeWindow for convenience. | 54 // an HWND for a NativeWindow for convenience. |
| 56 return reinterpret_cast<gfx::NativeWindow>(hwnd); | 55 return reinterpret_cast<gfx::NativeWindow>(hwnd); |
| 57 } | 56 } |
| 58 | 57 |
| 59 private: | 58 private: |
| 60 void Initialize() override {} | |
| 61 | |
| 62 // Finding the corresponding monitor from a point is generally handled by | 59 // Finding the corresponding monitor from a point is generally handled by |
| 63 // Windows's MonitorFromPoint. This mocked function requires that the provided | 60 // Windows's MonitorFromPoint. This mocked function requires that the provided |
| 64 // point is contained entirely in the monitor. | 61 // point is contained entirely in the monitor. |
| 65 MONITORINFOEX MonitorInfoFromScreenPoint(const gfx::Point& screen_point) const | 62 MONITORINFOEX MonitorInfoFromScreenPoint(const gfx::Point& screen_point) const |
| 66 override { | 63 override { |
| 67 for (const MONITORINFOEX& monitor_info : monitor_infos_) { | 64 for (const MONITORINFOEX& monitor_info : monitor_infos_) { |
| 68 if (gfx::Rect(monitor_info.rcMonitor).Contains(screen_point)) | 65 if (gfx::Rect(monitor_info.rcMonitor).Contains(screen_point)) |
| 69 return monitor_info; | 66 return monitor_info; |
| 70 } | 67 } |
| 71 NOTREACHED(); | 68 NOTREACHED(); |
| (...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3597 // this test is to make sure we don't crash. | 3594 // this test is to make sure we don't crash. |
| 3598 ScreenWin::GetSystemMetricsInDIP(SM_CXSIZEFRAME); | 3595 ScreenWin::GetSystemMetricsInDIP(SM_CXSIZEFRAME); |
| 3599 } | 3596 } |
| 3600 | 3597 |
| 3601 TEST_F(ScreenWinUninitializedForced2x, GetScaleFactorForHWND) { | 3598 TEST_F(ScreenWinUninitializedForced2x, GetScaleFactorForHWND) { |
| 3602 EXPECT_EQ(2.0, ScreenWin::GetScaleFactorForHWND(nullptr)); | 3599 EXPECT_EQ(2.0, ScreenWin::GetScaleFactorForHWND(nullptr)); |
| 3603 } | 3600 } |
| 3604 | 3601 |
| 3605 } // namespace win | 3602 } // namespace win |
| 3606 } // namespace display | 3603 } // namespace display |
| OLD | NEW |