| 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 25 matching lines...) Expand all Loading... |
| 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 : monitor_infos_(monitor_infos), |
| 39 hwnd_map_(hwnd_map) { | 39 hwnd_map_(hwnd_map) { |
| 40 UpdateFromDisplayInfos(display_infos); | 40 UpdateFromDisplayInfos(display_infos); |
| 41 } | 41 } |
| 42 | 42 |
| 43 ~TestScreenWin() override = default; | 43 ~TestScreenWin() override = default; |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 // display::win::ScreenWin: | 46 // win::ScreenWin: |
| 47 HWND GetHWNDFromNativeView(gfx::NativeView window) const override { | 47 HWND GetHWNDFromNativeView(gfx::NativeView window) const override { |
| 48 // NativeView is only used as an identifier in this tests, so interchange | 48 // NativeView is only used as an identifier in this tests, so interchange |
| 49 // NativeView with an HWND for convenience. | 49 // NativeView with an HWND for convenience. |
| 50 return reinterpret_cast<HWND>(window); | 50 return reinterpret_cast<HWND>(window); |
| 51 } | 51 } |
| 52 | 52 |
| 53 gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const override { | 53 gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const override { |
| 54 // NativeWindow is only used as an identifier in this tests, so interchange | 54 // NativeWindow is only used as an identifier in this tests, so interchange |
| 55 // an HWND for a NativeWindow for convenience. | 55 // an HWND for a NativeWindow for convenience. |
| 56 return reinterpret_cast<gfx::NativeWindow>(hwnd); | 56 return reinterpret_cast<gfx::NativeWindow>(hwnd); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 public: | 150 public: |
| 151 TestScreenWinManager() = default; | 151 TestScreenWinManager() = default; |
| 152 | 152 |
| 153 ~TestScreenWinManager() { Screen::SetScreenInstance(nullptr); } | 153 ~TestScreenWinManager() { Screen::SetScreenInstance(nullptr); } |
| 154 | 154 |
| 155 void AddMonitor(const gfx::Rect& pixel_bounds, | 155 void AddMonitor(const gfx::Rect& pixel_bounds, |
| 156 const gfx::Rect& pixel_work, | 156 const gfx::Rect& pixel_work, |
| 157 const wchar_t* device_name, | 157 const wchar_t* device_name, |
| 158 float device_scale_factor) override { | 158 float device_scale_factor) override { |
| 159 MONITORINFOEX monitor_info = | 159 MONITORINFOEX monitor_info = |
| 160 display::win::test::CreateMonitorInfo(pixel_bounds, | 160 win::test::CreateMonitorInfo(pixel_bounds, pixel_work, device_name); |
| 161 pixel_work, | |
| 162 device_name); | |
| 163 monitor_infos_.push_back(monitor_info); | 161 monitor_infos_.push_back(monitor_info); |
| 164 display_infos_.push_back(DisplayInfo(monitor_info, device_scale_factor, | 162 display_infos_.push_back(DisplayInfo(monitor_info, device_scale_factor, |
| 165 Display::ROTATE_0)); | 163 Display::ROTATE_0)); |
| 166 } | 164 } |
| 167 | 165 |
| 168 HWND CreateFakeHwnd(const gfx::Rect& bounds) override { | 166 HWND CreateFakeHwnd(const gfx::Rect& bounds) override { |
| 169 EXPECT_EQ(screen_win_, nullptr); | 167 EXPECT_EQ(screen_win_, nullptr); |
| 170 hwnd_map_.insert(std::pair<HWND, gfx::Rect>(++hwndLast_, bounds)); | 168 hwnd_map_.insert(std::pair<HWND, gfx::Rect>(++hwndLast_, bounds)); |
| 171 return hwndLast_; | 169 return hwndLast_; |
| 172 } | 170 } |
| (...skipping 3212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 public: | 3383 public: |
| 3386 ScreenWinUninitializedForced1x() = default; | 3384 ScreenWinUninitializedForced1x() = default; |
| 3387 | 3385 |
| 3388 void SetUp() override { | 3386 void SetUp() override { |
| 3389 testing::Test::SetUp(); | 3387 testing::Test::SetUp(); |
| 3390 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 3388 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 3391 switches::kForceDeviceScaleFactor, "1"); | 3389 switches::kForceDeviceScaleFactor, "1"); |
| 3392 } | 3390 } |
| 3393 | 3391 |
| 3394 void TearDown() override { | 3392 void TearDown() override { |
| 3395 display::Display::ResetForceDeviceScaleFactorForTesting(); | 3393 Display::ResetForceDeviceScaleFactorForTesting(); |
| 3396 testing::Test::TearDown(); | 3394 testing::Test::TearDown(); |
| 3397 } | 3395 } |
| 3398 | 3396 |
| 3399 private: | 3397 private: |
| 3400 DISALLOW_COPY_AND_ASSIGN(ScreenWinUninitializedForced1x); | 3398 DISALLOW_COPY_AND_ASSIGN(ScreenWinUninitializedForced1x); |
| 3401 }; | 3399 }; |
| 3402 | 3400 |
| 3403 } // namespace | 3401 } // namespace |
| 3404 | 3402 |
| 3405 TEST_F(ScreenWinUninitializedForced1x, ScreenToDIPPoints) { | 3403 TEST_F(ScreenWinUninitializedForced1x, ScreenToDIPPoints) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3499 public: | 3497 public: |
| 3500 ScreenWinUninitializedForced2x() = default; | 3498 ScreenWinUninitializedForced2x() = default; |
| 3501 | 3499 |
| 3502 void SetUp() override { | 3500 void SetUp() override { |
| 3503 testing::Test::SetUp(); | 3501 testing::Test::SetUp(); |
| 3504 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 3502 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 3505 switches::kForceDeviceScaleFactor, "2"); | 3503 switches::kForceDeviceScaleFactor, "2"); |
| 3506 } | 3504 } |
| 3507 | 3505 |
| 3508 void TearDown() override { | 3506 void TearDown() override { |
| 3509 display::Display::ResetForceDeviceScaleFactorForTesting(); | 3507 Display::ResetForceDeviceScaleFactorForTesting(); |
| 3510 testing::Test::TearDown(); | 3508 testing::Test::TearDown(); |
| 3511 } | 3509 } |
| 3512 | 3510 |
| 3513 private: | 3511 private: |
| 3514 DISALLOW_COPY_AND_ASSIGN(ScreenWinUninitializedForced2x); | 3512 DISALLOW_COPY_AND_ASSIGN(ScreenWinUninitializedForced2x); |
| 3515 }; | 3513 }; |
| 3516 | 3514 |
| 3517 } // namespace | 3515 } // namespace |
| 3518 | 3516 |
| 3519 TEST_F(ScreenWinUninitializedForced2x, ScreenToDIPPoints) { | 3517 TEST_F(ScreenWinUninitializedForced2x, ScreenToDIPPoints) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 // this test is to make sure we don't crash. | 3597 // this test is to make sure we don't crash. |
| 3600 ScreenWin::GetSystemMetricsInDIP(SM_CXSIZEFRAME); | 3598 ScreenWin::GetSystemMetricsInDIP(SM_CXSIZEFRAME); |
| 3601 } | 3599 } |
| 3602 | 3600 |
| 3603 TEST_F(ScreenWinUninitializedForced2x, GetScaleFactorForHWND) { | 3601 TEST_F(ScreenWinUninitializedForced2x, GetScaleFactorForHWND) { |
| 3604 EXPECT_EQ(2.0, ScreenWin::GetScaleFactorForHWND(nullptr)); | 3602 EXPECT_EQ(2.0, ScreenWin::GetScaleFactorForHWND(nullptr)); |
| 3605 } | 3603 } |
| 3606 | 3604 |
| 3607 } // namespace win | 3605 } // namespace win |
| 3608 } // namespace display | 3606 } // namespace display |
| OLD | NEW |