Merge "Fix the screen rotation issue" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Geometry.cpp
1 /*
2  * Copyright (c) 2021 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-test-suite-utils.h>
19 #include <dali/public-api/dali-core.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 struct TexturedQuadVertex
38 {
39   Vector2 position;
40   Vector2 textureCoordinates;
41 };
42
43 VertexBuffer CreateVertexBuffer(const std::string& aPosition, const std::string& aTexCoord)
44 {
45   const float        halfQuadSize              = .5f;
46   TexturedQuadVertex texturedQuadVertexData[4] = {
47     {Vector2(-halfQuadSize, -halfQuadSize), Vector2(0.f, 0.f)},
48     {Vector2(halfQuadSize, -halfQuadSize), Vector2(1.f, 0.f)},
49     {Vector2(-halfQuadSize, halfQuadSize), Vector2(0.f, 1.f)},
50     {Vector2(halfQuadSize, halfQuadSize), Vector2(1.f, 1.f)}};
51
52   Property::Map vertexFormat;
53   vertexFormat[aPosition] = Property::VECTOR2;
54   vertexFormat[aTexCoord] = Property::VECTOR2;
55
56   VertexBuffer vertexData = VertexBuffer::New(vertexFormat);
57   vertexData.SetData(texturedQuadVertexData, 4);
58
59   return vertexData;
60 }
61
62 } // namespace
63
64 int UtcDaliGeometryNew01(void)
65 {
66   TestApplication application;
67
68   Geometry geometry = Geometry::New();
69
70   DALI_TEST_EQUALS((bool)geometry, true, TEST_LOCATION);
71   END_TEST;
72 }
73
74 int UtcDaliGeometryNew02(void)
75 {
76   TestApplication application;
77   Geometry        geometry;
78   DALI_TEST_EQUALS((bool)geometry, false, TEST_LOCATION);
79   END_TEST;
80 }
81
82 int UtcDaliGeometryCopyConstructor(void)
83 {
84   TestApplication application;
85
86   Geometry geometry = Geometry::New();
87
88   Geometry geometryCopy(geometry);
89
90   DALI_TEST_EQUALS((bool)geometryCopy, true, TEST_LOCATION);
91   END_TEST;
92 }
93
94 int UtcDaliGeometryAssignmentOperator(void)
95 {
96   TestApplication application;
97
98   Geometry geometry = Geometry::New();
99
100   Geometry geometry2;
101   DALI_TEST_EQUALS((bool)geometry2, false, TEST_LOCATION);
102
103   geometry2 = geometry;
104   DALI_TEST_EQUALS((bool)geometry2, true, TEST_LOCATION);
105
106   END_TEST;
107 }
108
109 int UtcDaliGeometryMoveConstructor(void)
110 {
111   TestApplication application;
112
113   Geometry geometry = Geometry::New();
114   DALI_TEST_CHECK(geometry);
115   DALI_TEST_EQUALS(1, geometry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
116   DALI_TEST_EQUALS(0u, geometry.GetNumberOfVertexBuffers(), TEST_LOCATION);
117
118   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
119   geometry.AddVertexBuffer(vertexBuffer);
120   DALI_TEST_EQUALS(1u, geometry.GetNumberOfVertexBuffers(), TEST_LOCATION);
121
122   Geometry move = std::move(geometry);
123   DALI_TEST_CHECK(move);
124   DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
125   DALI_TEST_EQUALS(1u, move.GetNumberOfVertexBuffers(), TEST_LOCATION);
126   DALI_TEST_CHECK(!geometry);
127
128   END_TEST;
129 }
130
131 int UtcDaliGeometryMoveAssignment(void)
132 {
133   TestApplication application;
134
135   Geometry geometry = Geometry::New();
136   DALI_TEST_CHECK(geometry);
137   DALI_TEST_EQUALS(1, geometry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
138   DALI_TEST_EQUALS(0u, geometry.GetNumberOfVertexBuffers(), TEST_LOCATION);
139
140   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
141   geometry.AddVertexBuffer(vertexBuffer);
142   DALI_TEST_EQUALS(1u, geometry.GetNumberOfVertexBuffers(), TEST_LOCATION);
143
144   Geometry move;
145   move = std::move(geometry);
146   DALI_TEST_CHECK(move);
147   DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
148   DALI_TEST_EQUALS(1u, move.GetNumberOfVertexBuffers(), TEST_LOCATION);
149   DALI_TEST_CHECK(!geometry);
150
151   END_TEST;
152 }
153
154 int UtcDaliGeometryDownCast01(void)
155 {
156   TestApplication application;
157
158   Geometry geometry = Geometry::New();
159
160   BaseHandle handle(geometry);
161   Geometry   geometry2 = Geometry::DownCast(handle);
162   DALI_TEST_EQUALS((bool)geometry2, true, TEST_LOCATION);
163   END_TEST;
164 }
165
166 int UtcDaliGeometryDownCast02(void)
167 {
168   TestApplication application;
169
170   Handle   handle   = Handle::New(); // Create a custom object
171   Geometry geometry = Geometry::DownCast(handle);
172   DALI_TEST_EQUALS((bool)geometry, false, TEST_LOCATION);
173   END_TEST;
174 }
175
176 int UtcDaliGeometryAddVertexBuffer(void)
177 {
178   TestApplication application;
179
180   tet_infoline("Test AddVertexBuffer");
181   auto& bufferTrace = application.GetGlAbstraction().GetBufferTrace();
182   bufferTrace.Enable(true);
183   bufferTrace.EnableLogging(true);
184
185   VertexBuffer vertexBuffer1 = CreateVertexBuffer("aPosition1", "aTexCoord1");
186   Geometry     geometry      = Geometry::New();
187   geometry.AddVertexBuffer(vertexBuffer1);
188
189   Shader   shader   = CreateShader();
190   Renderer renderer = Renderer::New(geometry, shader);
191   Actor    actor    = Actor::New();
192   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
193   actor.AddRenderer(renderer);
194   application.GetScene().Add(actor);
195
196   application.SendNotification();
197   application.Render(0);
198   application.Render();
199   application.SendNotification();
200
201   {
202     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
203       application.GetGlAbstraction().GetBufferDataCalls();
204
205     DALI_TEST_EQUALS(bufferDataCalls.size(), 3u, TEST_LOCATION);
206
207     DALI_TEST_EQUALS(bufferDataCalls[0], 4 * sizeof(TexturedQuadVertex), TEST_LOCATION);
208   }
209
210   // add the second vertex buffer
211   application.GetGlAbstraction().ResetBufferDataCalls();
212
213   VertexBuffer vertexBuffer2 = CreateVertexBuffer("aPosition2", "aTexCoord2");
214   geometry.AddVertexBuffer(vertexBuffer2);
215   application.SendNotification();
216   application.Render(0);
217   application.Render();
218   application.SendNotification();
219
220   {
221     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
222       application.GetGlAbstraction().GetBufferDataCalls();
223
224     //Check that only the new buffer gets uploaded
225     DALI_TEST_EQUALS(bufferDataCalls.size(), 1u, TEST_LOCATION);
226     DALI_TEST_EQUALS(bufferDataCalls[0], 4 * sizeof(TexturedQuadVertex), TEST_LOCATION);
227   }
228
229   END_TEST;
230 }
231
232 int UtcDaliGeometryGetNumberOfVertexBuffers(void)
233 {
234   TestApplication application;
235   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
236   bufferTrace.Enable(true);
237   bufferTrace.EnableLogging(true);
238
239   tet_infoline("Test GetNumberOfVertexBuffers");
240   VertexBuffer vertexBuffer1 = CreateVertexBuffer("aPosition1", "aTexCoord1");
241   VertexBuffer vertexBuffer2 = CreateVertexBuffer("aPosition2", "aTexCoord2");
242   VertexBuffer vertexBuffer3 = CreateVertexBuffer("aPosition3", "aTexCoord3");
243
244   Geometry geometry = Geometry::New();
245   geometry.AddVertexBuffer(vertexBuffer1);
246   DALI_TEST_EQUALS(geometry.GetNumberOfVertexBuffers(), 1u, TEST_LOCATION);
247
248   geometry.AddVertexBuffer(vertexBuffer2);
249   geometry.AddVertexBuffer(vertexBuffer3);
250   DALI_TEST_EQUALS(geometry.GetNumberOfVertexBuffers(), 3u, TEST_LOCATION);
251
252   geometry.RemoveVertexBuffer(2u);
253   DALI_TEST_EQUALS(geometry.GetNumberOfVertexBuffers(), 2u, TEST_LOCATION);
254
255   END_TEST;
256 }
257
258 int UtcDaliGeometryRemoveVertexBuffer(void)
259 {
260   TestApplication application;
261   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
262   bufferTrace.Enable(true);
263   bufferTrace.EnableLogging(true);
264
265   tet_infoline("Test RemoveVertexBuffer");
266
267   VertexBuffer vertexBuffer1 = CreateVertexBuffer("aPosition1", "aTexCoord1");
268   VertexBuffer vertexBuffer2 = CreateVertexBuffer("aPosition2", "aTexCoord2");
269
270   Geometry geometry = Geometry::New();
271   geometry.AddVertexBuffer(vertexBuffer1);
272
273   Shader   shader   = CreateShader();
274   Renderer renderer = Renderer::New(geometry, shader);
275   Actor    actor    = Actor::New();
276   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
277   actor.AddRenderer(renderer);
278   application.GetScene().Add(actor);
279
280   DALI_TEST_EQUALS(geometry.GetNumberOfVertexBuffers(), 1u, TEST_LOCATION);
281
282   geometry.RemoveVertexBuffer(0);
283   geometry.AddVertexBuffer(vertexBuffer2);
284   DALI_TEST_EQUALS(geometry.GetNumberOfVertexBuffers(), 1u, TEST_LOCATION);
285
286   geometry.RemoveVertexBuffer(0);
287   DALI_TEST_EQUALS(geometry.GetNumberOfVertexBuffers(), 0u, TEST_LOCATION);
288
289   //Todo: test by checking the BufferDataCalls
290   // make sure the vertex buffer in actually removed from gl
291
292   END_TEST;
293 }
294
295 int UtcDaliGeometrySetIndexBuffer(void)
296 {
297   TestApplication application;
298   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
299   bufferTrace.Enable(true);
300   bufferTrace.EnableLogging(true);
301
302   tet_infoline("Test SetIndexBuffer");
303
304   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
305
306   Geometry geometry = Geometry::New();
307   geometry.AddVertexBuffer(vertexBuffer);
308
309   Shader   shader   = CreateShader();
310   Renderer renderer = Renderer::New(geometry, shader);
311   Actor    actor    = Actor::New();
312   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
313   actor.AddRenderer(renderer);
314   application.GetScene().Add(actor);
315
316   application.SendNotification();
317   application.Render(0);
318   application.Render();
319   application.SendNotification();
320
321   {
322     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
323       application.GetGlAbstraction().GetBufferDataCalls();
324
325     DALI_TEST_EQUALS(bufferDataCalls.size(), 3u, TEST_LOCATION);
326
327     DALI_TEST_EQUALS(bufferDataCalls[0], 4 * sizeof(TexturedQuadVertex), TEST_LOCATION);
328   }
329
330   // Set index buffer
331   application.GetGlAbstraction().ResetBufferDataCalls();
332
333   const unsigned short indexData[6] = {0, 3, 1, 0, 2, 3};
334   geometry.SetIndexBuffer(indexData, sizeof(indexData) / sizeof(indexData[0]));
335   application.SendNotification();
336   application.Render(0);
337   application.Render();
338   application.SendNotification();
339
340   {
341     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
342       application.GetGlAbstraction().GetBufferDataCalls();
343
344     //Only the index buffer should be uploaded
345     DALI_TEST_EQUALS(bufferDataCalls.size(), 1u, TEST_LOCATION);
346
347     // should be unsigned short instead of unsigned int
348     DALI_TEST_EQUALS(bufferDataCalls[0], 6 * sizeof(unsigned short), TEST_LOCATION);
349   }
350
351   END_TEST;
352 }
353
354 int UtcDaliGeometrySetGetGeometryType01(void)
355 {
356   TestApplication application;
357   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
358   bufferTrace.Enable(true);
359   bufferTrace.EnableLogging(true);
360
361   tet_infoline("Test SetType and GetType: without index buffer");
362
363   unsigned int numVertex    = 4u;
364   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
365
366   Geometry geometry = Geometry::New();
367   geometry.AddVertexBuffer(vertexBuffer);
368
369   Shader   shader   = CreateShader();
370   Renderer renderer = Renderer::New(geometry, shader);
371   Actor    actor    = Actor::New();
372   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
373   actor.AddRenderer(renderer);
374   application.GetScene().Add(actor);
375
376   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
377   TraceCallStack&    drawTrace     = glAbstraction.GetDrawTrace();
378
379   /****************************************************/
380   // Default (TRIANGLES), no index buffer
381   drawTrace.Reset();
382   drawTrace.Enable(true);
383   application.SendNotification();
384   application.Render(0);
385   application.Render();
386   application.SendNotification();
387   drawTrace.Enable(false);
388
389   // Test the default geometry type is GL_TRIANGLE
390   // no index buffer, call glDrawArrays,
391   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
392   std::stringstream out;
393   out << GL_TRIANGLES << ", " << 0 << ", " << numVertex;
394   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
395
396   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLES, TEST_LOCATION);
397
398   /*********************************************************/
399   // LINES, no index buffer
400   geometry.SetType(Geometry::LINES);
401
402   drawTrace.Reset();
403   drawTrace.Enable(true);
404   application.SendNotification();
405   application.Render(0);
406   application.Render();
407   application.SendNotification();
408   drawTrace.Enable(false);
409
410   // geometry type is set as GL_LINES
411   // no index buffer, call glDrawArrays,
412   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
413   out.str("");
414   out << GL_LINES << ", " << 0 << ", " << numVertex;
415   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
416
417   DALI_TEST_EQUALS(geometry.GetType(), Geometry::LINES, TEST_LOCATION);
418
419   /*****************************************************/
420   //POINTS
421   geometry.SetType(Geometry::POINTS);
422
423   drawTrace.Reset();
424   drawTrace.Enable(true);
425   application.SendNotification();
426   application.Render(0);
427   application.Render();
428   application.SendNotification();
429   drawTrace.Enable(false);
430
431   // geometry type is set as GL_POINTS
432   // no index buffer, call glDrawArrays,
433   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
434   out.str("");
435   out << GL_POINTS << ", " << 0 << ", " << numVertex;
436   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
437
438   DALI_TEST_EQUALS(geometry.GetType(), Geometry::POINTS, TEST_LOCATION);
439
440   /*****************************************************/
441   //TRIANGLE_STRIP, no index buffer
442   geometry.SetType(Geometry::TRIANGLE_STRIP);
443
444   drawTrace.Reset();
445   drawTrace.Enable(true);
446   application.SendNotification();
447   application.Render(0);
448   application.Render();
449   application.SendNotification();
450   drawTrace.Enable(false);
451
452   // geometry type is set as GL_TRIANGLE_STRIP
453   // no index buffer, call glDrawArrays,
454   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
455   out.str("");
456   out << GL_TRIANGLE_STRIP << ", " << 0 << ", " << numVertex;
457   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
458
459   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_STRIP, TEST_LOCATION);
460
461   /*****************************************************/
462   //TRIANGLE_FAN, no index buffer
463   geometry.SetType(Geometry::TRIANGLE_FAN);
464
465   drawTrace.Reset();
466   drawTrace.Enable(true);
467   application.SendNotification();
468   application.Render(0);
469   application.Render();
470   application.SendNotification();
471   drawTrace.Enable(false);
472
473   // geometry type is set as GL_TRIANGLE_FAN
474   // no index buffer, call glDrawArrays,
475   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
476   out.str("");
477   out << GL_TRIANGLE_FAN << ", " << 0 << ", " << numVertex;
478   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
479
480   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_FAN, TEST_LOCATION);
481
482   END_TEST;
483 }
484
485 int UtcDaliGeometrySetGetGeometryType02(void)
486 {
487   TestApplication application;
488   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
489   bufferTrace.Enable(true);
490   bufferTrace.EnableLogging(true);
491
492   tet_infoline("Test SetType and GetType: with index buffer");
493
494   unsigned int numVertex    = 4u;
495   unsigned int numIndex     = 6u; // 6 unsigned short
496   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
497
498   Geometry geometry = Geometry::New();
499   geometry.AddVertexBuffer(vertexBuffer);
500   const unsigned short indexData[6] = {0, 3, 1, 0, 2, 3};
501   geometry.SetIndexBuffer(indexData, sizeof(indexData) / sizeof(indexData[0]));
502
503   Shader   shader   = CreateShader();
504   Renderer renderer = Renderer::New(geometry, shader);
505   Actor    actor    = Actor::New();
506   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
507   actor.AddRenderer(renderer);
508   application.GetScene().Add(actor);
509
510   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
511   TraceCallStack&    drawTrace     = glAbstraction.GetDrawTrace();
512
513   /****************************************************/
514   // Default (TRIANGLES), with index buffer
515   drawTrace.Reset();
516   drawTrace.Enable(true);
517   application.SendNotification();
518   application.Render(0);
519   application.Render();
520   application.SendNotification();
521   drawTrace.Enable(false);
522
523   // Test the default geometry type is GL_TRIANGLE
524   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
525   std::stringstream out;
526   out << GL_TRIANGLES << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
527       << "indices";
528   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
529
530   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLES, TEST_LOCATION);
531
532   /*********************************************************/
533   // LINES, with index buffer
534   geometry.SetType(Geometry::LINES);
535
536   drawTrace.Reset();
537   drawTrace.Enable(true);
538   application.SendNotification();
539   application.Render(0);
540   application.Render();
541   application.SendNotification();
542   drawTrace.Enable(false);
543
544   // geometry type is set as GL_LINES
545   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
546   out.str("");
547   out << GL_LINES << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
548       << "indices";
549   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
550
551   DALI_TEST_EQUALS(geometry.GetType(), Geometry::LINES, TEST_LOCATION);
552
553   /*****************************************************/
554   //POINTS
555   geometry.SetType(Geometry::POINTS);
556
557   drawTrace.Reset();
558   drawTrace.Enable(true);
559   application.SendNotification();
560   application.Render(0);
561   application.Render();
562   application.SendNotification();
563   drawTrace.Enable(false);
564
565   // geometry type is set as GL_POINTS
566   // As Points does not use the index buffer, call glDrawArrays,
567   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
568   out.str("");
569   out << GL_POINTS << ", " << 0 << ", " << numVertex;
570   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
571
572   DALI_TEST_EQUALS(geometry.GetType(), Geometry::POINTS, TEST_LOCATION);
573
574   /*****************************************************/
575   //TRIANGLE_STRIP
576   geometry.SetType(Geometry::TRIANGLE_STRIP);
577
578   drawTrace.Reset();
579   drawTrace.Enable(true);
580   application.SendNotification();
581   application.Render(0);
582   application.Render();
583   application.SendNotification();
584   drawTrace.Enable(false);
585
586   // geometry type is set as GL_TRIANGLE_STRIP
587   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
588   out.str("");
589   out << GL_TRIANGLE_STRIP << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
590       << "indices";
591   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
592
593   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_STRIP, TEST_LOCATION);
594
595   /*****************************************************/
596   //TRIANGLE_FAN
597   geometry.SetType(Geometry::TRIANGLE_FAN);
598
599   drawTrace.Reset();
600   drawTrace.Enable(true);
601   application.SendNotification();
602   application.Render(0);
603   application.Render();
604   application.SendNotification();
605   drawTrace.Enable(false);
606
607   // geometry type is set as GL_TRIANGLE_FAN
608   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
609   out.str("");
610   out << GL_TRIANGLE_FAN << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
611       << "indices";
612   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
613
614   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_FAN, TEST_LOCATION);
615
616   END_TEST;
617 }
618
619 int UtcDaliGeometrySetIndexBufferNegative(void)
620 {
621   TestApplication application;
622   Dali::Geometry  instance;
623   try
624   {
625     unsigned short* arg1(nullptr);
626     unsigned long   arg2(0u);
627     instance.SetIndexBuffer(arg1, arg2);
628     DALI_TEST_CHECK(false); // Should not get here
629   }
630   catch(...)
631   {
632     DALI_TEST_CHECK(true); // We expect an assert
633   }
634   END_TEST;
635 }
636
637 int UtcDaliGeometryAddVertexBufferNegative(void)
638 {
639   TestApplication application;
640   Dali::Geometry  instance;
641   try
642   {
643     Dali::VertexBuffer arg1;
644     instance.AddVertexBuffer(arg1);
645     DALI_TEST_CHECK(false); // Should not get here
646   }
647   catch(...)
648   {
649     DALI_TEST_CHECK(true); // We expect an assert
650   }
651   END_TEST;
652 }
653
654 int UtcDaliGeometryRemoveVertexBufferNegative(void)
655 {
656   TestApplication application;
657   Dali::Geometry  instance;
658   try
659   {
660     unsigned long arg1(0u);
661     instance.RemoveVertexBuffer(arg1);
662     DALI_TEST_CHECK(false); // Should not get here
663   }
664   catch(...)
665   {
666     DALI_TEST_CHECK(true); // We expect an assert
667   }
668   END_TEST;
669 }
670
671 int UtcDaliGeometrySetTypeNegative(void)
672 {
673   TestApplication application;
674   Dali::Geometry  instance;
675   try
676   {
677     Dali::Geometry::Type arg1(Geometry::POINTS);
678     instance.SetType(arg1);
679     DALI_TEST_CHECK(false); // Should not get here
680   }
681   catch(...)
682   {
683     DALI_TEST_CHECK(true); // We expect an assert
684   }
685   END_TEST;
686 }
687
688 int UtcDaliGeometryGetNumberOfVertexBuffersNegative(void)
689 {
690   TestApplication application;
691   Dali::Geometry  instance;
692   try
693   {
694     instance.GetNumberOfVertexBuffers();
695     DALI_TEST_CHECK(false); // Should not get here
696   }
697   catch(...)
698   {
699     DALI_TEST_CHECK(true); // We expect an assert
700   }
701   END_TEST;
702 }
703
704 int UtcDaliGeometryGetTypeNegative(void)
705 {
706   TestApplication application;
707   Dali::Geometry  instance;
708   try
709   {
710     instance.GetType();
711     DALI_TEST_CHECK(false); // Should not get here
712   }
713   catch(...)
714   {
715     DALI_TEST_CHECK(true); // We expect an assert
716   }
717   END_TEST;
718 }