X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-actor-utils.cpp;h=d628f0d601e26d40e9e39b3dd7f2dc2f2c3b053c;hb=b412b5c5e9716149055783354274fc7f80bb1e99;hp=bf62bb8b4fd9e4157fe77754e558a632261c4d5f;hpb=d65dc625c30e54d41e071d45f36e06cd0ba88079;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 bf62bb8..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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -22,6 +22,7 @@ #include // INTERNAL INCLUDES +#include #include "mesh-builder.h" namespace Dali @@ -124,11 +125,43 @@ Texture CreateTexture(TextureType::Type type, Pixel::Format format, int width, i { Texture texture = Texture::New(type, format, width, height); - int bufferSize = width * height * 2; + int bufferSize = width * height * GetBytesPerPixel(format); uint8_t* buffer = reinterpret_cast(malloc(bufferSize)); PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, format, PixelData::FREE); texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height); return texture; } +TextureSet CreateTextureSet(Pixel::Format format, int width, int height) +{ + TextureSet textureSet = TextureSet::New(); + textureSet.SetTexture(0u, CreateTexture(TextureType::TEXTURE_2D, format, width, 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