| 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/root_window.h" | 5 #include "ui/aura/root_window.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/aura/client/event_client.h" | 10 #include "ui/aura/client/event_client.h" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 TEST_F(RootWindowTest, ScrollEventDispatch) { | 373 TEST_F(RootWindowTest, ScrollEventDispatch) { |
| 374 base::TimeDelta now = ui::EventTimeForNow(); | 374 base::TimeDelta now = ui::EventTimeForNow(); |
| 375 test::TestEventHandler* filter = new test::TestEventHandler; | 375 test::TestEventHandler* filter = new test::TestEventHandler; |
| 376 root_window()->SetEventFilter(filter); | 376 root_window()->SetEventFilter(filter); |
| 377 | 377 |
| 378 test::TestWindowDelegate delegate; | 378 test::TestWindowDelegate delegate; |
| 379 scoped_ptr<Window> w1(CreateWindow(1, root_window(), &delegate)); | 379 scoped_ptr<Window> w1(CreateWindow(1, root_window(), &delegate)); |
| 380 w1->SetBounds(gfx::Rect(20, 20, 40, 40)); | 380 w1->SetBounds(gfx::Rect(20, 20, 40, 40)); |
| 381 | 381 |
| 382 // A scroll event on the root-window itself is dispatched. | 382 // A scroll event on the root-window itself is dispatched. |
| 383 ui::ScrollEvent scroll1(ui::ET_SCROLL, gfx::Point(10, 10), now, 0, 0, -10, 2); | 383 ui::ScrollEvent scroll1(ui::ET_SCROLL, |
| 384 gfx::Point(10, 10), |
| 385 now, |
| 386 0, |
| 387 0, -10, |
| 388 0, -10, |
| 389 2); |
| 384 root_window()->AsRootWindowHostDelegate()->OnHostScrollEvent(&scroll1); | 390 root_window()->AsRootWindowHostDelegate()->OnHostScrollEvent(&scroll1); |
| 385 EXPECT_EQ(1, filter->num_scroll_events()); | 391 EXPECT_EQ(1, filter->num_scroll_events()); |
| 386 | 392 |
| 387 // Scroll event on a window should be dispatched properly. | 393 // Scroll event on a window should be dispatched properly. |
| 388 ui::ScrollEvent scroll2(ui::ET_SCROLL, gfx::Point(25, 30), now, 0, -10, 0, 2); | 394 ui::ScrollEvent scroll2(ui::ET_SCROLL, |
| 395 gfx::Point(25, 30), |
| 396 now, |
| 397 0, |
| 398 -10, 0, |
| 399 -10, 0, |
| 400 2); |
| 389 root_window()->AsRootWindowHostDelegate()->OnHostScrollEvent(&scroll2); | 401 root_window()->AsRootWindowHostDelegate()->OnHostScrollEvent(&scroll2); |
| 390 EXPECT_EQ(2, filter->num_scroll_events()); | 402 EXPECT_EQ(2, filter->num_scroll_events()); |
| 391 } | 403 } |
| 392 | 404 |
| 393 namespace { | 405 namespace { |
| 394 | 406 |
| 395 // FilterFilter that tracks the types of events it's seen. | 407 // FilterFilter that tracks the types of events it's seen. |
| 396 class EventFilterRecorder : public ui::EventHandler { | 408 class EventFilterRecorder : public ui::EventHandler { |
| 397 public: | 409 public: |
| 398 typedef std::vector<ui::EventType> Events; | 410 typedef std::vector<ui::EventType> Events; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 // Tap on w2 which triggers nested gestures for w1. | 796 // Tap on w2 which triggers nested gestures for w1. |
| 785 test::EventGenerator generator(root_window(), w2.get()); | 797 test::EventGenerator generator(root_window(), w2.get()); |
| 786 generator.GestureTapAt(w2->bounds().CenterPoint()); | 798 generator.GestureTapAt(w2->bounds().CenterPoint()); |
| 787 | 799 |
| 788 // Both windows should get their gesture end events. | 800 // Both windows should get their gesture end events. |
| 789 EXPECT_EQ(1, d1.gesture_end_count()); | 801 EXPECT_EQ(1, d1.gesture_end_count()); |
| 790 EXPECT_EQ(1, d2.gesture_end_count()); | 802 EXPECT_EQ(1, d2.gesture_end_count()); |
| 791 } | 803 } |
| 792 | 804 |
| 793 } // namespace aura | 805 } // namespace aura |
| OLD | NEW |