blob: a23bc5d8957b1ec3b8c7e29e5e7e2ffd6e0de112 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// Copyright (c) 2012 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.
#ifndef UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_
#define UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_
#include <string>
#include "base/compiler_specific.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/window_delegate.h"
#include "ui/gfx/rect.h"
namespace aura {
namespace test {
// WindowDelegate implementation with all methods stubbed out.
class TestWindowDelegate : public WindowDelegate {
public:
TestWindowDelegate();
virtual ~TestWindowDelegate();
void set_window_component(int window_component) {
window_component_ = window_component;
}
// Overridden from WindowDelegate:
virtual gfx::Size GetMinimumSize() const OVERRIDE;
virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;
virtual void OnFocus(Window* old_focused_window) OVERRIDE;
virtual void OnBlur() OVERRIDE;
virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool ShouldDescendIntoChildForEventHandling(
Window* child,
const gfx::Point& location) OVERRIDE;
virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(ui::TouchEventImpl* event) OVERRIDE;
virtual ui::GestureStatus OnGestureEvent(
ui::GestureEventImpl* event) OVERRIDE;
virtual bool CanFocus() OVERRIDE;
virtual void OnCaptureLost() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void OnWindowDestroying() OVERRIDE;
virtual void OnWindowDestroyed() OVERRIDE;
virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
virtual bool HasHitTestMask() const OVERRIDE;
virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
private:
int window_component_;
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
};
// A simple WindowDelegate implementation for these tests. It owns itself
// (deletes itself when the Window it is attached to is destroyed).
class ColorTestWindowDelegate : public TestWindowDelegate {
public:
explicit ColorTestWindowDelegate(SkColor color);
virtual ~ColorTestWindowDelegate();
ui::KeyboardCode last_key_code() const { return last_key_code_; }
// Overridden from TestWindowDelegate:
virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
virtual void OnWindowDestroyed() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
private:
SkColor color_;
ui::KeyboardCode last_key_code_;
DISALLOW_COPY_AND_ASSIGN(ColorTestWindowDelegate);
};
// A simple WindowDelegate that has a hit-test mask.
class MaskedWindowDelegate : public TestWindowDelegate {
public:
explicit MaskedWindowDelegate(const gfx::Rect mask_rect);
// Overridden from TestWindowDelegate:
virtual bool HasHitTestMask() const OVERRIDE;
virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
private:
gfx::Rect mask_rect_;
DISALLOW_COPY_AND_ASSIGN(MaskedWindowDelegate);
};
// Keeps track of mouse/key events.
class EventCountDelegate : public TestWindowDelegate {
public:
EventCountDelegate();
// Overridden from TestWindowDelegate:
virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
// Returns the counts of mouse motion events in the
// form of "<enter> <move> <leave>".
std::string GetMouseMotionCountsAndReset();
// Returns the counts of mouse button events in the
// form of "<press> <release>".
std::string GetMouseButtonCountsAndReset();
// Returns the counts of key events in the form of
// "<press> <release>".
std::string GetKeyCountsAndReset();
private:
int mouse_enter_count_;
int mouse_move_count_;
int mouse_leave_count_;
int mouse_press_count_;
int mouse_release_count_;
int key_press_count_;
int key_release_count_;
DISALLOW_COPY_AND_ASSIGN(EventCountDelegate);
};
} // namespace test
} // namespace aura
#endif // UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_
|