X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fui%2Faura%2Fgestures%2Fgesture_recognizer_unittest.cc;h=596cb1f40cbdb23baf0122488e507d6d846cb808;hb=490a4587e7e356282cb1453efaf36de4acc9762f;hp=a9df40cbe11c0af3d6fcd506677efb07b70a7fe5;hpb=3a51af92707b9c600d06a404c9db8f07fcd50959;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/ui/aura/gestures/gesture_recognizer_unittest.cc b/src/ui/aura/gestures/gesture_recognizer_unittest.cc index a9df40c..596cb1f 100644 --- a/src/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/src/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -4338,6 +4338,52 @@ TEST_P(GestureRecognizerTest, LatencyPassedFromTouchEvent) { EXPECT_EQ(0U, delegate->latency_info().latency_components.size()); } +// A delegate that deletes a window on long press. +class GestureEventDeleteWindowOnLongPress : public GestureEventConsumeDelegate { + public: + GestureEventDeleteWindowOnLongPress() + : window_(NULL) {} + + void set_window(aura::Window** window) { window_ = window; } + + virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE { + GestureEventConsumeDelegate::OnGestureEvent(gesture); + if (gesture->type() != ui::ET_GESTURE_LONG_PRESS) + return; + ui::GestureRecognizer::Get()->CleanupStateForConsumer(*window_); + delete *window_; + *window_ = NULL; + } + + private: + aura::Window** window_; + DISALLOW_COPY_AND_ASSIGN(GestureEventDeleteWindowOnLongPress); +}; + +// Check that deleting the window in response to a long press gesture doesn't +// crash. +TEST_P(GestureRecognizerTest, GestureEventLongPressDeletingWindow) { + GestureEventDeleteWindowOnLongPress delegate; + const int kWindowWidth = 123; + const int kWindowHeight = 45; + const int kTouchId = 2; + gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); + aura::Window* window(CreateTestWindowWithDelegate( + &delegate, -1234, bounds, root_window())); + delegate.set_window(&window); + + ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, + gfx::Point(101, 201), + kTouchId, + ui::EventTimeForNow()); + DispatchEventUsingWindowDispatcher(&press1); + EXPECT_TRUE(window != NULL); + + // Wait until the timer runs out. + delegate.WaitUntilReceivedGesture(ui::ET_GESTURE_LONG_PRESS); + EXPECT_EQ(NULL, window); +} + INSTANTIATE_TEST_CASE_P(GestureRecognizer, GestureRecognizerTest, ::testing::Bool());