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/gfx/screen_win.h" | 5 #include "ui/gfx/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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 class TestScreenWin : public gfx::ScreenWin { | 45 class TestScreenWin : public gfx::ScreenWin { |
46 public: | 46 public: |
47 TestScreenWin(const std::vector<gfx::win::DisplayInfo>& display_infos, | 47 TestScreenWin(const std::vector<gfx::win::DisplayInfo>& display_infos, |
48 const std::vector<MONITORINFOEX>& monitor_infos, | 48 const std::vector<MONITORINFOEX>& monitor_infos, |
49 const std::unordered_map<HWND, gfx::Rect>& hwnd_map) | 49 const std::unordered_map<HWND, gfx::Rect>& hwnd_map) |
50 : monitor_infos_(monitor_infos), | 50 : monitor_infos_(monitor_infos), |
51 hwnd_map_(hwnd_map) { | 51 hwnd_map_(hwnd_map) { |
52 UpdateFromDisplayInfos(display_infos); | 52 UpdateFromDisplayInfos(display_infos); |
53 } | 53 } |
54 | 54 |
55 ~TestScreenWin() = default; | 55 ~TestScreenWin() override = default; |
56 | 56 |
57 protected: | 57 protected: |
58 // gfx::ScreenWin: | 58 // gfx::ScreenWin: |
59 HWND GetHWNDFromNativeView(NativeView window) const override { | 59 HWND GetHWNDFromNativeView(NativeView window) const override { |
60 // NativeView is only used as an identifier in this tests, so interchange | 60 // NativeView is only used as an identifier in this tests, so interchange |
61 // NativeView with an HWND for convenience. | 61 // NativeView with an HWND for convenience. |
62 return reinterpret_cast<HWND>(window); | 62 return reinterpret_cast<HWND>(window); |
63 } | 63 } |
64 | 64 |
65 NativeWindow GetNativeWindowFromHWND(HWND hwnd) const override { | 65 NativeWindow GetNativeWindowFromHWND(HWND hwnd) const override { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 EXPECT_NE(largest_area, 0); | 99 EXPECT_NE(largest_area, 0); |
100 return candidate; | 100 return candidate; |
101 } | 101 } |
102 | 102 |
103 MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) | 103 MONITORINFOEX MonitorInfoFromWindow(HWND hwnd, DWORD default_options) |
104 const override { | 104 const override { |
105 auto search = hwnd_map_.find(hwnd); | 105 auto search = hwnd_map_.find(hwnd); |
106 if (search != hwnd_map_.end()) | 106 if (search != hwnd_map_.end()) |
107 return MonitorInfoFromScreenRect(search->second); | 107 return MonitorInfoFromScreenRect(search->second); |
108 | 108 |
109 EXPECT_EQ(default_options, MONITOR_DEFAULTTOPRIMARY); | 109 EXPECT_EQ(default_options, static_cast<DWORD>(MONITOR_DEFAULTTOPRIMARY)); |
110 for (const auto& monitor_info : monitor_infos_) { | 110 for (const auto& monitor_info : monitor_infos_) { |
111 if (monitor_info.rcMonitor.left == 0 && | 111 if (monitor_info.rcMonitor.left == 0 && |
112 monitor_info.rcMonitor.top == 0) { | 112 monitor_info.rcMonitor.top == 0) { |
113 return monitor_info; | 113 return monitor_info; |
114 } | 114 } |
115 } | 115 } |
116 NOTREACHED(); | 116 NOTREACHED(); |
117 return monitor_infos_[0]; | 117 return monitor_infos_[0]; |
118 } | 118 } |
119 | 119 |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 screen->GetDisplayMatching(gfx::Rect(10139, 2299, 100, 100))); | 644 screen->GetDisplayMatching(gfx::Rect(10139, 2299, 100, 100))); |
645 } | 645 } |
646 | 646 |
647 TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, GetPrimaryDisplay) { | 647 TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, GetPrimaryDisplay) { |
648 gfx::Screen* screen = GetScreen(); | 648 gfx::Screen* screen = GetScreen(); |
649 gfx::Display primary = screen->GetPrimaryDisplay(); | 649 gfx::Display primary = screen->GetPrimaryDisplay(); |
650 EXPECT_EQ(gfx::Point(0, 0), primary.bounds().origin()); | 650 EXPECT_EQ(gfx::Point(0, 0), primary.bounds().origin()); |
651 } | 651 } |
652 | 652 |
653 } // namespace gfx | 653 } // namespace gfx |
OLD | NEW |