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