| Index: ui/gfx/screen_win_unittest.cc | 
| diff --git a/ui/gfx/screen_win_unittest.cc b/ui/gfx/screen_win_unittest.cc | 
| index b1118c17e23b693c07341a39dc97452ac685eb5f..7115d09e419324d4d9c715c7d75db4c5deac9a0d 100644 | 
| --- a/ui/gfx/screen_win_unittest.cc | 
| +++ b/ui/gfx/screen_win_unittest.cc | 
| @@ -6,6 +6,7 @@ | 
|  | 
| #include <cwchar> | 
| #include <string> | 
| +#include <unordered_map> | 
| #include <vector> | 
|  | 
| #include <windows.h> | 
| @@ -34,8 +35,114 @@ MONITORINFOEX CreateMonitorInfo(gfx::Rect monitor, | 
| return monitor_info; | 
| } | 
|  | 
| +class TestScreenWin : public gfx::ScreenWin { | 
| + public: | 
| +  explicit TestScreenWin(const std::vector<DisplayInfo>& display_infos, | 
| +                         const std::vector<MONITORINFOEX>& monitor_infos, | 
| +                         const std::unordered_map<HWND, gfx::Rect>& hwnd_map) | 
| +      : gfx::ScreenWin(display_infos), | 
| +        monitor_infos_(monitor_infos), | 
| +        hwnd_map_(hwnd_map) {} | 
| + | 
| + private: | 
| +  MONITORINFOEX MonitorInfoFromScreenPoint(const gfx::Point& screen_point) const | 
| +      override { | 
| +    for (const MONITORINFOEX& monitor_info : monitor_infos_) { | 
| +      if (gfx::Rect(monitor_info.rcMonitor).Contains(screen_point)) { | 
| +        return monitor_info; | 
| +      } | 
| +    } | 
| +    NOTREACHED(); | 
| +    return monitor_infos_[0]; | 
| +  } | 
| + | 
| +  MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect) const | 
| +      override { | 
| +    MONITORINFOEX candidate = monitor_infos_[0]; | 
| +    int largest_area = 0; | 
| +    for (const MONITORINFOEX& monitor_info : monitor_infos_) { | 
| +      gfx::Rect bounds(monitor_info.rcMonitor); | 
| +      if (bounds.Intersects(screen_rect)) { | 
| +        bounds.Intersect(screen_rect); | 
| +        int area = bounds.height() * bounds.width(); | 
| +        if (largest_area < area) { | 
| +          candidate = monitor_info; | 
| +          largest_area = area; | 
| +        } | 
| +      } | 
| +    } | 
| +    EXPECT_NE(largest_area, 0); | 
| +    return candidate; | 
| +  } | 
| + | 
| +  MONITORINFOEX MonitorInfoFromWindow(HWND hwnd) const override { | 
| +    auto search = hwnd_map_.find(hwnd); | 
| +    EXPECT_NE(search, hwnd_map_.end()); | 
| +    return MonitorInfoFromScreenRect(search->second); | 
| +  } | 
| + | 
| +  HWND GetRootWindow(HWND hwnd) const override { | 
| +    return hwnd; | 
| +  } | 
| + | 
| + private: | 
| +  std::vector<MONITORINFOEX> monitor_infos_; | 
| +  std::unordered_map<HWND, gfx::Rect> hwnd_map_; | 
| +}; | 
| + | 
| }  // namespace | 
|  | 
| +// Manages setting up the ScreenWin global state. | 
| +class TestScreenWinInitializer { | 
| + public: | 
| +  TestScreenWinInitializer() : hwndLast_(0) {} | 
| +  ~TestScreenWinInitializer() { | 
| +    gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr); | 
| +  } | 
| + | 
| +  void AddMonitor(const gfx::Rect& pixel_bounds, | 
| +                  const gfx::Rect& pixel_work, | 
| +                  const wchar_t* device_name, | 
| +                  float device_scale_factor) { | 
| +    MONITORINFOEX monitor_info = CreateMonitorInfo(pixel_bounds, | 
| +                                                   pixel_work, | 
| +                                                   device_name); | 
| +    monitor_infos_.push_back(monitor_info); | 
| +    display_infos_.push_back(ScreenWin::DisplayInfo(monitor_info, | 
| +                                                    gfx::Display::ROTATE_0, | 
| +                                                    device_scale_factor)); | 
| +  } | 
| + | 
| +  void InitializeScreenWin() { | 
| +    ASSERT_EQ(screen_win_, nullptr); | 
| +    screen_win_.reset(new TestScreenWin(display_infos_, | 
| +                                        monitor_infos_, | 
| +                                        hwnd_map_)); | 
| +    gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_win_.get()); | 
| +  } | 
| + | 
| +  HWND CreateFakeHwnd(const gfx::Rect& bounds) { | 
| +    EXPECT_EQ(screen_win_, nullptr); | 
| +    ++hwndLast_; | 
| +    hwnd_map_.insert(std::pair<HWND, gfx::Rect>(hwndLast_, bounds)); | 
| +    return hwndLast_; | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    if (!screen_win_) { | 
| +      InitializeScreenWin(); | 
| +    } | 
| +    return screen_win_.get(); | 
| +  } | 
| + | 
| + private: | 
| +  HWND hwndLast_; | 
| +  scoped_ptr<ScreenWin> screen_win_; | 
| +  std::vector<MONITORINFOEX> monitor_infos_; | 
| +  std::vector<gfx::ScreenWin::DisplayInfo> display_infos_; | 
| +  std::unordered_map<HWND, gfx::Rect> hwnd_map_; | 
| +}; | 
| + | 
| class ScreenWinTest : public testing::Test { | 
| private: | 
| void SetUp() override { | 
| @@ -49,32 +156,869 @@ class ScreenWinTest : public testing::Test { | 
| } | 
| }; | 
|  | 
| -TEST_F(ScreenWinTest, SingleDisplay1x) { | 
| -  std::vector<MONITORINFOEX> monitor_infos; | 
| -  monitor_infos.push_back(CreateMonitorInfo(gfx::Rect(0, 0, 1920, 1200), | 
| -                                            gfx::Rect(0, 0, 1920, 1100), | 
| -                                            L"primary")); | 
| -  std::vector<gfx::Display> displays = | 
| -      ScreenWin::GetDisplaysForMonitorInfos(monitor_infos); | 
| +// Single Display of 1.0 Device Scale Factor. | 
| +class ScreenWinTestSingleDisplay1x : public ScreenWinTest { | 
| + public: | 
| +  static void SetUpTestCase() { | 
| +    ScreenWinTest::SetUpTestCase(); | 
| +    screen_win_initializer_.reset(new TestScreenWinInitializer()); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(0, 0, 1920, 1200), | 
| +                                        gfx::Rect(0, 0, 1920, 1100), | 
| +                                        L"primary", | 
| +                                        1.0); | 
| +    fake_hwnd_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(0, 0, 1920, 1100)); | 
| +    screen_win_initializer_->InitializeScreenWin(); | 
| +  } | 
| + | 
| +  static void TearDownTestCase() { | 
| +    screen_win_initializer_.reset(); | 
| +    ScreenWinTest::TearDownTestCase(); | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    return screen_win_initializer_->GetScreen(); | 
| +  } | 
| + | 
| +  HWND GetFakeHwnd() { | 
| +    return fake_hwnd_; | 
| +  } | 
|  | 
| + private: | 
| +  static scoped_ptr<TestScreenWinInitializer> screen_win_initializer_; | 
| +  static HWND fake_hwnd_; | 
| +}; | 
| + | 
| +scoped_ptr<TestScreenWinInitializer> | 
| +ScreenWinTestSingleDisplay1x::screen_win_initializer_; | 
| + | 
| +HWND ScreenWinTestSingleDisplay1x::fake_hwnd_ = NULL; | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, GetDisplays) { | 
| +  std::vector<gfx::Display> displays = GetScreen()->GetAllDisplays(); | 
| ASSERT_EQ(1u, displays.size()); | 
| EXPECT_EQ(gfx::Rect(0, 0, 1920, 1200), displays[0].bounds()); | 
| EXPECT_EQ(gfx::Rect(0, 0, 1920, 1100), displays[0].work_area()); | 
| } | 
|  | 
| -TEST_F(ScreenWinTest, SingleDisplay2x) { | 
| -  gfx::SetDefaultDeviceScaleFactor(2.0); | 
| +TEST_F(ScreenWinTestSingleDisplay1x, ScreenToDIPPoints) { | 
| +  gfx::Point origin(0, 0); | 
| +  gfx::Point middle(365, 694); | 
| +  gfx::Point lower_right(1919, 1199); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::ScreenToDIPPoint(origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::ScreenToDIPPoint(middle)); | 
| +  EXPECT_EQ(lower_right, ScreenWin::ScreenToDIPPoint(lower_right)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, DIPToScreenPoints) { | 
| +  gfx::Point origin(0, 0); | 
| +  gfx::Point middle(365, 694); | 
| +  gfx::Point lower_right(1919, 1199); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::DIPToScreenPoint(origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::DIPToScreenPoint(middle)); | 
| +  EXPECT_EQ(lower_right, ScreenWin::DIPToScreenPoint(lower_right)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, ClientToDIPPoints) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| + | 
| +  gfx::Point origin(0, 0); | 
| +  gfx::Point middle(365, 694); | 
| +  gfx::Point lower_right(1919, 1199); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::ClientToDIPPoint(hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::ClientToDIPPoint(hwnd, middle)); | 
| +  EXPECT_EQ(lower_right, ScreenWin::ClientToDIPPoint(hwnd, lower_right)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, DIPToClientPoints) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| + | 
| +  gfx::Point origin(0, 0); | 
| +  gfx::Point middle(365, 694); | 
| +  gfx::Point lower_right(1919, 1199); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::DIPToClientPoint(hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::DIPToClientPoint(hwnd, middle)); | 
| +  EXPECT_EQ(lower_right, ScreenWin::DIPToClientPoint(hwnd, lower_right)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, ScreenToDIPRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| + | 
| +  gfx::Rect origin(0, 0, 50, 100); | 
| +  gfx::Rect middle(253, 495, 41, 52); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::ScreenToDIPRect(hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::ScreenToDIPRect(hwnd, middle)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, DIPToScreenRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| + | 
| +  gfx::Rect origin(0, 0, 50, 100); | 
| +  gfx::Rect middle(253, 495, 41, 52); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::DIPToScreenRect(hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::DIPToScreenRect(hwnd, middle)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, ClientToDIPRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| + | 
| +  gfx::Rect origin(0, 0, 50, 100); | 
| +  gfx::Rect middle(253, 495, 41, 52); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::ClientToDIPRect(hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::ClientToDIPRect(hwnd, middle)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, DIPToClientRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| + | 
| +  gfx::Rect origin(0, 0, 50, 100); | 
| +  gfx::Rect middle(253, 495, 41, 52); | 
| + | 
| +  EXPECT_EQ(origin, ScreenWin::DIPToClientRect(hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::DIPToClientRect(hwnd, middle)); | 
| +} | 
|  | 
| -  std::vector<MONITORINFOEX> monitor_infos; | 
| -  monitor_infos.push_back(CreateMonitorInfo(gfx::Rect(0, 0, 1920, 1200), | 
| -                                            gfx::Rect(0, 0, 1920, 1100), | 
| -                                            L"primary")); | 
| -  std::vector<gfx::Display> displays = | 
| -      ScreenWin::GetDisplaysForMonitorInfos(monitor_infos); | 
| +TEST_F(ScreenWinTestSingleDisplay1x, ScreenToDIPSize) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
|  | 
| +  gfx::Size size(42, 131); | 
| +  EXPECT_EQ(size, ScreenWin::ScreenToDIPSize(hwnd, size)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay1x, DIPToScreenSize) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| + | 
| +  gfx::Size size(42, 131); | 
| +  EXPECT_EQ(size, ScreenWin::DIPToScreenSize(hwnd, size)); | 
| +} | 
| + | 
| +// Single Display of 2.0 Device Scale Factor. | 
| +class ScreenWinTestSingleDisplay2x : public ScreenWinTest { | 
| + public: | 
| +  static void SetUpTestCase() { | 
| +    ScreenWinTest::SetUpTestCase(); | 
| +    screen_win_initializer_.reset(new TestScreenWinInitializer()); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(0, 0, 1920, 1200), | 
| +                                        gfx::Rect(0, 0, 1920, 1100), | 
| +                                        L"primary", | 
| +                                        2.0); | 
| +    fake_hwnd_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(0, 0, 1920, 1100)); | 
| +    screen_win_initializer_->InitializeScreenWin(); | 
| +  } | 
| + | 
| +  static void TearDownTestCase() { | 
| +    screen_win_initializer_.reset(); | 
| +    ScreenWinTest::TearDownTestCase(); | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    return screen_win_initializer_->GetScreen(); | 
| +  } | 
| + | 
| +  HWND GetFakeHwnd() { | 
| +    return fake_hwnd_; | 
| +  } | 
| + | 
| + private: | 
| +  static scoped_ptr<TestScreenWinInitializer> screen_win_initializer_; | 
| +  static HWND fake_hwnd_; | 
| +}; | 
| + | 
| +scoped_ptr<TestScreenWinInitializer> | 
| +ScreenWinTestSingleDisplay2x::screen_win_initializer_; | 
| + | 
| +HWND ScreenWinTestSingleDisplay2x::fake_hwnd_ = NULL; | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, GetDisplays) { | 
| +  std::vector<gfx::Display> displays = GetScreen()->GetAllDisplays(); | 
| ASSERT_EQ(1u, displays.size()); | 
| EXPECT_EQ(gfx::Rect(0, 0, 960, 600), displays[0].bounds()); | 
| EXPECT_EQ(gfx::Rect(0, 0, 960, 550), displays[0].work_area()); | 
| } | 
|  | 
| +TEST_F(ScreenWinTestSingleDisplay2x, ScreenToDIPPoints) { | 
| +  EXPECT_EQ(gfx::Point(0, 0), ScreenWin::ScreenToDIPPoint(gfx::Point(0, 0))); | 
| +  EXPECT_EQ(gfx::Point(182, 347), | 
| +            ScreenWin::ScreenToDIPPoint(gfx::Point(365, 694))); | 
| +  EXPECT_EQ(gfx::Point(959, 599), | 
| +            ScreenWin::ScreenToDIPPoint(gfx::Point(1919, 1199))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, DIPToScreenPoints) { | 
| +  EXPECT_EQ(gfx::Point(0, 0), ScreenWin::DIPToScreenPoint(gfx::Point(0, 0))); | 
| +  EXPECT_EQ(gfx::Point(364, 694), | 
| +            ScreenWin::DIPToScreenPoint(gfx::Point(182, 347))); | 
| +  EXPECT_EQ(gfx::Point(1918, 1198), | 
| +            ScreenWin::DIPToScreenPoint(gfx::Point(959, 599))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, ClientToDIPPoints) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Point(0, 0), | 
| +            ScreenWin::ClientToDIPPoint(hwnd, gfx::Point(0, 0))); | 
| +  EXPECT_EQ(gfx::Point(182, 347), | 
| +            ScreenWin::ClientToDIPPoint(hwnd, gfx::Point(365, 694))); | 
| +  EXPECT_EQ(gfx::Point(959, 599), | 
| +            ScreenWin::ClientToDIPPoint(hwnd, gfx::Point(1919, 1199))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, DIPToClientPoints) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Point(0, 0), | 
| +            ScreenWin::DIPToClientPoint(hwnd, gfx::Point(0, 0))); | 
| +  EXPECT_EQ(gfx::Point(364, 694), | 
| +            ScreenWin::DIPToClientPoint(hwnd, gfx::Point(182, 347))); | 
| +  EXPECT_EQ(gfx::Point(1918, 1198), | 
| +            ScreenWin::DIPToClientPoint(hwnd, gfx::Point(959, 599))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, ScreenToDIPRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ScreenToDIPRect(hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ScreenToDIPRect(hwnd, gfx::Rect(253, 496, 41, 52))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, DIPToScreenRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToScreenRect(hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToScreenRect(hwnd, gfx::Rect(126, 248, 21, 26))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, ClientToDIPRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ClientToDIPRect(hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ClientToDIPRect(hwnd, gfx::Rect(253, 496, 41, 52))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, DIPToClientRects) { | 
| +  HWND hwnd = GetFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToClientRect(hwnd, gfx::Rect(126, 248, 21, 26))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, ScreenToDIPSize) { | 
| +  EXPECT_EQ(gfx::Size(21, 66), | 
| +            ScreenWin::ScreenToDIPSize(GetFakeHwnd(), gfx::Size(42, 131))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestSingleDisplay2x, DIPToScreenSize) { | 
| +  EXPECT_EQ(gfx::Size(42, 132), | 
| +            ScreenWin::DIPToScreenSize(GetFakeHwnd(), gfx::Size(21, 66))); | 
| +} | 
| + | 
| +// Two Displays of 1.0 Device Scale Factor. | 
| +class ScreenWinTestTwoDisplays1x : public ScreenWinTest { | 
| + public: | 
| +  static void SetUpTestCase() { | 
| +    ScreenWinTest::SetUpTestCase(); | 
| +    screen_win_initializer_.reset(new TestScreenWinInitializer()); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(0, 0, 1920, 1200), | 
| +                                        gfx::Rect(0, 0, 1920, 1100), | 
| +                                        L"primary", | 
| +                                        1.0); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(1920, 0, 800, 600), | 
| +                                        gfx::Rect(1920, 0, 800, 600), | 
| +                                        L"secondary", | 
| +                                        1.0); | 
| +    fake_hwnd_left_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(0, 0, 1920, 1100)); | 
| +    fake_hwnd_right_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(1920, 0, 800, 600)); | 
| +    screen_win_initializer_->InitializeScreenWin(); | 
| +  } | 
| + | 
| +  static void TearDownTestCase() { | 
| +    screen_win_initializer_.reset(); | 
| +    ScreenWinTest::TearDownTestCase(); | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    return screen_win_initializer_->GetScreen(); | 
| +  } | 
| + | 
| +  HWND GetLeftFakeHwnd() { | 
| +    return fake_hwnd_left_; | 
| +  } | 
| + | 
| +  HWND GetRightFakeHwnd() { | 
| +    return fake_hwnd_right_; | 
| +  } | 
| + | 
| + private: | 
| +  static scoped_ptr<TestScreenWinInitializer> screen_win_initializer_; | 
| +  static HWND fake_hwnd_left_; | 
| +  static HWND fake_hwnd_right_; | 
| +}; | 
| + | 
| +scoped_ptr<TestScreenWinInitializer> | 
| +ScreenWinTestTwoDisplays1x::screen_win_initializer_; | 
| + | 
| +HWND ScreenWinTestTwoDisplays1x::fake_hwnd_left_ = NULL; | 
| + | 
| +HWND ScreenWinTestTwoDisplays1x::fake_hwnd_right_ = NULL; | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x, GetDisplays) { | 
| +  std::vector<gfx::Display> displays = GetScreen()->GetAllDisplays(); | 
| +  ASSERT_EQ(2u, displays.size()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 1920, 1200), displays[0].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 1920, 1100), displays[0].work_area()); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 800, 600), displays[1].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 800, 600), displays[1].work_area()); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x, ScreenToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  gfx::Rect left_origin(0, 0, 50, 100); | 
| +  gfx::Rect left_middle(253, 495, 41, 52); | 
| +  EXPECT_EQ(left_origin, ScreenWin::ScreenToDIPRect(left_hwnd, left_origin)); | 
| +  EXPECT_EQ(left_middle, ScreenWin::ScreenToDIPRect(left_hwnd, left_middle)); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  gfx::Rect right_origin(1920, 0, 200, 300); | 
| +  gfx::Rect right_middle(2000, 496, 100, 200); | 
| +  EXPECT_EQ(right_origin, ScreenWin::ScreenToDIPRect(right_hwnd, right_origin)); | 
| +  EXPECT_EQ(right_middle, ScreenWin::ScreenToDIPRect(right_hwnd, right_middle)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x, DIPToScreenRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  gfx::Rect left_origin(0, 0, 50, 100); | 
| +  gfx::Rect left_middle(253, 495, 41, 52); | 
| +  EXPECT_EQ(left_origin, ScreenWin::DIPToScreenRect(left_hwnd, left_origin)); | 
| +  EXPECT_EQ(left_middle, ScreenWin::DIPToScreenRect(left_hwnd, left_middle)); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  gfx::Rect right_origin(1920, 0, 200, 300); | 
| +  gfx::Rect right_middle(2000, 496, 100, 200); | 
| +  EXPECT_EQ(right_origin, ScreenWin::DIPToScreenRect(right_hwnd, right_origin)); | 
| +  EXPECT_EQ(right_middle, ScreenWin::DIPToScreenRect(right_hwnd, right_middle)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x, ClientToDIPRects) { | 
| +  gfx::Rect origin(0, 0, 50, 100); | 
| +  gfx::Rect middle(253, 495, 41, 52); | 
| + | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(origin, ScreenWin::ClientToDIPRect(left_hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::ClientToDIPRect(left_hwnd, middle)); | 
| + | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(origin, ScreenWin::ClientToDIPRect(right_hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::ClientToDIPRect(right_hwnd, middle)); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x, DIPToClientRects) { | 
| +  gfx::Rect origin(0, 0, 50, 100); | 
| +  gfx::Rect middle(253, 495, 41, 52); | 
| + | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(origin, ScreenWin::DIPToClientRect(left_hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::DIPToClientRect(left_hwnd, middle)); | 
| + | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(origin, ScreenWin::DIPToClientRect(right_hwnd, origin)); | 
| +  EXPECT_EQ(middle, ScreenWin::DIPToClientRect(right_hwnd, middle)); | 
| +} | 
| + | 
| +// Two Displays of 2.0 Device Scale Factor. | 
| +class ScreenWinTestTwoDisplays2x : public ScreenWinTest { | 
| + public: | 
| +  static void SetUpTestCase() { | 
| +    ScreenWinTest::SetUpTestCase(); | 
| +    screen_win_initializer_.reset(new TestScreenWinInitializer()); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(0, 0, 1920, 1200), | 
| +                                        gfx::Rect(0, 0, 1920, 1100), | 
| +                                        L"primary", | 
| +                                        2.0); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(1920, 0, 800, 600), | 
| +                                        gfx::Rect(1920, 0, 800, 600), | 
| +                                        L"secondary", | 
| +                                        2.0); | 
| +    fake_hwnd_left_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(0, 0, 1920, 1100)); | 
| +    fake_hwnd_right_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(1920, 0, 800, 600)); | 
| +    screen_win_initializer_->InitializeScreenWin(); | 
| +  } | 
| + | 
| +  static void TearDownTestCase() { | 
| +    screen_win_initializer_.reset(); | 
| +    ScreenWinTest::TearDownTestCase(); | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    return screen_win_initializer_->GetScreen(); | 
| +  } | 
| + | 
| +  HWND GetLeftFakeHwnd() { | 
| +    return fake_hwnd_left_; | 
| +  } | 
| + | 
| +  HWND GetRightFakeHwnd() { | 
| +    return fake_hwnd_right_; | 
| +  } | 
| + | 
| + private: | 
| +  static scoped_ptr<TestScreenWinInitializer> screen_win_initializer_; | 
| +  static HWND fake_hwnd_left_; | 
| +  static HWND fake_hwnd_right_; | 
| +}; | 
| + | 
| +scoped_ptr<TestScreenWinInitializer> | 
| +ScreenWinTestTwoDisplays2x::screen_win_initializer_; | 
| + | 
| +HWND ScreenWinTestTwoDisplays2x::fake_hwnd_left_ = NULL; | 
| + | 
| +HWND ScreenWinTestTwoDisplays2x::fake_hwnd_right_ = NULL; | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x, GetDisplays) { | 
| +  std::vector<gfx::Display> displays = GetScreen()->GetAllDisplays(); | 
| +  ASSERT_EQ(2u, displays.size()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 960, 600), displays[0].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 960, 550), displays[0].work_area()); | 
| +  EXPECT_EQ(gfx::Rect(960, 0, 400, 300), displays[1].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(960, 0, 400, 300), displays[1].work_area()); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x, ScreenToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(960, 0, 100, 150), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(1920, 0, 200, 300))); | 
| +  EXPECT_EQ(gfx::Rect(1000, 248, 50, 100), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(2000, 496, 100, 200))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x, DIPToScreenRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 200, 300), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(960, 0, 100, 150))); | 
| +  EXPECT_EQ(gfx::Rect(2000, 496, 100, 200), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(1000, 248, 50, 100))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x, ClientToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(253, 496, 41, 52))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x, DIPToClientRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); | 
| +} | 
| + | 
| +// Two Displays of 1.0 (Left) and 2.0 (Right) Device Scale Factor. | 
| +class ScreenWinTestTwoDisplays1x2x : public ScreenWinTest { | 
| + public: | 
| +  static void SetUpTestCase() { | 
| +    ScreenWinTest::SetUpTestCase(); | 
| +    screen_win_initializer_.reset(new TestScreenWinInitializer()); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(0, 0, 1920, 1200), | 
| +                                        gfx::Rect(0, 0, 1920, 1100), | 
| +                                        L"primary", | 
| +                                        1.0); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(1920, 0, 800, 600), | 
| +                                        gfx::Rect(1920, 0, 800, 600), | 
| +                                        L"secondary", | 
| +                                        2.0); | 
| +    fake_hwnd_left_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(0, 0, 1920, 1100)); | 
| +    fake_hwnd_right_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(1920, 0, 800, 600)); | 
| +    screen_win_initializer_->InitializeScreenWin(); | 
| +  } | 
| + | 
| +  static void TearDownTestCase() { | 
| +    screen_win_initializer_.reset(); | 
| +    ScreenWinTest::TearDownTestCase(); | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    return screen_win_initializer_->GetScreen(); | 
| +  } | 
| + | 
| +  HWND GetLeftFakeHwnd() { | 
| +    return fake_hwnd_left_; | 
| +  } | 
| + | 
| +  HWND GetRightFakeHwnd() { | 
| +    return fake_hwnd_right_; | 
| +  } | 
| + | 
| + private: | 
| +  static scoped_ptr<TestScreenWinInitializer> screen_win_initializer_; | 
| +  static HWND fake_hwnd_left_; | 
| +  static HWND fake_hwnd_right_; | 
| +}; | 
| + | 
| +scoped_ptr<TestScreenWinInitializer> | 
| +ScreenWinTestTwoDisplays1x2x::screen_win_initializer_; | 
| + | 
| +HWND ScreenWinTestTwoDisplays1x2x::fake_hwnd_left_ = NULL; | 
| + | 
| +HWND ScreenWinTestTwoDisplays1x2x::fake_hwnd_right_ = NULL; | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x2x, GetDisplays) { | 
| +  std::vector<gfx::Display> displays = GetScreen()->GetAllDisplays(); | 
| +  ASSERT_EQ(2u, displays.size()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 1920, 1200), displays[0].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 1920, 1100), displays[0].work_area()); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 400, 300), displays[1].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 400, 300), displays[1].work_area()); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x2x, ScreenToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(253, 496, 41, 52), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 100, 150), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(1920, 0, 200, 300))); | 
| +  EXPECT_EQ(gfx::Rect(1960, 248, 50, 100), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(2000, 496, 100, 200))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x2x, DIPToScreenRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(252, 496, 42, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 200, 300), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(1920, 0, 100, 150))); | 
| +  EXPECT_EQ(gfx::Rect(2000, 496, 100, 200), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(1960, 248, 50, 100))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x2x, ClientToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(253, 496, 41, 52), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(253, 496, 41, 52))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays1x2x, DIPToClientRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(252, 496, 42, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(right_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToClientRect(right_hwnd, | 
| +                                       gfx::Rect(126, 248, 21, 26))); | 
| +} | 
| + | 
| +// Two Displays of 2.0 (Left) and 1.0 (Right) Device Scale Factor. | 
| +class ScreenWinTestTwoDisplays2x1x : public ScreenWinTest { | 
| + public: | 
| +  static void SetUpTestCase() { | 
| +    ScreenWinTest::SetUpTestCase(); | 
| +    screen_win_initializer_.reset(new TestScreenWinInitializer()); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(0, 0, 1920, 1200), | 
| +                                        gfx::Rect(0, 0, 1920, 1100), | 
| +                                        L"primary", | 
| +                                        2.0); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(1920, 0, 800, 600), | 
| +                                        gfx::Rect(1920, 0, 800, 600), | 
| +                                        L"secondary", | 
| +                                        1.0); | 
| +    fake_hwnd_left_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(0, 0, 1920, 1100)); | 
| +    fake_hwnd_right_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(1920, 0, 800, 600)); | 
| +    screen_win_initializer_->InitializeScreenWin(); | 
| +  } | 
| + | 
| +  static void TearDownTestCase() { | 
| +    screen_win_initializer_.reset(); | 
| +    ScreenWinTest::TearDownTestCase(); | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    return screen_win_initializer_->GetScreen(); | 
| +  } | 
| + | 
| +  HWND GetLeftFakeHwnd() { | 
| +    return fake_hwnd_left_; | 
| +  } | 
| + | 
| +  HWND GetRightFakeHwnd() { | 
| +    return fake_hwnd_right_; | 
| +  } | 
| + | 
| + private: | 
| +  static scoped_ptr<TestScreenWinInitializer> screen_win_initializer_; | 
| +  static HWND fake_hwnd_left_; | 
| +  static HWND fake_hwnd_right_; | 
| +}; | 
| + | 
| +scoped_ptr<TestScreenWinInitializer> | 
| +ScreenWinTestTwoDisplays2x1x::screen_win_initializer_; | 
| + | 
| +HWND ScreenWinTestTwoDisplays2x1x::fake_hwnd_left_ = NULL; | 
| + | 
| +HWND ScreenWinTestTwoDisplays2x1x::fake_hwnd_right_ = NULL; | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1x, GetDisplays) { | 
| +  std::vector<gfx::Display> displays = GetScreen()->GetAllDisplays(); | 
| +  ASSERT_EQ(2u, displays.size()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 960, 600), displays[0].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 960, 550), displays[0].work_area()); | 
| +  EXPECT_EQ(gfx::Rect(960, 0, 800, 600), displays[1].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(960, 0, 800, 600), displays[1].work_area()); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1x, ScreenToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(960, 0, 200, 300), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(1920, 0, 200, 300))); | 
| +  EXPECT_EQ(gfx::Rect(1040, 496, 100, 200), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(2000, 496, 100, 200))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1x, DIPToScreenRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(1920, 0, 200, 300), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(960, 0, 200, 300))); | 
| +  EXPECT_EQ(gfx::Rect(2000, 496, 100, 200), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(1040, 496, 100, 200))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1x, ClientToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(253, 496, 41, 52), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(253, 496, 41, 52))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1x, DIPToClientRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(right_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(253, 496, 41, 52), | 
| +            ScreenWin::DIPToClientRect(right_hwnd, | 
| +                                       gfx::Rect(253, 496, 41, 52))); | 
| +} | 
| + | 
| +// Two Displays of 2.0 (Left) and 1.0 (Right) Device Scale Factor under | 
| +// Windows DPI Virtualization. Note that the displays do not form a euclidean | 
| +// space. | 
| +class ScreenWinTestTwoDisplays2x1xVirtualized : public ScreenWinTest { | 
| + public: | 
| +  static void SetUpTestCase() { | 
| +    ScreenWinTest::SetUpTestCase(); | 
| +    screen_win_initializer_.reset(new TestScreenWinInitializer()); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(0, 0, 3200, 1600), | 
| +                                        gfx::Rect(0, 0, 3200, 1500), | 
| +                                        L"primary", | 
| +                                        2.0); | 
| +    screen_win_initializer_->AddMonitor(gfx::Rect(6400, 0, 3840, 2400), | 
| +                                        gfx::Rect(6400, 0, 3840, 2400), | 
| +                                        L"secondary", | 
| +                                        2.0); | 
| +    fake_hwnd_left_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(0, 0, 3200, 1500)); | 
| +    fake_hwnd_right_ = | 
| +        screen_win_initializer_->CreateFakeHwnd(gfx::Rect(6400, 0, 3840, 2400)); | 
| +    screen_win_initializer_->InitializeScreenWin(); | 
| +  } | 
| + | 
| +  static void TearDownTestCase() { | 
| +    screen_win_initializer_.reset(); | 
| +    ScreenWinTest::TearDownTestCase(); | 
| +  } | 
| + | 
| +  Screen* GetScreen() { | 
| +    return screen_win_initializer_->GetScreen(); | 
| +  } | 
| + | 
| +  HWND GetLeftFakeHwnd() { | 
| +    return fake_hwnd_left_; | 
| +  } | 
| + | 
| +  HWND GetRightFakeHwnd() { | 
| +    return fake_hwnd_right_; | 
| +  } | 
| + | 
| + private: | 
| +  static scoped_ptr<TestScreenWinInitializer> screen_win_initializer_; | 
| +  static HWND fake_hwnd_left_; | 
| +  static HWND fake_hwnd_right_; | 
| +}; | 
| + | 
| +scoped_ptr<TestScreenWinInitializer> | 
| +ScreenWinTestTwoDisplays2x1xVirtualized::screen_win_initializer_; | 
| + | 
| +HWND ScreenWinTestTwoDisplays2x1xVirtualized::fake_hwnd_left_ = NULL; | 
| + | 
| +HWND ScreenWinTestTwoDisplays2x1xVirtualized::fake_hwnd_right_ = NULL; | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, GetDisplays) { | 
| +  std::vector<gfx::Display> displays = GetScreen()->GetAllDisplays(); | 
| +  ASSERT_EQ(2u, displays.size()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 1600, 800), displays[0].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 1600, 750), displays[0].work_area()); | 
| +  EXPECT_EQ(gfx::Rect(3200, 0, 1920, 1200), displays[1].bounds()); | 
| +  EXPECT_EQ(gfx::Rect(3200, 0, 1920, 1200), displays[1].work_area()); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, ScreenToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ScreenToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(3200, 0, 100, 150), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(6400, 0, 200, 300))); | 
| +  EXPECT_EQ(gfx::Rect(3500, 248, 50, 100), | 
| +            ScreenWin::ScreenToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(7000, 496, 100, 200))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, DIPToScreenRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToScreenRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(6400, 0, 200, 300), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(3200, 0, 100, 150))); | 
| +  EXPECT_EQ(gfx::Rect(7000, 496, 100, 200), | 
| +            ScreenWin::DIPToScreenRect(right_hwnd, | 
| +                                       gfx::Rect(3500, 248, 50, 100))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, ClientToDIPRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ClientToDIPRect(left_hwnd, gfx::Rect(253, 496, 41, 52))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 25, 50), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, gfx::Rect(0, 0, 50, 100))); | 
| +  EXPECT_EQ(gfx::Rect(126, 248, 21, 26), | 
| +            ScreenWin::ClientToDIPRect(right_hwnd, | 
| +                                       gfx::Rect(253, 496, 41, 52))); | 
| +} | 
| + | 
| +TEST_F(ScreenWinTestTwoDisplays2x1xVirtualized, DIPToClientRects) { | 
| +  HWND left_hwnd = GetLeftFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToClientRect(left_hwnd, gfx::Rect(126, 248, 21, 26))); | 
| + | 
| +  HWND right_hwnd = GetRightFakeHwnd(); | 
| +  EXPECT_EQ(gfx::Rect(0, 0, 50, 100), | 
| +            ScreenWin::DIPToClientRect(right_hwnd, gfx::Rect(0, 0, 25, 50))); | 
| +  EXPECT_EQ(gfx::Rect(252, 496, 42, 52), | 
| +            ScreenWin::DIPToClientRect(right_hwnd, | 
| +                                       gfx::Rect(126, 248, 21, 26))); | 
| +} | 
| + | 
| }  // namespace gfx | 
|  |