INTERRUPTED events are divided into touch and hover. 69/300069/4
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 16 Oct 2023 09:27:52 +0000 (18:27 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Tue, 17 Oct 2023 05:20:29 +0000 (14:20 +0900)
Change-Id: I1474072e22199263922dd2ddb33ae38387999679

automated-tests/src/dali/utc-Dali-TouchEventCombiner.cpp
dali/integration-api/events/touch-event-combiner.cpp

index f9664c4..8c8fc30 100644 (file)
@@ -835,9 +835,45 @@ int UtcDaliTouchEventCombinerSingleTouchInterrupted(void)
     Integration::HoverEvent hoverEvent;
     Integration::Point      point = GeneratePoint(1, PointState::INTERRUPTED, 100.0f, 100.0f);
 
-    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
     DALI_TEST_EQUALS(touchEvent.GetPointCount(), 1u, TEST_LOCATION);
     DALI_TEST_EQUALS(touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION);
+  }
+
+  // Send up, should not be able to send as combiner has been reset.
+  // Up event
+  {
+    Integration::TouchEvent touchEvent;
+    Integration::HoverEvent hoverEvent;
+    Integration::Point      point = GeneratePoint(1, PointState::UP, 100.0f, 100.0f);
+
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
+  }
+
+  // motion event for hover
+  {
+    Integration::TouchEvent touchEvent;
+    Integration::HoverEvent hoverEvent;
+    Integration::Point      point = GeneratePoint(1, PointState::MOTION, 100.0f, 100.0f);
+    point.SetDeviceClass(Device::Class::Type::MOUSE);
+
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
+    DALI_TEST_EQUALS(hoverEvent.GetPointCount(), 1u, TEST_LOCATION);
+    DALI_TEST_EQUALS(hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION);
+    DALI_TEST_EQUALS(hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION);
+    DALI_TEST_EQUALS(hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION);
+  }
+
+  time++;
+
+  // Interrupted event
+  {
+    Integration::TouchEvent touchEvent;
+    Integration::HoverEvent hoverEvent;
+    Integration::Point      point = GeneratePoint(1, PointState::INTERRUPTED, 100.0f, 100.0f);
+    point.SetDeviceClass(Device::Class::Type::MOUSE);
+
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
     DALI_TEST_EQUALS(hoverEvent.GetPointCount(), 1u, TEST_LOCATION);
     DALI_TEST_EQUALS(hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION);
   }
@@ -877,9 +913,41 @@ int UtcDaliTouchEventCombinerMultiTouchInterrupted(void)
     Integration::HoverEvent hoverEvent;
     Integration::Point      point = GeneratePoint(1, PointState::INTERRUPTED, 100.0f, 100.0f);
 
-    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
     DALI_TEST_EQUALS(touchEvent.GetPointCount(), 1u, TEST_LOCATION);
     DALI_TEST_EQUALS(touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION);
+  }
+
+  // Send up, should not be able to send as combiner has been reset.
+  // Up event
+  {
+    Integration::TouchEvent touchEvent;
+    Integration::HoverEvent hoverEvent;
+    Integration::Point      point = GeneratePoint(1, PointState::UP, 100.0f, 100.0f);
+
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
+  }
+
+  // Several motion for hover
+  for(unsigned int pointCount = 1u; pointCount < maximum; ++pointCount)
+  {
+    Integration::TouchEvent touchEvent;
+    Integration::HoverEvent hoverEvent;
+    Integration::Point      point = GeneratePoint(pointCount, PointState::MOTION, 100.0f, 100.0f);
+    point.SetDeviceClass(Device::Class::Type::MOUSE);
+
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
+    DALI_TEST_EQUALS(hoverEvent.GetPointCount(), pointCount, TEST_LOCATION);
+  }
+
+  // Interrupted event
+  {
+    Integration::TouchEvent touchEvent;
+    Integration::HoverEvent hoverEvent;
+    Integration::Point      point = GeneratePoint(1, PointState::INTERRUPTED, 100.0f, 100.0f);
+    point.SetDeviceClass(Device::Class::Type::MOUSE);
+
+    DALI_TEST_EQUALS(Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent(point, time, touchEvent, hoverEvent), TEST_LOCATION);
     DALI_TEST_EQUALS(hoverEvent.GetPointCount(), 1u, TEST_LOCATION);
     DALI_TEST_EQUALS(hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION);
   }
index 7423590..4f01dfd 100644 (file)
@@ -336,12 +336,18 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(cons
 
     case PointState::INTERRUPTED:
     {
-      Reset();
-
       // We should still tell core about the interruption.
-      touchEvent.AddPoint(point);
-      hoverEvent.AddPoint(point);
-      dispatchEvent = TouchEventCombiner::DISPATCH_BOTH;
+      if(!mPressedPoints.empty())
+      {
+        touchEvent.AddPoint(point);
+        dispatchEvent = TouchEventCombiner::DISPATCH_TOUCH;
+      }
+      if((!mHoveredPoints.empty()))
+      {
+        hoverEvent.AddPoint(point);
+        dispatchEvent = dispatchEvent == TouchEventCombiner::DISPATCH_TOUCH ? TouchEventCombiner::DISPATCH_BOTH : TouchEventCombiner::DISPATCH_HOVER;
+      }
+      Reset();
       break;
     }