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)12TestCursorClient::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()20TestCursorClient::~TestCursorClient() { 21 client::SetCursorClient(root_window_, NULL); 22 } 23 SetCursor(gfx::NativeCursor cursor)24void TestCursorClient::SetCursor(gfx::NativeCursor cursor) { 25 } 26 GetCursor() const27gfx::NativeCursor TestCursorClient::GetCursor() const { 28 return ui::kCursorNull; 29 } 30 ShowCursor()31void TestCursorClient::ShowCursor() { 32 visible_ = true; 33 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, 34 OnCursorVisibilityChanged(true)); 35 } 36 HideCursor()37void TestCursorClient::HideCursor() { 38 visible_ = false; 39 FOR_EACH_OBSERVER(aura::client::CursorClientObserver, observers_, 40 OnCursorVisibilityChanged(false)); 41 } 42 SetCursorSet(ui::CursorSetType cursor_set)43void TestCursorClient::SetCursorSet(ui::CursorSetType cursor_set) { 44 } 45 GetCursorSet() const46ui::CursorSetType TestCursorClient::GetCursorSet() const { 47 return ui::CURSOR_SET_NORMAL; 48 } 49 SetScale(float scale)50void TestCursorClient::SetScale(float scale) { 51 } 52 GetScale() const53float TestCursorClient::GetScale() const { 54 return 1.f; 55 } 56 IsCursorVisible() const57bool TestCursorClient::IsCursorVisible() const { 58 return visible_; 59 } 60 EnableMouseEvents()61void TestCursorClient::EnableMouseEvents() { 62 mouse_events_enabled_ = true; 63 } 64 DisableMouseEvents()65void TestCursorClient::DisableMouseEvents() { 66 mouse_events_enabled_ = false; 67 } 68 IsMouseEventsEnabled() const69bool TestCursorClient::IsMouseEventsEnabled() const { 70 return mouse_events_enabled_; 71 } 72 SetDisplay(const gfx::Display & display)73void TestCursorClient::SetDisplay(const gfx::Display& display) { 74 } 75 LockCursor()76void TestCursorClient::LockCursor() { 77 cursor_lock_count_++; 78 } 79 UnlockCursor()80void TestCursorClient::UnlockCursor() { 81 cursor_lock_count_--; 82 if (cursor_lock_count_ < 0) 83 cursor_lock_count_ = 0; 84 } 85 IsCursorLocked() const86bool TestCursorClient::IsCursorLocked() const { 87 return cursor_lock_count_ > 0; 88 } 89 AddObserver(aura::client::CursorClientObserver * observer)90void TestCursorClient::AddObserver( 91 aura::client::CursorClientObserver* observer) { 92 observers_.AddObserver(observer); 93 } 94 RemoveObserver(aura::client::CursorClientObserver * observer)95void TestCursorClient::RemoveObserver( 96 aura::client::CursorClientObserver* observer) { 97 observers_.RemoveObserver(observer); 98 } 99 100 } // namespace test 101 } // namespace aura 102