[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-scene3d-internal / utc-Dali-MaterialImpl.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <stdlib.h>
21 #include <toolkit-event-thread-callback.h>
22 #include <iostream>
23
24 #include <dali-scene3d/internal/graphics/builtin-shader-extern-gen.h>
25 #include <dali-scene3d/internal/model-components/material-impl.h>
26 #include <dali-scene3d/public-api/loader/shader-option.h>
27
28 using namespace Dali;
29 using namespace Dali::Toolkit;
30
31 void model_components_material_impl_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void model_components_material_impl_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 namespace
42 {
43 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
44 } // namespace
45
46 // Method test
47 int UtcDaliMaterialImplSetGetTextureInformation(void)
48 {
49   tet_infoline("UtcDaliMaterialImplSetGetTextureInformation.");
50
51   ToolkitTestApplication application;
52
53   Scene3D::Material material = Scene3D::Material::New();
54
55   Scene3D::Internal::Material::TextureInformation baseColor;
56   Dali::Texture                                   baseColorTexture = Dali::Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100);
57   Dali::Sampler                                   baseColorSampler = Dali::Sampler::New();
58   baseColor.mTexture                                               = baseColorTexture;
59   baseColor.mSampler                                               = baseColorSampler;
60   baseColor.mUrl                                                   = "baseColor";
61   GetImplementation(material).SetTextureInformation(Scene3D::Material::TextureType::BASE_COLOR, std::move(baseColor));
62   DALI_TEST_EQUALS(baseColorTexture, material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR), TEST_LOCATION);
63   DALI_TEST_EQUALS(baseColorSampler, material.GetSampler(Scene3D::Material::TextureType::BASE_COLOR), TEST_LOCATION);
64   DALI_TEST_EQUALS("baseColor", material.GetProperty<std::string>(Scene3D::Material::Property::BASE_COLOR_URL), TEST_LOCATION);
65
66   Scene3D::Internal::Material::TextureInformation metallicRoughness;
67   Dali::Texture                                   metallicRoughnessTexture = Dali::Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100);
68   Dali::Sampler                                   metallicRoughnessSampler = Dali::Sampler::New();
69   metallicRoughness.mTexture                                               = metallicRoughnessTexture;
70   metallicRoughness.mSampler                                               = metallicRoughnessSampler;
71   metallicRoughness.mUrl                                                   = "metallicRoughness";
72   GetImplementation(material).SetTextureInformation(Scene3D::Material::TextureType::METALLIC_ROUGHNESS, std::move(metallicRoughness));
73   DALI_TEST_EQUALS(metallicRoughnessTexture, material.GetTexture(Scene3D::Material::TextureType::METALLIC_ROUGHNESS), TEST_LOCATION);
74   DALI_TEST_EQUALS(metallicRoughnessSampler, material.GetSampler(Scene3D::Material::TextureType::METALLIC_ROUGHNESS), TEST_LOCATION);
75   DALI_TEST_EQUALS("metallicRoughness", material.GetProperty<std::string>(Scene3D::Material::Property::METALLIC_ROUGHNESS_URL), TEST_LOCATION);
76
77   Scene3D::Internal::Material::TextureInformation normal;
78   Dali::Texture                                   normalTexture = Dali::Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100);
79   Dali::Sampler                                   normalSampler = Dali::Sampler::New();
80   normal.mTexture                                               = normalTexture;
81   normal.mSampler                                               = normalSampler;
82   normal.mUrl                                                   = "normal";
83   GetImplementation(material).SetTextureInformation(Scene3D::Material::TextureType::NORMAL, std::move(normal));
84   DALI_TEST_EQUALS(normalTexture, material.GetTexture(Scene3D::Material::TextureType::NORMAL), TEST_LOCATION);
85   DALI_TEST_EQUALS(normalSampler, material.GetSampler(Scene3D::Material::TextureType::NORMAL), TEST_LOCATION);
86   DALI_TEST_EQUALS("normal", material.GetProperty<std::string>(Scene3D::Material::Property::NORMAL_URL), TEST_LOCATION);
87
88   Dali::TextureSet textureSet = GetImplementation(material).GetTextureSet();
89   DALI_TEST_EQUALS(3, textureSet.GetTextureCount(), TEST_LOCATION);
90   DALI_TEST_EQUALS(baseColorTexture, textureSet.GetTexture(0u), TEST_LOCATION);
91   DALI_TEST_EQUALS(metallicRoughnessTexture, textureSet.GetTexture(1u), TEST_LOCATION);
92   DALI_TEST_EQUALS(normalTexture, textureSet.GetTexture(2u), TEST_LOCATION);
93   DALI_TEST_EQUALS(baseColorSampler, textureSet.GetSampler(0u), TEST_LOCATION);
94   DALI_TEST_EQUALS(metallicRoughnessSampler, textureSet.GetSampler(1u), TEST_LOCATION);
95
96   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
97   GetImplementation(material).UpdateMaterialData();
98
99   Scene3D::Loader::ShaderOption option;
100   option.AddOption(Scene3D::Loader::ShaderOption::Type::THREE_TEXTURE);
101   option.AddOption(Scene3D::Loader::ShaderOption::Type::GLTF_CHANNELS);
102   option.AddOption(Scene3D::Loader::ShaderOption::Type::BASE_COLOR_TEXTURE);
103   option.AddOption(Scene3D::Loader::ShaderOption::Type::METALLIC_ROUGHNESS_TEXTURE);
104   option.AddOption(Scene3D::Loader::ShaderOption::Type::NORMAL_TEXTURE);
105
106   DALI_TEST_EQUALS(option.GetOptionHash(), GetImplementation(material).GetShaderOption().GetOptionHash(), TEST_LOCATION);
107
108   Scene3D ::Internal ::Material ::TextureInformation occlusion;
109   Dali ::Texture                                     occlusiontexture = Dali ::Texture ::New(TextureType ::TEXTURE_2D, Pixel ::RGBA8888, 100, 100);
110   Dali ::Sampler                                     occlusionSampler = Dali ::Sampler ::New();
111   occlusion.mTexture                                                  = occlusiontexture;
112   occlusion.mSampler                                                  = occlusionSampler;
113   occlusion.mUrl                                                      = "occlusion";
114   GetImplementation(material).SetTextureInformation(Scene3D ::Material ::TextureType ::OCCLUSION, std ::move(occlusion));
115   DALI_TEST_EQUALS(occlusiontexture, material.GetTexture(Scene3D ::Material ::TextureType ::OCCLUSION), TEST_LOCATION);
116   DALI_TEST_EQUALS(occlusionSampler, material.GetSampler(Scene3D ::Material ::TextureType ::OCCLUSION), TEST_LOCATION);
117   DALI_TEST_EQUALS("occlusion", material.GetProperty<std ::string>(Scene3D ::Material ::Property ::OCCLUSION_URL), TEST_LOCATION);
118
119   Scene3D::Internal::Material::TextureInformation emissive;
120   Dali::Texture                                   emissiveTexture = Dali::Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100);
121   Dali::Sampler                                   emissiveSampler = Dali::Sampler::New();
122   emissive.mTexture                                               = emissiveTexture;
123   emissive.mSampler                                               = emissiveSampler;
124   emissive.mUrl                                                   = "emissive";
125   GetImplementation(material).SetTextureInformation(Scene3D::Material::TextureType::EMISSIVE, std::move(emissive));
126   DALI_TEST_EQUALS(emissiveTexture, material.GetTexture(Scene3D::Material::TextureType::EMISSIVE), TEST_LOCATION);
127   DALI_TEST_EQUALS(emissiveSampler, material.GetSampler(Scene3D::Material::TextureType::EMISSIVE), TEST_LOCATION);
128   DALI_TEST_EQUALS("emissive", material.GetProperty<std::string>(Scene3D::Material::Property::EMISSIVE_URL), TEST_LOCATION);
129
130   Scene3D ::Internal ::Material ::TextureInformation specular;
131   Dali ::Texture                                     specularTexture = Dali ::Texture ::New(TextureType ::TEXTURE_2D, Pixel ::RGBA8888, 100, 100);
132   Dali ::Sampler                                     specularSampler = Dali ::Sampler ::New();
133   specular.mTexture                                                  = specularTexture;
134   specular.mSampler                                                  = specularSampler;
135   specular.mUrl                                                      = "specular";
136   GetImplementation(material).SetTextureInformation(Scene3D ::Material ::TextureType ::SPECULAR, std ::move(specular));
137   DALI_TEST_EQUALS(specularTexture, material.GetTexture(Scene3D ::Material ::TextureType ::SPECULAR), TEST_LOCATION);
138   DALI_TEST_EQUALS(specularSampler, material.GetSampler(Scene3D ::Material ::TextureType ::SPECULAR), TEST_LOCATION);
139   DALI_TEST_EQUALS("specular", material.GetProperty<std ::string>(Scene3D ::Material ::Property ::SPECULAR_URL), TEST_LOCATION);
140
141   Scene3D::Internal::Material::TextureInformation specularColor;
142   Dali::Texture                                   specularColorTexture = Dali::Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100);
143   Dali::Sampler                                   specularColorSampler = Dali::Sampler::New();
144   specularColor.mTexture                                               = specularColorTexture;
145   specularColor.mSampler                                               = specularColorSampler;
146   specularColor.mUrl                                                   = "specularColor";
147   GetImplementation(material).SetTextureInformation(Scene3D::Material::TextureType::SPECULAR_COLOR, std::move(specularColor));
148   DALI_TEST_EQUALS(specularColorTexture, material.GetTexture(Scene3D::Material::TextureType::SPECULAR_COLOR), TEST_LOCATION);
149   DALI_TEST_EQUALS(specularColorSampler, material.GetSampler(Scene3D::Material::TextureType::SPECULAR_COLOR), TEST_LOCATION);
150   DALI_TEST_EQUALS("specularColor", material.GetProperty<std::string>(Scene3D::Material::Property::SPECULAR_COLOR_URL), TEST_LOCATION);
151
152   textureSet = GetImplementation(material).GetTextureSet();
153   DALI_TEST_EQUALS(7, textureSet.GetTextureCount(), TEST_LOCATION);
154   DALI_TEST_EQUALS(baseColorTexture, textureSet.GetTexture(0u), TEST_LOCATION);
155   DALI_TEST_EQUALS(metallicRoughnessTexture, textureSet.GetTexture(1u), TEST_LOCATION);
156   DALI_TEST_EQUALS(normalTexture, textureSet.GetTexture(2u), TEST_LOCATION);
157   DALI_TEST_EQUALS(occlusiontexture, textureSet.GetTexture(3u), TEST_LOCATION);
158   DALI_TEST_EQUALS(emissiveTexture, textureSet.GetTexture(4u), TEST_LOCATION);
159   DALI_TEST_EQUALS(specularTexture, textureSet.GetTexture(5u), TEST_LOCATION);
160   DALI_TEST_EQUALS(specularColorTexture, textureSet.GetTexture(6u), TEST_LOCATION);
161
162   DALI_TEST_EQUALS(baseColorSampler, textureSet.GetSampler(0u), TEST_LOCATION);
163   DALI_TEST_EQUALS(metallicRoughnessSampler, textureSet.GetSampler(1u), TEST_LOCATION);
164   DALI_TEST_EQUALS(normalSampler, textureSet.GetSampler(2u), TEST_LOCATION);
165   DALI_TEST_EQUALS(occlusionSampler, textureSet.GetSampler(3u), TEST_LOCATION);
166   DALI_TEST_EQUALS(emissiveSampler, textureSet.GetSampler(4u), TEST_LOCATION);
167   DALI_TEST_EQUALS(specularSampler, textureSet.GetSampler(5u), TEST_LOCATION);
168   DALI_TEST_EQUALS(specularColorSampler, textureSet.GetSampler(6u), TEST_LOCATION);
169
170   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
171   GetImplementation(material).UpdateMaterialData();
172
173   option.AddOption(Scene3D::Loader::ShaderOption::Type::OCCLUSION);
174   option.AddOption(Scene3D::Loader::ShaderOption::Type::EMISSIVE);
175   option.AddOption(Scene3D::Loader::ShaderOption::Type::SPECULAR);
176   option.AddOption(Scene3D::Loader::ShaderOption::Type::SPECULAR_COLOR);
177
178   DALI_TEST_EQUALS(option.GetOptionHash(), GetImplementation(material).GetShaderOption().GetOptionHash(), TEST_LOCATION);
179
180   END_TEST;
181 }
182
183 // Method test
184 int UtcDaliMaterialCheckUniform(void)
185 {
186   tet_infoline("UtcDaliMaterialCheckUniform.");
187
188   ToolkitTestApplication application;
189
190   Scene3D::Material material = Scene3D::Material::New();
191
192   Vector4 baseColorFactor(0.1f, 0.2f, 0.3f, 0.4f);
193   material.SetProperty(Scene3D::Material::Property::BASE_COLOR_FACTOR, baseColorFactor);
194   DALI_TEST_EQUALS(baseColorFactor, material.GetProperty<Vector4>(Scene3D::Material::Property::BASE_COLOR_FACTOR), TEST_LOCATION);
195
196   float metallicFactor = 0.5f;
197   material.SetProperty(Scene3D::Material::Property::METALLIC_FACTOR, metallicFactor);
198   DALI_TEST_EQUALS(metallicFactor, material.GetProperty<float>(Scene3D::Material::Property::METALLIC_FACTOR), TEST_LOCATION);
199
200   float roughnessFactor = 0.6f;
201   material.SetProperty(Scene3D::Material::Property::ROUGHNESS_FACTOR, roughnessFactor);
202   DALI_TEST_EQUALS(roughnessFactor, material.GetProperty<float>(Scene3D::Material::Property::ROUGHNESS_FACTOR), TEST_LOCATION);
203
204   float normalScale = 0.7f;
205   material.SetProperty(Scene3D::Material::Property::NORMAL_SCALE, normalScale);
206   DALI_TEST_EQUALS(normalScale, material.GetProperty<float>(Scene3D::Material::Property::NORMAL_SCALE), TEST_LOCATION);
207
208   float occlusionStrength = 0.8f;
209   material.SetProperty(Scene3D::Material::Property::OCCLUSION_STRENGTH, occlusionStrength);
210   DALI_TEST_EQUALS(occlusionStrength, material.GetProperty<float>(Scene3D::Material::Property::OCCLUSION_STRENGTH), TEST_LOCATION);
211
212   Vector3 emissiveFactor(0.9f, 0.1f, 0.2f);
213   material.SetProperty(Scene3D::Material::Property::EMISSIVE_FACTOR, emissiveFactor);
214   DALI_TEST_EQUALS(emissiveFactor, material.GetProperty<Vector3>(Scene3D::Material::Property::EMISSIVE_FACTOR), TEST_LOCATION);
215
216   Dali::Scene3D::Material::AlphaModeType alphaMode = Dali::Scene3D::Material::AlphaModeType::BLEND;
217   material.SetProperty(Scene3D::Material::Property::ALPHA_MODE, alphaMode);
218   DALI_TEST_EQUALS(alphaMode, material.GetProperty<Dali::Scene3D::Material::AlphaModeType>(Scene3D::Material ::Property ::ALPHA_MODE), TEST_LOCATION);
219
220   float alphaCutoff = 0.9f;
221   material.SetProperty(Scene3D ::Material ::Property ::ALPHA_CUTOFF, alphaCutoff);
222   DALI_TEST_EQUALS(alphaCutoff, material.GetProperty<float>(Scene3D ::Material ::Property ::ALPHA_CUTOFF), TEST_LOCATION);
223
224   bool doubleSided = false;
225   material.SetProperty(Scene3D ::Material ::Property ::DOUBLE_SIDED, doubleSided);
226   DALI_TEST_EQUALS(doubleSided, material.GetProperty<bool>(Scene3D ::Material ::Property ::DOUBLE_SIDED), TEST_LOCATION);
227
228   float ior = 1.0f;
229   material.SetProperty(Scene3D::Material::Property::IOR, ior);
230   DALI_TEST_EQUALS(ior, material.GetProperty<float>(Scene3D::Material::Property::IOR), TEST_LOCATION);
231
232   float specularFactor = 1.0f;
233   material.SetProperty(Scene3D::Material::Property::SPECULAR_FACTOR, specularFactor);
234   DALI_TEST_EQUALS(specularFactor, material.GetProperty<float>(Scene3D::Material::Property::SPECULAR_FACTOR), TEST_LOCATION);
235
236   Vector3 specularColorFactor(1.0f, 1.0f, 1.0f);
237   material.SetProperty(Scene3D::Material::Property::SPECULAR_COLOR_FACTOR, specularColorFactor);
238   DALI_TEST_EQUALS(specularColorFactor, material.GetProperty<Vector3>(Scene3D::Material::Property::SPECULAR_COLOR_FACTOR), TEST_LOCATION);
239
240   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
241   GetImplementation(material).UpdateMaterialData();
242
243   Dali::Shader   shader   = Dali::Shader::New(SHADER_DEFAULT_PHYSICALLY_BASED_SHADER_VERT.data(), SHADER_DEFAULT_PHYSICALLY_BASED_SHADER_FRAG.data());
244   Dali::Geometry geometry = Dali::Geometry::New();
245   Dali::Renderer renderer = Dali::Renderer::New(geometry, shader);
246
247   GetImplementation(material).SetRendererUniform(renderer);
248
249   DALI_TEST_EQUALS(baseColorFactor, renderer.GetProperty<Vector4>(renderer.GetPropertyIndex("uColorFactor")), TEST_LOCATION);
250   DALI_TEST_EQUALS(metallicFactor, renderer.GetProperty<float>(renderer.GetPropertyIndex("uMetallicFactor")), TEST_LOCATION);
251   DALI_TEST_EQUALS(roughnessFactor, renderer.GetProperty<float>(renderer.GetPropertyIndex("uRoughnessFactor")), TEST_LOCATION);
252   DALI_TEST_EQUALS(normalScale, renderer.GetProperty<float>(renderer.GetPropertyIndex("uNormalScale")), TEST_LOCATION);
253   DALI_TEST_EQUALS(emissiveFactor, renderer.GetProperty<Vector3>(renderer.GetPropertyIndex("uEmissiveFactor")), TEST_LOCATION);
254   float dielectricSpecular = (Dali::Equals(ior, -1.0)) ? 0.04f : powf((ior - 1.0f) / (ior + 1.0f), 2.0f);
255   DALI_TEST_EQUALS(dielectricSpecular, renderer.GetProperty<float>(renderer.GetPropertyIndex("uDielectricSpecular")), TEST_LOCATION);
256   DALI_TEST_EQUALS(specularFactor, renderer.GetProperty<float>(renderer.GetPropertyIndex("uSpecularFactor")), TEST_LOCATION);
257   DALI_TEST_EQUALS(specularColorFactor, renderer.GetProperty<Vector3>(renderer.GetPropertyIndex("uSpecularColorFactor")), TEST_LOCATION);
258   float opaque = alphaMode == Dali::Scene3D::Material::AlphaModeType::BLEND ? 0.0f : 1.0f;
259   float mask   = alphaMode == Dali::Scene3D::Material::AlphaModeType::MASK ? 1.0f : 0.0f;
260   DALI_TEST_EQUALS(opaque, renderer.GetProperty<float>(renderer.GetPropertyIndex("uOpaque")), TEST_LOCATION);
261   DALI_TEST_EQUALS(mask, renderer.GetProperty<float>(renderer.GetPropertyIndex("uMask")), TEST_LOCATION);
262   DALI_TEST_EQUALS(alphaCutoff, renderer.GetProperty<float>(renderer.GetPropertyIndex("uAlphaThreshold")), TEST_LOCATION);
263
264   DALI_TEST_EQUALS(DepthTestMode::ON, renderer.GetProperty<DepthTestMode::Type>(Dali::Renderer::Property::DEPTH_TEST_MODE), TEST_LOCATION);
265   DALI_TEST_EQUALS(FaceCullingMode::BACK, renderer.GetProperty<FaceCullingMode::Type>(Dali::Renderer::Property::FACE_CULLING_MODE), TEST_LOCATION);
266   DALI_TEST_EQUALS(DepthTestMode::ON, renderer.GetProperty<DepthTestMode::Type>(Dali::Renderer::Property::DEPTH_TEST_MODE), TEST_LOCATION);
267
268   DALI_TEST_EQUALS(0.0f, renderer.GetProperty<float>(renderer.GetPropertyIndex("uBaseColorTextureTransformAvailable")), TEST_LOCATION);
269   DALI_TEST_EQUALS(0.0f, renderer.GetProperty<float>(renderer.GetPropertyIndex("uNormalTextureTransformAvailable")), TEST_LOCATION);
270   DALI_TEST_EQUALS(0.0f, renderer.GetProperty<float>(renderer.GetPropertyIndex("uNormalRoughnessTextureTransformAvailable")), TEST_LOCATION);
271   DALI_TEST_EQUALS(0.0f, renderer.GetProperty<float>(renderer.GetPropertyIndex("uMetalRoughnessTextureTransformAvailable")), TEST_LOCATION);
272   DALI_TEST_EQUALS(0.0f, renderer.GetProperty<float>(renderer.GetPropertyIndex("uOcclusionTextureTransformAvailable")), TEST_LOCATION);
273   DALI_TEST_EQUALS(0.0f, renderer.GetProperty<float>(renderer.GetPropertyIndex("uEmissiveTextureTransformAvailable")), TEST_LOCATION);
274
275   END_TEST;
276 }
277
278 int UtcDaliMaterialImplLoadTexture_1(void)
279 {
280   tet_infoline("UtcDaliMaterialLoadTexture.");
281
282   ToolkitTestApplication application;
283
284   Scene3D::Material material = Scene3D::Material::New();
285
286   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
287   DALI_TEST_CHECK(!material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR));
288   material.SetProperty(Scene3D::Material::Property::BASE_COLOR_URL, TEST_IMAGE_FILE_NAME);
289   DALI_TEST_EQUALS(false, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
290
291   application.SendNotification();
292   application.Render(16);
293
294   DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
295
296   application.SendNotification();
297   application.Render(16);
298
299   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
300   DALI_TEST_CHECK(material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR));
301   Dali::Texture baseColorTexture = material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR);
302
303   Dali::TextureSet textureSet = GetImplementation(material).GetTextureSet();
304   DALI_TEST_EQUALS(1u, textureSet.GetTextureCount(), TEST_LOCATION);
305   DALI_TEST_EQUALS(baseColorTexture, textureSet.GetTexture(0u), TEST_LOCATION);
306   DALI_TEST_CHECK(textureSet.GetSampler(0u));
307
308   material.SetProperty(Scene3D::Material::Property::BASE_COLOR_URL, TEST_IMAGE_FILE_NAME);
309   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
310   DALI_TEST_EQUALS(baseColorTexture, material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR), TEST_LOCATION);
311
312   material.SetProperty(Scene3D::Material::Property::BASE_COLOR_URL, "");
313   DALI_TEST_CHECK(!material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR));
314
315   END_TEST;
316 }
317
318 int UtcDaliMaterialImplLoadTexture_2(void)
319 {
320   tet_infoline("UtcDaliMaterialImplLoadTexture_2.");
321
322   ToolkitTestApplication application;
323
324   Scene3D::Material material = Scene3D::Material::New();
325
326   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
327   DALI_TEST_CHECK(!material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR));
328   material.SetProperty(Scene3D::Material::Property::BASE_COLOR_URL, TEST_IMAGE_FILE_NAME);
329   DALI_TEST_EQUALS(false, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
330   material.SetProperty(Scene3D::Material::Property::BASE_COLOR_URL, "");
331   DALI_TEST_EQUALS(true, GetImplementation(material).IsResourceReady(), TEST_LOCATION);
332   DALI_TEST_CHECK(!material.GetTexture(Scene3D::Material::TextureType::BASE_COLOR));
333
334   END_TEST;
335 }