2527a0bcb200e838eadb15a882886b46c766a2f1
[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 //  TODO: Not supported yes
425 //  TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
426 //  std::ostringstream out;
427 //  out << GL_DEPTH_TEST;
428 //  DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
429
430   DALI_TEST_EQUALS( geometry.GetRequiresDepthTesting(), true, TEST_LOCATION );
431
432   END_TEST;
433 }
434
435 int UtcDaliGeometryPropertyRequiresDepthTest(void)
436 {
437   TestApplication application;
438
439   tet_infoline("Test SetRequiresDepthTesting, GetRequiresDepthTesting");
440
441   Shader shader = Shader::New("VertexSource", "FragmentSource");
442   Material material = Material::New( shader );
443
444   Geometry geometry = CreateQuadGeometry();
445   Renderer renderer = Renderer::New( geometry, material );
446
447   Actor actor = Actor::New();
448   actor.AddRenderer(renderer);
449   actor.SetSize(400, 400);
450   Stage::GetCurrent().Add(actor);
451
452   DALI_TEST_EQUALS( geometry.GetProperty<bool>(Geometry::Property::REQUIRES_DEPTH_TEST), false, TEST_LOCATION );
453
454   geometry.SetProperty(Geometry::Property::REQUIRES_DEPTH_TEST, true );
455
456   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
457   glAbstraction.EnableCullFaceCallTrace(true);
458   application.SendNotification();
459   application.Render();
460 //  TODO: Not supported yes
461 //  TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
462 //  std::ostringstream out;
463 //  out << GL_DEPTH_TEST;
464 //  DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
465
466   DALI_TEST_EQUALS( geometry.GetProperty<bool>(Geometry::Property::REQUIRES_DEPTH_TEST), true, TEST_LOCATION );
467
468   END_TEST;
469 }
470
471 int UtcDaliGeometryConstraint(void)
472 {
473   TestApplication application;
474
475   tet_infoline("Test that a custom geometry property can be constrained");
476
477   Shader shader = Shader::New("VertexSource", "FragmentSource");
478   Material material = Material::New( shader );
479   material.SetProperty(Material::Property::COLOR, Color::WHITE);
480
481   Geometry geometry = CreateQuadGeometry();
482   Renderer renderer = Renderer::New( geometry, material );
483
484   Actor actor = Actor::New();
485   actor.AddRenderer(renderer);
486   actor.SetSize(400, 400);
487   Stage::GetCurrent().Add(actor);
488
489   Vector4 initialColor = Color::WHITE;
490   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
491
492   application.SendNotification();
493   application.Render(0);
494   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
495
496   // Apply constraint
497   Constraint constraint = Constraint::New<Vector4>( geometry, colorIndex, TestConstraintNoBlue );
498   constraint.Apply();
499   application.SendNotification();
500   application.Render(0);
501
502   // Expect no blue component in either buffer - yellow
503   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
504   application.Render(0);
505   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
506
507   geometry.RemoveConstraints();
508   geometry.SetProperty(colorIndex, Color::WHITE );
509   application.SendNotification();
510   application.Render(0);
511   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
512
513   END_TEST;
514 }
515
516 int UtcDaliGeometryConstraint02(void)
517 {
518   TestApplication application;
519
520   tet_infoline("Test that a uniform map geometry property can be constrained");
521
522   Shader shader = Shader::New("VertexSource", "FragmentSource");
523   Material material = Material::New( shader );
524   material.SetProperty(Material::Property::COLOR, Color::WHITE);
525
526   Geometry geometry = CreateQuadGeometry();
527   Renderer renderer = Renderer::New( geometry, material );
528
529   Actor actor = Actor::New();
530   actor.AddRenderer(renderer);
531   actor.SetSize(400, 400);
532   Stage::GetCurrent().Add(actor);
533   application.SendNotification();
534   application.Render(0);
535
536   Vector4 initialColor = Color::WHITE;
537   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
538
539   TestGlAbstraction& gl = application.GetGlAbstraction();
540
541   application.SendNotification();
542   application.Render(0);
543
544   Vector4 actualValue(Vector4::ZERO);
545   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
546   DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
547
548   // Apply constraint
549   Constraint constraint = Constraint::New<Vector4>( geometry, colorIndex, TestConstraintNoBlue );
550   constraint.Apply();
551   application.SendNotification();
552   application.Render(0);
553
554    // Expect no blue component in either buffer - yellow
555   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
556   DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
557
558   application.Render(0);
559   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
560   DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
561
562   geometry.RemoveConstraints();
563   geometry.SetProperty(colorIndex, Color::WHITE );
564   application.SendNotification();
565   application.Render(0);
566
567   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
568   DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
569
570   END_TEST;
571 }
572
573
574
575 int UtcDaliGeometryAnimatedProperty01(void)
576 {
577   TestApplication application;
578
579   tet_infoline("Test that a custom geometry property can be animated");
580
581   Shader shader = Shader::New("VertexSource", "FragmentSource");
582   Material material = Material::New( shader );
583   material.SetProperty(Material::Property::COLOR, Color::WHITE);
584
585   Geometry geometry = CreateQuadGeometry();
586   Renderer renderer = Renderer::New( geometry, material );
587
588   Actor actor = Actor::New();
589   actor.AddRenderer(renderer);
590   actor.SetSize(400, 400);
591   Stage::GetCurrent().Add(actor);
592
593   Vector4 initialColor = Color::WHITE;
594   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
595
596   application.SendNotification();
597   application.Render(0);
598   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
599
600   Animation  animation = Animation::New(1.0f);
601   KeyFrames keyFrames = KeyFrames::New();
602   keyFrames.Add(0.0f, initialColor);
603   keyFrames.Add(1.0f, Color::TRANSPARENT);
604   animation.AnimateBetween( Property( geometry, colorIndex ), keyFrames );
605   animation.Play();
606
607   application.SendNotification();
608   application.Render(500);
609
610   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
611
612   application.Render(500);
613
614   DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
615
616   END_TEST;
617 }
618
619 int UtcDaliGeometryAnimatedProperty02(void)
620 {
621   TestApplication application;
622
623   tet_infoline("Test that a uniform map geometry property can be animated");
624
625   Shader shader = Shader::New("VertexSource", "FragmentSource");
626   Material material = Material::New( shader );
627   material.SetProperty(Material::Property::COLOR, Color::WHITE);
628
629   Geometry geometry = CreateQuadGeometry();
630   Renderer renderer = Renderer::New( geometry, material );
631
632   Actor actor = Actor::New();
633   actor.AddRenderer(renderer);
634   actor.SetSize(400, 400);
635   Stage::GetCurrent().Add(actor);
636   application.SendNotification();
637   application.Render(0);
638
639   Vector4 initialColor = Color::WHITE;
640   Property::Index colorIndex = geometry.RegisterProperty( "uFadeColor", initialColor );
641
642   TestGlAbstraction& gl = application.GetGlAbstraction();
643
644   application.SendNotification();
645   application.Render(0);
646
647   Vector4 actualValue(Vector4::ZERO);
648   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
649   DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
650
651   Animation  animation = Animation::New(1.0f);
652   KeyFrames keyFrames = KeyFrames::New();
653   keyFrames.Add(0.0f, initialColor);
654   keyFrames.Add(1.0f, Color::TRANSPARENT);
655   animation.AnimateBetween( Property( geometry, colorIndex ), keyFrames );
656   animation.Play();
657
658   application.SendNotification();
659   application.Render(500);
660
661   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
662   DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
663
664   application.Render(500);
665   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
666   DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
667
668   END_TEST;
669 }