1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/events/ozone/chromeos/cursor_controller.h"
12 const gfx::AcceleratedWidget kTestWindow
= 1;
16 class CursorControllerTest
: public testing::Test
{
18 CursorControllerTest() {}
19 ~CursorControllerTest() override
{}
21 void TearDown() override
{
22 ui::CursorController::GetInstance()->ClearCursorConfigForWindow(
26 DISALLOW_COPY_AND_ASSIGN(CursorControllerTest
);
29 TEST_F(CursorControllerTest
, UnconfiguredIdentity
) {
30 ui::CursorController
* cursor_controller
= CursorController::GetInstance();
32 // Check that unconfigured windows use identity.
33 gfx::Vector2dF
delta(2.f
, 3.f
);
34 cursor_controller
->ApplyCursorConfigForWindow(kTestWindow
, &delta
);
35 EXPECT_FLOAT_EQ(2.f
, delta
.x());
36 EXPECT_FLOAT_EQ(3.f
, delta
.y());
39 TEST_F(CursorControllerTest
, ClearedIdentity
) {
40 ui::CursorController
* cursor_controller
= CursorController::GetInstance();
42 // Check that configured & cleared windows use identity.
43 cursor_controller
->SetCursorConfigForWindow(kTestWindow
,
44 gfx::Display::ROTATE_180
, 3.2f
);
45 cursor_controller
->ClearCursorConfigForWindow(kTestWindow
);
46 gfx::Vector2dF
delta(3.f
, 5.f
);
47 cursor_controller
->ApplyCursorConfigForWindow(kTestWindow
, &delta
);
48 EXPECT_FLOAT_EQ(3.f
, delta
.x());
49 EXPECT_FLOAT_EQ(5.f
, delta
.y());
52 TEST_F(CursorControllerTest
, RotatedHighDpi
) {
53 ui::CursorController
* cursor_controller
= CursorController::GetInstance();
55 // Check that 90deg rotated highdpi window transforms correctly.
56 cursor_controller
->SetCursorConfigForWindow(kTestWindow
,
57 gfx::Display::ROTATE_90
, 2.f
);
58 gfx::Vector2dF
delta(3.f
, 5.f
);
59 cursor_controller
->ApplyCursorConfigForWindow(kTestWindow
, &delta
);
60 EXPECT_FLOAT_EQ(-10.f
, delta
.x());
61 EXPECT_FLOAT_EQ(6.f
, delta
.y());