From 8715ceed76c609c1653aff77ae79640e34471e32 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Thu, 22 Jun 2023 13:48:57 +0900 Subject: [PATCH] Sync test harness Change-Id: Ib89a365dae26ff2db51d40d4bebdf5bb140e9a92 --- .../dali-toolkit-test-utils/test-actor-utils.cpp | 26 ++++++++++++++++++++++ .../dali-toolkit-test-utils/test-actor-utils.h | 25 +++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp index eb1ab88..d628f0d 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp @@ -22,6 +22,7 @@ #include // INTERNAL INCLUDES +#include #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>& damagedRects, std::multiset, 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 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.h index 94f1493..6571365 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include // For std::multiset #include 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& lhs, const Rect& 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>& damagedRects, std::multiset, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation); + } // namespace Dali #endif // DALI_TEST_ACTOR_UTILS_H -- 2.7.4