summaryrefslogtreecommitdiffstats
path: root/ash/display/screen_ash_unittest.cc
blob: a60d54fba20cefd10ecf4b882a54d74a475d6b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"

namespace ash {

class ScreenAshTest : public test::AshTestBase {
 public:
  ScreenAshTest() {}
  ~ScreenAshTest() override {}

 private:
  DISALLOW_COPY_AND_ASSIGN(ScreenAshTest);
};

// Tests that ScreenAsh::GetWindowAtScreenPoint() returns the correct window on
// the correct display.
TEST_F(ScreenAshTest, TestGetWindowAtScreenPoint) {
  if (!SupportsMultipleDisplays())
    return;

  UpdateDisplay("200x200,400x400");

  aura::test::TestWindowDelegate delegate;
  scoped_ptr<aura::Window> win1(CreateTestWindowInShellWithDelegate(
      &delegate, 0, gfx::Rect(0, 0, 200, 200)));

  scoped_ptr<aura::Window> win2(CreateTestWindowInShellWithDelegate(
      &delegate, 1, gfx::Rect(200, 200, 100, 100)));

  ASSERT_NE(win1->GetRootWindow(), win2->GetRootWindow());

  EXPECT_EQ(win1.get(), gfx::Screen::GetScreen()->GetWindowAtScreenPoint(
                            gfx::Point(50, 60)));
  EXPECT_EQ(win2.get(), gfx::Screen::GetScreen()->GetWindowAtScreenPoint(
                            gfx::Point(250, 260)));
}

}  // namespace ash