From 65cac87a922237c1e254848955fe427585051b12 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Mon, 11 Aug 2025 19:42:15 +0900 Subject: [PATCH] VisualTest for PreInitialize cases Signed-off-by: Eunki, Hong --- common/visual-test.h | 50 +++++---- .../images/expected-result.png | Bin 0 -> 354 bytes .../preinitialize-gles-to-vk-test.cpp | 95 ++++++++++++++++++ .../images/expected-result.png | Bin 0 -> 354 bytes .../preinitialize-gles-test.cpp | 95 ++++++++++++++++++ .../images/expected-result.png | Bin 0 -> 354 bytes .../preinitialize-gles-to-vk-test.cpp | 95 ++++++++++++++++++ .../images/expected-result.png | Bin 0 -> 354 bytes .../preinitialize-vk-test.cpp | 95 ++++++++++++++++++ 9 files changed, 408 insertions(+), 22 deletions(-) create mode 100644 visual-tests/preinitialize-gles-to-vk/images/expected-result.png create mode 100644 visual-tests/preinitialize-gles-to-vk/preinitialize-gles-to-vk-test.cpp create mode 100644 visual-tests/preinitialize-gles/images/expected-result.png create mode 100644 visual-tests/preinitialize-gles/preinitialize-gles-test.cpp create mode 100644 visual-tests/preinitialize-vk-to-gles/images/expected-result.png create mode 100644 visual-tests/preinitialize-vk-to-gles/preinitialize-gles-to-vk-test.cpp create mode 100644 visual-tests/preinitialize-vk/images/expected-result.png create mode 100644 visual-tests/preinitialize-vk/preinitialize-vk-test.cpp diff --git a/common/visual-test.h b/common/visual-test.h index d4568bd..e94f338 100644 --- a/common/visual-test.h +++ b/common/visual-test.h @@ -26,6 +26,7 @@ #include #include #include +#include extern char *gTempFilename; extern char *gTempDir; @@ -46,30 +47,35 @@ bool ParseEnvironment(int argc, char **argv, int width, int height); * @note This sets the DPI to be 96 for all tests so that text tests all produce * the same output image */ -#define DALI_VISUAL_TEST_WITH_WINDOW_SIZE(VisualTestName, InitFunction, \ - WindowWidth, WindowHeight) \ - int DALI_EXPORT_API main(int argc, char **argv) { \ - int n = asprintf(&gTempDir, "/tmp/dali-tests"); \ - if (n > 0) { \ - bool cont = ParseEnvironment(argc, argv, WindowWidth, WindowHeight); \ - if (!cont) \ - return 0; \ - n = asprintf(&gTempFilename, "%s/%s", gTempDir, #VisualTestName); \ - setenv("DALI_DPI_HORIZONTAL", "96", true); \ - setenv("DALI_DPI_VERTICAL", "96", true); \ - Rect windowSize{0, 0, WindowWidth, WindowHeight}; \ - WindowData windowData; \ - windowData.SetTransparency(false); \ - windowData.SetPositionSize(windowSize); \ - Application application = \ - Application::New(&argc, &argv, "", false, windowData); \ - VisualTestName test(application); \ - application.InitSignal().Connect(&test, &VisualTestName::InitFunction); \ - application.MainLoop(); \ - return gExitValue; \ - } \ +#define DALI_VISUAL_TEST_WITH_WINDOW_SIZE_AND_PREPROESS(VisualTestName, InitFunction, \ + WindowWidth, WindowHeight, \ + Preprocess) \ + int DALI_EXPORT_API main(int argc, char** argv) \ + { \ + int n=asprintf(&gTempDir, "/tmp/dali-tests"); \ + if(n>0) \ + { \ + bool cont = ParseEnvironment(argc, argv, WindowWidth, WindowHeight); \ + if(!cont) return 0; \ + n=asprintf(&gTempFilename, "%s/%s", gTempDir, #VisualTestName); \ + setenv("DALI_DPI_HORIZONTAL", "96", true); \ + setenv("DALI_DPI_VERTICAL", "96", true); \ + Preprocess(); \ + Rect windowSize{0, 0, WindowWidth, WindowHeight}; \ + WindowData windowData; \ + windowData.SetTransparency(false); \ + windowData.SetPositionSize(windowSize); \ + Application application = \ + Application::New(&argc, &argv, "", false, windowData); \ + VisualTestName test(application); \ + application.InitSignal().Connect(&test, &VisualTestName::InitFunction); \ + application.MainLoop(); \ + return gExitValue; \ + } \ } +#define DALI_VISUAL_TEST_WITH_WINDOW_SIZE(VisualTestName, InitFunction, WindowWidth, WindowHeight) DALI_VISUAL_TEST_WITH_WINDOW_SIZE_AND_PREPROESS(VisualTestName, InitFunction, WindowWidth, WindowHeight, std::function([](){})) + /** * DALI_VISUAL_TEST is a wrapper for the boilerplate code to create the main * function of the visual test application with the default main window size diff --git a/visual-tests/preinitialize-gles-to-vk/images/expected-result.png b/visual-tests/preinitialize-gles-to-vk/images/expected-result.png new file mode 100644 index 0000000000000000000000000000000000000000..9211f5b089a182a967943da471ace8d2b885f6f9 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5y8Awi_W^)%vv7|ftIx;Y9?C1WI$O_~uBzpw; zGB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZkpaffhPl)S(AYfp49rb)N zP=qnb+uensgH_f8$YC$>^mS!_$-%>-!?R)g>{CD?bx#+^kch)?PdaikFmSMJ$WHt3 z*JQ_PoO555!NzoXui-I?A)+iTNg<;k zGdZJF*Tlde#Mu!<1v@)hSz78DD60!_0ClK>bfhGfq*^5xr2;7iBLgE-T>}eUL&Fe5 vODhu-D?=k~14}CdgGcW-*r901%}>cptHiBg@+OWZpaup{S3j3^P6-* literal 0 HcmV?d00001 diff --git a/visual-tests/preinitialize-gles-to-vk/preinitialize-gles-to-vk-test.cpp b/visual-tests/preinitialize-gles-to-vk/preinitialize-gles-to-vk-test.cpp new file mode 100644 index 0000000..b567cc2 --- /dev/null +++ b/visual-tests/preinitialize-gles-to-vk/preinitialize-gles-to-vk-test.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2020 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +#include +#include + +#include + +// INTERNAL INCLUDES +#include "visual-test.h" + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ +const std::string EXPECTED_IMAGE_FILE = TEST_IMAGE_DIR "preinitialize-gles-to-vk/expected-result.png"; +} // namespace + +/** + * @brief This test is to make sure we can create PreInitialize application with GLES backend, and actual applicatoin is Vulkan backend. + */ +class PreInitialieTestGlesToVulkan: public VisualTest +{ +public: + + PreInitialieTestGlesToVulkan( Application& application ) + : mApplication( application ) + { + } + + void OnInit( Application application ) + { + Dali::Window window = mApplication.GetWindow(); + window.SetBackgroundColor( Color::WHITE ); + + Control simpleControl = Control::New(); + simpleControl[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + simpleControl[Actor::Property::SIZE] = Vector2(100.0f, 100.0f); + simpleControl[Control::Property::BACKGROUND] = Color::RED; + + window.Add(simpleControl); + + // Start the test + PerformNextTest(); + } + + void PostRender(std::string outputFile, bool success) override + { + CompareImageFile(EXPECTED_IMAGE_FILE, outputFile, 0.98f); + mApplication.Quit(); + } + + void PerformNextTest() + { + Window window = mApplication.GetWindow(); + CaptureWindowAfterFrameRendered(window); + } + +private: + Application& mApplication; +}; + +void PreInitialize() +{ + // Set preferred backend as GLES. + setenv("DALI_GRAPHICS_BACKEND", "GLES", 1); + + printf("DaliToolkitPreInitialize\n"); + DaliToolkitPreInitialize(nullptr, nullptr, nullptr); + printf("DaliToolkitPreInitialize done\n"); + + // Forcibly set backend as Vulkan. + Dali::Graphics::SetGraphicsBackend(Dali::Graphics::Backend::VULKAN); +} + +DALI_VISUAL_TEST_WITH_WINDOW_SIZE_AND_PREPROESS( PreInitialieTestGlesToVulkan, OnInit, 200, 200, PreInitialize ) diff --git a/visual-tests/preinitialize-gles/images/expected-result.png b/visual-tests/preinitialize-gles/images/expected-result.png new file mode 100644 index 0000000000000000000000000000000000000000..9211f5b089a182a967943da471ace8d2b885f6f9 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5y8Awi_W^)%vv7|ftIx;Y9?C1WI$O_~uBzpw; zGB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZkpaffhPl)S(AYfp49rb)N zP=qnb+uensgH_f8$YC$>^mS!_$-%>-!?R)g>{CD?bx#+^kch)?PdaikFmSMJ$WHt3 z*JQ_PoO555!NzoXui-I?A)+iTNg<;k zGdZJF*Tlde#Mu!<1v@)hSz78DD60!_0ClK>bfhGfq*^5xr2;7iBLgE-T>}eUL&Fe5 vODhu-D?=k~14}CdgGcW-*r901%}>cptHiBg@+OWZpaup{S3j3^P6-* literal 0 HcmV?d00001 diff --git a/visual-tests/preinitialize-gles/preinitialize-gles-test.cpp b/visual-tests/preinitialize-gles/preinitialize-gles-test.cpp new file mode 100644 index 0000000..7ba263b --- /dev/null +++ b/visual-tests/preinitialize-gles/preinitialize-gles-test.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2020 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +#include +#include + +#include + +// INTERNAL INCLUDES +#include "visual-test.h" + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ +const std::string EXPECTED_IMAGE_FILE = TEST_IMAGE_DIR "preinitialize-gles/expected-result.png"; +} // namespace + +/** + * @brief This test is to make sure we can create PreInitialize application with GLES backend. + */ +class PreInitialieTestGles: public VisualTest +{ +public: + + PreInitialieTestGles( Application& application ) + : mApplication( application ) + { + } + + void OnInit( Application application ) + { + Dali::Window window = mApplication.GetWindow(); + window.SetBackgroundColor( Color::WHITE ); + + Control simpleControl = Control::New(); + simpleControl[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + simpleControl[Actor::Property::SIZE] = Vector2(100.0f, 100.0f); + simpleControl[Control::Property::BACKGROUND] = Color::RED; + + window.Add(simpleControl); + + // Start the test + PerformNextTest(); + } + + void PostRender(std::string outputFile, bool success) override + { + CompareImageFile(EXPECTED_IMAGE_FILE, outputFile, 0.98f); + mApplication.Quit(); + } + + void PerformNextTest() + { + Window window = mApplication.GetWindow(); + CaptureWindowAfterFrameRendered(window); + } + +private: + Application& mApplication; +}; + +void PreInitialize() +{ + // Set preferred backend as GLES. + setenv("DALI_GRAPHICS_BACKEND", "GLES", 1); + + printf("DaliToolkitPreInitialize\n"); + DaliToolkitPreInitialize(nullptr, nullptr, nullptr); + printf("DaliToolkitPreInitialize done\n"); + + // Forcibly set backend as GLES. + Dali::Graphics::SetGraphicsBackend(Dali::Graphics::Backend::GLES); +} + +DALI_VISUAL_TEST_WITH_WINDOW_SIZE_AND_PREPROESS( PreInitialieTestGles, OnInit, 200, 200, PreInitialize ) diff --git a/visual-tests/preinitialize-vk-to-gles/images/expected-result.png b/visual-tests/preinitialize-vk-to-gles/images/expected-result.png new file mode 100644 index 0000000000000000000000000000000000000000..9211f5b089a182a967943da471ace8d2b885f6f9 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5y8Awi_W^)%vv7|ftIx;Y9?C1WI$O_~uBzpw; zGB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZkpaffhPl)S(AYfp49rb)N zP=qnb+uensgH_f8$YC$>^mS!_$-%>-!?R)g>{CD?bx#+^kch)?PdaikFmSMJ$WHt3 z*JQ_PoO555!NzoXui-I?A)+iTNg<;k zGdZJF*Tlde#Mu!<1v@)hSz78DD60!_0ClK>bfhGfq*^5xr2;7iBLgE-T>}eUL&Fe5 vODhu-D?=k~14}CdgGcW-*r901%}>cptHiBg@+OWZpaup{S3j3^P6-* literal 0 HcmV?d00001 diff --git a/visual-tests/preinitialize-vk-to-gles/preinitialize-gles-to-vk-test.cpp b/visual-tests/preinitialize-vk-to-gles/preinitialize-gles-to-vk-test.cpp new file mode 100644 index 0000000..6b6e4b0 --- /dev/null +++ b/visual-tests/preinitialize-vk-to-gles/preinitialize-gles-to-vk-test.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2020 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +#include +#include + +#include + +// INTERNAL INCLUDES +#include "visual-test.h" + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ +const std::string EXPECTED_IMAGE_FILE = TEST_IMAGE_DIR "preinitialize-vk-to-gles/expected-result.png"; +} // namespace + +/** + * @brief This test is to make sure we can create PreInitialize application with Vulkan backend, and actual applicatoin is GLES backend. + */ +class PreInitialieTestVulkanToGles: public VisualTest +{ +public: + + PreInitialieTestVulkanToGles( Application& application ) + : mApplication( application ) + { + } + + void OnInit( Application application ) + { + Dali::Window window = mApplication.GetWindow(); + window.SetBackgroundColor( Color::WHITE ); + + Control simpleControl = Control::New(); + simpleControl[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + simpleControl[Actor::Property::SIZE] = Vector2(100.0f, 100.0f); + simpleControl[Control::Property::BACKGROUND] = Color::RED; + + window.Add(simpleControl); + + // Start the test + PerformNextTest(); + } + + void PostRender(std::string outputFile, bool success) override + { + CompareImageFile(EXPECTED_IMAGE_FILE, outputFile, 0.98f); + mApplication.Quit(); + } + + void PerformNextTest() + { + Window window = mApplication.GetWindow(); + CaptureWindowAfterFrameRendered(window); + } + +private: + Application& mApplication; +}; + +void PreInitialize() +{ + // Set preferred backend as Vulkan. + setenv("DALI_GRAPHICS_BACKEND", "VK", 1); + + printf("DaliToolkitPreInitialize\n"); + DaliToolkitPreInitialize(nullptr, nullptr, nullptr); + printf("DaliToolkitPreInitialize done\n"); + + // Forcibly set backend as GLES. + Dali::Graphics::SetGraphicsBackend(Dali::Graphics::Backend::GLES); +} + +DALI_VISUAL_TEST_WITH_WINDOW_SIZE_AND_PREPROESS( PreInitialieTestVulkanToGles, OnInit, 200, 200, PreInitialize ) diff --git a/visual-tests/preinitialize-vk/images/expected-result.png b/visual-tests/preinitialize-vk/images/expected-result.png new file mode 100644 index 0000000000000000000000000000000000000000..9211f5b089a182a967943da471ace8d2b885f6f9 GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^CqS5y8Awi_W^)%vv7|ftIx;Y9?C1WI$O_~uBzpw; zGB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZkpaffhPl)S(AYfp49rb)N zP=qnb+uensgH_f8$YC$>^mS!_$-%>-!?R)g>{CD?bx#+^kch)?PdaikFmSMJ$WHt3 z*JQ_PoO555!NzoXui-I?A)+iTNg<;k zGdZJF*Tlde#Mu!<1v@)hSz78DD60!_0ClK>bfhGfq*^5xr2;7iBLgE-T>}eUL&Fe5 vODhu-D?=k~14}CdgGcW-*r901%}>cptHiBg@+OWZpaup{S3j3^P6-* literal 0 HcmV?d00001 diff --git a/visual-tests/preinitialize-vk/preinitialize-vk-test.cpp b/visual-tests/preinitialize-vk/preinitialize-vk-test.cpp new file mode 100644 index 0000000..eb036b0 --- /dev/null +++ b/visual-tests/preinitialize-vk/preinitialize-vk-test.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2020 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. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +#include +#include + +#include + +// INTERNAL INCLUDES +#include "visual-test.h" + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ +const std::string EXPECTED_IMAGE_FILE = TEST_IMAGE_DIR "preinitialize-vk/expected-result.png"; +} // namespace + +/** + * @brief This test is to make sure we can create PreInitialize application with Vulkan backend. + */ +class PreInitialieTestVulkan: public VisualTest +{ +public: + + PreInitialieTestVulkan( Application& application ) + : mApplication( application ) + { + } + + void OnInit( Application application ) + { + Dali::Window window = mApplication.GetWindow(); + window.SetBackgroundColor( Color::WHITE ); + + Control simpleControl = Control::New(); + simpleControl[Actor::Property::PARENT_ORIGIN] = ParentOrigin::CENTER; + simpleControl[Actor::Property::SIZE] = Vector2(100.0f, 100.0f); + simpleControl[Control::Property::BACKGROUND] = Color::RED; + + window.Add(simpleControl); + + // Start the test + PerformNextTest(); + } + + void PostRender(std::string outputFile, bool success) override + { + CompareImageFile(EXPECTED_IMAGE_FILE, outputFile, 0.98f); + mApplication.Quit(); + } + + void PerformNextTest() + { + Window window = mApplication.GetWindow(); + CaptureWindowAfterFrameRendered(window); + } + +private: + Application& mApplication; +}; + +void PreInitialize() +{ + // Set preferred backend as Vulkan. + setenv("DALI_GRAPHICS_BACKEND", "VK", 1); + + printf("DaliToolkitPreInitialize\n"); + DaliToolkitPreInitialize(nullptr, nullptr, nullptr); + printf("DaliToolkitPreInitialize done\n"); + + // Forcibly set backend as Vulkan. + Dali::Graphics::SetGraphicsBackend(Dali::Graphics::Backend::VULKAN); +} + +DALI_VISUAL_TEST_WITH_WINDOW_SIZE_AND_PREPROESS( PreInitialieTestVulkan, OnInit, 200, 200, PreInitialize )