From 8377af047615841c9458d5f6c036fe9fddc9159c Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Wed, 13 Sep 2023 15:45:12 +0900 Subject: [PATCH] Add NewHoverEvent api Change-Id: Id84499e6d3b3cbeb00c052a05aba0bcfc6c0e1f9 --- automated-tests/src/dali/utc-Dali-HoverEvent.cpp | 161 +++++++++++++++++++++ .../src/dali/utc-Dali-HoverProcessing.cpp | 15 ++ dali/integration-api/events/touch-integ.cpp | 14 ++ dali/integration-api/events/touch-integ.h | 20 +++ 4 files changed, 210 insertions(+) create mode 100644 automated-tests/src/dali/utc-Dali-HoverEvent.cpp diff --git a/automated-tests/src/dali/utc-Dali-HoverEvent.cpp b/automated-tests/src/dali/utc-Dali-HoverEvent.cpp new file mode 100644 index 0000000..f25cbc9 --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-HoverEvent.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include +#include + +#include + +void utc_dali_hover_event_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_hover_event_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ +TouchPoint GenerateTouchPoint() +{ + return TouchPoint(1, PointState::STARTED, 100.0f, 200.0f); +} +} // namespace + +int UtcDaliHoverEventConstructorP(void) +{ + HoverEvent hoverEvent; + DALI_TEST_CHECK(!hoverEvent); + END_TEST; +} + +int UtcDaliHoverEventCopyConstructorP(void) +{ + HoverEvent hoverEvent = Integration::NewHoverEvent(123u, GenerateTouchPoint()); + DALI_TEST_CHECK(hoverEvent); + + const auto refCount = hoverEvent.GetBaseObject().ReferenceCount(); + + HoverEvent hoverEvent2(hoverEvent); + DALI_TEST_CHECK(hoverEvent); + DALI_TEST_CHECK(hoverEvent2); + DALI_TEST_EQUALS(hoverEvent, hoverEvent2, TEST_LOCATION); + DALI_TEST_EQUALS(refCount + 1, hoverEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliHoverEventMoveConstructorP(void) +{ + HoverEvent hoverEvent = Integration::NewHoverEvent(123u, GenerateTouchPoint()); + DALI_TEST_CHECK(hoverEvent); + + const auto refCount = hoverEvent.GetBaseObject().ReferenceCount(); + + HoverEvent hoverEvent2(std::move(hoverEvent)); + DALI_TEST_CHECK(!hoverEvent); + DALI_TEST_CHECK(hoverEvent2); + DALI_TEST_EQUALS(refCount, hoverEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliHoverEventCopyAssignmentP(void) +{ + HoverEvent hoverEvent = Integration::NewHoverEvent(123u, GenerateTouchPoint()); + DALI_TEST_CHECK(hoverEvent); + + const auto refCount = hoverEvent.GetBaseObject().ReferenceCount(); + + HoverEvent hoverEvent2; + DALI_TEST_CHECK(!hoverEvent2); + + hoverEvent2 = hoverEvent; + DALI_TEST_CHECK(hoverEvent); + DALI_TEST_CHECK(hoverEvent2); + DALI_TEST_EQUALS(hoverEvent, hoverEvent2, TEST_LOCATION); + DALI_TEST_EQUALS(refCount + 1, hoverEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliHoverEventMoveAssignmentP(void) +{ + HoverEvent hoverEvent = Integration::NewHoverEvent(123u, GenerateTouchPoint()); + DALI_TEST_CHECK(hoverEvent); + + const auto refCount = hoverEvent.GetBaseObject().ReferenceCount(); + + HoverEvent hoverEvent2; + DALI_TEST_CHECK(!hoverEvent2); + + hoverEvent2 = std::move(hoverEvent); + DALI_TEST_CHECK(!hoverEvent); + DALI_TEST_CHECK(hoverEvent2); + DALI_TEST_EQUALS(refCount, hoverEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliHoverEventCopyConstructorWithPointP(void) +{ + Dali::Integration::Point point; + + Vector2 touchPoint(10.0, 20.0); + point.SetDeviceId(1); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y)); + + HoverEvent hoverEvent = Integration::NewHoverEvent(123u, point); + DALI_TEST_CHECK(hoverEvent); + + const auto refCount = hoverEvent.GetBaseObject().ReferenceCount(); + + HoverEvent hoverEvent2(hoverEvent); + DALI_TEST_CHECK(hoverEvent); + DALI_TEST_CHECK(hoverEvent2); + DALI_TEST_EQUALS(hoverEvent, hoverEvent2, TEST_LOCATION); + DALI_TEST_EQUALS(refCount + 1, hoverEvent.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + END_TEST; +} + +int UtcDaliHoverEventMoveConstructorWithPointP(void) +{ + Dali::Integration::Point point; + + Vector2 touchPoint(10.0, 20.0); + point.SetDeviceId(1); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(touchPoint.x, touchPoint.y)); + + HoverEvent hoverEvent = Integration::NewHoverEvent(123u, point); + DALI_TEST_CHECK(hoverEvent); + + const auto refCount = hoverEvent.GetBaseObject().ReferenceCount(); + + HoverEvent hoverEvent2(std::move(hoverEvent)); + DALI_TEST_CHECK(!hoverEvent); + DALI_TEST_CHECK(hoverEvent2); + DALI_TEST_EQUALS(refCount, hoverEvent2.GetBaseObject().ReferenceCount(), TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp index f28d202..9dc8c89 100644 --- a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1330,3 +1331,17 @@ int UtcDaliHoverEventCreate(void) END_TEST; } + +int UtcDaliHoverEventIntegNewHoverEvent(void) +{ + uint32_t timestamp = 92858u; + TouchPoint tp(1, PointState::STARTED, 34.4f, 123.89f, 5.0f, 7.0f); + Dali::HoverEvent hoverEvent = Integration::NewHoverEvent(timestamp, tp); + + DALI_TEST_EQUALS(hoverEvent.GetPointCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.GetState(0), PointState::STARTED, TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.GetLocalPosition(0), Vector2(5.0f, 7.0f), TEST_LOCATION); + DALI_TEST_EQUALS(hoverEvent.GetScreenPosition(0), Vector2(34.4f, 123.89f), TEST_LOCATION); + + END_TEST; +} diff --git a/dali/integration-api/events/touch-integ.cpp b/dali/integration-api/events/touch-integ.cpp index efab5f3..ae69dda 100644 --- a/dali/integration-api/events/touch-integ.cpp +++ b/dali/integration-api/events/touch-integ.cpp @@ -15,6 +15,7 @@ */ #include +#include #include namespace Dali @@ -34,6 +35,19 @@ Dali::TouchEvent NewTouchEvent(uint32_t timeStamp, const Dali::Integration::Poin return handle; } +Dali::HoverEvent NewHoverEvent(uint32_t timeStamp, const TouchPoint& point) +{ + return NewHoverEvent(timeStamp, Integration::Point(point)); +} + +Dali::HoverEvent NewHoverEvent(uint32_t timeStamp, const Dali::Integration::Point& point) +{ + Internal::HoverEventPtr hoverEventImpl(new Internal::HoverEvent(timeStamp)); + hoverEventImpl->AddPoint(point); + Dali::HoverEvent handle(hoverEventImpl.Get()); + return handle; +} + } // namespace Integration } // namespace Dali diff --git a/dali/integration-api/events/touch-integ.h b/dali/integration-api/events/touch-integ.h index 6552fb9..4aeceab 100644 --- a/dali/integration-api/events/touch-integ.h +++ b/dali/integration-api/events/touch-integ.h @@ -22,6 +22,7 @@ #include #include #include +#include namespace Dali { @@ -45,6 +46,25 @@ DALI_CORE_API Dali::TouchEvent NewTouchEvent(uint32_t timeStamp, const TouchPoin */ DALI_CORE_API Dali::TouchEvent NewTouchEvent(uint32_t timeStamp, const Dali::Integration::Point& point); +/** + * Create a new hover data handle from timestamp and point. + * + * @param[in] timeStamp The time stamp of the hover event. + * @param[in] point The point on screen where the hover occurred. + * @return A new hover data handle. + */ +DALI_CORE_API Dali::HoverEvent NewHoverEvent(uint32_t timeStamp, const TouchPoint& point); + +/** + * Create a new hover data handle from timestamp and point. + * + * @param[in] timeStamp The time stamp of the hpver event. + * @param[in] point The point on screen where the hover occurred. + * @return A new hover data handle. + */ +DALI_CORE_API Dali::HoverEvent NewHoverEvent(uint32_t timeStamp, const Dali::Integration::Point& point); + + } // namespace Integration } // namespace Dali -- 2.7.4