| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_ | 5 #ifndef UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_ |
| 6 #define UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_ | 6 #define UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 void set_window_component(int window_component) { | 28 void set_window_component(int window_component) { |
| 29 window_component_ = window_component; | 29 window_component_ = window_component; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Overridden from WindowDelegate: | 32 // Overridden from WindowDelegate: |
| 33 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 33 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
| 34 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | 34 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, |
| 35 const gfx::Rect& new_bounds) OVERRIDE; | 35 const gfx::Rect& new_bounds) OVERRIDE; |
| 36 virtual void OnFocus(Window* old_focused_window) OVERRIDE; | 36 virtual void OnFocus(Window* old_focused_window) OVERRIDE; |
| 37 virtual void OnBlur() OVERRIDE; | 37 virtual void OnBlur() OVERRIDE; |
| 38 virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | |
| 39 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; | 38 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; |
| 40 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; | 39 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; |
| 41 virtual bool ShouldDescendIntoChildForEventHandling( | 40 virtual bool ShouldDescendIntoChildForEventHandling( |
| 42 Window* child, | 41 Window* child, |
| 43 const gfx::Point& location) OVERRIDE; | 42 const gfx::Point& location) OVERRIDE; |
| 44 virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | |
| 45 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | |
| 46 virtual ui::EventResult OnGestureEvent( | |
| 47 ui::GestureEvent* event) OVERRIDE; | |
| 48 virtual bool CanFocus() OVERRIDE; | 43 virtual bool CanFocus() OVERRIDE; |
| 49 virtual void OnCaptureLost() OVERRIDE; | 44 virtual void OnCaptureLost() OVERRIDE; |
| 50 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 45 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 51 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | 46 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; |
| 52 virtual void OnWindowDestroying() OVERRIDE; | 47 virtual void OnWindowDestroying() OVERRIDE; |
| 53 virtual void OnWindowDestroyed() OVERRIDE; | 48 virtual void OnWindowDestroyed() OVERRIDE; |
| 54 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE; | 49 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE; |
| 55 virtual bool HasHitTestMask() const OVERRIDE; | 50 virtual bool HasHitTestMask() const OVERRIDE; |
| 56 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE; | 51 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE; |
| 57 | 52 |
| 53 // Overridden from ui::EventHandler: |
| 54 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
| 55 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| 56 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
| 57 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 58 |
| 58 private: | 59 private: |
| 59 int window_component_; | 60 int window_component_; |
| 60 bool delete_on_destroyed_; | 61 bool delete_on_destroyed_; |
| 61 | 62 |
| 62 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); | 63 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 // A simple WindowDelegate implementation for these tests. It owns itself | 66 // A simple WindowDelegate implementation for these tests. It owns itself |
| 66 // (deletes itself when the Window it is attached to is destroyed). | 67 // (deletes itself when the Window it is attached to is destroyed). |
| 67 class ColorTestWindowDelegate : public TestWindowDelegate { | 68 class ColorTestWindowDelegate : public TestWindowDelegate { |
| 68 public: | 69 public: |
| 69 explicit ColorTestWindowDelegate(SkColor color); | 70 explicit ColorTestWindowDelegate(SkColor color); |
| 70 virtual ~ColorTestWindowDelegate(); | 71 virtual ~ColorTestWindowDelegate(); |
| 71 | 72 |
| 72 ui::KeyboardCode last_key_code() const { return last_key_code_; } | 73 ui::KeyboardCode last_key_code() const { return last_key_code_; } |
| 73 | 74 |
| 74 // Overridden from TestWindowDelegate: | 75 // Overridden from TestWindowDelegate: |
| 75 virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 76 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
| 76 virtual void OnWindowDestroyed() OVERRIDE; | 77 virtual void OnWindowDestroyed() OVERRIDE; |
| 77 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 78 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 78 | 79 |
| 79 private: | 80 private: |
| 80 SkColor color_; | 81 SkColor color_; |
| 81 ui::KeyboardCode last_key_code_; | 82 ui::KeyboardCode last_key_code_; |
| 82 | 83 |
| 83 DISALLOW_COPY_AND_ASSIGN(ColorTestWindowDelegate); | 84 DISALLOW_COPY_AND_ASSIGN(ColorTestWindowDelegate); |
| 84 }; | 85 }; |
| 85 | 86 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 97 | 98 |
| 98 DISALLOW_COPY_AND_ASSIGN(MaskedWindowDelegate); | 99 DISALLOW_COPY_AND_ASSIGN(MaskedWindowDelegate); |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 // Keeps track of mouse/key events. | 102 // Keeps track of mouse/key events. |
| 102 class EventCountDelegate : public TestWindowDelegate { | 103 class EventCountDelegate : public TestWindowDelegate { |
| 103 public: | 104 public: |
| 104 EventCountDelegate(); | 105 EventCountDelegate(); |
| 105 | 106 |
| 106 // Overridden from TestWindowDelegate: | 107 // Overridden from TestWindowDelegate: |
| 107 virtual bool OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 108 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
| 108 virtual bool OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 109 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| 109 | 110 |
| 110 // Returns the counts of mouse motion events in the | 111 // Returns the counts of mouse motion events in the |
| 111 // form of "<enter> <move> <leave>". | 112 // form of "<enter> <move> <leave>". |
| 112 std::string GetMouseMotionCountsAndReset(); | 113 std::string GetMouseMotionCountsAndReset(); |
| 113 | 114 |
| 114 // Returns the counts of mouse button events in the | 115 // Returns the counts of mouse button events in the |
| 115 // form of "<press> <release>". | 116 // form of "<press> <release>". |
| 116 std::string GetMouseButtonCountsAndReset(); | 117 std::string GetMouseButtonCountsAndReset(); |
| 117 | 118 |
| 118 // Returns the counts of key events in the form of | 119 // Returns the counts of key events in the form of |
| 119 // "<press> <release>". | 120 // "<press> <release>". |
| 120 std::string GetKeyCountsAndReset(); | 121 std::string GetKeyCountsAndReset(); |
| 121 | 122 |
| 122 private: | 123 private: |
| 123 int mouse_enter_count_; | 124 int mouse_enter_count_; |
| 124 int mouse_move_count_; | 125 int mouse_move_count_; |
| 125 int mouse_leave_count_; | 126 int mouse_leave_count_; |
| 126 int mouse_press_count_; | 127 int mouse_press_count_; |
| 127 int mouse_release_count_; | 128 int mouse_release_count_; |
| 128 int key_press_count_; | 129 int key_press_count_; |
| 129 int key_release_count_; | 130 int key_release_count_; |
| 130 | 131 |
| 131 DISALLOW_COPY_AND_ASSIGN(EventCountDelegate); | 132 DISALLOW_COPY_AND_ASSIGN(EventCountDelegate); |
| 132 }; | 133 }; |
| 133 | 134 |
| 134 } // namespace test | 135 } // namespace test |
| 135 } // namespace aura | 136 } // namespace aura |
| 136 | 137 |
| 137 #endif // UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_ | 138 #endif // UI_AURA_TEST_TEST_WINDOW_DELEGATE_H_ |
| OLD | NEW |