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-scene3d/public-api/loader/cube-map-loader.h"
22 #include <dali-test-suite-utils.h>
23 #include <string_view>
28 using namespace Dali::Scene3D::Loader;
30 int UtcDaliCubeMapLoaderFailNonexistent(void)
33 DALI_TEST_CHECK(!LoadCubeMapData("non-existent.jpg", data));
37 int UtcDaliCubeMapLoaderFailInvalid1(void)
40 DALI_TEST_CHECK(!LoadCubeMapData(TEST_RESOURCE_DIR "/gallery-small-1.jpg", data)); // Wrong sized image
44 int UtcDaliCubeMapLoaderSuccess01(void)
47 auto path = TEST_RESOURCE_DIR "/forest_radiance.ktx";
48 DALI_TEST_CHECK(LoadCubeMapData(path, cubeData));
50 DALI_TEST_EQUAL(6u, cubeData.data.size());
51 for (auto& face: cubeData.data)
54 for (auto& mipData: face)
56 DALI_TEST_EQUAL(size, mipData.GetWidth());
57 DALI_TEST_EQUAL(size, mipData.GetHeight());
58 DALI_TEST_EQUAL(Pixel::Format::RGB888, mipData.GetPixelFormat());
66 int UtcDaliCubeMapLoaderSuccess02(void)
69 auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png"; // cross horizontal
70 DALI_TEST_CHECK(LoadCubeMapData(path, cubeData));
72 DALI_TEST_EQUAL(6u, cubeData.data.size());
73 for (auto& face: cubeData.data)
76 DALI_TEST_EQUAL(size, face[0].GetWidth());
77 DALI_TEST_EQUAL(size, face[0].GetHeight());
78 DALI_TEST_EQUAL(Pixel::Format::RGBA8888, face[0].GetPixelFormat());
84 int UtcDaliCubeMapLoaderCubeDataCreateTexture01(void)
87 auto path = TEST_RESOURCE_DIR "/forest_radiance.ktx";
88 DALI_TEST_CHECK(LoadCubeMapData(path, cubeData));
91 auto texture = cubeData.CreateTexture();
93 DALI_TEST_CHECK(texture);
94 DALI_TEST_EQUAL(64u, texture.GetWidth());
95 DALI_TEST_EQUAL(64u, texture.GetHeight());
100 int UtcDaliCubeMapLoaderCubeDataCreateTexture02(void)
103 auto path = TEST_RESOURCE_DIR "/forest_diffuse_cubemap.png";
104 DALI_TEST_CHECK(LoadCubeMapData(path, cubeData));
107 auto texture = cubeData.CreateTexture();
109 DALI_TEST_CHECK(texture);
110 DALI_TEST_EQUAL(512u, texture.GetWidth());
111 DALI_TEST_EQUAL(512u, texture.GetHeight());