Upload package dali_0.9.11.
[platform/core/uifw/dali-core.git] / automated-tests / TET / dali-test-suite / geometry / utc-Dali-Spline.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 #include <iostream>
18
19 #include <stdlib.h>
20 #include <tet_api.h>
21
22 #include <dali/public-api/dali-core.h>
23
24 #include <dali-test-suite-utils.h>
25
26 using namespace Dali;
27 using namespace Dali::Internal;
28 using Dali::Spline;
29 using Dali::Vector3;
30
31 static void Startup();
32 static void Cleanup();
33
34 extern "C" {
35   void (*tet_startup)() = Startup;
36   void (*tet_cleanup)() = Cleanup;
37 }
38
39 static void utcDaliSplineGetKnot01();
40 static void utcDaliSplineGetKnot02();
41 static void utcDaliSplineGetKnot03();
42 static void utcDaliSplineGetOutTangent01();
43 static void utcDaliSplineGetOutTangent02();
44 static void utcDaliSplineGetOutTangent03();
45 static void utcDaliSplineGetInTangent01();
46 static void utcDaliSplineGetInTangent02();
47 static void utcDaliSplineGetInTangent03();
48 static void utcDaliSplineGenerateControlPoints01();
49 static void utcDaliSplineGenerateControlPoints02();
50 static void utcDaliSplineGenerateControlPoints03();
51
52 static void UtcDaliSplineGetYFromMonotonicX();
53 static void UtcDaliSplineGetY01();
54 static void UtcDaliSplineGetY02();
55 static void UtcDaliSplineGetY02b();
56 static void UtcDaliSplineGetY03();
57 static void UtcDaliSplineGetY04();
58 static void UtcDaliSplineGetY04b();
59 static void UtcDaliSplineGetPoint01();
60 static void UtcDaliSplineGetPoint02();
61 static void UtcDaliSplineGetPoint03();
62 static void UtcDaliSplineGetPoint04();
63 static void UtcDaliSplineGetPoint05();
64 static void UtcDaliSplineGetPoint06();
65
66
67 enum {
68   POSITIVE_TC_IDX = 0x01,
69   NEGATIVE_TC_IDX,
70 };
71
72 // Add test functionality for all APIs in the class (Positive and Negative)
73 extern "C" {
74   struct tet_testlist tet_testlist[] = {
75     { utcDaliSplineGetKnot01, POSITIVE_TC_IDX },
76     { utcDaliSplineGetKnot02, NEGATIVE_TC_IDX },
77     { utcDaliSplineGetKnot03, NEGATIVE_TC_IDX },
78     { utcDaliSplineGetOutTangent01, POSITIVE_TC_IDX },
79     { utcDaliSplineGetOutTangent02, NEGATIVE_TC_IDX },
80     { utcDaliSplineGetOutTangent03, NEGATIVE_TC_IDX },
81     { utcDaliSplineGetInTangent01, POSITIVE_TC_IDX },
82     { utcDaliSplineGetInTangent02, NEGATIVE_TC_IDX },
83     { utcDaliSplineGetInTangent03, NEGATIVE_TC_IDX },
84     { utcDaliSplineGenerateControlPoints01, POSITIVE_TC_IDX },
85     { utcDaliSplineGenerateControlPoints02, NEGATIVE_TC_IDX },
86     { utcDaliSplineGenerateControlPoints03, NEGATIVE_TC_IDX },
87     { UtcDaliSplineGetYFromMonotonicX, POSITIVE_TC_IDX },
88     { UtcDaliSplineGetY01, POSITIVE_TC_IDX },
89     { UtcDaliSplineGetY02, NEGATIVE_TC_IDX },
90     { UtcDaliSplineGetY02b, NEGATIVE_TC_IDX },
91     { UtcDaliSplineGetY03, NEGATIVE_TC_IDX },
92     { UtcDaliSplineGetY04, NEGATIVE_TC_IDX },
93     { UtcDaliSplineGetY04b,NEGATIVE_TC_IDX },
94     { UtcDaliSplineGetPoint01, POSITIVE_TC_IDX },
95     { UtcDaliSplineGetPoint02, POSITIVE_TC_IDX },
96     { UtcDaliSplineGetPoint03, NEGATIVE_TC_IDX },
97     { UtcDaliSplineGetPoint04, NEGATIVE_TC_IDX },
98     { UtcDaliSplineGetPoint05, NEGATIVE_TC_IDX },
99     { UtcDaliSplineGetPoint06, NEGATIVE_TC_IDX },
100     { NULL, 0 }
101   };
102 }
103
104 // Called only once before first test is run.
105 static void Startup()
106 {
107 }
108
109 // Called only once after last test is run
110 static void Cleanup()
111 {
112 }
113
114 // Knots fed into Allegro, which generates control points
115 static Spline* SetupBezierSpline1()
116 {
117   Spline *bezierSpline = new Spline();
118
119   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0));
120   bezierSpline->AddKnot(Vector3(120.0,  70.0, 0.0));
121   bezierSpline->AddKnot(Vector3(190.0, 250.0, 0.0));
122   bezierSpline->AddKnot(Vector3(260.0, 260.0, 0.0));
123   bezierSpline->AddKnot(Vector3(330.0, 220.0, 0.0));
124   bezierSpline->AddKnot(Vector3(400.0,  50.0, 0.0));
125
126   bezierSpline->SetInTangent (0, Vector3(  0.0,   0.0, 0.0));
127   bezierSpline->SetInTangent (1, Vector3(107.0,  58.0, 0.0));
128   bezierSpline->SetInTangent (2, Vector3(152.0, 220.0, 0.0));
129   bezierSpline->SetInTangent (3, Vector3(243.0, 263.0, 0.0));
130   bezierSpline->SetInTangent (4, Vector3(317.0, 235.0, 0.0));
131   bezierSpline->SetInTangent (5, Vector3(383.0,  93.0, 0.0));
132
133   bezierSpline->SetOutTangent(0, Vector3( 68.0,  55.0, 0.0));
134   bezierSpline->SetOutTangent(1, Vector3(156.0, 102.0, 0.0));
135   bezierSpline->SetOutTangent(2, Vector3(204.0, 261.0, 0.0));
136   bezierSpline->SetOutTangent(3, Vector3(280.0, 256.0, 0.0));
137   bezierSpline->SetOutTangent(4, Vector3(360.0, 185.0, 0.0));
138   bezierSpline->SetOutTangent(5, Vector3(410.0,  40.0, 0.0));
139   return bezierSpline;
140 }
141
142 // Knots fed into Allegro, which generates control points
143 static Spline* SetupBezierSpline2()
144 {
145   Spline *spline = new Spline();
146   spline->AddKnot(Vector3( 30.0,  80.0, 0.0));
147   spline->AddKnot(Vector3( 70.0, 120.0, 0.0));
148   spline->AddKnot(Vector3(100.0, 100.0, 0.0));
149   spline->SetInTangent (0, Vector3(  0.0,   0.0, 0.0));
150   spline->SetInTangent (1, Vector3( 56.0, 119.0, 0.0));
151   spline->SetInTangent (2, Vector3( 93.0, 104.0, 0.0));
152   spline->SetOutTangent(0, Vector3( 39.0,  90.0, 0.0));
153   spline->SetOutTangent(1, Vector3( 78.0, 120.0, 0.0));
154   spline->SetOutTangent(2, Vector3(110.0,  90.0, 0.0));
155   return spline;
156 }
157
158
159 typedef struct
160 {
161   float x;
162   float y;
163 } tPoint;
164
165 tPoint test[] = {
166   {0.0f,     0.0f},
167   {50.0f,   50.0f},
168   {120.0f,  70.0f},
169   {190.0f, 250.0f},
170   {260.0f, 260.0f},
171   {330.0f, 220.0f},
172   {400.0f,  50.0f},
173   {106.0f,  62.5f},
174   {242.0f, 261.3f},
175   {320.0f, 229.3f},
176   {390.0f,  78.1f},
177   {399.9999f, 50.0f},
178   {401.0f,   0.0f},
179   {501.0f,   0.0f},
180   {-100.0f,   0.0f},
181 };
182
183
184 // Positive test case for a method
185 static void UtcDaliSplineGetYFromMonotonicX()
186 {
187   TestApplication application;
188
189   Spline *bezierSpline = SetupBezierSpline1();
190
191
192   for(unsigned int i=0; i<sizeof(test)/sizeof(tPoint); i++)
193   {
194     DALI_TEST_EQUALS(1, 1, (const char *)TEST_LOCATION);
195
196     DALI_TEST_EQUALS((float)bezierSpline->GetYFromMonotonicX(test[i].x),
197                      (float)test[i].y, 0.1f,
198                      TEST_LOCATION);
199   }
200
201   delete bezierSpline;
202 }
203
204 static void utcDaliSplineGetKnot01()
205 {
206   TestApplication application;
207
208   Spline *bezierSpline= new Spline();
209   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0));
210   bezierSpline->AddKnot(Vector3(120.0,  70.0, 0.0));
211   bezierSpline->AddKnot(Vector3(190.0, 250.0, 0.0));
212   bezierSpline->AddKnot(Vector3(260.0, 260.0, 0.0));
213   bezierSpline->AddKnot(Vector3(330.0, 220.0, 0.0));
214   bezierSpline->AddKnot(Vector3(400.0,  50.0, 0.0));
215
216   DALI_TEST_EQUALS(bezierSpline->GetKnot(0), Vector3( 50.0,  50.0, 0.0), TEST_LOCATION);
217   DALI_TEST_EQUALS(bezierSpline->GetKnot(1), Vector3(120.0,  70.0, 0.0), TEST_LOCATION);
218   DALI_TEST_EQUALS(bezierSpline->GetKnot(2), Vector3(190.0, 250.0, 0.0), TEST_LOCATION);
219   DALI_TEST_EQUALS(bezierSpline->GetKnot(3), Vector3(260.0, 260.0, 0.0), TEST_LOCATION);
220   DALI_TEST_EQUALS(bezierSpline->GetKnot(4), Vector3(330.0, 220.0, 0.0), TEST_LOCATION);
221   DALI_TEST_EQUALS(bezierSpline->GetKnot(5), Vector3(400.0,  50.0, 0.0), TEST_LOCATION);
222 }
223
224 static void utcDaliSplineGetKnot02()
225 {
226   TestApplication application;
227
228   Spline *bezierSpline= new Spline();
229   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0f));
230
231   try
232   {
233     bezierSpline->GetKnot(1);
234     tet_result(TET_FAIL);
235   }
236   catch (Dali::DaliException& e)
237   {
238     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
239     DALI_TEST_ASSERT(e, "knotIndex < mKnots.size()", TEST_LOCATION);
240   }
241 }
242
243 static void utcDaliSplineGetKnot03()
244 {
245   TestApplication application;
246
247   Spline *bezierSpline= new Spline();
248
249   try
250   {
251     bezierSpline->GetKnot(0);
252     tet_result(TET_FAIL);
253   }
254   catch (Dali::DaliException& e)
255   {
256     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
257     DALI_TEST_ASSERT(e, "knotIndex < mKnots.size()", TEST_LOCATION);
258   }
259 }
260
261 static void utcDaliSplineGetInTangent01()
262 {
263   TestApplication application;
264
265   Spline *bezierSpline= new Spline();
266   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0));
267   bezierSpline->AddKnot(Vector3(120.0,  70.0, 0.0));
268   bezierSpline->SetInTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused
269   bezierSpline->SetInTangent(1, Vector3(108.0f, 57.0f, 0.0));
270
271   DALI_TEST_EQUALS(bezierSpline->GetInTangent(0), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
272   DALI_TEST_EQUALS(bezierSpline->GetInTangent(1), Vector3(108.0f, 57.0f, 0.0f), TEST_LOCATION);
273 }
274
275
276
277 static void utcDaliSplineGetInTangent02()
278 {
279   TestApplication application;
280
281   Spline *bezierSpline= new Spline();
282   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0));
283   bezierSpline->AddKnot(Vector3(120.0,  70.0, 0.0));
284   bezierSpline->SetInTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused
285   bezierSpline->SetInTangent(1, Vector3(108.0f, 57.0f, 0.0));
286
287   try
288   {
289     bezierSpline->GetInTangent(5);
290     tet_result(TET_FAIL);
291   }
292   catch (Dali::DaliException& e)
293   {
294     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
295     DALI_TEST_ASSERT(e, "knotIndex < mInTangents.size()", TEST_LOCATION);
296   }
297 }
298
299
300 static void utcDaliSplineGetInTangent03()
301 {
302   TestApplication application;
303
304   Spline *bezierSpline= new Spline();
305   try
306   {
307     bezierSpline->GetInTangent(0);
308     tet_result(TET_FAIL);
309   }
310   catch (Dali::DaliException& e)
311   {
312     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
313     DALI_TEST_ASSERT(e, "knotIndex < mInTangents.size()", TEST_LOCATION);
314   }
315 }
316
317
318 static void utcDaliSplineGetOutTangent01()
319 {
320   TestApplication application;
321
322   Spline *bezierSpline= new Spline();
323   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0));
324   bezierSpline->AddKnot(Vector3(120.0,  70.0, 0.0));
325   bezierSpline->SetOutTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused
326   bezierSpline->SetOutTangent(1, Vector3(108.0f, 57.0f, 0.0));
327
328   DALI_TEST_EQUALS(bezierSpline->GetOutTangent(0), Vector3(0.0f, 0.0f, 0.0f), TEST_LOCATION);
329   DALI_TEST_EQUALS(bezierSpline->GetOutTangent(1), Vector3(108.0f, 57.0f, 0.0f), TEST_LOCATION);
330 }
331
332
333
334 static void utcDaliSplineGetOutTangent02()
335 {
336   TestApplication application;
337
338   Spline *bezierSpline= new Spline();
339   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0));
340   bezierSpline->AddKnot(Vector3(120.0,  70.0, 0.0));
341   bezierSpline->SetOutTangent(0, Vector3(0.0f, 0.0f, 0.0)); // Intangent for initial value is unused
342   bezierSpline->SetOutTangent(1, Vector3(108.0f, 57.0f, 0.0));
343
344   try
345   {
346     bezierSpline->GetOutTangent(5);
347     tet_result(TET_FAIL);
348   }
349   catch (Dali::DaliException& e)
350   {
351     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
352     DALI_TEST_ASSERT(e, "knotIndex < mOutTangents.size()", TEST_LOCATION);
353   }
354 }
355
356
357 static void utcDaliSplineGetOutTangent03()
358 {
359   TestApplication application;
360
361   Spline *bezierSpline= new Spline();
362   try
363   {
364     bezierSpline->GetOutTangent(0);
365     tet_result(TET_FAIL);
366   }
367   catch (Dali::DaliException& e)
368   {
369     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
370     DALI_TEST_ASSERT(e, "knotIndex < mOutTangents.size()", TEST_LOCATION);
371   }
372 }
373
374
375 static void utcDaliSplineGenerateControlPoints01()
376 {
377   TestApplication application;
378
379   Spline *bezierSpline = new Spline();
380
381   bezierSpline->AddKnot(Vector3( 50.0,  50.0, 0.0));
382   bezierSpline->AddKnot(Vector3(120.0,  70.0, 0.0));
383   bezierSpline->AddKnot(Vector3(190.0, 250.0, 0.0));
384   bezierSpline->AddKnot(Vector3(260.0, 260.0, 0.0));
385   bezierSpline->AddKnot(Vector3(330.0, 220.0, 0.0));
386   bezierSpline->AddKnot(Vector3(400.0,  50.0, 0.0));
387
388   bezierSpline->GenerateControlPoints(0.25);
389
390   // first in tangent is never used, ignore it.
391   DALI_TEST_EQUALS(bezierSpline->GetInTangent(1), Vector3(107.0,  58.0, 0.0), 1.0, TEST_LOCATION);
392   DALI_TEST_EQUALS(bezierSpline->GetInTangent(2), Vector3(152.0, 220.0, 0.0), 1.0, TEST_LOCATION);
393   DALI_TEST_EQUALS(bezierSpline->GetInTangent(3), Vector3(243.0, 263.0, 0.0), 1.0, TEST_LOCATION);
394   DALI_TEST_EQUALS(bezierSpline->GetInTangent(4), Vector3(317.0, 235.0, 0.0), 1.0, TEST_LOCATION);
395   DALI_TEST_EQUALS(bezierSpline->GetInTangent(5), Vector3(383.0,  93.0, 0.0), 1.0, TEST_LOCATION);
396
397   DALI_TEST_EQUALS(bezierSpline->GetOutTangent(0), Vector3( 68.0,  55.0, 0.0), 1.0, TEST_LOCATION);
398   DALI_TEST_EQUALS(bezierSpline->GetOutTangent(1), Vector3(156.0, 102.0, 0.0), 1.0, TEST_LOCATION);
399   DALI_TEST_EQUALS(bezierSpline->GetOutTangent(2), Vector3(204.0, 261.0, 0.0), 1.0, TEST_LOCATION);
400   DALI_TEST_EQUALS(bezierSpline->GetOutTangent(3), Vector3(280.0, 256.0, 0.0), 1.0, TEST_LOCATION);
401   DALI_TEST_EQUALS(bezierSpline->GetOutTangent(4), Vector3(360.0, 185.0, 0.0), 1.0, TEST_LOCATION);
402   // last out tangent is never used, ignore it.
403 }
404
405 static void utcDaliSplineGenerateControlPoints02()
406 {
407   TestApplication application;
408
409   Spline *bezierSpline = new Spline();
410   try
411   {
412     bezierSpline->GenerateControlPoints(0.25);
413     tet_result(TET_FAIL);
414   }
415   catch (Dali::DaliException& e)
416   {
417     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
418     DALI_TEST_ASSERT(e, "numKnots > 1", TEST_LOCATION);
419   }
420 }
421
422
423 static void utcDaliSplineGenerateControlPoints03()
424 {
425   TestApplication application;
426
427   Spline *bezierSpline = new Spline();
428   bezierSpline->AddKnot(Vector3(400.0,  50.0, 0.0f));
429   try
430   {
431     bezierSpline->GenerateControlPoints(0.25);
432     tet_result(TET_FAIL);
433   }
434   catch (Dali::DaliException& e)
435   {
436     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
437     DALI_TEST_ASSERT(e, "numKnots > 1", TEST_LOCATION);
438   }
439 }
440
441
442 static void UtcDaliSplineGetY01()
443 {
444   TestApplication application;
445   Spline *spline = SetupBezierSpline2();
446
447   DALI_TEST_EQUALS(spline->GetY(0, 0.0f), 80.0f, TEST_LOCATION);  // First control point
448   DALI_TEST_EQUALS(spline->GetY(0, 0.5f), 102.0f, 2.0f, TEST_LOCATION);
449   DALI_TEST_EQUALS(spline->GetY(0, 1.0f), 120.0f, TEST_LOCATION); // Second control point
450   DALI_TEST_EQUALS(spline->GetY(1, 0.0f), 120.0f, TEST_LOCATION); // Second control point
451   DALI_TEST_EQUALS(spline->GetY(1, 0.5f), 112.0f, 2.0f, TEST_LOCATION);
452   DALI_TEST_EQUALS(spline->GetY(1, 1.0f), 100.0f, TEST_LOCATION); // Third control point
453   delete spline;
454 }
455
456 // Test segments outside range (should assert and fail tetcase!)
457 static void UtcDaliSplineGetY02()
458 {
459   TestApplication application;
460
461   try
462   {
463     Spline *spline = SetupBezierSpline2();
464     spline->GetY(3,  0.0f); // Segment outside range - expect assertion
465
466     // If we get here, assertion hasn't triggered.
467     tet_result(TET_FAIL);
468     delete spline;
469   }
470   catch (Dali::DaliException& e)
471   {
472     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
473     DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION);
474   }
475 }
476
477 // Test segments outside range (should assert and fail tetcase!)
478 static void UtcDaliSplineGetY02b()
479 {
480   TestApplication application;
481   try
482   {
483     Spline *spline = SetupBezierSpline2();
484     spline->GetY(-1,  0.0f); // Segment outside range - expect assertion
485
486     // If we get here, assertion hasn't triggered.
487     tet_result(TET_FAIL);
488     delete spline;
489   }
490   catch (Dali::DaliException& e)
491   {
492     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
493     DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION);
494   }
495 }
496
497
498 // Test parameter ouside 0-1 - should return 0.
499 static void UtcDaliSplineGetY03()
500 {
501   TestApplication application;
502   Spline *spline = SetupBezierSpline2();
503   DALI_TEST_EQUALS(spline->GetY(1, -1.0f), 0.0f, TEST_LOCATION);
504   DALI_TEST_EQUALS(spline->GetY(1, 2.0f), 0.0f, TEST_LOCATION);
505   delete spline;
506 }
507
508 // Test on empty spline - should assert
509 static void UtcDaliSplineGetY04()
510 {
511   TestApplication application;
512   try
513   {
514     Spline *spline = new Spline();
515     spline->GetY(0, 0.0f); // Should assert
516     tet_result(TET_FAIL);
517     delete spline;
518   }
519   catch (Dali::DaliException& e)
520   {
521     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
522     DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION);
523   }
524 }
525
526
527 // Test on empty spline - should assert
528 static void UtcDaliSplineGetY04b()
529 {
530   TestApplication application;
531   try
532   {
533     Spline *spline = new Spline();
534     spline->GetY(0, 1.0f);
535     tet_result(TET_FAIL); // assertion didn't trigger
536     delete spline;
537   }
538   catch (Dali::DaliException& e)
539   {
540     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
541     DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION);
542   }
543 }
544
545
546
547 static void UtcDaliSplineGetPoint01()
548 {
549   TestApplication application;
550   Spline *spline = SetupBezierSpline2();
551
552   // Test control points
553   Vector3 pt = spline->GetPoint(0, 0.0f);
554   DALI_TEST_EQUALS(pt.x, 30.0f, TEST_LOCATION);
555   DALI_TEST_EQUALS(pt.y, 80.0f, TEST_LOCATION);
556
557   // Test control points
558   pt = spline->GetPoint(0, 1.0f);
559   DALI_TEST_EQUALS(pt.x,  70.0f, TEST_LOCATION);
560   DALI_TEST_EQUALS(pt.y, 120.0f, TEST_LOCATION);
561
562   // Halfway point computed using Allegro engine
563   pt = spline->GetPoint(0, 0.5f);
564   DALI_TEST_EQUALS(pt.x,  47.0f, 2.0f, TEST_LOCATION);
565   DALI_TEST_EQUALS(pt.y, 102.0f, 2.0f, TEST_LOCATION);
566
567   // Test control point
568   pt = spline->GetPoint(1, 0.0f);
569   DALI_TEST_EQUALS(pt.x,  70.0f, TEST_LOCATION);
570   DALI_TEST_EQUALS(pt.y, 120.0f, TEST_LOCATION);
571
572   // Halfway point computed using Allegro engine
573   pt = spline->GetPoint(1, 0.5f);
574   DALI_TEST_EQUALS(pt.x,  85.0f, 2.0f, TEST_LOCATION);
575   DALI_TEST_EQUALS(pt.y, 112.0f, 2.0f, TEST_LOCATION);
576
577   // Test control points
578   pt = spline->GetPoint(1, 1.0f);
579   DALI_TEST_EQUALS(pt.x, 100.0f, TEST_LOCATION);
580   DALI_TEST_EQUALS(pt.y, 100.0f, TEST_LOCATION);
581   delete spline;
582 }
583
584
585 static void UtcDaliSplineGetPoint02()
586 {
587   TestApplication application;
588   Spline *spline = SetupBezierSpline2();
589
590   // Test control points
591   Vector3 pt = spline->GetPoint(0.0f);
592   DALI_TEST_EQUALS(pt.x, 30.0f, TEST_LOCATION);
593   DALI_TEST_EQUALS(pt.y, 80.0f, TEST_LOCATION);
594
595   // Halfway point computed using Allegro engine
596   pt = spline->GetPoint(0.25f);
597   DALI_TEST_EQUALS(pt.x,  47.0f, 2.0f, TEST_LOCATION);
598   DALI_TEST_EQUALS(pt.y, 102.0f, 2.0f, TEST_LOCATION);
599
600   // Test control points
601   pt = spline->GetPoint(0.5f);
602   DALI_TEST_EQUALS(pt.x,  70.0f, TEST_LOCATION);
603   DALI_TEST_EQUALS(pt.y, 120.0f, TEST_LOCATION);
604
605   // Halfway point computed using Allegro engine
606   pt = spline->GetPoint(0.75f);
607   DALI_TEST_EQUALS(pt.x,  85.0f, 2.0f, TEST_LOCATION);
608   DALI_TEST_EQUALS(pt.y, 112.0f, 2.0f, TEST_LOCATION);
609
610   // Test control points
611   pt = spline->GetPoint(1.0f);
612   DALI_TEST_EQUALS(pt.x, 100.0f, TEST_LOCATION);
613   DALI_TEST_EQUALS(pt.y, 100.0f, TEST_LOCATION);
614   delete spline;
615 }
616
617
618 // Test on segment index out of bounds - should assert and fail tet case
619 static void UtcDaliSplineGetPoint03()
620 {
621   TestApplication application;
622   try
623   {
624     Spline *spline = SetupBezierSpline2();
625
626     spline->GetPoint(-1, 0.5f); // should assert
627     tet_result(TET_FAIL);
628     delete spline;
629   }
630   catch (Dali::DaliException& e)
631   {
632     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
633     DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION);
634   }
635 }
636
637 // Test on segment index out of bounds - should assert and fail tet case
638 static void UtcDaliSplineGetPoint04()
639 {
640   TestApplication application;
641   try
642   {
643     Spline *spline = SetupBezierSpline2();
644
645     spline->GetPoint(123, 0.5f); // should assert
646     tet_result(TET_FAIL);
647     delete spline;
648   }
649   catch (Dali::DaliException& e)
650   {
651     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
652     DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION);
653   }
654 }
655
656
657 // Test on parameter out of bounds - should return 0,0
658 static void UtcDaliSplineGetPoint05()
659 {
660   TestApplication application;
661   Spline *spline = SetupBezierSpline2();
662
663   Vector3 pt = spline->GetPoint(0, -32.0f);
664   DALI_TEST_EQUALS(pt.x, 0.0f, TEST_LOCATION);
665   DALI_TEST_EQUALS(pt.y, 0.0f, TEST_LOCATION);
666
667   pt = spline->GetPoint(0, 23444.0f);
668   DALI_TEST_EQUALS(pt.x, 0.0f, TEST_LOCATION);
669   DALI_TEST_EQUALS(pt.y, 0.0f, TEST_LOCATION);
670 }
671
672 // Test on empty spline - should assert and fail tet case
673 static void UtcDaliSplineGetPoint06()
674 {
675   TestApplication application;
676   try
677   {
678     Spline *spline = new Spline();
679     spline->GetPoint(0, 23444.0f);
680     tet_result(TET_FAIL);
681     delete(spline);
682   }
683   catch (Dali::DaliException& e)
684   {
685     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
686     DALI_TEST_ASSERT(e, "segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size()", TEST_LOCATION);
687   }
688 }
689
690