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

Unified Diff: ash/drag_drop/drag_drop_controller_unittest.cc

Issue 16463002: Change ordering of Shell event handlers: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/drag_drop/drag_drop_controller.cc ('k') | ash/shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/drag_drop/drag_drop_controller_unittest.cc
diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc
index 91cb67cd99234df83a791375717d5a5c7ec0325d..e27f19cee2197ee3accafe13c2689f3bed666566 100644
--- a/ash/drag_drop/drag_drop_controller_unittest.cc
+++ b/ash/drag_drop/drag_drop_controller_unittest.cc
@@ -1108,105 +1108,5 @@ TEST_F(DragDropControllerTest, MAYBE_DragCancelAcrossDisplays) {
}
}
-class SimpleEventHandler : public ui::EventHandler {
- public:
- SimpleEventHandler()
- : handled_event_received_(false),
- unhandled_event_received_(false) {
- ash::Shell::GetInstance()->PrependPreTargetHandler(this);
- }
-
- virtual ~SimpleEventHandler() {
- ash::Shell::GetInstance()->RemovePreTargetHandler(this);
- }
-
- bool handled_event_received() { return handled_event_received_; }
- bool unhandled_event_received() { return unhandled_event_received_; }
-
- void Reset() {
- handled_event_received_ = false;
- unhandled_event_received_ = false;
- }
-
- private:
- // Overridden from ui::EventHandler.
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
- if (event->handled())
- handled_event_received_ = true;
- else
- unhandled_event_received_ = true;
- }
-
- bool handled_event_received_;
- bool unhandled_event_received_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleEventHandler);
-};
-
-TEST_F(DragDropControllerTest,
- DragDropControllerReceivesAllEventsDuringDragDrop) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableTouchDragDrop);
- scoped_ptr<views::Widget> widget(CreateNewWidget());
- DragTestView* drag_view = new DragTestView;
- AddViewToWidgetAndResize(widget.get(), drag_view);
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
- widget->GetNativeView());
- ui::OSExchangeData data;
- data.SetString(UTF8ToUTF16("I am being dragged"));
- SimpleEventHandler handler;
-
- // Since we are not in drag/drop, |handler| should receive unhandled events.
- generator.PressTouch();
- gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
- handler.Reset();
- DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point);
- EXPECT_TRUE(handler.unhandled_event_received());
- EXPECT_FALSE(handler.handled_event_received());
-
- EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
-
- // Since dragging has started, |handler| should not receive unhandled events.
- UpdateDragData(&data);
- gfx::Point gesture_location = point;
- int num_drags = drag_view->width();
- for (int i = 0; i < num_drags; ++i) {
- gesture_location.Offset(1, 0);
- handler.Reset();
- DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location);
- EXPECT_FALSE(handler.handled_event_received());
- EXPECT_FALSE(handler.unhandled_event_received());
-
- // Execute any scheduled draws to process deferred mouse events.
- RunAllPendingInMessageLoop();
- }
-
- // Handler should not receive any other gestures that DragDropController
- // does not care about.
- std::set<ui::EventType> drag_drop_gestures;
- drag_drop_gestures.insert(ui::ET_GESTURE_SCROLL_UPDATE);
- drag_drop_gestures.insert(ui::ET_GESTURE_SCROLL_END);
- drag_drop_gestures.insert(ui::ET_GESTURE_LONG_TAP);
- drag_drop_gestures.insert(ui::ET_SCROLL_FLING_START);
- for (ui::EventType type = ui::ET_UNKNOWN; type < ui::ET_LAST;
- type = static_cast<ui::EventType>(type + 1)) {
- if (!IsGestureEventType(type) ||
- drag_drop_gestures.find(type) != drag_drop_gestures.end())
- continue;
-
- handler.Reset();
- DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location);
- EXPECT_FALSE(handler.handled_event_received());
- EXPECT_FALSE(handler.unhandled_event_received());
-
- // Execute any scheduled draws to process deferred mouse events.
- RunAllPendingInMessageLoop();
- }
-
- // End dragging.
- DispatchGesture(ui::ET_GESTURE_SCROLL_END, gesture_location);
- EXPECT_TRUE(drag_drop_controller_->drop_received_);
-}
-
} // namespace test
} // namespace aura
« no previous file with comments | « ash/drag_drop/drag_drop_controller.cc ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698