Add NewHoverEvent api 52/298752/3
authorjoogab.yun <joogab.yun@samsung.com>
Wed, 13 Sep 2023 06:45:12 +0000 (15:45 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Wed, 13 Sep 2023 08:09:37 +0000 (17:09 +0900)
Change-Id: Id84499e6d3b3cbeb00c052a05aba0bcfc6c0e1f9

automated-tests/src/dali/utc-Dali-HoverEvent.cpp [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-HoverProcessing.cpp
dali/integration-api/events/touch-integ.cpp
dali/integration-api/events/touch-integ.h

diff --git a/automated-tests/src/dali/utc-Dali-HoverEvent.cpp b/automated-tests/src/dali/utc-Dali-HoverEvent.cpp
new file mode 100644 (file)
index 0000000..f25cbc9
--- /dev/null
@@ -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 <dali-test-suite-utils.h>
+#include <dali/integration-api/events/touch-integ.h>
+#include <dali/public-api/dali-core.h>
+#include <stdlib.h>
+
+#include <iostream>
+
+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;
+}
index f28d202..9dc8c89 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/events/hover-event-devel.h>
 #include <dali/integration-api/events/hover-event-integ.h>
+#include <dali/integration-api/events/touch-integ.h>
 #include <dali/integration-api/render-task-list-integ.h>
 #include <dali/public-api/dali-core.h>
 #include <stdlib.h>
@@ -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;
+}
index efab5f3..ae69dda 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <dali/integration-api/events/touch-integ.h>
+#include <dali/internal/event/events/hover-event-impl.h>
 #include <dali/internal/event/events/touch-event-impl.h>
 
 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
index 6552fb9..4aeceab 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/integration-api/events/point.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/hover-event.h>
 
 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