| 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 #include "ui/aura/test/test_window_delegate.h" | 5 #include "ui/aura/test/test_window_delegate.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
| 10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return scoped_refptr<ui::Texture>(); | 95 return scoped_refptr<ui::Texture>(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 //////////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////////// |
| 99 // ColorTestWindowDelegate | 99 // ColorTestWindowDelegate |
| 100 | 100 |
| 101 ColorTestWindowDelegate::ColorTestWindowDelegate(SkColor color) | 101 ColorTestWindowDelegate::ColorTestWindowDelegate(SkColor color) |
| 102 : color_(color), | 102 : color_(color), |
| 103 last_key_code_(ui::VKEY_UNKNOWN) { | 103 last_key_code_(ui::VKEY_UNKNOWN) { |
| 104 } | 104 } |
| 105 |
| 105 ColorTestWindowDelegate::~ColorTestWindowDelegate() { | 106 ColorTestWindowDelegate::~ColorTestWindowDelegate() { |
| 106 } | 107 } |
| 107 | 108 |
| 108 ui::EventResult ColorTestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) { | 109 void ColorTestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) { |
| 109 last_key_code_ = event->key_code(); | 110 last_key_code_ = event->key_code(); |
| 110 return ui::ER_HANDLED; | 111 event->SetHandled(); |
| 111 } | 112 } |
| 113 |
| 112 void ColorTestWindowDelegate::OnWindowDestroyed() { | 114 void ColorTestWindowDelegate::OnWindowDestroyed() { |
| 113 delete this; | 115 delete this; |
| 114 } | 116 } |
| 117 |
| 115 void ColorTestWindowDelegate::OnPaint(gfx::Canvas* canvas) { | 118 void ColorTestWindowDelegate::OnPaint(gfx::Canvas* canvas) { |
| 116 canvas->DrawColor(color_, SkXfermode::kSrc_Mode); | 119 canvas->DrawColor(color_, SkXfermode::kSrc_Mode); |
| 117 } | 120 } |
| 118 | 121 |
| 119 //////////////////////////////////////////////////////////////////////////////// | 122 //////////////////////////////////////////////////////////////////////////////// |
| 120 // MaskedWindowDelegate | 123 // MaskedWindowDelegate |
| 121 | 124 |
| 122 MaskedWindowDelegate::MaskedWindowDelegate(const gfx::Rect mask_rect) | 125 MaskedWindowDelegate::MaskedWindowDelegate(const gfx::Rect mask_rect) |
| 123 : mask_rect_(mask_rect) { | 126 : mask_rect_(mask_rect) { |
| 124 } | 127 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 137 EventCountDelegate::EventCountDelegate() | 140 EventCountDelegate::EventCountDelegate() |
| 138 : mouse_enter_count_(0), | 141 : mouse_enter_count_(0), |
| 139 mouse_move_count_(0), | 142 mouse_move_count_(0), |
| 140 mouse_leave_count_(0), | 143 mouse_leave_count_(0), |
| 141 mouse_press_count_(0), | 144 mouse_press_count_(0), |
| 142 mouse_release_count_(0), | 145 mouse_release_count_(0), |
| 143 key_press_count_(0), | 146 key_press_count_(0), |
| 144 key_release_count_(0) { | 147 key_release_count_(0) { |
| 145 } | 148 } |
| 146 | 149 |
| 147 ui::EventResult EventCountDelegate::OnKeyEvent(ui::KeyEvent* event) { | 150 void EventCountDelegate::OnKeyEvent(ui::KeyEvent* event) { |
| 148 switch (event->type()) { | 151 switch (event->type()) { |
| 149 case ui::ET_KEY_PRESSED: | 152 case ui::ET_KEY_PRESSED: |
| 150 key_press_count_++; | 153 key_press_count_++; |
| 151 break; | 154 break; |
| 152 case ui::ET_KEY_RELEASED: | 155 case ui::ET_KEY_RELEASED: |
| 153 key_release_count_++; | 156 key_release_count_++; |
| 154 default: | 157 default: |
| 155 break; | 158 break; |
| 156 } | 159 } |
| 157 return ui::ER_UNHANDLED; | |
| 158 } | 160 } |
| 159 | 161 |
| 160 ui::EventResult EventCountDelegate::OnMouseEvent(ui::MouseEvent* event) { | 162 ui::EventResult EventCountDelegate::OnMouseEvent(ui::MouseEvent* event) { |
| 161 switch (event->type()) { | 163 switch (event->type()) { |
| 162 case ui::ET_MOUSE_MOVED: | 164 case ui::ET_MOUSE_MOVED: |
| 163 mouse_move_count_++; | 165 mouse_move_count_++; |
| 164 break; | 166 break; |
| 165 case ui::ET_MOUSE_ENTERED: | 167 case ui::ET_MOUSE_ENTERED: |
| 166 mouse_enter_count_++; | 168 mouse_enter_count_++; |
| 167 break; | 169 break; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 std::string result = StringPrintf("%d %d", | 207 std::string result = StringPrintf("%d %d", |
| 206 key_press_count_, | 208 key_press_count_, |
| 207 key_release_count_); | 209 key_release_count_); |
| 208 key_press_count_ = 0; | 210 key_press_count_ = 0; |
| 209 key_release_count_ = 0; | 211 key_release_count_ = 0; |
| 210 return result; | 212 return result; |
| 211 } | 213 } |
| 212 | 214 |
| 213 } // namespace test | 215 } // namespace test |
| 214 } // namespace aura | 216 } // namespace aura |
| OLD | NEW |