2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 // Enable debug log for test coverage
19 #define DEBUG_ENABLED 1
21 #include "dali-scene-loader/public-api/cube-loader.h"
22 #include <dali-test-suite-utils.h>
23 #include <string_view>
28 using namespace Dali::SceneLoader;
30 int UtcDaliCubeLoaderFailNonexistent(void)
33 DALI_TEST_CHECK(!LoadCubeData("non-existent.jpg", data));
37 int UtcDaliCubeLoaderFailInvalid1(void)
40 DALI_TEST_CHECK(!LoadCubeData(TEST_RESOURCE_DIR "/gallery-small-1.jpg", data)); // Wrong sized image
44 int UtcDaliCubeLoaderSuccess01(void)
47 auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png"; // cross horizontal
48 DALI_TEST_CHECK(LoadCubeData(path, cubeData));
50 DALI_TEST_EQUAL(6u, cubeData.data.size());
51 for (auto& face: cubeData.data)
54 DALI_TEST_EQUAL(size, face[0].GetWidth());
55 DALI_TEST_EQUAL(size, face[0].GetHeight());
56 DALI_TEST_EQUAL(Pixel::Format::RGBA8888, face[0].GetPixelFormat());
62 int UtcDaliCubeLoaderSuccess02(void)
65 auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap_cross_vertical.png"; // cross vertical
66 DALI_TEST_CHECK(LoadCubeData(path, cubeData));
68 DALI_TEST_EQUAL(6u, cubeData.data.size());
69 for (auto& face: cubeData.data)
72 DALI_TEST_EQUAL(size, face[0].GetWidth());
73 DALI_TEST_EQUAL(size, face[0].GetHeight());
74 DALI_TEST_EQUAL(Pixel::Format::RGBA8888, face[0].GetPixelFormat());
80 int UtcDaliCubeLoaderSuccess03(void)
83 auto path = TEST_RESOURCE_DIR "/cubemap_array_horizontal.png"; // array horizontal
84 DALI_TEST_CHECK(LoadCubeData(path, cubeData));
86 DALI_TEST_EQUAL(6u, cubeData.data.size());
87 for (auto& face: cubeData.data)
90 DALI_TEST_EQUAL(size, face[0].GetWidth());
91 DALI_TEST_EQUAL(size, face[0].GetHeight());
92 DALI_TEST_EQUAL(Pixel::Format::RGB888, face[0].GetPixelFormat());
98 int UtcDaliCubeLoaderSuccess04(void)
101 auto path = TEST_RESOURCE_DIR "/cubemap_array_vertical.png"; // array horizontal
102 DALI_TEST_CHECK(LoadCubeData(path, cubeData));
104 DALI_TEST_EQUAL(6u, cubeData.data.size());
105 for (auto& face: cubeData.data)
108 DALI_TEST_EQUAL(size, face[0].GetWidth());
109 DALI_TEST_EQUAL(size, face[0].GetHeight());
110 DALI_TEST_EQUAL(Pixel::Format::RGB888, face[0].GetPixelFormat());
116 int UtcDaliCubeLoaderCubeDataCreateTexture(void)
119 auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png";
120 DALI_TEST_CHECK(LoadCubeData(path, cubeData));
123 auto texture = cubeData.CreateTexture();
125 DALI_TEST_CHECK(texture);
126 DALI_TEST_EQUAL(512u, texture.GetWidth());
127 DALI_TEST_EQUAL(512u, texture.GetHeight());