X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-TapGestureDetector.cpp;h=6eeab2f21f2c763a383dbe7c03fa641531669e16;hb=fe58df83b2d72c4beceb101eb9cffcc5442f3d6e;hp=714c146a5694f4b71e0ddc9bd9a1854ba8de806e;hpb=92b051cadd0db5d9f985aacbbbf832995fb55f53;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp index 714c146..6eeab2f 100644 --- a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,13 @@ void utc_dali_tap_gesture_detector_cleanup(void) /////////////////////////////////////////////////////////////////////////////// namespace { +bool gHitTestTouchCallBackCalled = false; +static bool TestHitTestTouchCallback(Actor, const TouchEvent&) +{ + gHitTestTouchCallBackCalled = true; + return false; + END_TEST; +} // Stores data that is populated in the callback and will be read by the TET cases struct SignalData { @@ -136,6 +143,21 @@ Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector return touchEvent; } +Integration::TouchEvent GenerateSingleMouse(PointState::Type state, const Vector2& screenPosition, int source, uint32_t time) +{ + Integration::TouchEvent touchEvent; + Integration::Point point; + point.SetState(state); + point.SetDeviceId(4); + point.SetScreenPosition(screenPosition); + point.SetDeviceClass(Device::Class::MOUSE); + point.SetDeviceSubclass(Device::Subclass::NONE); + point.SetMouseButton(static_cast(source)); + touchEvent.points.push_back(point); + touchEvent.time = time; + return touchEvent; +} + } // namespace /////////////////////////////////////////////////////////////////////////////// @@ -166,7 +188,6 @@ int UtcDaliTapGestureDetectorAssignmentOperatorP(void) TestApplication application; TapGestureDetector detector = TapGestureDetector::New(); - ; TapGestureDetector assign; assign = detector; @@ -176,6 +197,34 @@ int UtcDaliTapGestureDetectorAssignmentOperatorP(void) END_TEST; } +int UtcDaliRTapGestureDetectorMoveConstructorP(void) +{ + TestApplication application; + + TapGestureDetector detector = TapGestureDetector::New(); + DALI_TEST_CHECK(detector); + + TapGestureDetector moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + +int UtcDaliTapGestureDetectorMoveAssignmentOperatorP(void) +{ + TestApplication application; + + TapGestureDetector detector; + detector = TapGestureDetector::New(); + DALI_TEST_CHECK(detector); + + TapGestureDetector moved; + moved = std::move(detector); + DALI_TEST_CHECK(moved); + DALI_TEST_CHECK(!detector); + END_TEST; +} + int UtcDaliTapGestureDetectorNew(void) { TestApplication application; @@ -1022,7 +1071,7 @@ int UtcDaliTapGestureWhenGesturePropargation(void) END_TEST; } -int UtcDaliTapGestureGetSourceType(void) +int UtcDaliTapGestureGetSourceTypeWithMouse(void) { TestApplication application; @@ -1043,42 +1092,68 @@ int UtcDaliTapGestureGetSourceType(void) detector.DetectedSignal().Connect(&application, functor); // Emit a down signal with MouseButton - application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 0, 100)); - application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 0, 120)); + application.ProcessEvent(GenerateSingleMouse(PointState::DOWN, Vector2(20.0f, 20.0f), 1, 100)); + application.ProcessEvent(GenerateSingleMouse(PointState::UP, Vector2(20.0f, 20.0f), 1, 120)); application.SendNotification(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::INVALID, TEST_LOCATION); + DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::MOUSE, TEST_LOCATION); + DALI_TEST_EQUALS(data.receivedGesture.GetSourceData(), GestureSourceData::MOUSE_PRIMARY, TEST_LOCATION); data.Reset(); // Emit a down signal with MouseButton - application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 1, 700)); - application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 1, 720)); + application.ProcessEvent(GenerateSingleMouse(PointState::DOWN, Vector2(20.0f, 20.0f), 3, 1300)); + application.ProcessEvent(GenerateSingleMouse(PointState::UP, Vector2(20.0f, 20.0f), 3, 1320)); application.SendNotification(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::PRIMARY, TEST_LOCATION); + DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::MOUSE, TEST_LOCATION); + DALI_TEST_EQUALS(data.receivedGesture.GetSourceData(), GestureSourceData::MOUSE_SECONDARY, TEST_LOCATION); data.Reset(); // Emit a down signal with MouseButton - application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 3, 1300)); - application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 3, 1320)); + application.ProcessEvent(GenerateSingleMouse(PointState::DOWN, Vector2(20.0f, 20.0f), 2, 1900)); + application.ProcessEvent(GenerateSingleMouse(PointState::UP, Vector2(20.0f, 20.0f), 2, 1920)); application.SendNotification(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::SECONDARY, TEST_LOCATION); + DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::MOUSE, TEST_LOCATION); + DALI_TEST_EQUALS(data.receivedGesture.GetSourceData(), GestureSourceData::MOUSE_TERTIARY, TEST_LOCATION); - data.Reset(); + END_TEST; +} - // Emit a down signal with MouseButton - application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 2, 1900)); - application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 2, 1920)); +int UtcDaliTapGestureGetSourceTypeWithTouch(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + + TapGestureDetector detector = TapGestureDetector::New(); + detector.Attach(actor); + detector.DetectedSignal().Connect(&application, functor); + + // Emit a down signal with touch + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 1, 100)); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 1, 120)); application.SendNotification(); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::TERTIARY, TEST_LOCATION); + DALI_TEST_EQUALS(data.receivedGesture.GetSourceType(), GestureSourceType::TOUCH, TEST_LOCATION); + + data.Reset(); END_TEST; } @@ -1144,4 +1219,111 @@ int UtcDaliTapGestureReceiveAllTapEvents(void) data.Reset(); END_TEST; -} \ No newline at end of file +} + +int UtcDaliTapGestureDoesWantedHitTest(void) +{ + TestApplication application; + + Actor blue = Actor::New(); + blue.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + blue.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + Actor green = Actor::New(); + green.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + green.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + application.GetScene().Add(blue); + application.GetScene().Add(green); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData blueData; + GestureReceivedFunctor blueFunctor(blueData); + + TapGestureDetector blueDetector = TapGestureDetector::New(); + blueDetector.Attach(blue); + blueDetector.DetectedSignal().Connect(&application, blueFunctor); + + SignalData greenData; + GestureReceivedFunctor greenFunctor(greenData); + + TapGestureDetector greenDetector = TapGestureDetector::New(); + greenDetector.Attach(green); + greenDetector.DetectedSignal().Connect(&application, greenFunctor); + + // connect to its hit-test signal + gHitTestTouchCallBackCalled = false; + Dali::DevelActor::HitTestResultSignal(green).Connect(TestHitTestTouchCallback); + + // Emit a down signal + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 0, 100)); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 20.0f), 0, 120)); + application.SendNotification(); + + // check hit-test events + // The green actor received an event that the green actor was hit. + DALI_TEST_EQUALS(true, gHitTestTouchCallBackCalled, TEST_LOCATION); + + // The green actor passed the hit-test. So blue was the final hit. + DALI_TEST_EQUALS(false, greenData.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(true, blueData.functorCalled, TEST_LOCATION); + + blueData.Reset(); + greenData.Reset(); + + END_TEST; +} + +int UtcDaliTapGestureDetectorCheck(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); + + Actor actor2 = Actor::New(); + actor2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 100.0f)); + actor2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor2); + + // Render and notify + application.SendNotification(); + application.Render(); + + SignalData data; + GestureReceivedFunctor functor(data); + TapGestureDetector detector1 = TapGestureDetector::New(); + detector1.SetMaximumTapsRequired(1u); + detector1.Attach(actor); + detector1.DetectedSignal().Connect(&application, functor); + + TapGestureDetector detector2 = TapGestureDetector::New(); + detector2.SetMaximumTapsRequired(2u); + detector2.Attach(actor2); + + // Emit signals, Send the single tab. + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 0, 100)); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(50.0f, 50.0f), 0, 120)); + application.SendNotification(); + + // The detector1 get the tap event. + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Emit signals, Send the second tab. + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(50.0f, 50.0f), 0, 130)); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(50.0f, 50.0f), 0, 150)); + application.SendNotification(); + + // The detector1 must get the tap event. SetMaximumTapsRequired(2u) of detector2 should not affect detector1. + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + END_TEST; +}