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

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

Issue 11280290: events: Change gesture-event handler in EventHandler to not return any values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/gestures/gesture_recognizer_unittest.cc ('k') | ui/aura/test/test_event_handler.h » ('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/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
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
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
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/aura/test/test_event_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698