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 UtcDaliShaderAnimatedProperty02(void)
356 TestApplication application;
358 tet_infoline("Test that a uniform map shader property can be animated");
360 Shader shader = Shader::New(VertexSource, FragmentSource);
361 Geometry geometry = CreateQuadGeometry();
362 Renderer renderer = Renderer::New(geometry, shader);
364 Actor actor = Actor::New();
365 actor.AddRenderer(renderer);
366 actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
367 application.GetScene().Add(actor);
368 application.SendNotification();
369 application.Render(0);
371 Vector4 initialColor = Color::WHITE;
372 Property::Index colorIndex = shader.RegisterProperty("uFadeColor", initialColor);
374 TestGlAbstraction& gl = application.GetGlAbstraction();
376 application.SendNotification();
377 application.Render(0);
379 Vector4 actualValue(Vector4::ZERO);
380 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
381 DALI_TEST_EQUALS(actualValue, initialColor, TEST_LOCATION);
383 Animation animation = Animation::New(1.0f);
384 KeyFrames keyFrames = KeyFrames::New();
385 keyFrames.Add(0.0f, initialColor);
386 keyFrames.Add(1.0f, Color::TRANSPARENT);
387 animation.AnimateBetween(Property(shader, colorIndex), keyFrames);
390 application.SendNotification();
391 application.Render(500);
393 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
394 DALI_TEST_EQUALS(actualValue, Color::WHITE * 0.5f, TEST_LOCATION);
396 application.Render(500);
397 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
398 DALI_TEST_EQUALS(actualValue, Color::TRANSPARENT, TEST_LOCATION);
400 // change shader program
402 map["vertex"] = VertexSource;
403 map["fragment"] = FragmentSource;
404 map["hints"] = "MODIFIES_GEOMETRY";
405 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
406 application.SendNotification();
407 application.Render(100);
409 // register another custom property as well
410 Property::Index customIndex = shader.RegisterProperty("uCustom3", Vector3(1, 2, 3));
411 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(1, 2, 3), TEST_LOCATION);
413 application.SendNotification();
414 application.Render(100);
416 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uFadeColor", actualValue));
417 DALI_TEST_EQUALS(actualValue, Color::TRANSPARENT, TEST_LOCATION);
420 DALI_TEST_CHECK(gl.GetUniformValue<Vector3>("uCustom3", customValue));
421 DALI_TEST_EQUALS(customValue, Vector3(1, 2, 3), TEST_LOCATION);
425 int UtcDaliShaderProgramProperty(void)
427 TestApplication application;
429 tet_infoline("Test get/set progam property");
431 Shader shader = Shader::New("", "");
432 std::string hintSet = "MODIFIES_GEOMETRY";
435 map["vertex"] = VertexSource;
436 map["fragment"] = FragmentSource;
437 map["hints"] = hintSet;
439 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
440 // register a custom property as well
441 Property::Index customIndex = shader.RegisterProperty("custom", Vector3(1, 2, 3));
442 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(1, 2, 3), TEST_LOCATION);
444 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
445 DALI_TEST_CHECK(value.GetType() == Property::MAP);
446 const Property::Map* outMap = value.GetMap();
448 std::string v = (*outMap)["vertex"].Get<std::string>();
449 std::string f = (*outMap)["fragment"].Get<std::string>();
450 std::string h = (*outMap)["hints"].Get<std::string>();
452 DALI_TEST_CHECK(v == VertexSource);
453 DALI_TEST_CHECK(f == FragmentSource);
454 DALI_TEST_CHECK(h == hintSet);
456 value = shader.GetCurrentProperty(Shader::Property::PROGRAM);
457 DALI_TEST_CHECK(value.GetType() == Property::MAP);
458 outMap = value.GetMap();
459 // check that changing the shader did not cause us to loose custom property
460 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(1, 2, 3), TEST_LOCATION);
461 using Dali::Animation;
462 Animation animation = Animation::New(0.1f);
463 animation.AnimateTo(Property(shader, customIndex), Vector3(4, 5, 6));
465 application.SendNotification();
466 application.Render(100);
467 DALI_TEST_EQUALS(shader.GetProperty<Vector3>(customIndex), Vector3(4, 5, 6), TEST_LOCATION);
469 v = (*outMap)["vertex"].Get<std::string>();
470 f = (*outMap)["fragment"].Get<std::string>();
471 h = (*outMap)["hints"].Get<std::string>();
473 DALI_TEST_CHECK(v == VertexSource);
474 DALI_TEST_CHECK(f == FragmentSource);
475 DALI_TEST_CHECK(h == hintSet);
479 hintSet = "OUTPUT_IS_TRANSPARENT,MODIFIES_GEOMETRY";
480 map["hints"] = hintSet;
481 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
482 value = shader.GetProperty(Shader::Property::PROGRAM);
483 hintGot = (*value.GetMap())["hints"].Get<std::string>();
484 DALI_TEST_CHECK(hintGot == hintSet);
486 hintSet = "OUTPUT_IS_TRANSPARENT";
487 map["hints"] = hintSet;
488 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
489 value = shader.GetProperty(Shader::Property::PROGRAM);
490 hintGot = (*value.GetMap())["hints"].Get<std::string>();
491 DALI_TEST_CHECK(hintGot == hintSet);
494 map["hints"] = hintSet;
495 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
496 value = shader.GetProperty(Shader::Property::PROGRAM);
497 hintGot = (*value.GetMap())["hints"].Get<std::string>();
498 DALI_TEST_CHECK(hintGot == hintSet);
501 map["hints"] = hintSet;
502 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(map));
503 value = shader.GetProperty(Shader::Property::PROGRAM);
504 hintGot = (*value.GetMap())["hints"].Get<std::string>();
505 DALI_TEST_CHECK(hintGot == "NONE");
510 int UtcDaliShaderPropertyValueConstructorMap(void)
512 TestApplication application;
514 tet_infoline("UtcDaliShaderPropertyValueConstructorMap");
516 std::string hintSet = "MODIFIES_GEOMETRY";
518 map["vertex"] = VertexSource;
519 map["fragment"] = FragmentSource;
520 map["renderPassTag"] = 0;
521 map["hints"] = hintSet;
522 map["name"] = "Test";
524 Shader shader = Shader::New(map);
526 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
527 DALI_TEST_CHECK(value.GetType() == Property::MAP);
529 const Property::Map* outMap = value.GetMap();
530 std::string v = (*outMap)["vertex"].Get<std::string>();
531 std::string f = (*outMap)["fragment"].Get<std::string>();
532 std::string h = (*outMap)["hints"].Get<std::string>();
533 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
534 std::string n = (*outMap)["name"].Get<std::string>();
536 DALI_TEST_CHECK(v == map["vertex"].Get<std::string>());
537 DALI_TEST_CHECK(f == map["fragment"].Get<std::string>());
538 DALI_TEST_CHECK(h == map["hints"].Get<std::string>());
539 DALI_TEST_CHECK(r == map["renderPassTag"].Get<int32_t>());
540 DALI_TEST_CHECK(n == map["name"].Get<std::string>());
545 int UtcDaliShaderPropertyValueConstructorMap2(void)
547 TestApplication application;
549 tet_infoline("UtcDaliShaderPropertyValueConstructorMap2");
551 std::string hintSet = "MODIFIES_GEOMETRY";
553 map["vertex"] = VertexSource;
554 map["fragment"] = FragmentSource;
555 map["renderPassTag"] = 0;
556 map["hints"] = Shader::Hint::Value::MODIFIES_GEOMETRY;
557 map["name"] = "Test";
559 Shader shader = Shader::New(map);
561 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
562 DALI_TEST_CHECK(value.GetType() == Property::MAP);
564 const Property::Map* outMap = value.GetMap();
565 std::string v = (*outMap)["vertex"].Get<std::string>();
566 std::string f = (*outMap)["fragment"].Get<std::string>();
567 std::string h = (*outMap)["hints"].Get<std::string>();
568 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
569 std::string n = (*outMap)["name"].Get<std::string>();
571 DALI_TEST_CHECK(v == map["vertex"].Get<std::string>());
572 DALI_TEST_CHECK(f == map["fragment"].Get<std::string>());
573 // Note : shader.GetProperty return string even we input hints as enum.
574 DALI_TEST_CHECK(h == hintSet);
575 DALI_TEST_CHECK(r == map["renderPassTag"].Get<int32_t>());
576 DALI_TEST_CHECK(n == map["name"].Get<std::string>());
581 int UtcDaliShaderPropertyValueConstructorArray(void)
583 TestApplication application;
585 tet_infoline("UtcDaliShaderPropertyValueConstructorArray");
587 std::string hintSet = "MODIFIES_GEOMETRY";
588 Property::Map map[2];
589 map[0]["vertex"] = VertexSource;
590 map[0]["fragment"] = FragmentSource;
591 map[0]["renderPassTag"] = 0;
592 map[0]["hints"] = hintSet;
593 map[0]["name"] = "Test0";
595 map[1]["vertex"] = VertexSource2;
596 map[1]["fragment"] = FragmentSource2;
597 map[1]["renderPassTag"] = 1;
598 map[1]["hints"] = hintSet;
599 map[1]["name"] = "Test1";
601 Property::Array array;
602 array.PushBack(map[0]);
603 array.PushBack(map[1]);
605 Shader shader = Shader::New(array);
607 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
608 DALI_TEST_CHECK(value.GetType() == Property::ARRAY);
610 const Property::Array* outArray = value.GetArray();
611 uint32_t arrayCount = outArray->Size();
612 DALI_TEST_CHECK(arrayCount == 2u);
614 for(uint32_t i = 0; i < arrayCount; ++i)
616 const Property::Map* outMap = outArray->GetElementAt(i).GetMap();
617 std::string v = (*outMap)["vertex"].Get<std::string>();
618 std::string f = (*outMap)["fragment"].Get<std::string>();
619 std::string h = (*outMap)["hints"].Get<std::string>();
620 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
621 std::string n = (*outMap)["name"].Get<std::string>();
623 DALI_TEST_CHECK(v == map[i]["vertex"].Get<std::string>());
624 DALI_TEST_CHECK(f == map[i]["fragment"].Get<std::string>());
625 DALI_TEST_CHECK(h == map[i]["hints"].Get<std::string>());
626 DALI_TEST_CHECK(r == map[i]["renderPassTag"].Get<int32_t>());
627 DALI_TEST_CHECK(n == map[i]["name"].Get<std::string>());
633 int UtcDaliShaderProgramPropertyArray(void)
635 TestApplication application;
637 tet_infoline("Test get/set progam property array");
639 Shader shader = Shader::New("", "");
640 std::string hintSet = "MODIFIES_GEOMETRY";
642 Property::Map map[2];
643 map[0]["vertex"] = VertexSource;
644 map[0]["fragment"] = FragmentSource;
645 map[0]["renderPassTag"] = 0;
646 map[0]["hints"] = hintSet;
647 map[0]["name"] = "Test0";
649 map[1]["vertex"] = VertexSource2;
650 map[1]["fragment"] = FragmentSource2;
651 map[1]["renderPassTag"] = 1;
652 map[1]["hints"] = hintSet;
653 map[1]["name"] = "Test1";
655 Property::Array array;
656 array.PushBack(map[0]);
657 array.PushBack(map[1]);
659 shader.SetProperty(Shader::Property::PROGRAM, Property::Value(array));
661 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
662 DALI_TEST_CHECK(value.GetType() == Property::ARRAY);
664 const Property::Array* outArray = value.GetArray();
665 uint32_t arrayCount = outArray->Size();
666 DALI_TEST_CHECK(arrayCount == 2u);
668 for(uint32_t i = 0; i < arrayCount; ++i)
670 const Property::Map* outMap = outArray->GetElementAt(i).GetMap();
671 std::string v = (*outMap)["vertex"].Get<std::string>();
672 std::string f = (*outMap)["fragment"].Get<std::string>();
673 std::string h = (*outMap)["hints"].Get<std::string>();
674 int32_t r = (*outMap)["renderPassTag"].Get<int32_t>();
675 std::string n = (*outMap)["name"].Get<std::string>();
677 DALI_TEST_CHECK(v == map[i]["vertex"].Get<std::string>());
678 DALI_TEST_CHECK(f == map[i]["fragment"].Get<std::string>());
679 DALI_TEST_CHECK(h == map[i]["hints"].Get<std::string>());
680 DALI_TEST_CHECK(r == map[i]["renderPassTag"].Get<int32_t>());
681 DALI_TEST_CHECK(n == map[i]["name"].Get<std::string>());
687 int UtcDaliShaderWrongData(void)
689 TestApplication application;
691 tet_infoline("Test get/set wrong data");
693 Shader shader = Shader::New(Property::Value(1.0f));
695 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
696 DALI_TEST_CHECK(value.GetType() == Property::ARRAY);
698 const Property::Array* outArray = value.GetArray();
699 uint32_t arrayCount = outArray->Size();
700 DALI_TEST_CHECK(arrayCount == 0u);