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

Side by Side Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 139983009: ui::LocatedEvent location() returns gfx::PointF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental change. Created 6 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
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/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 int mouse_event_flags() const { return mouse_event_flags_; } 53 int mouse_event_flags() const { return mouse_event_flags_; }
54 54
55 virtual int GetNonClientComponent(const gfx::Point& location) const OVERRIDE { 55 virtual int GetNonClientComponent(const gfx::Point& location) const OVERRIDE {
56 NonClientDelegate* self = const_cast<NonClientDelegate*>(this); 56 NonClientDelegate* self = const_cast<NonClientDelegate*>(this);
57 self->non_client_count_++; 57 self->non_client_count_++;
58 self->non_client_location_ = location; 58 self->non_client_location_ = location;
59 return HTTOPLEFT; 59 return HTTOPLEFT;
60 } 60 }
61 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 61 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
62 mouse_event_count_++; 62 mouse_event_count_++;
63 mouse_event_location_ = event->location(); 63 mouse_event_location_ = gfx::ToFlooredPoint(event->location());
64 mouse_event_flags_ = event->flags(); 64 mouse_event_flags_ = event->flags();
65 event->SetHandled(); 65 event->SetHandled();
66 } 66 }
67 67
68 private: 68 private:
69 int non_client_count_; 69 int non_client_count_;
70 gfx::Point non_client_location_; 70 gfx::Point non_client_location_;
71 int mouse_event_count_; 71 int mouse_event_count_;
72 gfx::Point mouse_event_location_; 72 gfx::Point mouse_event_location_;
73 int mouse_event_flags_; 73 int mouse_event_flags_;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); 205 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
206 } 206 }
207 207
208 TEST_F(WindowEventDispatcherTest, TranslatedEvent) { 208 TEST_F(WindowEventDispatcherTest, TranslatedEvent) {
209 scoped_ptr<Window> w1(test::CreateTestWindowWithDelegate(NULL, 1, 209 scoped_ptr<Window> w1(test::CreateTestWindowWithDelegate(NULL, 1,
210 gfx::Rect(50, 50, 100, 100), root_window())); 210 gfx::Rect(50, 50, 100, 100), root_window()));
211 211
212 gfx::Point origin(100, 100); 212 gfx::Point origin(100, 100);
213 ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, 0, 0); 213 ui::MouseEvent root(ui::ET_MOUSE_PRESSED, origin, origin, 0, 0);
214 214
215 EXPECT_EQ("100,100", root.location().ToString()); 215 EXPECT_EQ("100,100", gfx::ToFlooredPoint(root.location()).ToString());
216 EXPECT_EQ("100,100", root.root_location().ToString()); 216 EXPECT_EQ("100,100", root.root_location().ToString());
217 217
218 ui::MouseEvent translated_event( 218 ui::MouseEvent translated_event(
219 root, static_cast<Window*>(root_window()), w1.get(), 219 root, static_cast<Window*>(root_window()), w1.get(),
220 ui::ET_MOUSE_ENTERED, root.flags()); 220 ui::ET_MOUSE_ENTERED, root.flags());
221 EXPECT_EQ("50,50", translated_event.location().ToString()); 221 EXPECT_EQ("50,50",
222 gfx::ToFlooredPoint(translated_event.location()).ToString());
222 EXPECT_EQ("100,100", translated_event.root_location().ToString()); 223 EXPECT_EQ("100,100", translated_event.root_location().ToString());
223 } 224 }
224 225
225 namespace { 226 namespace {
226 227
227 class TestEventClient : public client::EventClient { 228 class TestEventClient : public client::EventClient {
228 public: 229 public:
229 static const int kNonLockWindowId = 100; 230 static const int kNonLockWindowId = 100;
230 static const int kLockWindowId = 200; 231 static const int kLockWindowId = 200;
231 232
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 virtual void OnEvent(ui::Event* event) OVERRIDE { 469 virtual void OnEvent(ui::Event* event) OVERRIDE {
469 ui::EventHandler::OnEvent(event); 470 ui::EventHandler::OnEvent(event);
470 events_.push_back(event->type()); 471 events_.push_back(event->type());
471 if (wait_until_event_ == event->type() && run_loop_) { 472 if (wait_until_event_ == event->type() && run_loop_) {
472 run_loop_->Quit(); 473 run_loop_->Quit();
473 wait_until_event_ = ui::ET_UNKNOWN; 474 wait_until_event_ = ui::ET_UNKNOWN;
474 } 475 }
475 } 476 }
476 477
477 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 478 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
478 mouse_locations_.push_back(event->location()); 479 mouse_locations_.push_back(gfx::ToFlooredPoint(event->location()));
479 mouse_event_flags_.push_back(event->flags()); 480 mouse_event_flags_.push_back(event->flags());
480 } 481 }
481 482
482 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { 483 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
483 touch_locations_.push_back(event->location()); 484 touch_locations_.push_back(gfx::ToFlooredPoint(event->location()));
484 } 485 }
485 486
486 private: 487 private:
487 scoped_ptr<base::RunLoop> run_loop_; 488 scoped_ptr<base::RunLoop> run_loop_;
488 ui::EventType wait_until_event_; 489 ui::EventType wait_until_event_;
489 490
490 Events events_; 491 Events events_;
491 EventLocations mouse_locations_; 492 EventLocations mouse_locations_;
492 EventLocations touch_locations_; 493 EventLocations touch_locations_;
493 EventFlags mouse_event_flags_; 494 EventFlags mouse_event_flags_;
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 delegate.GetMouseMotionCountsAndReset(); 2095 delegate.GetMouseMotionCountsAndReset();
2095 2096
2096 // Notify both hosts that the cursor is now hidden. This should send a single 2097 // Notify both hosts that the cursor is now hidden. This should send a single
2097 // mouse-exit event to |window|. 2098 // mouse-exit event to |window|.
2098 host()->OnCursorVisibilityChanged(false); 2099 host()->OnCursorVisibilityChanged(false);
2099 second_host->OnCursorVisibilityChanged(false); 2100 second_host->OnCursorVisibilityChanged(false);
2100 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); 2101 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset());
2101 } 2102 }
2102 2103
2103 } // namespace aura 2104 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698