Sync test harness 38/294638/2
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 22 Jun 2023 04:48:57 +0000 (13:48 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 26 Jun 2023 00:17:01 +0000 (00:17 +0000)
Change-Id: Ib89a365dae26ff2db51d40d4bebdf5bb140e9a92

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.h

index eb1ab88..d628f0d 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/dali-core.h>
 
 // INTERNAL INCLUDES
+#include <dali-test-suite-utils.h>
 #include "mesh-builder.h"
 
 namespace Dali
@@ -138,4 +139,29 @@ TextureSet CreateTextureSet(Pixel::Format format, int width, int height)
   return textureSet;
 }
 
+void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation)
+{
+  // Just check damagedRect contain all expectRectList.
+  DALI_TEST_GREATER(damagedRects.size() + 1u, expectedRectList.size(), testLocation);
+
+  for(auto& rect : damagedRects)
+  {
+    auto iter = expectedRectList.find(rect);
+    if(iter != expectedRectList.end())
+    {
+      expectedRectList.erase(iter);
+    }
+    else if(checkRectsExact)
+    {
+      std::ostringstream o;
+      o << rect << " exist in expectRectList" << std::endl;
+      fprintf(stderr, "Test failed in %s, checking %s", testLocation, o.str().c_str());
+      tet_result(TET_FAIL);
+    }
+  }
+
+  // Check all rects are matched
+  DALI_TEST_EQUALS(expectedRectList.empty(), true, testLocation);
+}
+
 } // namespace Dali
index 94f1493..6571365 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/public-api/rendering/texture.h>
+#include <set> // For std::multiset
 #include <string>
 
 namespace Dali
@@ -63,6 +64,30 @@ Actor CreateRenderableActor2(TextureSet textures, const std::string& vertexShade
 Texture    CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height);
 TextureSet CreateTextureSet(Pixel::Format format, int width, int height);
 
+// Check dirtyRect is equal with expected multiset.
+// Note that the order of damagedRect is not important
+struct RectSorter
+{
+  bool operator()(const Rect<int>& lhs, const Rect<int>& rhs) const
+  {
+    if(lhs.x != rhs.x)
+    {
+      return lhs.x < rhs.x;
+    }
+    if(lhs.y != rhs.y)
+    {
+      return lhs.y < rhs.y;
+    }
+    if(lhs.width != rhs.width)
+    {
+      return lhs.width < rhs.width;
+    }
+    return lhs.height < rhs.height;
+  }
+};
+
+void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation);
+
 } // namespace Dali
 
 #endif // DALI_TEST_ACTOR_UTILS_H