2 * Copyright (c) 2024 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-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
20 #include <mesh-builder.h>
27 void utc_dali_shader_startup(void)
29 test_return_value = TET_UNDEF;
32 void utc_dali_shader_cleanup(void)
34 test_return_value = TET_PASS;
39 static const char* VertexSource =
40 "This is a custom vertex shader\n"
41 "made on purpose to look nothing like a normal vertex shader inside dali\n";
43 static const char* FragmentSource =
44 "This is a custom fragment shader\n"
45 "made on purpose to look nothing like a normal fragment shader inside dali\n";
47 static const char* VertexSource2 =
48 "This is a custom vertex shader2\n"
49 "made on purpose to look nothing like a normal vertex shader inside dali\n";
51 static const char* FragmentSource2 =
52 "This is a custom fragment shader2\n"
53 "made on purpose to look nothing like a normal fragment shader inside dali\n";
55 void TestConstraintNoBlue(Vector4& current, const PropertyInputContainer& inputs)
62 int UtcDaliShaderMethodNew01(void)
64 TestApplication application;
66 Shader shader = Shader::New(VertexSource, FragmentSource);
67 DALI_TEST_EQUALS((bool)shader, true, TEST_LOCATION);
71 int UtcDaliShaderMethodNew02(void)
73 TestApplication application;
76 Shader shader = Shader::New(map);
77 DALI_TEST_EQUALS((bool)shader, true, TEST_LOCATION);
81 int UtcDaliShaderMethodNew03(void)
83 TestApplication application;
86 Shader shader = Shader::New(array);
87 DALI_TEST_EQUALS((bool)shader, true, TEST_LOCATION);
91 int UtcDaliShaderMethodNew04(void)
93 TestApplication application;
96 DALI_TEST_EQUALS((bool)shader, false, TEST_LOCATION);
100 int UtcDaliShaderMethodNew05(void)
102 TestApplication application;
104 Shader shader = Shader::New(VertexSource, FragmentSource, Shader::Hint::NONE, "testShader");
105 DALI_TEST_EQUALS((bool)shader, true, TEST_LOCATION);
109 int UtcDaliShaderAssignmentOperator(void)
111 TestApplication application;
113 Shader shader1 = Shader::New(VertexSource, FragmentSource);
117 DALI_TEST_CHECK(!(shader1 == shader2));
121 DALI_TEST_CHECK(shader1 == shader2);
123 shader2 = Shader::New(VertexSource, FragmentSource);
126 DALI_TEST_CHECK(!(shader1 == shader2));
131 int UtcDaliShaderMoveConstructor(void)
133 TestApplication application;
135 Shader shader = Shader::New(VertexSource, FragmentSource);
136 DALI_TEST_CHECK(shader);
137 DALI_TEST_EQUALS(1, shader.GetBaseObject().ReferenceCount(), TEST_LOCATION);
139 // Register a custom property
140 Vector2 vec(1.0f, 2.0f);
141 Property::Index customIndex = shader.RegisterProperty("custom", vec);
142 DALI_TEST_EQUALS(shader.GetProperty<Vector2>(customIndex), vec, TEST_LOCATION);
144 Shader move = std::move(shader);
145 DALI_TEST_CHECK(move);
146 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
147 DALI_TEST_EQUALS(move.GetProperty<Vector2>(customIndex), vec, TEST_LOCATION);
148 DALI_TEST_CHECK(!shader);
153 int UtcDaliShaderMoveAssignment(void)
155 TestApplication application;
157 Shader shader = Shader::New(VertexSource, FragmentSource);
158 DALI_TEST_CHECK(shader);
159 DALI_TEST_EQUALS(1, shader.GetBaseObject().ReferenceCount(), TEST_LOCATION);
161 // Register a custom property
162 Vector2 vec(1.0f, 2.0f);
163 Property::Index customIndex = shader.RegisterProperty("custom", vec);
164 DALI_TEST_EQUALS(shader.GetProperty<Vector2>(customIndex), vec, TEST_LOCATION);
167 move = std::move(shader);
168 DALI_TEST_CHECK(move);
169 DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
170 DALI_TEST_EQUALS(move.GetProperty<Vector2>(customIndex), vec, TEST_LOCATION);
171 DALI_TEST_CHECK(!shader);
176 int UtcDaliShaderDownCast01(void)
178 TestApplication application;
180 Shader shader = Shader::New(VertexSource, FragmentSource);
182 BaseHandle handle(shader);
183 Shader shader2 = Shader::DownCast(handle);
184 DALI_TEST_EQUALS((bool)shader2, true, TEST_LOCATION);
188 int UtcDaliShaderDownCast02(void)
190 TestApplication application;
192 Handle handle = Handle::New(); // Create a custom object
193 Shader shader = Shader::DownCast(handle);
194 DALI_TEST_EQUALS((bool)shader, false, TEST_LOCATION);
198 int UtcDaliShaderDefaultProperties(void)
200 TestApplication application;
201 // from shader-impl.cpp
202 // DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM )
204 Shader shader = Shader::New(VertexSource, FragmentSource);
205 DALI_TEST_EQUALS(shader.GetPropertyCount(), 1, TEST_LOCATION);
207 DALI_TEST_EQUALS(shader.GetPropertyName(Shader::Property::PROGRAM), "program", TEST_LOCATION);
208 DALI_TEST_EQUALS(shader.GetPropertyIndex("program"), (Property::Index)Shader::Property::PROGRAM, TEST_LOCATION);
209 DALI_TEST_EQUALS(shader.GetPropertyType(Shader::Property::PROGRAM), Property::MAP, TEST_LOCATION);
210 DALI_TEST_EQUALS(shader.IsPropertyWritable(Shader::Property::PROGRAM), true, TEST_LOCATION);
211 DALI_TEST_EQUALS(shader.IsPropertyAnimatable(Shader::Property::PROGRAM), false, TEST_LOCATION);
212 DALI_TEST_EQUALS(shader.IsPropertyAConstraintInput(Shader::Property::PROGRAM), false, TEST_LOCATION);
217 int UtcDaliShaderConstraint01(void)
219 TestApplication application;
221 tet_infoline("Test that a non-uniform shader property can be constrained");
223 Shader shader = Shader::New(VertexSource, FragmentSource);
224 Geometry geometry = CreateQuadGeometry();
225 Renderer renderer = Renderer::New(geometry, shader);
227 Actor actor = Actor::New();
228 actor.AddRenderer(renderer);
229 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
230 application.GetScene().Add(actor);
232 Vector4 initialColor = Color::WHITE;
233 Property::Index colorIndex = shader.RegisterProperty("uFadeColor", initialColor);
235 application.SendNotification();
236 application.Render(0);
237 DALI_TEST_EQUALS(shader.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION);
240 Constraint constraint = Constraint::New<Vector4>(shader, colorIndex, TestConstraintNoBlue);
242 application.SendNotification();
243 application.Render(0);
245 // Expect no blue component in either buffer - yellow
246 DALI_TEST_EQUALS(shader.GetCurrentProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION);
247 application.Render(0);
248 DALI_TEST_EQUALS(shader.GetCurrentProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION);
250 shader.RemoveConstraints();
251 shader.SetProperty(colorIndex, Color::WHITE);
252 application.SendNotification();
253 application.Render(0);
254 DALI_TEST_EQUALS(shader.GetCurrentProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION);
259 int UtcDaliShaderConstraint02(void)
261 TestApplication application;
263 tet_infoline("Test that a uniform map shader property can be constrained");
265 Shader shader = Shader::New(VertexSource, FragmentSource);
266 Geometry geometry = CreateQuadGeometry();
267 Renderer renderer = Renderer::New(geometry, shader);
269 Actor actor = Actor::New();
270 actor.AddRenderer(renderer);
271 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
272 application.GetScene().Add(actor);
273 application.SendNotification();
274 application.Render(0);
276 Vector4 initialColor = Color::WHITE;
277 Property::Index colorIndex = shader.RegisterProperty("uFadeColor", initialColor);
279 TestGlAbstraction& gl = application.GetGlAbstraction();
281 application.SendNotification();
282 application.Render(0);
284 Vector4 actualValue(Vector4::ZERO);
285 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
286 DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION);
289 Constraint constraint = Constraint::New<Vector4>(shader, colorIndex, TestConstraintNoBlue);
291 application.SendNotification();
292 application.Render(0);
294 // Expect no blue component in either buffer - yellow
295 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
296 DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION);
298 application.Render(0);
299 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
300 DALI_TEST_EQUALS(actualValue, Color::YELLOW, TEST_LOCATION);
302 shader.RemoveConstraints();
303 shader.SetProperty(colorIndex, Color::WHITE);
304 application.SendNotification();
305 application.Render(0);
307 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
308 DALI_TEST_EQUALS(actualValue, Color::WHITE, TEST_LOCATION);
313 int UtcDaliShaderAnimatedProperty01(void)
315 TestApplication application;
317 tet_infoline("Test that a non-uniform shader property can be animated");
319 Shader shader = Shader::New(VertexSource, FragmentSource);
320 Geometry geometry = CreateQuadGeometry();
321 Renderer renderer = Renderer::New(geometry, shader);
323 Actor actor = Actor::New();
324 actor.AddRenderer(renderer);
325 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
326 application.GetScene().Add(actor);
328 Vector4 initialColor = Color::WHITE;
329 Property::Index colorIndex = shader.RegisterProperty("uFadeColor", initialColor);
331 application.SendNotification();
332 application.Render(0);
333 DALI_TEST_EQUALS(shader.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION);
335 Animation animation = Animation::New(1.0f);
336 KeyFrames keyFrames = KeyFrames::New();
337 keyFrames.Add(0.0f, initialColor);
338 keyFrames.Add(1.0f, Color::TRANSPARENT);
339 animation.AnimateBetween(Property(shader, colorIndex), keyFrames);
342 application.SendNotification();
343 application.Render(500);
345 DALI_TEST_EQUALS(shader.GetCurrentProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION);
347 application.Render(500);
349 DALI_TEST_EQUALS(shader.GetCurrentProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION);
354 int UtcDaliShaderGetShaderLanguageVersion(void)
356 TestApplication application;
358 tet_infoline("Test get shader language version");
360 auto originalShaderVersion = application.GetGlAbstraction().GetShaderLanguageVersion();
364 uint32_t expectVersion = 100;
365 application.GetGlAbstraction().mShaderLanguageVersion = expectVersion;
367 DALI_TEST_EQUALS(Dali::Shader::GetShaderLanguageVersion(), expectVersion, TEST_LOCATION);
370 application.GetGlAbstraction().mShaderLanguageVersion = expectVersion;
372 DALI_TEST_EQUALS(Dali::Shader::GetShaderLanguageVersion(), expectVersion, TEST_LOCATION);
376 DALI_TEST_CHECK(false);
379 application.GetGlAbstraction().mShaderLanguageVersion = originalShaderVersion;
384 int UtcDaliShaderAnimatedProperty02(void)
386 TestApplication application;
388 tet_infoline("Test that a uniform map shader property can be animated");
390 Shader shader = Shader::New(VertexSource, FragmentSource);
391 Geometry geometry = CreateQuadGeometry();
392 Renderer renderer = Renderer::New(geometry, shader);
394 Actor actor = Actor::New();
395 actor.AddRenderer(renderer);
396 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
397 application.GetScene().Add(actor);
398 application.SendNotification();
399 application.Render(0);
401 Vector4 initialColor = Color::WHITE;
402 Property::Index colorIndex = shader.RegisterProperty("uFadeColor", initialColor);
404 TestGlAbstraction& gl = application.GetGlAbstraction();
406 application.SendNotification();
407 application.Render(0);
409 Vector4 actualValue(Vector4::ZERO);
410 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
411 DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION);
413 Animation animation = Animation::New(1.0f);
414 KeyFrames keyFrames = KeyFrames::New();
415 keyFrames.Add(0.0f, initialColor);
416 keyFrames.Add(1.0f, Color::TRANSPARENT);
417 animation.AnimateBetween(Property(shader, colorIndex), keyFrames);
420 application.SendNotification();
421 application.Render(500);
423 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
424 DALI_TEST_EQUALS(actualValue, Color::WHITE * 0.5f, TEST_LOCATION);
426 application.Render(500);
427 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
428 DALI_TEST_EQUALS(actualValue, Color::TRANSPARENT, TEST_LOCATION);
430 // change shader program
432 map["vertex"] = VertexSource;
433 map["fragment"] = FragmentSource;
434 map["hints"] = "MODIFIES_GEOMETRY";
435 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
436 application.SendNotification();
437 application.Render(100);
439 // register another custom property as well
440 Property::Index customIndex = shader.RegisterProperty("uCustom3", Vector3(1, 2, 3));
441 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(1, 2, 3), TEST_LOCATION);
443 application.SendNotification();
444 application.Render(100);
446 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
447 DALI_TEST_EQUALS(actualValue, Color::TRANSPARENT, TEST_LOCATION);
450 DALI_TEST_CHECK(gl.GetUniformValue<Vector3>("uCustom3", customValue));
451 DALI_TEST_EQUALS(customValue, Vector3(1, 2, 3), TEST_LOCATION);
455 int UtcDaliShaderProgramProperty(void)
457 TestApplication application;
459 tet_infoline("Test get/set progam property");
461 Shader shader = Shader::New("", "");
462 std::string hintSet = "MODIFIES_GEOMETRY";
465 map["vertex"] = VertexSource;
466 map["fragment"] = FragmentSource;
467 map["hints"] = hintSet;
469 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
470 // register a custom property as well
471 Property::Index customIndex = shader.RegisterProperty("custom", Vector3(1, 2, 3));
472 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(1, 2, 3), TEST_LOCATION);
474 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
475 DALI_TEST_CHECK(value.GetType() == Property::MAP);
476 const Property::Map* outMap = value.GetMap();
478 std::string v = (*outMap)["vertex"].Get<std::string>();
479 std::string f = (*outMap)["fragment"].Get<std::string>();
480 std::string h = (*outMap)["hints"].Get<std::string>();
482 DALI_TEST_CHECK(v == VertexSource);
483 DALI_TEST_CHECK(f == FragmentSource);
484 DALI_TEST_CHECK(h == hintSet);
486 value = shader.GetCurrentProperty(Shader::Property::PROGRAM);
487 DALI_TEST_CHECK(value.GetType() == Property::MAP);
488 outMap = value.GetMap();
489 // check that changing the shader did not cause us to loose custom property
490 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(1, 2, 3), TEST_LOCATION);
491 using Dali::Animation;
492 Animation animation = Animation::New(0.1f);
493 animation.AnimateTo(Property(shader, customIndex), Vector3(4, 5, 6));
495 application.SendNotification();
496 application.Render(100);
497 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(4, 5, 6), TEST_LOCATION);
499 v = (*outMap)["vertex"].Get<std::string>();
500 f = (*outMap)["fragment"].Get<std::string>();
501 h = (*outMap)["hints"].Get<std::string>();
503 DALI_TEST_CHECK(v == VertexSource);
504 DALI_TEST_CHECK(f == FragmentSource);
505 DALI_TEST_CHECK(h == hintSet);
509 hintSet = "OUTPUT_IS_TRANSPARENT,MODIFIES_GEOMETRY";
510 map["hints"] = hintSet;
511 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
512 value = shader.GetProperty(Shader::Property::PROGRAM);
513 hintGot = (*value.GetMap())["hints"].Get<std::string>();
514 DALI_TEST_CHECK(hintGot == hintSet);
516 hintSet = "OUTPUT_IS_TRANSPARENT";
517 map["hints"] = hintSet;
518 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
519 value = shader.GetProperty(Shader::Property::PROGRAM);
520 hintGot = (*value.GetMap())["hints"].Get<std::string>();
521 DALI_TEST_CHECK(hintGot == hintSet);
524 map["hints"] = hintSet;
525 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
526 value = shader.GetProperty(Shader::Property::PROGRAM);
527 hintGot = (*value.GetMap())["hints"].Get<std::string>();
528 DALI_TEST_CHECK(hintGot == hintSet);
531 map["hints"] = hintSet;
532 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
533 value = shader.GetProperty(Shader::Property::PROGRAM);
534 hintGot = (*value.GetMap())["hints"].Get<std::string>();
535 DALI_TEST_CHECK(hintGot == "NONE");
540 int UtcDaliShaderPropertyValueConstructorMap(void)
542 TestApplication application;
544 tet_infoline("UtcDaliShaderPropertyValueConstructorMap");
546 std::string hintSet = "MODIFIES_GEOMETRY";
548 map["vertex"] = VertexSource;
549 map["fragment"] = FragmentSource;
550 map["renderPassTag"] = 0;
551 map["hints"] = hintSet;
552 map["name"] = "Test";
554 Shader shader = Shader::New(map);
556 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
557 DALI_TEST_CHECK(value.GetType() == Property::MAP);
559 const Property::Map* outMap = value.GetMap();
560 std::string v = (*outMap)["vertex"].Get<std::string>();
561 std::string f = (*outMap)["fragment"].Get<std::string>();
562 std::string h = (*outMap)["hints"].Get<std::string>();
563 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
564 std::string n = (*outMap)["name"].Get<std::string>();
566 DALI_TEST_CHECK(v == map["vertex"].Get<std::string>());
567 DALI_TEST_CHECK(f == map["fragment"].Get<std::string>());
568 DALI_TEST_CHECK(h == map["hints"].Get<std::string>());
569 DALI_TEST_CHECK(r == map["renderPassTag"].Get<int32_t>());
570 DALI_TEST_CHECK(n == map["name"].Get<std::string>());
575 int UtcDaliShaderPropertyValueConstructorMap2(void)
577 TestApplication application;
579 tet_infoline("UtcDaliShaderPropertyValueConstructorMap2");
581 std::string hintSet = "MODIFIES_GEOMETRY";
583 map["vertex"] = VertexSource;
584 map["fragment"] = FragmentSource;
585 map["renderPassTag"] = 0;
586 map["hints"] = Shader::Hint::Value::MODIFIES_GEOMETRY;
587 map["name"] = "Test";
589 Shader shader = Shader::New(map);
591 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
592 DALI_TEST_CHECK(value.GetType() == Property::MAP);
594 const Property::Map* outMap = value.GetMap();
595 std::string v = (*outMap)["vertex"].Get<std::string>();
596 std::string f = (*outMap)["fragment"].Get<std::string>();
597 std::string h = (*outMap)["hints"].Get<std::string>();
598 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
599 std::string n = (*outMap)["name"].Get<std::string>();
601 DALI_TEST_CHECK(v == map["vertex"].Get<std::string>());
602 DALI_TEST_CHECK(f == map["fragment"].Get<std::string>());
603 // Note : shader.GetProperty return string even we input hints as enum.
604 DALI_TEST_CHECK(h == hintSet);
605 DALI_TEST_CHECK(r == map["renderPassTag"].Get<int32_t>());
606 DALI_TEST_CHECK(n == map["name"].Get<std::string>());
611 int UtcDaliShaderPropertyValueConstructorArray(void)
613 TestApplication application;
615 tet_infoline("UtcDaliShaderPropertyValueConstructorArray");
617 std::string hintSet = "MODIFIES_GEOMETRY";
618 Property::Map map[2];
619 map[0]["vertex"] = VertexSource;
620 map[0]["fragment"] = FragmentSource;
621 map[0]["renderPassTag"] = 0;
622 map[0]["hints"] = hintSet;
623 map[0]["name"] = "Test0";
625 map[1]["vertex"] = VertexSource2;
626 map[1]["fragment"] = FragmentSource2;
627 map[1]["renderPassTag"] = 1;
628 map[1]["hints"] = hintSet;
629 map[1]["name"] = "Test1";
631 Property::Array array;
632 array.PushBack(map[0]);
633 array.PushBack(map[1]);
635 Shader shader = Shader::New(array);
637 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
638 DALI_TEST_CHECK(value.GetType() == Property::ARRAY);
640 const Property::Array* outArray = value.GetArray();
641 uint32_t arrayCount = outArray->Size();
642 DALI_TEST_CHECK(arrayCount == 2u);
644 for(uint32_t i = 0; i < arrayCount; ++i)
646 const Property::Map* outMap = outArray->GetElementAt(i).GetMap();
647 std::string v = (*outMap)["vertex"].Get<std::string>();
648 std::string f = (*outMap)["fragment"].Get<std::string>();
649 std::string h = (*outMap)["hints"].Get<std::string>();
650 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
651 std::string n = (*outMap)["name"].Get<std::string>();
653 DALI_TEST_CHECK(v == map[i]["vertex"].Get<std::string>());
654 DALI_TEST_CHECK(f == map[i]["fragment"].Get<std::string>());
655 DALI_TEST_CHECK(h == map[i]["hints"].Get<std::string>());
656 DALI_TEST_CHECK(r == map[i]["renderPassTag"].Get<int32_t>());
657 DALI_TEST_CHECK(n == map[i]["name"].Get<std::string>());
663 int UtcDaliShaderProgramPropertyArray(void)
665 TestApplication application;
667 tet_infoline("Test get/set progam property array");
669 Shader shader = Shader::New("", "");
670 std::string hintSet = "MODIFIES_GEOMETRY";
672 Property::Map map[2];
673 map[0]["vertex"] = VertexSource;
674 map[0]["fragment"] = FragmentSource;
675 map[0]["renderPassTag"] = 0;
676 map[0]["hints"] = hintSet;
677 map[0]["name"] = "Test0";
679 map[1]["vertex"] = VertexSource2;
680 map[1]["fragment"] = FragmentSource2;
681 map[1]["renderPassTag"] = 1;
682 map[1]["hints"] = hintSet;
683 map[1]["name"] = "Test1";
685 Property::Array array;
686 array.PushBack(map[0]);
687 array.PushBack(map[1]);
689 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(array));
691 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
692 DALI_TEST_CHECK(value.GetType() == Property::ARRAY);
694 const Property::Array* outArray = value.GetArray();
695 uint32_t arrayCount = outArray->Size();
696 DALI_TEST_CHECK(arrayCount == 2u);
698 for(uint32_t i = 0; i < arrayCount; ++i)
700 const Property::Map* outMap = outArray->GetElementAt(i).GetMap();
701 std::string v = (*outMap)["vertex"].Get<std::string>();
702 std::string f = (*outMap)["fragment"].Get<std::string>();
703 std::string h = (*outMap)["hints"].Get<std::string>();
704 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
705 std::string n = (*outMap)["name"].Get<std::string>();
707 DALI_TEST_CHECK(v == map[i]["vertex"].Get<std::string>());
708 DALI_TEST_CHECK(f == map[i]["fragment"].Get<std::string>());
709 DALI_TEST_CHECK(h == map[i]["hints"].Get<std::string>());
710 DALI_TEST_CHECK(r == map[i]["renderPassTag"].Get<int32_t>());
711 DALI_TEST_CHECK(n == map[i]["name"].Get<std::string>());
717 int UtcDaliShaderWrongData(void)
719 TestApplication application;
721 tet_infoline("Test get/set wrong data");
723 Shader shader = Shader::New(Property::Value(1.0f));
725 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
726 DALI_TEST_CHECK(value.GetType() == Property::ARRAY);
728 const Property::Array* outArray = value.GetArray();
729 uint32_t arrayCount = outArray->Size();
730 DALI_TEST_CHECK(arrayCount == 0u);