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