| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { | 452 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE { |
| 453 events_.push_back(event->type()); | 453 events_.push_back(event->type()); |
| 454 return ui::ER_UNHANDLED; | 454 return ui::ER_UNHANDLED; |
| 455 } | 455 } |
| 456 | 456 |
| 457 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 457 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
| 458 events_.push_back(event->type()); | 458 events_.push_back(event->type()); |
| 459 return ui::ER_UNHANDLED; | 459 return ui::ER_UNHANDLED; |
| 460 } | 460 } |
| 461 | 461 |
| 462 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 462 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
| 463 events_.push_back(event->type()); | 463 events_.push_back(event->type()); |
| 464 return ui::ER_UNHANDLED; | |
| 465 } | 464 } |
| 466 | 465 |
| 467 private: | 466 private: |
| 468 Events events_; | 467 Events events_; |
| 469 | 468 |
| 470 DISALLOW_COPY_AND_ASSIGN(EventFilterRecorder); | 469 DISALLOW_COPY_AND_ASSIGN(EventFilterRecorder); |
| 471 }; | 470 }; |
| 472 | 471 |
| 473 // Converts an EventType to a string. | 472 // Converts an EventType to a string. |
| 474 std::string EventTypeToString(ui::EventType type) { | 473 std::string EventTypeToString(ui::EventType type) { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 namespace { | 738 namespace { |
| 740 | 739 |
| 741 // A window delegate that detaches the parent of the target's parent window when | 740 // A window delegate that detaches the parent of the target's parent window when |
| 742 // it receives a tap event. | 741 // it receives a tap event. |
| 743 class DetachesParentOnTapDelegate : public test::TestWindowDelegate { | 742 class DetachesParentOnTapDelegate : public test::TestWindowDelegate { |
| 744 public: | 743 public: |
| 745 DetachesParentOnTapDelegate() {} | 744 DetachesParentOnTapDelegate() {} |
| 746 virtual ~DetachesParentOnTapDelegate() {} | 745 virtual ~DetachesParentOnTapDelegate() {} |
| 747 | 746 |
| 748 private: | 747 private: |
| 749 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 748 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
| 750 if (event->type() == ui::ET_GESTURE_TAP_DOWN) | 749 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 751 return ui::ER_HANDLED; | 750 event->SetHandled(); |
| 751 return; |
| 752 } |
| 752 | 753 |
| 753 if (event->type() == ui::ET_GESTURE_TAP) { | 754 if (event->type() == ui::ET_GESTURE_TAP) { |
| 754 Window* parent = static_cast<Window*>(event->target())->parent(); | 755 Window* parent = static_cast<Window*>(event->target())->parent(); |
| 755 parent->parent()->RemoveChild(parent); | 756 parent->parent()->RemoveChild(parent); |
| 756 return ui::ER_HANDLED; | 757 event->SetHandled(); |
| 757 } | 758 } |
| 758 return ui::ER_UNHANDLED; | |
| 759 } | 759 } |
| 760 | 760 |
| 761 DISALLOW_COPY_AND_ASSIGN(DetachesParentOnTapDelegate); | 761 DISALLOW_COPY_AND_ASSIGN(DetachesParentOnTapDelegate); |
| 762 }; | 762 }; |
| 763 | 763 |
| 764 } // namespace | 764 } // namespace |
| 765 | 765 |
| 766 // Tests that the gesture recognizer is reset for all child windows when a | 766 // Tests that the gesture recognizer is reset for all child windows when a |
| 767 // window hides. No expectations, just checks that the test does not crash. | 767 // window hides. No expectations, just checks that the test does not crash. |
| 768 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { | 768 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { |
| 769 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL)); | 769 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL)); |
| 770 DetachesParentOnTapDelegate delegate; | 770 DetachesParentOnTapDelegate delegate; |
| 771 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL)); | 771 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL)); |
| 772 Window* child = CreateWindow(11, parent.get(), &delegate); | 772 Window* child = CreateWindow(11, parent.get(), &delegate); |
| 773 test::EventGenerator generator(root_window(), child); | 773 test::EventGenerator generator(root_window(), child); |
| 774 generator.GestureTapAt(gfx::Point(40, 40)); | 774 generator.GestureTapAt(gfx::Point(40, 40)); |
| 775 } | 775 } |
| 776 | 776 |
| 777 } // namespace aura | 777 } // namespace aura |
| OLD | NEW |