2 * Copyright (c) 2015 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 #include <dali/public-api/dali-core.h>
19 #include <dali-test-suite-utils.h>
23 #include <mesh-builder.h>
27 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
34 void material_test_startup(void)
36 test_return_value = TET_UNDEF;
39 void material_test_cleanup(void)
41 test_return_value = TET_PASS;
44 int UtcDaliMaterialNew01(void)
46 TestApplication application;
48 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
49 Material material = Material::New(shader);
51 DALI_TEST_CHECK( material );
55 int UtcDaliMaterialNew02(void)
57 TestApplication application;
59 DALI_TEST_CHECK( !material );
63 int UtcDaliMaterialCopyConstructor(void)
65 TestApplication application;
67 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
68 Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
69 Material material = Material::New(shader);
70 material.AddTexture( image, "sTexture" );
72 Material materialCopy(material);
74 DALI_TEST_CHECK( materialCopy );
79 int UtcDaliMaterialAssignmentOperator(void)
81 TestApplication application;
83 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
84 Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
85 Material material = Material::New(shader);
88 DALI_TEST_CHECK( !material2 );
91 DALI_TEST_CHECK( material2 );
96 int UtcDaliMaterialDownCast01(void)
98 TestApplication application;
99 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
100 Material material = Material::New(shader);
102 BaseHandle handle(material);
103 Material material2 = Material::DownCast(handle);
104 DALI_TEST_CHECK( material2 );
109 int UtcDaliMaterialDownCast02(void)
111 TestApplication application;
113 Handle handle = Handle::New(); // Create a custom object
114 Material material = Material::DownCast(handle);
115 DALI_TEST_CHECK( !material );
119 int UtcDaliMaterialSetShader(void)
121 TestApplication application;
123 tet_infoline("Test SetShader(shader) ");
125 Shader shader1 = Shader::New( "vertexSrc1", "fragmentSrc1" );
126 shader1.RegisterProperty( "uFadeColor", Color::CYAN );
128 Shader shader2 = Shader::New( "vertexSrc1", "fragmentSrc1" );
129 shader2.RegisterProperty( "uFadeColor", Color::MAGENTA );
132 Material material = Material::New(shader1);
134 Geometry geometry = CreateQuadGeometry();
135 Renderer renderer = Renderer::New( geometry, material );
137 Actor actor = Actor::New();
138 actor.AddRenderer(renderer);
139 actor.SetSize(400, 400);
140 Stage::GetCurrent().Add(actor);
142 TestGlAbstraction& gl = application.GetGlAbstraction();
143 application.SendNotification();
144 application.Render(0);
145 Vector4 actualValue(Vector4::ZERO);
146 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
147 DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
150 material.SetShader( shader2 );
152 application.SendNotification();
153 application.Render(0);
154 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
155 DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
158 material.SetShader( shader1 );
160 application.SendNotification();
161 application.Render(0);
162 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
163 DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
168 int UtcDaliMaterialGetShader(void)
170 TestApplication application;
172 tet_infoline("Test GetShader() ");
174 Shader shader1 = Shader::New( "vertexSrc1", "fragmentSrc1" );
175 Shader shader2 = Shader::New( "vertexSrc1", "fragmentSrc1" );
178 Material material = Material::New(shader1);
179 DALI_TEST_EQUALS( shader1, material.GetShader(), TEST_LOCATION );
182 material.SetShader( shader2 );
183 DALI_TEST_EQUALS( shader2, material.GetShader(), TEST_LOCATION );
186 material.SetShader( shader1 );
187 DALI_TEST_EQUALS( shader1, material.GetShader(), TEST_LOCATION );
192 int UtcDaliMaterialGetNumberOfTextures(void)
194 TestApplication application;
196 tet_infoline("Test GetNumberOfTextures()");
198 Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
199 Material material = CreateMaterial();
201 Geometry geometry = CreateQuadGeometry();
202 Renderer renderer = Renderer::New( geometry, material );
203 Actor actor = Actor::New();
204 actor.AddRenderer(renderer);
205 actor.SetParentOrigin( ParentOrigin::CENTER );
206 actor.SetSize(400, 400);
207 Stage::GetCurrent().Add( actor );
209 material.AddTexture( image, "sTexture0" );
210 material.AddTexture( image, "sTexture1" );
211 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 2u, TEST_LOCATION );
213 material.AddTexture( image, "sTexture2" );
214 material.AddTexture( image, "sTexture3" );
215 material.AddTexture( image, "sTexture4" );
216 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 5u, TEST_LOCATION );
218 material.RemoveTexture(3);
219 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 4u, TEST_LOCATION );
221 material.RemoveTexture(3);
222 material.RemoveTexture(0);
223 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 2u, TEST_LOCATION );
228 int UtcDaliMaterialSetFaceCullingMode(void)
230 TestApplication application;
232 tet_infoline("Test SetFaceCullingMode(cullingMode)");
233 Geometry geometry = CreateQuadGeometry();
234 Material material = CreateMaterial();
235 Renderer renderer = Renderer::New( geometry, material );
237 Actor actor = Actor::New();
238 actor.AddRenderer(renderer);
239 actor.SetSize(400, 400);
240 Stage::GetCurrent().Add(actor);
242 TestGlAbstraction& gl = application.GetGlAbstraction();
243 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
244 cullFaceStack.Reset();
245 gl.EnableCullFaceCallTrace(true);
247 material.SetFaceCullingMode( Material::CULL_BACK_AND_FRONT);
248 application.SendNotification();
249 application.Render();
251 // Todo: test the glCullFace(GL_FRONT_AND_BACK) is actually been called, cannot pass this test with current implementation
252 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION);
253 //string parameter("GL_FRONT_AND_BACK" );
254 //DALI_TEST_CHECK( cullFaceStack.TestMethodAndParams(0, "CullFace", parameter) );
259 int UtcDaliMaterialBlendingOptions01(void)
261 TestApplication application;
263 tet_infoline("Test SetBlendFunc(src, dest) ");
265 Geometry geometry = CreateQuadGeometry();
266 Material material = CreateMaterial();
267 Renderer renderer = Renderer::New( geometry, material );
269 Actor actor = Actor::New();
270 // set a transparent actor color so that blending is enabled
271 actor.SetOpacity( 0.5f );
272 actor.AddRenderer(renderer);
273 actor.SetSize(400, 400);
274 Stage::GetCurrent().Add(actor);
276 material.SetBlendFunc(BlendingFactor::ONE_MINUS_SRC_COLOR, BlendingFactor::SRC_ALPHA_SATURATE);
278 // Test that Set was successful:
279 BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
280 BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
281 BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
282 BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
283 material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
285 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
286 DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
287 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
288 DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
290 application.SendNotification();
291 application.Render();
293 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
295 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
296 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
297 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
298 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
303 int UtcDaliMaterialBlendingOptions02(void)
305 TestApplication application;
307 tet_infoline("Test SetBlendFunc(srcRgb, destRgb, srcAlpha, destAlpha) ");
309 Geometry geometry = CreateQuadGeometry();
310 Material material = CreateMaterial();
311 Renderer renderer = Renderer::New( geometry, material );
313 Actor actor = Actor::New();
314 actor.SetOpacity( 0.5f ); // enable blending
315 actor.AddRenderer(renderer);
316 actor.SetSize(400, 400);
317 Stage::GetCurrent().Add(actor);
319 material.SetBlendFunc( BlendingFactor::CONSTANT_COLOR, BlendingFactor::ONE_MINUS_CONSTANT_COLOR,
320 BlendingFactor::CONSTANT_ALPHA, BlendingFactor::ONE_MINUS_CONSTANT_ALPHA );
322 // Test that Set was successful:
324 BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
325 BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
326 BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
327 BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
328 material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
330 DALI_TEST_EQUALS( BlendingFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
331 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
332 DALI_TEST_EQUALS( BlendingFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
333 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
336 application.SendNotification();
337 application.Render();
339 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
340 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
341 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
342 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
343 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
350 int UtcDaliMaterialBlendingOptions03(void)
352 TestApplication application;
354 tet_infoline("Test GetBlendEquation() defaults ");
356 Geometry geometry = CreateQuadGeometry();
357 Material material = CreateMaterial();
358 Renderer renderer = Renderer::New( geometry, material );
360 Actor actor = Actor::New();
361 actor.AddRenderer(renderer);
362 actor.SetSize(400, 400);
363 Stage::GetCurrent().Add(actor);
365 // Test the defaults as documented in blending.h
366 BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
367 BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
368 material.GetBlendEquation( equationRgb, equationAlpha );
369 DALI_TEST_EQUALS( BlendingEquation::ADD, equationRgb, TEST_LOCATION );
370 DALI_TEST_EQUALS( BlendingEquation::ADD, equationAlpha, TEST_LOCATION );
376 int UtcDaliMaterialBlendingOptions04(void)
378 TestApplication application;
380 tet_infoline("Test SetBlendEquation() ");
382 Geometry geometry = CreateQuadGeometry();
383 Material material = CreateMaterial();
384 Renderer renderer = Renderer::New( geometry, material );
386 Actor actor = Actor::New();
387 actor.SetOpacity( 0.1f );
388 actor.AddRenderer(renderer);
389 actor.SetSize(400, 400);
390 Stage::GetCurrent().Add(actor);
392 // Test the single blending equation setting
394 material.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT );
395 BlendingEquation::Type equationRgba( BlendingEquation::SUBTRACT );
396 material.GetBlendEquation( equationRgba, equationRgba );
397 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgba, TEST_LOCATION );
400 material.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT, BlendingEquation::REVERSE_SUBTRACT );
402 // Test that Set was successful
404 BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
405 BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
406 material.GetBlendEquation( equationRgb, equationAlpha );
407 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
408 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
411 // Render & check GL commands
412 application.SendNotification();
413 application.Render();
415 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
416 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
417 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
422 int UtcDaliMaterialSetBlendMode01(void)
424 TestApplication application;
426 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
428 Geometry geometry = CreateQuadGeometry();
429 Material material = CreateMaterial();
430 Renderer renderer = Renderer::New( geometry, material );
432 Actor actor = Actor::New();
433 actor.SetOpacity( 0.98f );
434 actor.AddRenderer(renderer);
435 actor.SetSize(400, 400);
436 Stage::GetCurrent().Add(actor);
438 material.SetBlendMode(BlendingMode::ON);
440 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
441 glAbstraction.EnableEnableDisableCallTrace(true);
443 application.SendNotification();
444 application.Render();
446 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
447 std::ostringstream blendStr;
448 blendStr << GL_BLEND;
449 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
455 int UtcDaliMaterialSetBlendMode02(void)
457 TestApplication application;
459 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
461 Geometry geometry = CreateQuadGeometry();
462 Material material = CreateMaterial();
463 Renderer renderer = Renderer::New( geometry, material );
465 Actor actor = Actor::New();
466 actor.SetOpacity( 0.15f );
467 actor.AddRenderer(renderer);
468 actor.SetSize(400, 400);
469 Stage::GetCurrent().Add(actor);
471 material.SetBlendMode(BlendingMode::OFF);
473 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
474 glAbstraction.EnableEnableDisableCallTrace(true);
476 application.SendNotification();
477 application.Render();
479 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
480 std::ostringstream blendStr;
481 blendStr << GL_BLEND;
482 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
487 int UtcDaliMaterialSetBlendMode03(void)
489 TestApplication application;
491 tet_infoline("Test setting the blend mode to auto with a transparent material color renders with blending enabled");
493 Geometry geometry = CreateQuadGeometry();
494 Material material = CreateMaterial();
495 Renderer renderer = Renderer::New( geometry, material );
497 Actor actor = Actor::New();
498 actor.SetOpacity( 0.75f );
499 actor.AddRenderer(renderer);
500 actor.SetSize(400, 400);
501 Stage::GetCurrent().Add(actor);
503 material.SetBlendMode(BlendingMode::AUTO);
505 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
506 glAbstraction.EnableEnableDisableCallTrace(true);
508 application.SendNotification();
509 application.Render();
511 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
512 std::ostringstream blendStr;
513 blendStr << GL_BLEND;
514 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
519 int UtcDaliMaterialSetBlendMode04(void)
521 TestApplication application;
523 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
525 Geometry geometry = CreateQuadGeometry();
526 Material material = CreateMaterial();
527 Renderer renderer = Renderer::New( geometry, material );
529 Actor actor = Actor::New();
530 actor.AddRenderer(renderer);
531 actor.SetSize(400, 400);
532 Stage::GetCurrent().Add(actor);
534 material.SetBlendMode(BlendingMode::AUTO);
536 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
537 glAbstraction.EnableEnableDisableCallTrace(true);
539 application.SendNotification();
540 application.Render();
542 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
543 std::ostringstream blendStr;
544 blendStr << GL_BLEND;
545 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
550 int UtcDaliMaterialSetBlendMode04b(void)
552 TestApplication application;
554 tet_infoline("Test setting the blend mode to auto with an opaque material color and a transparent actor color renders with blending enabled");
556 Geometry geometry = CreateQuadGeometry();
557 Material material = CreateMaterial();
558 Renderer renderer = Renderer::New( geometry, material );
560 Actor actor = Actor::New();
561 actor.AddRenderer(renderer);
562 actor.SetSize(400, 400);
563 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
564 Stage::GetCurrent().Add(actor);
566 material.SetBlendMode(BlendingMode::AUTO);
568 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
569 glAbstraction.EnableEnableDisableCallTrace(true);
571 application.SendNotification();
572 application.Render();
574 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
575 std::ostringstream blendStr;
576 blendStr << GL_BLEND;
577 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
582 int UtcDaliMaterialSetBlendMode04c(void)
584 TestApplication application;
586 tet_infoline("Test setting the blend mode to auto with an opaque material color and an opaque actor color renders with blending disabled");
588 Geometry geometry = CreateQuadGeometry();
589 Material material = CreateMaterial();
590 Renderer renderer = Renderer::New( geometry, material );
592 Actor actor = Actor::New();
593 actor.AddRenderer(renderer);
594 actor.SetSize(400, 400);
595 actor.SetColor( Color::MAGENTA );
596 Stage::GetCurrent().Add(actor);
598 material.SetBlendMode(BlendingMode::AUTO);
600 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
601 glAbstraction.EnableEnableDisableCallTrace(true);
603 application.SendNotification();
604 application.Render();
606 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
607 std::ostringstream blendStr;
608 blendStr << GL_BLEND;
609 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
614 int UtcDaliMaterialSetBlendMode05(void)
616 TestApplication application;
618 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
620 Geometry geometry = CreateQuadGeometry();
621 BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
622 Material material = CreateMaterial( image );
623 Renderer renderer = Renderer::New( geometry, material );
625 Actor actor = Actor::New();
626 actor.AddRenderer(renderer);
627 actor.SetSize(400, 400);
628 Stage::GetCurrent().Add(actor);
630 material.SetBlendMode(BlendingMode::AUTO);
632 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
633 glAbstraction.EnableEnableDisableCallTrace(true);
635 application.SendNotification();
636 application.Render();
638 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
639 std::ostringstream blendStr;
640 blendStr << GL_BLEND;
641 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
646 int UtcDaliMaterialSetBlendMode06(void)
648 TestApplication application;
649 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_TRANSPARENT renders with blending enabled");
651 Geometry geometry = CreateQuadGeometry();
652 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_TRANSPARENT );
653 Material material = Material::New(shader);
655 Renderer renderer = Renderer::New( geometry, material );
657 Actor actor = Actor::New();
658 actor.AddRenderer(renderer);
659 actor.SetSize(400, 400);
660 Stage::GetCurrent().Add(actor);
662 material.SetBlendMode(BlendingMode::AUTO);
664 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
665 glAbstraction.EnableEnableDisableCallTrace(true);
667 application.SendNotification();
668 application.Render();
670 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
671 std::ostringstream blendStr;
672 blendStr << GL_BLEND;
673 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
679 //Todo: test the Shader::HINT_OUTPUT_IS_OPAQUE would disable the blending, the test cannot pass with current implementation
680 /*int UtcDaliMaterialSetBlendMode07(void)
682 TestApplication application;
683 tet_infoline("Test setting the blend mode to auto with a transparent color and an image without an alpha channel and a shader with the hint OUTPUT_IS_OPAQUE renders with blending disabled");
684 Geometry geometry = CreateQuadGeometry();
685 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
686 Material material = Material::New(shader);
688 Renderer renderer = Renderer::New( geometry, material );
690 Actor actor = Actor::New();
691 actor.AddRenderer(renderer);
692 actor.SetSize(400, 400);
693 Stage::GetCurrent().Add(actor);
695 material.SetBlendMode(BlendingMode::AUTO);
697 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
698 glAbstraction.EnableEnableDisableCallTrace(true);
700 application.SendNotification();
701 application.Render();
703 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
704 std::ostringstream blendStr;
705 blendStr << GL_BLEND;
706 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
711 int UtcDaliMaterialSetBlendMode08(void)
713 TestApplication application;
714 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_OPAQUE renders with blending disabled");
716 Geometry geometry = CreateQuadGeometry();
717 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
718 Material material = Material::New(shader);
719 BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
720 material.AddTexture( image, "sTexture" );
721 Renderer renderer = Renderer::New( geometry, material );
723 Actor actor = Actor::New();
724 actor.AddRenderer(renderer);
725 actor.SetSize(400, 400);
726 Stage::GetCurrent().Add(actor);
728 material.SetBlendMode(BlendingMode::AUTO);
730 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
731 glAbstraction.EnableEnableDisableCallTrace(true);
733 application.SendNotification();
734 application.Render();
736 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
737 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
742 int UtcDaliMaterialGetBlendMode(void)
744 TestApplication application;
746 tet_infoline("Test GetBlendMode()");
748 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
749 Material material = Material::New(shader);
752 DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::AUTO, TEST_LOCATION );
755 material.SetBlendMode(BlendingMode::ON);
756 DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::ON, TEST_LOCATION );
759 material.SetBlendMode(BlendingMode::OFF);
760 DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::OFF, TEST_LOCATION );
765 int UtcDaliMaterialSetBlendColor(void)
767 TestApplication application;
769 tet_infoline("Test SetBlendColor(color)");
771 Geometry geometry = CreateQuadGeometry();
772 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
773 Material material = Material::New(shader);
774 BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
775 material.AddTexture( image, "sTexture" );
776 Renderer renderer = Renderer::New( geometry, material );
778 Actor actor = Actor::New();
779 actor.AddRenderer(renderer);
780 actor.SetSize(400, 400);
781 Stage::GetCurrent().Add(actor);
783 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
785 material.SetBlendColor( Color::TRANSPARENT );
786 application.SendNotification();
787 application.Render();
788 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
790 material.SetBlendColor( Color::MAGENTA );
791 application.SendNotification();
792 application.Render();
793 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
795 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
796 material.SetBlendColor( color );
797 application.SendNotification();
798 application.Render();
799 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );
804 int UtcDaliMaterialGetBlendColor(void)
806 TestApplication application;
808 tet_infoline("Test GetBlendColor()");
810 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
811 Material material = Material::New(shader);
813 DALI_TEST_EQUALS( material.GetBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
815 material.SetBlendColor( Color::MAGENTA );
816 application.SendNotification();
817 application.Render();
818 DALI_TEST_EQUALS( material.GetBlendColor(), Color::MAGENTA, TEST_LOCATION );
820 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
821 material.SetBlendColor( color );
822 application.SendNotification();
823 application.Render();
824 DALI_TEST_EQUALS( material.GetBlendColor(), color, TEST_LOCATION );
829 int UtcDaliMaterialConstraint(void)
831 TestApplication application;
833 tet_infoline("Test that a custom material property can be constrained");
835 Shader shader = Shader::New( "VertexSource", "FragmentSource");
836 Material material = Material::New( shader );
838 Geometry geometry = CreateQuadGeometry();
839 Renderer renderer = Renderer::New( geometry, material );
841 Actor actor = Actor::New();
842 actor.AddRenderer(renderer);
843 actor.SetSize(400, 400);
844 Stage::GetCurrent().Add(actor);
846 Vector4 initialColor = Color::WHITE;
847 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
849 application.SendNotification();
850 application.Render(0);
851 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
854 Constraint constraint = Constraint::New<Vector4>( material, colorIndex, TestConstraintNoBlue );
856 application.SendNotification();
857 application.Render(0);
859 // Expect no blue component in either buffer - yellow
860 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
861 application.Render(0);
862 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
864 material.RemoveConstraints();
865 material.SetProperty(colorIndex, Color::WHITE );
866 application.SendNotification();
867 application.Render(0);
868 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
873 int UtcDaliMaterialConstraint02(void)
875 TestApplication application;
877 tet_infoline("Test that a uniform map material property can be constrained");
879 Shader shader = Shader::New( "VertexSource", "FragmentSource");
880 Material material = Material::New( shader );
882 Geometry geometry = CreateQuadGeometry();
883 Renderer renderer = Renderer::New( geometry, material );
885 Actor actor = Actor::New();
886 actor.AddRenderer(renderer);
887 actor.SetSize(400, 400);
888 Stage::GetCurrent().Add(actor);
889 application.SendNotification();
890 application.Render(0);
892 Vector4 initialColor = Color::WHITE;
893 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
895 TestGlAbstraction& gl = application.GetGlAbstraction();
897 application.SendNotification();
898 application.Render(0);
900 Vector4 actualValue(Vector4::ZERO);
901 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
902 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
905 Constraint constraint = Constraint::New<Vector4>( material, colorIndex, TestConstraintNoBlue );
907 application.SendNotification();
908 application.Render(0);
910 // Expect no blue component in either buffer - yellow
911 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
912 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
914 application.Render(0);
915 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
916 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
918 material.RemoveConstraints();
919 material.SetProperty(colorIndex, Color::WHITE );
920 application.SendNotification();
921 application.Render(0);
923 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
924 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
929 int UtcDaliMaterialAnimatedProperty01(void)
931 TestApplication application;
933 tet_infoline("Test that a non-uniform material property can be animated");
935 Shader shader = Shader::New( "VertexSource", "FragmentSource");
936 Material material = Material::New( shader );
938 Geometry geometry = CreateQuadGeometry();
939 Renderer renderer = Renderer::New( geometry, material );
941 Actor actor = Actor::New();
942 actor.AddRenderer(renderer);
943 actor.SetSize(400, 400);
944 Stage::GetCurrent().Add(actor);
946 Vector4 initialColor = Color::WHITE;
947 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
949 application.SendNotification();
950 application.Render(0);
951 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
953 Animation animation = Animation::New(1.0f);
954 KeyFrames keyFrames = KeyFrames::New();
955 keyFrames.Add(0.0f, initialColor);
956 keyFrames.Add(1.0f, Color::TRANSPARENT);
957 animation.AnimateBetween( Property( material, colorIndex ), keyFrames );
960 application.SendNotification();
961 application.Render(500);
963 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
965 application.Render(500);
967 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
972 int UtcDaliMaterialAnimatedProperty02(void)
974 TestApplication application;
976 tet_infoline("Test that a uniform map material property can be animated");
978 Shader shader = Shader::New( "VertexSource", "FragmentSource");
979 Material material = Material::New( shader );
981 Geometry geometry = CreateQuadGeometry();
982 Renderer renderer = Renderer::New( geometry, material );
984 Actor actor = Actor::New();
985 actor.AddRenderer(renderer);
986 actor.SetSize(400, 400);
987 Stage::GetCurrent().Add(actor);
988 application.SendNotification();
989 application.Render(0);
991 Vector4 initialColor = Color::WHITE;
992 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
994 TestGlAbstraction& gl = application.GetGlAbstraction();
996 application.SendNotification();
997 application.Render(0);
999 Vector4 actualValue(Vector4::ZERO);
1000 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1001 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1003 Animation animation = Animation::New(1.0f);
1004 KeyFrames keyFrames = KeyFrames::New();
1005 keyFrames.Add(0.0f, initialColor);
1006 keyFrames.Add(1.0f, Color::TRANSPARENT);
1007 animation.AnimateBetween( Property( material, colorIndex ), keyFrames );
1010 application.SendNotification();
1011 application.Render(500);
1013 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1014 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1016 application.Render(500);
1017 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1018 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1024 int UtcDaliMaterialSetTextureUniformName01(void)
1026 TestApplication application;
1028 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1030 Material material = CreateMaterial();
1031 material.AddTexture( image, "sTexture" );
1033 int textureIndex = material.GetTextureIndex( "sTexture" );
1034 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1036 material.SetTextureUniformName( 0, "sEffectTexture" );
1037 textureIndex = material.GetTextureIndex( "sEffectTexture" );
1038 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1040 Geometry geometry = CreateQuadGeometry();
1041 Renderer renderer = Renderer::New( geometry, material );
1042 Actor actor = Actor::New();
1043 actor.AddRenderer(renderer);
1044 actor.SetParentOrigin( ParentOrigin::CENTER );
1045 actor.SetSize(400, 400);
1047 Stage::GetCurrent().Add( actor );
1049 TestGlAbstraction& gl = application.GetGlAbstraction();
1051 application.SendNotification();
1052 application.Render();
1055 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
1056 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1061 int UtcDaliMaterialSetTextureUniformName02(void)
1063 TestApplication application;
1065 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1066 Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1068 Material material = CreateMaterial();
1069 material.AddTexture( image, "sTexture");
1070 material.SetTextureUniformName( 0, "sEffectTexture" );
1071 material.AddTexture( image2, "sTexture2");
1073 int textureIndex = material.GetTextureIndex( "sEffectTexture" );
1074 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1076 textureIndex = material.GetTextureIndex( "sTexture2" );
1077 DALI_TEST_EQUALS( textureIndex, 1, TEST_LOCATION );
1079 Geometry geometry = CreateQuadGeometry();
1080 Renderer renderer = Renderer::New( geometry, material );
1081 Actor actor = Actor::New();
1082 actor.AddRenderer(renderer);
1083 actor.SetParentOrigin( ParentOrigin::CENTER );
1084 actor.SetSize(400, 400);
1086 Stage::GetCurrent().Add( actor );
1088 TestGlAbstraction& gl = application.GetGlAbstraction();
1090 application.SendNotification();
1091 application.Render();
1094 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
1095 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1097 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture2", textureUnit ) );
1098 DALI_TEST_EQUALS( textureUnit, 1, TEST_LOCATION );
1103 int UtcDaliMaterialSetTextureAffectsTransparency(void)
1105 TestApplication application;
1107 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1109 Material material = CreateMaterial();
1110 material.AddTexture( image, "sTexture" );
1112 Geometry geometry = CreateQuadGeometry();
1113 Renderer renderer = Renderer::New( geometry, material );
1114 Actor actor = Actor::New();
1115 actor.AddRenderer(renderer);
1116 actor.SetParentOrigin( ParentOrigin::CENTER );
1117 actor.SetSize(400, 400);
1118 Stage::GetCurrent().Add( actor );
1120 TestGlAbstraction& gl = application.GetGlAbstraction();
1122 // Test SetAffectsTransparency( false )
1123 material.SetTextureAffectsTransparency( 0, false );
1125 gl.EnableEnableDisableCallTrace(true);
1126 application.SendNotification();
1127 application.Render();
1129 TraceCallStack& glEnableStack = gl.GetEnableDisableTrace();
1130 std::ostringstream blendStr;
1131 blendStr << GL_BLEND;
1132 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
1134 // Test SetAffectsTransparency( true )
1135 material.SetTextureAffectsTransparency( 0, true );
1137 glEnableStack.Reset();
1138 gl.EnableEnableDisableCallTrace(true);
1139 application.SendNotification();
1140 application.Render();
1142 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
1147 int UtcDaliMaterialAddTexture01(void)
1149 TestApplication application;
1151 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1153 Material material = CreateMaterial();
1154 material.AddTexture( image, "sTexture");
1156 Geometry geometry = CreateQuadGeometry();
1157 Renderer renderer = Renderer::New( geometry, material );
1158 Actor actor = Actor::New();
1159 actor.AddRenderer(renderer);
1160 actor.SetParentOrigin( ParentOrigin::CENTER );
1161 actor.SetSize(400, 400);
1163 Stage::GetCurrent().Add( actor );
1165 TestGlAbstraction& gl = application.GetGlAbstraction();
1167 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1168 texParameterTrace.Reset();
1169 texParameterTrace.Enable( true );
1170 application.SendNotification();
1171 application.Render();
1174 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
1175 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1177 texParameterTrace.Enable( false );
1180 // There are three calls to TexParameteri when the texture is first created
1181 // as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
1182 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
1187 int UtcDaliMaterialAddTexture02(void)
1189 TestApplication application;
1191 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1193 Material material = CreateMaterial();
1195 Sampler sampler = Sampler::New();
1196 sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
1197 material.AddTexture( image, "sTexture", sampler );
1199 Geometry geometry = CreateQuadGeometry();
1200 Renderer renderer = Renderer::New( geometry, material );
1201 Actor actor = Actor::New();
1202 actor.AddRenderer(renderer);
1203 actor.SetParentOrigin( ParentOrigin::CENTER );
1204 actor.SetSize(400, 400);
1206 Stage::GetCurrent().Add( actor );
1208 TestGlAbstraction& gl = application.GetGlAbstraction();
1210 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1211 texParameterTrace.Reset();
1212 texParameterTrace.Enable( true );
1213 application.SendNotification();
1214 application.Render();
1217 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
1218 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1220 texParameterTrace.Enable( false );
1223 // There are three calls to TexParameteri when the texture is first created
1224 // Texture minification and magnification filters are now different than default so
1225 //there should have been two extra TexParameteri calls to set the new filter mode
1226 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
1231 int UtcDaliMaterialRemoveTexture(void)
1233 TestApplication application;
1235 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1237 Material material = CreateMaterial();
1238 material.RemoveTexture(0);
1239 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 0, TEST_LOCATION );
1241 material.RemoveTexture(1);
1242 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 0, TEST_LOCATION );
1244 Sampler sampler = Sampler::New();
1245 sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
1246 material.AddTexture( image, "sTexture", sampler );
1247 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 1, TEST_LOCATION );
1249 material.RemoveTexture(1);
1250 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 1, TEST_LOCATION );
1252 material.RemoveTexture(0);
1253 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 0, TEST_LOCATION );
1258 int UtcDaliMaterialSetSampler(void)
1260 TestApplication application;
1262 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1264 Material material = CreateMaterial();
1265 material.AddTexture( image, "sTexture");
1267 Geometry geometry = CreateQuadGeometry();
1268 Renderer renderer = Renderer::New( geometry, material );
1269 Actor actor = Actor::New();
1270 actor.AddRenderer(renderer);
1271 actor.SetParentOrigin( ParentOrigin::CENTER );
1272 actor.SetSize(400, 400);
1274 Stage::GetCurrent().Add( actor );
1276 TestGlAbstraction& gl = application.GetGlAbstraction();
1278 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1279 texParameterTrace.Reset();
1280 texParameterTrace.Enable( true );
1281 application.SendNotification();
1282 application.Render();
1285 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
1286 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1288 texParameterTrace.Enable( false );
1291 // There are three calls to TexParameteri when the texture is first created
1292 // as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
1293 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
1295 texParameterTrace.Reset();
1296 texParameterTrace.Enable( true );
1298 Sampler sampler = Sampler::New();
1299 sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
1300 material.SetTextureSampler(0, sampler );
1303 application.SendNotification();
1304 application.Render();
1306 texParameterTrace.Enable( false );
1309 //There should have been two calls to TexParameteri to set the new filtering mode
1310 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 2, TEST_LOCATION);
1316 int UtcDaliMaterialGetTextureIndex(void)
1318 TestApplication application;
1320 Image image0 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1321 Image image1 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1322 Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1323 Image image3 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1326 Material material = CreateMaterial();
1327 material.AddTexture( image0, "sTexture0");
1328 material.AddTexture( image1, "sTexture1");
1329 material.AddTexture( image2, "sTexture2");
1330 material.AddTexture( image3, "sTexture3");
1332 int textureIndex = material.GetTextureIndex( "sTexture0" );
1333 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1335 textureIndex = material.GetTextureIndex( "sTexture1" );
1336 DALI_TEST_EQUALS( textureIndex, 1, TEST_LOCATION );
1338 textureIndex = material.GetTextureIndex( "sTexture2" );
1339 DALI_TEST_EQUALS( textureIndex, 2, TEST_LOCATION );
1341 textureIndex = material.GetTextureIndex( "sTexture3" );
1342 DALI_TEST_EQUALS( textureIndex, 3, TEST_LOCATION );
1344 material.RemoveTexture(1);
1346 textureIndex = material.GetTextureIndex( "sTexture0" );
1347 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1349 textureIndex = material.GetTextureIndex( "sTexture2" );
1350 DALI_TEST_EQUALS( textureIndex, 1, TEST_LOCATION );
1352 textureIndex = material.GetTextureIndex( "sTexture3" );
1353 DALI_TEST_EQUALS( textureIndex, 2, TEST_LOCATION );