Revert "[Tizen] Appendix log for ttrace + Print keycode and timestamp"
[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 UtcDaliGeometrySetIndexBuffer32Bits(void)
355 {
356   TestApplication application;
357   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
358   bufferTrace.Enable(true);
359   bufferTrace.EnableLogging(true);
360
361   tet_infoline("Test SetIndexBuffer 32Bits");
362
363   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
364
365   Geometry geometry = Geometry::New();
366   geometry.AddVertexBuffer(vertexBuffer);
367
368   Shader   shader   = CreateShader();
369   Renderer renderer = Renderer::New(geometry, shader);
370   Actor    actor    = Actor::New();
371   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
372   actor.AddRenderer(renderer);
373   application.GetScene().Add(actor);
374
375   application.SendNotification();
376   application.Render(0);
377   application.Render();
378   application.SendNotification();
379
380   {
381     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
382       application.GetGlAbstraction().GetBufferDataCalls();
383
384     DALI_TEST_EQUALS(bufferDataCalls.size(), 3u, TEST_LOCATION);
385
386     DALI_TEST_EQUALS(bufferDataCalls[0], 4 * sizeof(TexturedQuadVertex), TEST_LOCATION);
387   }
388
389   // Set index buffer
390   application.GetGlAbstraction().ResetBufferDataCalls();
391
392   const uint32_t indexData32Bits[6] = {0, 3, 1, 0, 2, 3};
393   geometry.SetIndexBuffer(indexData32Bits, sizeof(indexData32Bits) / sizeof(indexData32Bits[0]));
394   application.SendNotification();
395   application.Render(0);
396   application.Render();
397   application.SendNotification();
398
399   {
400     const TestGlAbstraction::BufferDataCalls& bufferDataCalls =
401       application.GetGlAbstraction().GetBufferDataCalls();
402
403     //Only the index buffer should be uploaded
404     DALI_TEST_EQUALS(bufferDataCalls.size(), 1u, TEST_LOCATION);
405
406     // should be unsigned int instead of unsigned short
407     DALI_TEST_EQUALS(bufferDataCalls[0], 6 * sizeof(uint32_t), TEST_LOCATION);
408   }
409
410   END_TEST;
411 }
412
413 int UtcDaliGeometrySetGetGeometryType01(void)
414 {
415   TestApplication application;
416   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
417   bufferTrace.Enable(true);
418   bufferTrace.EnableLogging(true);
419
420   tet_infoline("Test SetType and GetType: without index buffer");
421
422   unsigned int numVertex    = 4u;
423   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
424
425   Geometry geometry = Geometry::New();
426   geometry.AddVertexBuffer(vertexBuffer);
427
428   Shader   shader   = CreateShader();
429   Renderer renderer = Renderer::New(geometry, shader);
430   Actor    actor    = Actor::New();
431   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
432   actor.AddRenderer(renderer);
433   application.GetScene().Add(actor);
434
435   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
436   TraceCallStack&    drawTrace     = glAbstraction.GetDrawTrace();
437
438   /****************************************************/
439   // Default (TRIANGLES), no index buffer
440   drawTrace.Reset();
441   drawTrace.Enable(true);
442   application.SendNotification();
443   application.Render(0);
444   application.Render();
445   application.SendNotification();
446   drawTrace.Enable(false);
447
448   // Test the default geometry type is GL_TRIANGLE
449   // no index buffer, call glDrawArrays,
450   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
451   std::stringstream out;
452   out << GL_TRIANGLES << ", " << 0 << ", " << numVertex;
453   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
454
455   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLES, TEST_LOCATION);
456
457   /*********************************************************/
458   // LINES, no index buffer
459   geometry.SetType(Geometry::LINES);
460
461   drawTrace.Reset();
462   drawTrace.Enable(true);
463   application.SendNotification();
464   application.Render(0);
465   application.Render();
466   application.SendNotification();
467   drawTrace.Enable(false);
468
469   // geometry type is set as GL_LINES
470   // no index buffer, call glDrawArrays,
471   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
472   out.str("");
473   out << GL_LINES << ", " << 0 << ", " << numVertex;
474   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
475
476   DALI_TEST_EQUALS(geometry.GetType(), Geometry::LINES, TEST_LOCATION);
477
478   /*****************************************************/
479   //POINTS
480   geometry.SetType(Geometry::POINTS);
481
482   drawTrace.Reset();
483   drawTrace.Enable(true);
484   application.SendNotification();
485   application.Render(0);
486   application.Render();
487   application.SendNotification();
488   drawTrace.Enable(false);
489
490   // geometry type is set as GL_POINTS
491   // no index buffer, call glDrawArrays,
492   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
493   out.str("");
494   out << GL_POINTS << ", " << 0 << ", " << numVertex;
495   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
496
497   DALI_TEST_EQUALS(geometry.GetType(), Geometry::POINTS, TEST_LOCATION);
498
499   /*****************************************************/
500   //TRIANGLE_STRIP, no index buffer
501   geometry.SetType(Geometry::TRIANGLE_STRIP);
502
503   drawTrace.Reset();
504   drawTrace.Enable(true);
505   application.SendNotification();
506   application.Render(0);
507   application.Render();
508   application.SendNotification();
509   drawTrace.Enable(false);
510
511   // geometry type is set as GL_TRIANGLE_STRIP
512   // no index buffer, call glDrawArrays,
513   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
514   out.str("");
515   out << GL_TRIANGLE_STRIP << ", " << 0 << ", " << numVertex;
516   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
517
518   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_STRIP, TEST_LOCATION);
519
520   /*****************************************************/
521   //TRIANGLE_FAN, no index buffer
522   geometry.SetType(Geometry::TRIANGLE_FAN);
523
524   drawTrace.Reset();
525   drawTrace.Enable(true);
526   application.SendNotification();
527   application.Render(0);
528   application.Render();
529   application.SendNotification();
530   drawTrace.Enable(false);
531
532   // geometry type is set as GL_TRIANGLE_FAN
533   // no index buffer, call glDrawArrays,
534   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
535   out.str("");
536   out << GL_TRIANGLE_FAN << ", " << 0 << ", " << numVertex;
537   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
538
539   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_FAN, TEST_LOCATION);
540
541   END_TEST;
542 }
543
544 int UtcDaliGeometrySetGetGeometryType02(void)
545 {
546   TestApplication application;
547   auto&           bufferTrace = application.GetGlAbstraction().GetBufferTrace();
548   bufferTrace.Enable(true);
549   bufferTrace.EnableLogging(true);
550
551   tet_infoline("Test SetType and GetType: with index buffer");
552
553   unsigned int numVertex    = 4u;
554   unsigned int numIndex     = 6u; // 6 unsigned short
555   VertexBuffer vertexBuffer = CreateVertexBuffer("aPosition", "aTexCoord");
556
557   Geometry geometry = Geometry::New();
558   geometry.AddVertexBuffer(vertexBuffer);
559   const unsigned short indexData[6] = {0, 3, 1, 0, 2, 3};
560   geometry.SetIndexBuffer(indexData, sizeof(indexData) / sizeof(indexData[0]));
561
562   Shader   shader   = CreateShader();
563   Renderer renderer = Renderer::New(geometry, shader);
564   Actor    actor    = Actor::New();
565   actor.SetProperty(Actor::Property::SIZE, Vector3::ONE * 100.f);
566   actor.AddRenderer(renderer);
567   application.GetScene().Add(actor);
568
569   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
570   TraceCallStack&    drawTrace     = glAbstraction.GetDrawTrace();
571
572   /****************************************************/
573   // Default (TRIANGLES), with index buffer
574   drawTrace.Reset();
575   drawTrace.Enable(true);
576   application.SendNotification();
577   application.Render(0);
578   application.Render();
579   application.SendNotification();
580   drawTrace.Enable(false);
581
582   // Test the default geometry type is GL_TRIANGLE
583   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
584   std::stringstream out;
585   out << GL_TRIANGLES << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
586       << "indices";
587   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
588
589   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLES, TEST_LOCATION);
590
591   /*********************************************************/
592   // LINES, with index buffer
593   geometry.SetType(Geometry::LINES);
594
595   drawTrace.Reset();
596   drawTrace.Enable(true);
597   application.SendNotification();
598   application.Render(0);
599   application.Render();
600   application.SendNotification();
601   drawTrace.Enable(false);
602
603   // geometry type is set as GL_LINES
604   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
605   out.str("");
606   out << GL_LINES << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
607       << "indices";
608   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
609
610   DALI_TEST_EQUALS(geometry.GetType(), Geometry::LINES, TEST_LOCATION);
611
612   /*****************************************************/
613   //POINTS
614   geometry.SetType(Geometry::POINTS);
615
616   drawTrace.Reset();
617   drawTrace.Enable(true);
618   application.SendNotification();
619   application.Render(0);
620   application.Render();
621   application.SendNotification();
622   drawTrace.Enable(false);
623
624   // geometry type is set as GL_POINTS
625   // As Points does not use the index buffer, call glDrawArrays,
626   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
627   out.str("");
628   out << GL_POINTS << ", " << 0 << ", " << numVertex;
629   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawArrays", out.str()), true, TEST_LOCATION);
630
631   DALI_TEST_EQUALS(geometry.GetType(), Geometry::POINTS, TEST_LOCATION);
632
633   /*****************************************************/
634   //TRIANGLE_STRIP
635   geometry.SetType(Geometry::TRIANGLE_STRIP);
636
637   drawTrace.Reset();
638   drawTrace.Enable(true);
639   application.SendNotification();
640   application.Render(0);
641   application.Render();
642   application.SendNotification();
643   drawTrace.Enable(false);
644
645   // geometry type is set as GL_TRIANGLE_STRIP
646   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
647   out.str("");
648   out << GL_TRIANGLE_STRIP << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
649       << "indices";
650   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
651
652   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_STRIP, TEST_LOCATION);
653
654   /*****************************************************/
655   //TRIANGLE_FAN
656   geometry.SetType(Geometry::TRIANGLE_FAN);
657
658   drawTrace.Reset();
659   drawTrace.Enable(true);
660   application.SendNotification();
661   application.Render(0);
662   application.Render();
663   application.SendNotification();
664   drawTrace.Enable(false);
665
666   // geometry type is set as GL_TRIANGLE_FAN
667   DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 2, TEST_LOCATION);
668   out.str("");
669   out << GL_TRIANGLE_FAN << ", " << numIndex << ", " << GL_UNSIGNED_SHORT << ", "
670       << "indices";
671   DALI_TEST_EQUALS(drawTrace.TestMethodAndParams(1, "DrawElements", out.str()), true, TEST_LOCATION);
672
673   DALI_TEST_EQUALS(geometry.GetType(), Geometry::TRIANGLE_FAN, TEST_LOCATION);
674
675   END_TEST;
676 }
677
678 int UtcDaliGeometrySetIndexBufferNegative(void)
679 {
680   TestApplication application;
681   Dali::Geometry  instance;
682   try
683   {
684     unsigned short* arg1(nullptr);
685     unsigned long   arg2(0u);
686     instance.SetIndexBuffer(arg1, arg2);
687     DALI_TEST_CHECK(false); // Should not get here
688   }
689   catch(...)
690   {
691     DALI_TEST_CHECK(true); // We expect an assert
692   }
693   END_TEST;
694 }
695
696 int UtcDaliGeometryAddVertexBufferNegative(void)
697 {
698   TestApplication application;
699   Dali::Geometry  instance;
700   try
701   {
702     Dali::VertexBuffer arg1;
703     instance.AddVertexBuffer(arg1);
704     DALI_TEST_CHECK(false); // Should not get here
705   }
706   catch(...)
707   {
708     DALI_TEST_CHECK(true); // We expect an assert
709   }
710   END_TEST;
711 }
712
713 int UtcDaliGeometryRemoveVertexBufferNegative(void)
714 {
715   TestApplication application;
716   Dali::Geometry  instance;
717   try
718   {
719     unsigned long arg1(0u);
720     instance.RemoveVertexBuffer(arg1);
721     DALI_TEST_CHECK(false); // Should not get here
722   }
723   catch(...)
724   {
725     DALI_TEST_CHECK(true); // We expect an assert
726   }
727   END_TEST;
728 }
729
730 int UtcDaliGeometrySetTypeNegative(void)
731 {
732   TestApplication application;
733   Dali::Geometry  instance;
734   try
735   {
736     Dali::Geometry::Type arg1(Geometry::POINTS);
737     instance.SetType(arg1);
738     DALI_TEST_CHECK(false); // Should not get here
739   }
740   catch(...)
741   {
742     DALI_TEST_CHECK(true); // We expect an assert
743   }
744   END_TEST;
745 }
746
747 int UtcDaliGeometryGetNumberOfVertexBuffersNegative(void)
748 {
749   TestApplication application;
750   Dali::Geometry  instance;
751   try
752   {
753     instance.GetNumberOfVertexBuffers();
754     DALI_TEST_CHECK(false); // Should not get here
755   }
756   catch(...)
757   {
758     DALI_TEST_CHECK(true); // We expect an assert
759   }
760   END_TEST;
761 }
762
763 int UtcDaliGeometryGetTypeNegative(void)
764 {
765   TestApplication application;
766   Dali::Geometry  instance;
767   try
768   {
769     instance.GetType();
770     DALI_TEST_CHECK(false); // Should not get here
771   }
772   catch(...)
773   {
774     DALI_TEST_CHECK(true); // We expect an assert
775   }
776   END_TEST;
777 }