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

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

Issue 101573006: Changes MouseEvent constructor to take changed_button_flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test; needs updated expectations as mouse entered wasnt sent before because of env::mouse_butto… Created 7 years 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/root_window_unittest.cc ('k') | ui/aura/window_targeter_unittest.cc » ('j') | 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 144
145 void EventGenerator::ReleaseRightButton() { 145 void EventGenerator::ReleaseRightButton() {
146 ReleaseButton(ui::EF_RIGHT_MOUSE_BUTTON); 146 ReleaseButton(ui::EF_RIGHT_MOUSE_BUTTON);
147 } 147 }
148 148
149 void EventGenerator::SendMouseExit() { 149 void EventGenerator::SendMouseExit() {
150 gfx::Point exit_location(current_location_); 150 gfx::Point exit_location(current_location_);
151 ConvertPointToTarget(current_root_window_->window(), &exit_location); 151 ConvertPointToTarget(current_root_window_->window(), &exit_location);
152 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location, 152 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location,
153 flags_); 153 flags_, 0);
154 Dispatch(&mouseev); 154 Dispatch(&mouseev);
155 } 155 }
156 156
157 void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) { 157 void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {
158 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? 158 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
159 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; 159 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
160 ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_); 160 ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, flags_, 0);
161 Dispatch(&mouseev); 161 Dispatch(&mouseev);
162 162
163 current_location_ = point_in_host; 163 current_location_ = point_in_host;
164 current_root_window_->ConvertPointFromHost(&current_location_); 164 current_root_window_->ConvertPointFromHost(&current_location_);
165 } 165 }
166 166
167 void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen, 167 void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
168 int count) { 168 int count) {
169 DCHECK_GT(count, 0); 169 DCHECK_GT(count, 0);
170 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? 170 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
171 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; 171 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
172 172
173 gfx::Vector2dF diff(point_in_screen - current_location_); 173 gfx::Vector2dF diff(point_in_screen - current_location_);
174 for (float i = 1; i <= count; i++) { 174 for (float i = 1; i <= count; i++) {
175 gfx::Vector2dF step(diff); 175 gfx::Vector2dF step(diff);
176 step.Scale(i / count); 176 step.Scale(i / count);
177 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step); 177 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step);
178 if (!grab_) 178 if (!grab_)
179 UpdateCurrentRootWindow(move_point); 179 UpdateCurrentRootWindow(move_point);
180 ConvertPointToTarget(current_root_window_->window(), &move_point); 180 ConvertPointToTarget(current_root_window_->window(), &move_point);
181 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_); 181 ui::MouseEvent mouseev(event_type, move_point, move_point, flags_, 0);
182 Dispatch(&mouseev); 182 Dispatch(&mouseev);
183 } 183 }
184 current_location_ = point_in_screen; 184 current_location_ = point_in_screen;
185 } 185 }
186 186
187 void EventGenerator::MoveMouseRelativeTo(const Window* window, 187 void EventGenerator::MoveMouseRelativeTo(const Window* window,
188 const gfx::Point& point_in_parent) { 188 const gfx::Point& point_in_parent) {
189 gfx::Point point(point_in_parent); 189 gfx::Point point(point_in_parent);
190 ConvertPointFromTarget(window, &point); 190 ConvertPointFromTarget(window, &point);
191 MoveMouseTo(point); 191 MoveMouseTo(point);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 504
505 void EventGenerator::UpdateCurrentRootWindow(const gfx::Point& point) { 505 void EventGenerator::UpdateCurrentRootWindow(const gfx::Point& point) {
506 current_root_window_ = delegate_->GetRootWindowAt(point); 506 current_root_window_ = delegate_->GetRootWindowAt(point);
507 } 507 }
508 508
509 void EventGenerator::PressButton(int flag) { 509 void EventGenerator::PressButton(int flag) {
510 if (!(flags_ & flag)) { 510 if (!(flags_ & flag)) {
511 flags_ |= flag; 511 flags_ |= flag;
512 grab_ = flags_ & kAllButtonMask; 512 grab_ = flags_ & kAllButtonMask;
513 gfx::Point location = GetLocationInCurrentRoot(); 513 gfx::Point location = GetLocationInCurrentRoot();
514 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_); 514 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, flags_,
515 flag);
515 Dispatch(&mouseev); 516 Dispatch(&mouseev);
516 } 517 }
517 } 518 }
518 519
519 void EventGenerator::ReleaseButton(int flag) { 520 void EventGenerator::ReleaseButton(int flag) {
520 if (flags_ & flag) { 521 if (flags_ & flag) {
521 gfx::Point location = GetLocationInCurrentRoot(); 522 gfx::Point location = GetLocationInCurrentRoot();
522 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, 523 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location,
523 location, flags_); 524 location, flags_, flag);
524 Dispatch(&mouseev); 525 Dispatch(&mouseev);
525 flags_ ^= flag; 526 flags_ ^= flag;
526 } 527 }
527 grab_ = flags_ & kAllButtonMask; 528 grab_ = flags_ & kAllButtonMask;
528 } 529 }
529 530
530 void EventGenerator::ConvertPointFromTarget(const aura::Window* target, 531 void EventGenerator::ConvertPointFromTarget(const aura::Window* target,
531 gfx::Point* point) const { 532 gfx::Point* point) const {
532 DCHECK(point); 533 DCHECK(point);
533 aura::client::ScreenPositionClient* client = 534 aura::client::ScreenPositionClient* client =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 base::MessageLoopProxy::current()->PostTask( 616 base::MessageLoopProxy::current()->PostTask(
616 FROM_HERE, 617 FROM_HERE,
617 base::Bind(&EventGenerator::DispatchNextPendingEvent, 618 base::Bind(&EventGenerator::DispatchNextPendingEvent,
618 base::Unretained(this))); 619 base::Unretained(this)));
619 } 620 }
620 } 621 }
621 622
622 623
623 } // namespace test 624 } // namespace test
624 } // namespace aura 625 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window_unittest.cc ('k') | ui/aura/window_targeter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698