Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1020)

Side by Side Diff: ui/aura/test/event_generator.cc

Issue 14293028: [CleanUp] Add MoveMouseToInHost to aura::test::EventGenerator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/event_generator.h" 5 #include "ui/aura/test/event_generator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "ui/aura/client/screen_position_client.h" 10 #include "ui/aura/client/screen_position_client.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 void EventGenerator::PressRightButton() { 140 void EventGenerator::PressRightButton() {
141 PressButton(ui::EF_RIGHT_MOUSE_BUTTON); 141 PressButton(ui::EF_RIGHT_MOUSE_BUTTON);
142 } 142 }
143 143
144 void EventGenerator::ReleaseRightButton() { 144 void EventGenerator::ReleaseRightButton() {
145 ReleaseButton(ui::EF_RIGHT_MOUSE_BUTTON); 145 ReleaseButton(ui::EF_RIGHT_MOUSE_BUTTON);
146 } 146 }
147 147
148 void EventGenerator::MoveMouseTo(const gfx::Point& point, int count) { 148 void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {
149 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
150 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
151 ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_);
152 Dispatch(&mouseev);
153
154 current_location_ = point_in_host;
155 current_root_window_->ConvertPointFromHost(&current_location_);
156 }
157
158 void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
159 int count) {
149 DCHECK_GT(count, 0); 160 DCHECK_GT(count, 0);
150 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? 161 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
151 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; 162 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
152 163
153 gfx::Vector2dF diff(point - current_location_); 164 gfx::Vector2dF diff(point_in_screen - current_location_);
154 for (float i = 1; i <= count; i++) { 165 for (float i = 1; i <= count; i++) {
155 gfx::Vector2dF step(diff); 166 gfx::Vector2dF step(diff);
156 step.Scale(i / count); 167 step.Scale(i / count);
157 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step); 168 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step);
158 if (!grab_) 169 if (!grab_)
159 UpdateCurrentRootWindow(move_point); 170 UpdateCurrentRootWindow(move_point);
160 ConvertPointToTarget(current_root_window_, &move_point); 171 ConvertPointToTarget(current_root_window_, &move_point);
161 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_); 172 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_);
162 Dispatch(&mouseev); 173 Dispatch(&mouseev);
163 } 174 }
164 current_location_ = point; 175 current_location_ = point_in_screen;
165 } 176 }
166 177
167 void EventGenerator::MoveMouseRelativeTo(const Window* window, 178 void EventGenerator::MoveMouseRelativeTo(const Window* window,
168 const gfx::Point& point_in_parent) { 179 const gfx::Point& point_in_parent) {
169 gfx::Point point(point_in_parent); 180 gfx::Point point(point_in_parent);
170 ConvertPointFromTarget(window, &point); 181 ConvertPointFromTarget(window, &point);
171 MoveMouseTo(point); 182 MoveMouseTo(point);
172 } 183 }
173 184
174 void EventGenerator::DragMouseTo(const gfx::Point& point) { 185 void EventGenerator::DragMouseTo(const gfx::Point& point) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 base::MessageLoopProxy::current()->PostTask( 563 base::MessageLoopProxy::current()->PostTask(
553 FROM_HERE, 564 FROM_HERE,
554 base::Bind(&EventGenerator::DispatchNextPendingEvent, 565 base::Bind(&EventGenerator::DispatchNextPendingEvent,
555 base::Unretained(this))); 566 base::Unretained(this)));
556 } 567 }
557 } 568 }
558 569
559 570
560 } // namespace test 571 } // namespace test
561 } // namespace aura 572 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698