• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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.
4 
5 #include "ui/aura/test/test_cursor_client.h"
6 
7 #include "ui/aura/client/cursor_client_observer.h"
8 
9 namespace aura {
10 namespace test {
11 
TestCursorClient(aura::Window * root_window)12 TestCursorClient::TestCursorClient(aura::Window* root_window)
13     : visible_(true),
14       mouse_events_enabled_(true),
15       cursor_lock_count_(0),
16       root_window_(root_window) {
17   client::SetCursorClient(root_window, this);
18 }
19 
~TestCursorClient()20 TestCursorClient::~TestCursorClient() {
21   client::SetCursorClient(root_window_, NULL);
22 }
23 
SetCursor(gfx::NativeCursor cursor)24 void TestCursorClient::SetCursor(gfx::NativeCursor cursor) {
25 }
26 
GetCursor() const27 gfx::NativeCursor TestCursorClient::GetCursor() const {
28   return ui::kCursorNull;
29 }
30 
ShowCursor()31 void TestCursorClient::ShowCursor() {
32   visible_ = true;
33   FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_,
34                     OnCursorVisibilityChanged(true));
35 }
36 
HideCursor()37 void TestCursorClient::HideCursor() {
38   visible_ = false;
39   FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_,
40                     OnCursorVisibilityChanged(false));
41 }
42 
SetCursorSet(ui::CursorSetType cursor_set)43 void TestCursorClient::SetCursorSet(ui::CursorSetType cursor_set) {
44 }
45 
GetCursorSet() const46 ui::CursorSetType TestCursorClient::GetCursorSet() const {
47   return ui::CURSOR_SET_NORMAL;
48 }
49 
SetScale(float scale)50 void TestCursorClient::SetScale(float scale) {
51 }
52 
GetScale() const53 float TestCursorClient::GetScale() const {
54   return 1.f;
55 }
56 
IsCursorVisible() const57 bool TestCursorClient::IsCursorVisible() const {
58   return visible_;
59 }
60 
EnableMouseEvents()61 void TestCursorClient::EnableMouseEvents() {
62   mouse_events_enabled_ = true;
63 }
64 
DisableMouseEvents()65 void TestCursorClient::DisableMouseEvents() {
66   mouse_events_enabled_ = false;
67 }
68 
IsMouseEventsEnabled() const69 bool TestCursorClient::IsMouseEventsEnabled() const {
70   return mouse_events_enabled_;
71 }
72 
SetDisplay(const gfx::Display & display)73 void TestCursorClient::SetDisplay(const gfx::Display& display) {
74 }
75 
LockCursor()76 void TestCursorClient::LockCursor() {
77   cursor_lock_count_++;
78 }
79 
UnlockCursor()80 void TestCursorClient::UnlockCursor() {
81   cursor_lock_count_--;
82   if (cursor_lock_count_ < 0)
83     cursor_lock_count_ = 0;
84 }
85 
IsCursorLocked() const86 bool TestCursorClient::IsCursorLocked() const {
87   return cursor_lock_count_ > 0;
88 }
89 
AddObserver(aura::client::CursorClientObserver * observer)90 void TestCursorClient::AddObserver(
91     aura::client::CursorClientObserver* observer) {
92   observers_.AddObserver(observer);
93 }
94 
RemoveObserver(aura::client::CursorClientObserver * observer)95 void TestCursorClient::RemoveObserver(
96     aura::client::CursorClientObserver* observer) {
97   observers_.RemoveObserver(observer);
98 }
99 
100 }  // namespace test
101 }  // namespace aura
102