Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/event_generator.h" | 5 #include "ui/aura/test/event_generator.h" |
| 6 | 6 |
| 7 #include "ui/aura/desktop.h" | 7 #include "ui/aura/desktop.h" |
| 8 #include "ui/aura/event.h" | 8 #include "ui/aura/event.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 } | 30 } |
| 31 | 31 |
| 32 EventGenerator::EventGenerator(Window* window) | 32 EventGenerator::EventGenerator(Window* window) |
| 33 : flags_(0), | 33 : flags_(0), |
| 34 current_location_(CenterOfWindowInDesktopCoordinate(window)) { | 34 current_location_(CenterOfWindowInDesktopCoordinate(window)) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 EventGenerator::~EventGenerator() { | 37 EventGenerator::~EventGenerator() { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void EventGenerator::ClickLeftButton() { | |
| 41 PressLeftButton(); | |
| 42 ReleaseLeftButton(); | |
| 43 } | |
| 44 | |
| 45 void EventGenerator::PressLeftButton() { | 40 void EventGenerator::PressLeftButton() { |
| 46 if ((flags_ & ui::EF_LEFT_BUTTON_DOWN) == 0) { | 41 if ((flags_ & ui::EF_LEFT_BUTTON_DOWN) == 0) { |
| 47 flags_ |= ui::EF_LEFT_BUTTON_DOWN; | 42 flags_ |= ui::EF_LEFT_BUTTON_DOWN; |
| 48 MouseEvent mouseev(ui::ET_MOUSE_PRESSED, current_location_, flags_); | 43 MouseEvent mouseev(ui::ET_MOUSE_PRESSED, current_location_, flags_); |
| 49 Dispatch(mouseev); | 44 Dispatch(mouseev); |
| 50 } | 45 } |
| 51 } | 46 } |
| 52 | 47 |
| 53 void EventGenerator::ReleaseLeftButton() { | 48 void EventGenerator::ReleaseLeftButton() { |
| 54 if (flags_ & ui::EF_LEFT_BUTTON_DOWN) { | 49 if (flags_ & ui::EF_LEFT_BUTTON_DOWN) { |
| 55 flags_ ^= ui::EF_LEFT_BUTTON_DOWN; | 50 flags_ ^= ui::EF_LEFT_BUTTON_DOWN; |
| 56 MouseEvent mouseev(ui::ET_MOUSE_RELEASED, current_location_, 0); | 51 MouseEvent mouseev(ui::ET_MOUSE_RELEASED, current_location_, 0); |
| 57 Dispatch(mouseev); | 52 Dispatch(mouseev); |
| 58 } | 53 } |
| 59 } | 54 } |
| 60 | 55 |
| 56 void EventGenerator::ClickLeftButton() { | |
| 57 PressLeftButton(); | |
| 58 ReleaseLeftButton(); | |
| 59 } | |
| 60 | |
| 61 void EventGenerator::DoubleClickLeftButton() { | |
| 62 flags_ |= ui::EF_IS_DOUBLE_CLICK; | |
| 63 PressLeftButton(); | |
| 64 flags_ ^= ui::EF_IS_DOUBLE_CLICK; | |
|
Ben Goodger (Google)
2011/11/30 22:42:45
Good idea. This is similar to what you propose, bu
| |
| 65 ReleaseLeftButton(); | |
| 66 } | |
| 67 | |
| 61 void EventGenerator::MoveMouseTo(const gfx::Point& point) { | 68 void EventGenerator::MoveMouseTo(const gfx::Point& point) { |
| 62 if (flags_ & ui::EF_LEFT_BUTTON_DOWN ) { | 69 if (flags_ & ui::EF_LEFT_BUTTON_DOWN ) { |
| 63 MouseEvent middle( | 70 MouseEvent middle( |
| 64 ui::ET_MOUSE_DRAGGED, current_location_.Middle(point), flags_); | 71 ui::ET_MOUSE_DRAGGED, current_location_.Middle(point), flags_); |
| 65 Dispatch(middle); | 72 Dispatch(middle); |
| 66 | 73 |
| 67 MouseEvent mouseev(ui::ET_MOUSE_DRAGGED, point, flags_); | 74 MouseEvent mouseev(ui::ET_MOUSE_DRAGGED, point, flags_); |
| 68 Dispatch(mouseev); | 75 Dispatch(mouseev); |
| 69 } else { | 76 } else { |
| 70 MouseEvent middle( | 77 MouseEvent middle( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 break; | 112 break; |
| 106 } | 113 } |
| 107 } | 114 } |
| 108 | 115 |
| 109 void EventGenerator::MoveMouseToCenterOf(Window* window) { | 116 void EventGenerator::MoveMouseToCenterOf(Window* window) { |
| 110 MoveMouseTo(CenterOfWindowInDesktopCoordinate(window)); | 117 MoveMouseTo(CenterOfWindowInDesktopCoordinate(window)); |
| 111 } | 118 } |
| 112 | 119 |
| 113 } // namespace test | 120 } // namespace test |
| 114 } // namespace aura | 121 } // namespace aura |
| OLD | NEW |