UTC coverage for new mesh
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Geometry.cpp
1 /*
2  * Copyright (c) 2015 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/public-api/dali-core.h>
19 #include <dali-test-suite-utils.h>
20
21 using namespace Dali;
22
23 #include <mesh-builder.h>
24
25 void geometry_test_startup(void)
26 {
27   test_return_value = TET_UNDEF;
28 }
29
30 void geometry_test_cleanup(void)
31 {
32   test_return_value = TET_PASS;
33 }
34
35 namespace
36 {
37
38 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
39 {
40   current.b = 0.0f;
41 }
42
43 struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
44
45 PropertyBuffer CreateVertexBuffer( const std::string& aPosition, const std::string& aTexCoord )
46 {
47   const float halfQuadSize = .5f;
48   TexturedQuadVertex texturedQuadVertexData[4] = {
49     { Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f) },
50     { Vector2( halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f) },
51     { Vector2(-halfQuadSize,  halfQuadSize), Vector2(0.f, 1.f) },
52     { Vector2( halfQuadSize,  halfQuadSize), Vector2(1.f, 1.f) } };
53
54   Property::Map vertexFormat;
55   vertexFormat[aPosition] = Property::VECTOR2;
56   vertexFormat[aTexCoord] = Property::VECTOR2;
57
58   PropertyBuffer vertexData = PropertyBuffer::New( vertexFormat, 4 );
59   vertexData.SetData(texturedQuadVertexData);
60
61   return vertexData;
62 }
63
64 PropertyBuffer CreateIndexBuffer()
65 {
66   unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 };
67   Property::Map indexFormat;
68   indexFormat["indices"] = Property::UNSIGNED_INTEGER; // Should be Unsigned Short
69   PropertyBuffer indices = PropertyBuffer::New( indexFormat, 3 );
70   indices.SetData(indexData);
71
72   return indices;
73 }
74
75 }
76
77
78 int UtcDaliGeometryNew01(void)
79 {
80   TestApplication application;
81
82   Geometry geometry = Geometry::New();
83
84   DALI_TEST_EQUALS( (bool)geometry, true, TEST_LOCATION );
85   END_TEST;
86 }
87
88 int UtcDaliGeometryNew02(void)
89 {
90   TestApplication application;
91   Geometry geometry;
92   DALI_TEST_EQUALS( (bool)geometry, false, TEST_LOCATION );
93   END_TEST;
94 }
95
96 int UtcDaliGeometryCopyConstructor(void)
97 {
98   TestApplication application;
99
100   Geometry geometry = Geometry::New();
101
102   Geometry geometryCopy(geometry);
103
104   DALI_TEST_EQUALS( (bool)geometryCopy, true, TEST_LOCATION );
105   END_TEST;
106 }
107
108 int UtcDaliGeometryAssignmentOperator(void)
109 {
110   TestApplication application;
111
112   Geometry geometry = Geometry::New();
113
114   Geometry geometry2;
115   DALI_TEST_EQUALS( (bool)geometry2, false, TEST_LOCATION );
116
117   geometry2 = geometry;
118   DALI_TEST_EQUALS( (bool)geometry2, true, TEST_LOCATION );
119
120   END_TEST;
121 }
122
123 int UtcDaliGeometryDownCast01(void)
124 {
125   TestApplication application;
126
127   Geometry geometry = Geometry::New();
128
129   BaseHandle handle(geometry);
130   Geometry geometry2 = Geometry::DownCast(handle);
131   DALI_TEST_EQUALS( (bool)geometry2, true, TEST_LOCATION );
132   END_TEST;
133 }
134
135 int UtcDaliGeometryDownCast02(void)
136 {
137   TestApplication application;
138
139   Handle handle = Handle::New(); // Create a custom object
140   Geometry geometry = Geometry::DownCast(handle);
141   DALI_TEST_EQUALS( (bool)geometry, false, TEST_LOCATION );
142   END_TEST;
143 }
144
145 int UtcDaliGeometryAddVertexBuffer(void)
146 {
147   TestApplication application;
148
149   tet_infoline("Test AddVertexBuffer");
150
151   PropertyBuffer vertexBuffer1 = CreateVertexBuffer("aPosition1", "aTexCoord1" );
152   Geometry geometry = Geometry::New();
153   geometry.AddVertexBuffer( vertexBuffer1 );
154
155   Material material = CreateMaterial(1.f);
156   Renderer renderer = Renderer::New(geometry, material);
157   Actor actor = Actor::New();
158   actor.SetSize(Vector3::ONE * 100.f);
159   actor.AddRenderer(renderer);
160   Stage::GetCurrent().Add(actor);
161
162   application.SendNotification();
163   application.Render(0);
164   application.Render();
165   application.SendNotification();
166
167   {
168     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
169         application.GetGlAbstraction().GetBufferDataCalls();
170
171     DALI_TEST_EQUALS( bufferDataCalls.size(), 1u, TEST_LOCATION );
172
173     DALI_TEST_EQUALS( bufferDataCalls[0], 4*sizeof( TexturedQuadVertex ), TEST_LOCATION );
174   }
175
176   // add the second vertex buffer
177   application.GetGlAbstraction().ResetBufferDataCalls();
178
179   PropertyBuffer vertexBuffer2 = CreateVertexBuffer( "aPosition2", "aTexCoord2" );
180   geometry.AddVertexBuffer( vertexBuffer2 );
181   application.SendNotification();
182   application.Render(0);
183   application.Render();
184   application.SendNotification();
185
186   {
187     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
188         application.GetGlAbstraction().GetBufferDataCalls();
189
190     DALI_TEST_EQUALS( bufferDataCalls.size(), 2u, TEST_LOCATION );
191
192     DALI_TEST_EQUALS( bufferDataCalls[0], 4*sizeof( TexturedQuadVertex ), TEST_LOCATION );
193     DALI_TEST_EQUALS( bufferDataCalls[1], 4*sizeof( TexturedQuadVertex ), TEST_LOCATION );
194   }
195
196   END_TEST;
197 }
198
199 int UtcDaliGeometryGetNumberOfVertexBuffers(void)
200 {
201   TestApplication application;
202
203   tet_infoline("Test GetNumberOfVertexBuffers");
204   PropertyBuffer vertexBuffer1 = CreateVertexBuffer("aPosition1", "aTexCoord1" );
205   PropertyBuffer vertexBuffer2 = CreateVertexBuffer("aPosition2", "aTexCoord2" );
206   PropertyBuffer vertexBuffer3 = CreateVertexBuffer("aPosition3", "aTexCoord3" );
207
208   Geometry geometry = Geometry::New();
209   geometry.AddVertexBuffer( vertexBuffer1 );
210   DALI_TEST_EQUALS( geometry.GetNumberOfVertexBuffers(), 1u, TEST_LOCATION );
211
212   geometry.AddVertexBuffer( vertexBuffer2 );
213   geometry.AddVertexBuffer( vertexBuffer3 );
214   DALI_TEST_EQUALS( geometry.GetNumberOfVertexBuffers(), 3u, TEST_LOCATION );
215
216   geometry.RemoveVertexBuffer( 2u );
217   DALI_TEST_EQUALS( geometry.GetNumberOfVertexBuffers(), 2u, TEST_LOCATION );
218
219   END_TEST;
220 }
221
222 int UtcDaliGeometryRemoveVertexBuffer(void)
223 {
224   TestApplication application;
225
226   tet_infoline("Test RemoveVertexBuffer");
227
228   PropertyBuffer vertexBuffer1 = CreateVertexBuffer("aPosition1", "aTexCoord1" );
229   PropertyBuffer vertexBuffer2 = CreateVertexBuffer("aPosition2", "aTexCoord2" );
230
231   Geometry geometry = Geometry::New();
232   geometry.AddVertexBuffer( vertexBuffer1 );
233
234   Material material = CreateMaterial(1.f);
235   Renderer renderer = Renderer::New(geometry, material);
236   Actor actor = Actor::New();
237   actor.SetSize(Vector3::ONE * 100.f);
238   actor.AddRenderer(renderer);
239   Stage::GetCurrent().Add(actor);
240
241   DALI_TEST_EQUALS( geometry.GetNumberOfVertexBuffers(), 1u, TEST_LOCATION );
242
243   geometry.RemoveVertexBuffer( 0 );
244   geometry.AddVertexBuffer( vertexBuffer2 );
245   DALI_TEST_EQUALS( geometry.GetNumberOfVertexBuffers(), 1u, TEST_LOCATION );
246
247   geometry.RemoveVertexBuffer( 0 );
248   DALI_TEST_EQUALS( geometry.GetNumberOfVertexBuffers(), 0u, TEST_LOCATION );
249
250   //Todo: test by checking the BufferDataCalls
251   // make sure the vertex buffer in actually removed from gl
252
253    END_TEST;
254 }
255
256 int UtcDaliGeometrySetIndexBuffer(void)
257 {
258   TestApplication application;
259
260   tet_infoline("Test SetIndexBuffer");
261
262   PropertyBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord" );
263   PropertyBuffer indexBuffer = CreateIndexBuffer( );
264
265   Geometry geometry = Geometry::New();
266   geometry.AddVertexBuffer( vertexBuffer );
267
268   Material material = CreateMaterial(1.f);
269   Renderer renderer = Renderer::New(geometry, material);
270   Actor actor = Actor::New();
271   actor.SetSize(Vector3::ONE * 100.f);
272   actor.AddRenderer(renderer);
273   Stage::GetCurrent().Add(actor);
274
275   application.SendNotification();
276   application.Render(0);
277   application.Render();
278   application.SendNotification();
279
280   {
281     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
282         application.GetGlAbstraction().GetBufferDataCalls();
283
284     DALI_TEST_EQUALS( bufferDataCalls.size(), 1u, TEST_LOCATION );
285
286     DALI_TEST_EQUALS( bufferDataCalls[0], 4*sizeof( TexturedQuadVertex ), TEST_LOCATION );
287   }
288
289   // Set index buffer
290   application.GetGlAbstraction().ResetBufferDataCalls();
291
292   geometry.SetIndexBuffer( indexBuffer );
293   application.SendNotification();
294   application.Render(0);
295   application.Render();
296   application.SendNotification();
297
298   {
299     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
300         application.GetGlAbstraction().GetBufferDataCalls();
301
302     DALI_TEST_EQUALS( bufferDataCalls.size(), 2u, TEST_LOCATION );
303
304     DALI_TEST_EQUALS( bufferDataCalls[0], 4*sizeof( TexturedQuadVertex ), TEST_LOCATION );
305     // should be unsigned short instead of unsigned int
306     DALI_TEST_EQUALS( bufferDataCalls[1], 6*sizeof( unsigned short ), TEST_LOCATION );
307   }
308
309
310   END_TEST;
311 }
312
313 int UtcDaliGeometrySetGetGeometryType(void)
314 {
315   TestApplication application;
316
317   tet_infoline("Test SetGeometryType and GetGeometryType");
318
319   unsigned int numVertex = 4u;
320   PropertyBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord" );
321
322   Geometry geometry = Geometry::New();
323   geometry.AddVertexBuffer( vertexBuffer );
324
325   Material material = CreateMaterial(1.f);
326   Renderer renderer = Renderer::New(geometry, material);
327   Actor actor = Actor::New();
328   actor.SetSize(Vector3::ONE * 100.f);
329   actor.AddRenderer(renderer);
330   Stage::GetCurrent().Add(actor);
331
332   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
333   TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
334
335   /****************************************************/
336   // Default (TRIANGLES), no index buffer
337   drawTrace.Reset();
338   drawTrace.Enable(true);
339   application.SendNotification();
340   application.Render(0);
341   application.Render();
342   application.SendNotification();
343   drawTrace.Enable( false );
344
345   // Test the default geometry type is GL_TRIANGLE
346   // no index buffer, call glDrawArrays,
347   DALI_TEST_EQUALS( drawTrace.CountMethod( "DrawArrays" ), 2, TEST_LOCATION);
348   std::stringstream out;
349   out << GL_TRIANGLES << ", " << 0 << ", " << numVertex;
350   DALI_TEST_EQUALS( drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
351
352   DALI_TEST_EQUALS( geometry.GetGeometryType(), Geometry::TRIANGLES, TEST_LOCATION);
353
354   /*********************************************************/
355   // LINES, no index buffer
356   geometry.SetGeometryType( Geometry::LINES );
357
358   drawTrace.Reset();
359   drawTrace.Enable(true);
360   application.SendNotification();
361   application.Render(0);
362   application.Render();
363   application.SendNotification();
364   drawTrace.Enable( false );
365
366   // geometry type is set as GL_LINES
367   // no index buffer, call glDrawArrays,
368   DALI_TEST_EQUALS( drawTrace.CountMethod( "DrawArrays" ), 2, TEST_LOCATION);
369   out.str("");
370   out << GL_LINES << ", " << 0 << ", " << numVertex;
371   DALI_TEST_EQUALS( drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
372
373   DALI_TEST_EQUALS( geometry.GetGeometryType(), Geometry::LINES, TEST_LOCATION);
374
375   /*****************************************************/
376   //POINTS
377   geometry.SetGeometryType( Geometry::POINTS );
378
379   drawTrace.Reset();
380   drawTrace.Enable(true);
381   application.SendNotification();
382   application.Render(0);
383   application.Render();
384   application.SendNotification();
385   drawTrace.Enable( false );
386
387   // geometry type is set as GL_POINTS
388   // no index buffer, call glDrawArrays,
389   DALI_TEST_EQUALS( drawTrace.CountMethod( "DrawArrays" ), 2, TEST_LOCATION);
390   out.str("");
391   out << GL_POINTS << ", " << 0 << ", " << numVertex;
392   DALI_TEST_EQUALS( drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
393
394   DALI_TEST_EQUALS( geometry.GetGeometryType(), Geometry::POINTS, TEST_LOCATION);
395
396   END_TEST;
397 }
398
399 int UtcDaliGeometrySetGetRequireDepthTesting(void)
400 {
401   TestApplication application;
402
403   tet_infoline("Test SetRequiresDepthTesting, GetRequiresDepthTesting");
404
405   Shader shader = Shader::New("VertexSource", "FragmentSource");
406   Material material = Material::New( shader );
407
408   Geometry geometry = CreateQuadGeometry();
409   Renderer renderer = Renderer::New( geometry, material );
410
411   Actor actor = Actor::New();
412   actor.AddRenderer(renderer);
413   actor.SetSize(400, 400);
414   Stage::GetCurrent().Add(actor);
415
416   DALI_TEST_EQUALS( geometry.GetRequiresDepthTesting(), false, TEST_LOCATION );
417
418   geometry.SetRequiresDepthTesting(true);
419
420   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
421   glAbstraction.EnableCullFaceCallTrace(true);
422   application.SendNotification();
423   application.Render();
424   TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
425   std::ostringstream out;
426   out << GL_DEPTH_TEST;
427   DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
428
429   DALI_TEST_EQUALS( geometry.GetRequiresDepthTesting(), true, TEST_LOCATION );
430
431   END_TEST;
432 }
433
434 int UtcDaliGeometryPropertyRequiresDepthTest(void)
435 {
436   TestApplication application;
437
438   tet_infoline("Test SetRequiresDepthTesting, GetRequiresDepthTesting");
439
440   Shader shader = Shader::New("VertexSource", "FragmentSource");
441   Material material = Material::New( shader );
442
443   Geometry geometry = CreateQuadGeometry();
444   Renderer renderer = Renderer::New( geometry, material );
445
446   Actor actor = Actor::New();
447   actor.AddRenderer(renderer);
448   actor.SetSize(400, 400);
449   Stage::GetCurrent().Add(actor);
450
451   DALI_TEST_EQUALS( geometry.GetProperty<bool>(Geometry::Property::REQUIRES_DEPTH_TEST), false, TEST_LOCATION );
452
453   geometry.SetProperty(Geometry::Property::REQUIRES_DEPTH_TEST, true );
454
455   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
456   glAbstraction.EnableCullFaceCallTrace(true);
457   application.SendNotification();
458   application.Render();
459   TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
460   std::ostringstream out;
461   out << GL_DEPTH_TEST;
462   DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
463
464   DALI_TEST_EQUALS( geometry.GetProperty<bool>(Geometry::Property::REQUIRES_DEPTH_TEST), true, TEST_LOCATION );
465
466   END_TEST;
467 }
468
469 int UtcDaliGeometryConstraint(void)
470 {
471   TestApplication application;
472
473   tet_infoline("Test that a custom geometry property can be constrained");
474
475   Shader shader = Shader::New("VertexSource", "FragmentSource");
476   Material material = Material::New( shader );
477   material.SetProperty(Material::Property::COLOR, Color::WHITE);
478
479   Geometry geometry = CreateQuadGeometry();
480   Renderer renderer = Renderer::New( geometry, material );
481
482   Actor actor = Actor::New();
483   actor.AddRenderer(renderer);
484   actor.SetSize(400, 400);
485   Stage::GetCurrent().Add(actor);
486
487   Vector4 initialColor = Color::WHITE;
488   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
489
490   application.SendNotification();
491   application.Render(0);
492   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
493
494   // Apply constraint
495   Constraint constraint = Constraint::New<Vector4>( geometry, colorIndex, TestConstraintNoBlue );
496   constraint.Apply();
497   application.SendNotification();
498   application.Render(0);
499
500   // Expect no blue component in either buffer - yellow
501   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
502   application.Render(0);
503   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
504
505   geometry.RemoveConstraints();
506   geometry.SetProperty(colorIndex, Color::WHITE );
507   application.SendNotification();
508   application.Render(0);
509   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
510
511   END_TEST;
512 }
513
514 int UtcDaliGeometryConstraint02(void)
515 {
516   TestApplication application;
517
518   tet_infoline("Test that a uniform map geometry property can be constrained");
519
520   Shader shader = Shader::New("VertexSource", "FragmentSource");
521   Material material = Material::New( shader );
522   material.SetProperty(Material::Property::COLOR, Color::WHITE);
523
524   Geometry geometry = CreateQuadGeometry();
525   Renderer renderer = Renderer::New( geometry, material );
526
527   Actor actor = Actor::New();
528   actor.AddRenderer(renderer);
529   actor.SetSize(400, 400);
530   Stage::GetCurrent().Add(actor);
531   application.SendNotification();
532   application.Render(0);
533
534   Vector4 initialColor = Color::WHITE;
535   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
536
537   TestGlAbstraction& gl = application.GetGlAbstraction();
538
539   application.SendNotification();
540   application.Render(0);
541
542   Vector4 actualValue(Vector4::ZERO);
543   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
544   DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
545
546   // Apply constraint
547   Constraint constraint = Constraint::New<Vector4>( geometry, colorIndex, TestConstraintNoBlue );
548   constraint.Apply();
549   application.SendNotification();
550   application.Render(0);
551
552    // Expect no blue component in either buffer - yellow
553   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
554   DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
555
556   application.Render(0);
557   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
558   DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
559
560   geometry.RemoveConstraints();
561   geometry.SetProperty(colorIndex, Color::WHITE );
562   application.SendNotification();
563   application.Render(0);
564
565   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
566   DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
567
568   END_TEST;
569 }
570
571
572
573 int UtcDaliGeometryAnimatedProperty01(void)
574 {
575   TestApplication application;
576
577   tet_infoline("Test that a custom geometry property can be animated");
578
579   Shader shader = Shader::New("VertexSource", "FragmentSource");
580   Material material = Material::New( shader );
581   material.SetProperty(Material::Property::COLOR, Color::WHITE);
582
583   Geometry geometry = CreateQuadGeometry();
584   Renderer renderer = Renderer::New( geometry, material );
585
586   Actor actor = Actor::New();
587   actor.AddRenderer(renderer);
588   actor.SetSize(400, 400);
589   Stage::GetCurrent().Add(actor);
590
591   Vector4 initialColor = Color::WHITE;
592   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
593
594   application.SendNotification();
595   application.Render(0);
596   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
597
598   Animation  animation = Animation::New(1.0f);
599   KeyFrames keyFrames = KeyFrames::New();
600   keyFrames.Add(0.0f, initialColor);
601   keyFrames.Add(1.0f, Color::TRANSPARENT);
602   animation.AnimateBetween( Property( geometry, colorIndex ), keyFrames );
603   animation.Play();
604
605   application.SendNotification();
606   application.Render(500);
607
608   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
609
610   application.Render(500);
611
612   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
613
614   END_TEST;
615 }
616
617 int UtcDaliGeometryAnimatedProperty02(void)
618 {
619   TestApplication application;
620
621   tet_infoline("Test that a uniform map geometry property can be animated");
622
623   Shader shader = Shader::New("VertexSource", "FragmentSource");
624   Material material = Material::New( shader );
625   material.SetProperty(Material::Property::COLOR, Color::WHITE);
626
627   Geometry geometry = CreateQuadGeometry();
628   Renderer renderer = Renderer::New( geometry, material );
629
630   Actor actor = Actor::New();
631   actor.AddRenderer(renderer);
632   actor.SetSize(400, 400);
633   Stage::GetCurrent().Add(actor);
634   application.SendNotification();
635   application.Render(0);
636
637   Vector4 initialColor = Color::WHITE;
638   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
639
640   TestGlAbstraction& gl = application.GetGlAbstraction();
641
642   application.SendNotification();
643   application.Render(0);
644
645   Vector4 actualValue(Vector4::ZERO);
646   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
647   DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
648
649   Animation  animation = Animation::New(1.0f);
650   KeyFrames keyFrames = KeyFrames::New();
651   keyFrames.Add(0.0f, initialColor);
652   keyFrames.Add(1.0f, Color::TRANSPARENT);
653   animation.AnimateBetween( Property( geometry, colorIndex ), keyFrames );
654   animation.Play();
655
656   application.SendNotification();
657   application.Render(500);
658
659   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
660   DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
661
662   application.Render(500);
663   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
664   DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
665
666   END_TEST;
667 }