Dali 3D User Interface Engine
utc-Dali-PropertyNotification.cpp
Go to the documentation of this file.
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>
22 #include <dali-test-suite-utils.h>
23 
24 using namespace Dali;
25 
27 {
29 }
30 
32 {
34 }
35 
36 namespace {
37 
38 static bool gCallBackCalled;
39 
40 static void TestCallback(PropertyNotification& source)
41 {
42  gCallBackCalled = true;
43 }
44 
45 const int RENDER_FRAME_INTERVAL(16);
46 const int DEFAULT_WAIT_PERIOD(100);
47 
48 
50 {
51 public:
52 
54  {
55  }
56 
58  {
59  }
60 
61  void Initialize()
62  {
63  mActor = Actor::New();
64  Stage::GetCurrent().Add( mActor );
65  mNotification = mActor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(100.0f) );
66  mNotification.NotifySignal().Connect( this, &TestClass::OnPropertyNotify );
67  }
68 
69  void RemovePropertyNotification()
70  {
71  mActor.RemovePropertyNotification( mNotification );
72  }
73 
74  void RemovePropertyNotifications()
75  {
76  mActor.RemovePropertyNotifications();
77  }
78 
79  void Terminate()
80  {
81  Stage::GetCurrent().Remove( mActor );
82  mActor.Reset();
83  mNotification.Reset();
84  }
85 
86  void OnPropertyNotify( PropertyNotification& source )
87  {
88  tet_infoline(" OnPropertyNotify");
89  gCallBackCalled = true;
90  }
91 
94 };
95 
96 
97 /*
98  * Simulate time passed by.
99  *
100  * @note this will always process at least 1 frame (1/60 sec)
101  *
102  * @param application Test application instance
103  * @param duration Time to pass in milliseconds.
104  * @return The actual time passed in milliseconds
105  */
106 int Wait(TestApplication& application, int duration = 0)
107 {
108  int time = 0;
109 
110  for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
111  {
112  application.SendNotification();
113  application.Render(RENDER_FRAME_INTERVAL);
114  time += RENDER_FRAME_INTERVAL;
115  }
116 
117  return time;
118 }
119 
120 } // unnamed namespace
121 
122 
123 // Positive test case for a method
125 {
126  TestApplication application;
127  tet_infoline(" UtcDaliPropertyNotificationDownCast");
128 
129  Actor actor = Actor::New();
131  BaseHandle handle = notification;
132  PropertyNotification notificationHandle;
133 
134  DALI_TEST_CHECK(notification);
135  DALI_TEST_CHECK(handle);
136  DALI_TEST_CHECK(!notificationHandle);
137 
138  notificationHandle = PropertyNotification::DownCast( handle );
139  DALI_TEST_CHECK(notificationHandle);
140  END_TEST;
141 }
142 
143 
144 // Negative test case for a method
146 {
147  TestApplication application;
148  tet_infoline(" UtcDaliPropertyNotificationDownCastNegative");
149 
150  // Create something derived from BaseHandle other than a PropertyNotification.
151  Actor somethingElse = Actor::New();
152 
153  Actor actor = Actor::New();
155  BaseHandle handle = somethingElse;
156  PropertyNotification notificationHandle;
157 
158  notificationHandle = PropertyNotification::DownCast( handle );
159  DALI_TEST_CHECK(!notificationHandle);
160  END_TEST;
161 }
162 
164 {
165  TestApplication application; // Reset all test adapter return codes
166  tet_infoline(" UtcDaliAddPropertyNotification");
167 
168  Actor actor = Actor::New();
169 
171  DALI_TEST_CHECK( notification );
172  END_TEST;
173 }
174 
176 {
177  TestApplication application; // Reset all test adapter return codes
178 
179  TestClass* object = new TestClass;
180 
181  object->Initialize();
182  application.Render(RENDER_FRAME_INTERVAL);
183  application.SendNotification();
184 
185  gCallBackCalled = false;
186 
187  tet_infoline(" UtcDaliAddPropertyNotificationCallback - Forcing notification condition true, should receive a notification");
188  object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
189  application.Render(RENDER_FRAME_INTERVAL);
190  application.SendNotification();
191  application.Render(RENDER_FRAME_INTERVAL);
192  application.SendNotification();
194  gCallBackCalled = false;
195 
196  tet_infoline(" UtcDaliAddPropertyNotificationCallback - Forcing notification condition false, should not receive a notification");
197  object->mActor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
198  application.Render(RENDER_FRAME_INTERVAL);
199  application.SendNotification();
200  application.Render(RENDER_FRAME_INTERVAL);
201  application.SendNotification();
203  gCallBackCalled = false;
204 
205  tet_infoline(" UtcDaliAddPropertyNotificationCallback - Deleting notification and it's owning object, should not receive a notification");
206  object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
207  application.Render(RENDER_FRAME_INTERVAL);
208  application.SendNotification();
209  object->Terminate();
210  application.Render(RENDER_FRAME_INTERVAL);
211  application.SendNotification();
213 
214  tet_infoline(" UtcDaliAddPropertyNotificationCallback - Removing notification and it's owning object, should not receive a notification");
215  object->Initialize();
216  application.Render(RENDER_FRAME_INTERVAL);
217  application.SendNotification();
218  gCallBackCalled = false;
219 
220  object->RemovePropertyNotification();
221 
222  object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
223  application.Render(RENDER_FRAME_INTERVAL);
224  application.SendNotification();
225  application.Render(RENDER_FRAME_INTERVAL);
226  application.SendNotification();
228 
229  tet_infoline(" UtcDaliAddPropertyNotificationCallback - Removing all notifications and it's owning object, should not receive a notification");
230  object->Initialize();
231  application.Render(RENDER_FRAME_INTERVAL);
232  application.SendNotification();
233  gCallBackCalled = false;
234 
235  object->RemovePropertyNotifications();
236 
237  object->mActor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
238  application.Render(RENDER_FRAME_INTERVAL);
239  application.SendNotification();
240  application.Render(RENDER_FRAME_INTERVAL);
241  application.SendNotification();
243 
244 
245  delete object;
246  END_TEST;
247 }
248 
250 {
251  TestApplication application;
252 
253  Actor actor = Actor::New();
254 
255  // Currently, Type registry properties cannot be animated
256  try
257  {
259  }
260  catch ( DaliException& e )
261  {
262  DALI_TEST_ASSERT( e, "false && \"Property notification added to event side only property", TEST_LOCATION );
263  }
264  END_TEST;
265 }
266 
268 {
269  TestApplication application;
270  tet_infoline(" UtcDaliPropertyNotificationGetCondition");
271 
272  Actor actor = Actor::New();
273 
274  PropertyCondition condition = GreaterThanCondition(100.0f);
276  DALI_TEST_CHECK( condition == notification.GetCondition() );
277  END_TEST;
278 }
279 
281 {
282 public:
283 
285  :mPropertyNotification(propertyNotification)
286  {
287 
288  }
289 
294  const PropertyCondition& GetCondition() const
295  {
296  return mPropertyNotification.GetCondition();
297  }
298 
300 };
301 
303 {
304  TestApplication application;
305  tet_infoline(" UtcDaliPropertyNotificationGetConditionConst");
306 
307  Actor actor = Actor::New();
308 
309  PropertyCondition condition = GreaterThanCondition(100.0f);
311  PropertyNotificationConstWrapper notificationConst(notification);
312  const PropertyCondition& conditionReference1 = notificationConst.GetCondition();
313  const PropertyCondition& conditionReference2 = notificationConst.GetCondition();
314 
315  DALI_TEST_CHECK( (&conditionReference1) == (&conditionReference2) );
316  DALI_TEST_CHECK( conditionReference1 == condition );
317  END_TEST;
318 }
319 
321 {
322  TestApplication application;
323  tet_infoline(" UtcDaliPropertyNotificationGetTarget");
324 
325  Actor actor = Actor::New();
326  Actor actor2 = Actor::New();
327 
329  GreaterThanCondition(100.0f));
330  Actor targetActor = Actor::DownCast( notification.GetTarget() );
331 
332  DALI_TEST_CHECK( targetActor == actor );
333  END_TEST;
334 }
335 
337 {
338  TestApplication application;
339  tet_infoline(" UtcDaliPropertyNotificationGetProperty");
340 
341  Actor actor = Actor::New();
342 
344  GreaterThanCondition(100.0f));
345  Property::Index targetProperty = notification.GetTargetProperty();
346 
348  END_TEST;
349 }
350 
352 {
353  TestApplication application;
354  tet_infoline(" UtcDaliPropertyNotificationGetNotifyMode");
355 
356  Actor actor = Actor::New();
357 
359  GreaterThanCondition(100.0f));
361  PropertyNotification::NotifyMode notifyMode = notification.GetNotifyMode();
362 
364  END_TEST;
365 }
366 
368 {
369  TestApplication application;
370  tet_infoline(" UtcDaliPropertyNotificationGetNotifyMode");
371 
372  Actor actor = Actor::New();
373 
375  GreaterThanCondition(100.0f));
377  gCallBackCalled = false;
378  notification.NotifySignal().Connect( &TestCallback );
379 
380  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
381 
382  application.Render(RENDER_FRAME_INTERVAL);
383  application.SendNotification();
384  application.Render(RENDER_FRAME_INTERVAL);
385  application.SendNotification();
386 
387  bool notifyResult = notification.GetNotifyResult();
388 
389  DALI_TEST_EQUALS( notifyResult, false, TEST_LOCATION );
390 
391  END_TEST;
392 }
393 
395 {
396  TestApplication application;
397  tet_infoline(" UtcDaliPropertyNotificationGreaterThan");
398 
399  Actor actor = Actor::New();
400  Stage::GetCurrent().Add(actor);
401 
403  notification.NotifySignal().Connect( &TestCallback );
404 
405  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
406  Wait(application, DEFAULT_WAIT_PERIOD);
407 
408  // Move right to satisfy condition
409  gCallBackCalled = false;
410  actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
411  Wait(application, DEFAULT_WAIT_PERIOD);
413 
414  // Move left to un-satisfy condition
415  gCallBackCalled = false;
416  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
417  Wait(application, DEFAULT_WAIT_PERIOD);
419 
420  // Move right to satisfy condition again.
421  gCallBackCalled = false;
422  Wait(application, DEFAULT_WAIT_PERIOD);
423  actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
424  Wait(application, DEFAULT_WAIT_PERIOD);
426  END_TEST;
427 }
428 
430 {
431  TestApplication application;
432  tet_infoline(" UtcDaliPropertyNotificationLessThan");
433 
434  Actor actor = Actor::New();
435  Stage::GetCurrent().Add(actor);
436 
438  notification.NotifySignal().Connect( &TestCallback );
439 
440  actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
441  Wait(application, DEFAULT_WAIT_PERIOD);
442 
443  // Move left to satisfy condition
444  gCallBackCalled = false;
445  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
446  Wait(application, DEFAULT_WAIT_PERIOD);
448 
449  // Move right to un-satisfy condition
450  gCallBackCalled = false;
451  actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
452  Wait(application, DEFAULT_WAIT_PERIOD);
454 
455  // Move left to satisfy condition again.
456  gCallBackCalled = false;
457  Wait(application, DEFAULT_WAIT_PERIOD);
458  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
459  Wait(application, DEFAULT_WAIT_PERIOD);
461  END_TEST;
462 }
463 
465 {
466  TestApplication application;
467  tet_infoline(" UtcDaliPropertyNotificationInside");
468 
469  Actor actor = Actor::New();
470  Stage::GetCurrent().Add(actor);
471 
473  notification.NotifySignal().Connect( &TestCallback );
474 
475  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
476  Wait(application, DEFAULT_WAIT_PERIOD);
477 
478  // Move inside to satisfy condition
479  gCallBackCalled = false;
480  actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f));
481  Wait(application, DEFAULT_WAIT_PERIOD);
483 
484  // Move outside (right) to un-satisfy condition
485  gCallBackCalled = false;
486  actor.SetPosition(Vector3(300.0f, 0.0f, 0.0f));
487  Wait(application, DEFAULT_WAIT_PERIOD);
489 
490  // Move inside to satisfy condition again.
491  gCallBackCalled = false;
492  Wait(application, DEFAULT_WAIT_PERIOD);
493  actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f));
494  Wait(application, DEFAULT_WAIT_PERIOD);
496  END_TEST;
497 }
498 
500 {
501  TestApplication application;
502  tet_infoline(" UtcDaliPropertyNotificationOutside");
503 
504  Actor actor = Actor::New();
505  Stage::GetCurrent().Add(actor);
506 
508  notification.NotifySignal().Connect( &TestCallback );
509 
510  actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f));
511  Wait(application, DEFAULT_WAIT_PERIOD);
512 
513  // Move outside (left) to satisfy condition
514  gCallBackCalled = false;
515  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
516  Wait(application, DEFAULT_WAIT_PERIOD);
518 
519  // Move inside to un-satisfy condition
520  gCallBackCalled = false;
521  actor.SetPosition(Vector3(150.0f, 0.0f, 0.0f));
522  Wait(application, DEFAULT_WAIT_PERIOD);
524 
525  // Move outside (right) to satisfy condition again.
526  gCallBackCalled = false;
527  Wait(application, DEFAULT_WAIT_PERIOD);
528  actor.SetPosition(Vector3(300.0f, 0.0f, 0.0f));
529  Wait(application, DEFAULT_WAIT_PERIOD);
531  END_TEST;
532 }
533 
535 {
536  TestApplication application;
537  tet_infoline(" UtcDaliPropertyNotificationGreaterThan");
538 
539  Actor actor = Actor::New();
540  Stage::GetCurrent().Add(actor);
541 
543  notification.NotifySignal().Connect( &TestCallback );
544  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, GreaterThanCondition(100.0f) );
545  notification.NotifySignal().Connect( &TestCallback );
546  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, GreaterThanCondition(100.0f) );
547  notification.NotifySignal().Connect( &TestCallback );
548  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, GreaterThanCondition(0.5f) );
549  notification.NotifySignal().Connect( &TestCallback );
550 
551  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
552  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
553  Wait(application, DEFAULT_WAIT_PERIOD);
554 
555  // Move right to satisfy XAxis condition
556  gCallBackCalled = false;
557  actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
558  Wait(application, DEFAULT_WAIT_PERIOD);
560 
561  // Move down to satisfy YAxis condition
562  gCallBackCalled = false;
563  actor.SetPosition(Vector3(200.0f, 200.0f, 0.0f));
564  Wait(application, DEFAULT_WAIT_PERIOD);
566 
567  // Move forward to satisfy ZAxis
568  gCallBackCalled = false;
569  Wait(application, DEFAULT_WAIT_PERIOD);
570  actor.SetPosition(Vector3(200.0f, 200.0f, 200.0f));
571  Wait(application, DEFAULT_WAIT_PERIOD);
573 
574  // Change alpha Colour to satisfy w/alpha component condition
575  gCallBackCalled = false;
576  Wait(application, DEFAULT_WAIT_PERIOD);
577  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f));
578  Wait(application, DEFAULT_WAIT_PERIOD);
580  END_TEST;
581 }
582 
584 {
585  TestApplication application;
586  tet_infoline(" UtcDaliPropertyNotificationLessThan");
587 
588  Actor actor = Actor::New();
589  Stage::GetCurrent().Add(actor);
590 
592  notification.NotifySignal().Connect( &TestCallback );
593  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, LessThanCondition(-100.0f) );
594  notification.NotifySignal().Connect( &TestCallback );
595  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, LessThanCondition(-100.0f) );
596  notification.NotifySignal().Connect( &TestCallback );
597  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, LessThanCondition(0.5f) );
598  notification.NotifySignal().Connect( &TestCallback );
599 
600  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
601  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f));
602  Wait(application, DEFAULT_WAIT_PERIOD);
603 
604  // Move left to satisfy XAxis condition
605  gCallBackCalled = false;
606  actor.SetPosition(Vector3(-200.0f, 0.0f, 0.0f));
607  Wait(application, DEFAULT_WAIT_PERIOD);
609 
610  // Move up to satisfy YAxis condition
611  gCallBackCalled = false;
612  actor.SetPosition(Vector3(-200.0f, -200.0f, 0.0f));
613  Wait(application, DEFAULT_WAIT_PERIOD);
615 
616  // Move back to satisfy ZAxis
617  gCallBackCalled = false;
618  Wait(application, DEFAULT_WAIT_PERIOD);
619  actor.SetPosition(Vector3(-200.0f, -200.0f, -200.0f));
620  Wait(application, DEFAULT_WAIT_PERIOD);
622 
623  // Change alpha Colour to satisfy w/alpha component condition
624  gCallBackCalled = false;
625  Wait(application, DEFAULT_WAIT_PERIOD);
626  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.0f));
627  Wait(application, DEFAULT_WAIT_PERIOD);
629  END_TEST;
630 }
631 
633 {
634  TestApplication application;
635  tet_infoline(" UtcDaliPropertyNotificationInside");
636 
637  Actor actor = Actor::New();
638  Stage::GetCurrent().Add(actor);
639 
640  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, InsideCondition(-100.0f, 100.0f) );
641  notification.NotifySignal().Connect( &TestCallback );
642  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, InsideCondition(-100.0f, 100.0f) );
643  notification.NotifySignal().Connect( &TestCallback );
644  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, InsideCondition(-100.0f, 100.0f) );
645  notification.NotifySignal().Connect( &TestCallback );
646  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, InsideCondition(0.25f, 0.75f) );
647  notification.NotifySignal().Connect( &TestCallback );
648 
649  // set outside all conditions
650  actor.SetPosition(Vector3(200.0f, 200.0f, 200.0f));
651  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f));
652  Wait(application, DEFAULT_WAIT_PERIOD);
653 
654  // Move x to inside condition
655  gCallBackCalled = false;
656  actor.SetPosition(Vector3(0.0f, 200.0f, 200.0f));
657  Wait(application, DEFAULT_WAIT_PERIOD);
659 
660  // Move y to inside condition
661  gCallBackCalled = false;
662  actor.SetPosition(Vector3(0.0f, 0.0f, 200.0f));
663  Wait(application, DEFAULT_WAIT_PERIOD);
665 
666  // Move z to inside condition
667  gCallBackCalled = false;
668  Wait(application, DEFAULT_WAIT_PERIOD);
669  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
670  Wait(application, DEFAULT_WAIT_PERIOD);
672 
673  // change alpha to inside condition
674  gCallBackCalled = false;
675  Wait(application, DEFAULT_WAIT_PERIOD);
676  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.5f));
677  Wait(application, DEFAULT_WAIT_PERIOD);
679  END_TEST;
680 }
681 
683 {
684  TestApplication application;
685  tet_infoline(" UtcDaliPropertyNotificationOutside");
686 
687  Actor actor = Actor::New();
688  Stage::GetCurrent().Add(actor);
689 
690  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::POSITION, 0, OutsideCondition(-100.0f, 100.0f) );
691  notification.NotifySignal().Connect( &TestCallback );
692  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 1, OutsideCondition(-100.0f, 100.0f) );
693  notification.NotifySignal().Connect( &TestCallback );
694  notification = actor.AddPropertyNotification( Actor::Property::POSITION, 2, OutsideCondition(-100.0f, 100.0f) );
695  notification.NotifySignal().Connect( &TestCallback );
696  notification = actor.AddPropertyNotification( Actor::Property::COLOR, 3, OutsideCondition(0.25f, 0.75f) );
697  notification.NotifySignal().Connect( &TestCallback );
698 
699  // set inside all conditions
700  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
701  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 0.5f));
702  Wait(application, DEFAULT_WAIT_PERIOD);
703 
704  // Move x to outside condition
705  gCallBackCalled = false;
706  actor.SetPosition(Vector3(200.0f, 0.0f, 0.0f));
707  Wait(application, DEFAULT_WAIT_PERIOD);
709 
710  // Move y to outside condition
711  gCallBackCalled = false;
712  actor.SetPosition(Vector3(200.0f, 200.0f, 0.0f));
713  Wait(application, DEFAULT_WAIT_PERIOD);
715 
716  // Move z to outside condition
717  gCallBackCalled = false;
718  Wait(application, DEFAULT_WAIT_PERIOD);
719  actor.SetPosition(Vector3(200.0f, 200.0f, 200.0f));
720  Wait(application, DEFAULT_WAIT_PERIOD);
722 
723  // change alpha to outside condition
724  gCallBackCalled = false;
725  Wait(application, DEFAULT_WAIT_PERIOD);
726  actor.SetColor(Vector4(0.0f, 0.0f, 0.0f, 1.0f));
727  Wait(application, DEFAULT_WAIT_PERIOD);
729  END_TEST;
730 }
731 
733 {
734  TestApplication application;
735  tet_infoline(" UtcDaliPropertyConditionGetArguments");
736 
737  PropertyCondition condition = GreaterThanCondition( 50.0f );
738 
739  DALI_TEST_EQUALS( condition.GetArgumentCount(), 1u, TEST_LOCATION );
740  float value = condition.GetArgument( 0 );
741  DALI_TEST_EQUALS( value, 50.0f, TEST_LOCATION );
742 
743  condition = InsideCondition( 125.0f, 250.0f );
744 
745  DALI_TEST_EQUALS( condition.GetArgumentCount(), 2u, TEST_LOCATION );
746  float value1 = condition.GetArgument( 0 );
747  float value2 = condition.GetArgument( 1 );
748  DALI_TEST_EQUALS( value1, 125.0f, TEST_LOCATION );
749  DALI_TEST_EQUALS( value2, 250.0f, TEST_LOCATION );
750  END_TEST;
751 }
752 
754 {
755  TestApplication application;
756  tet_infoline(" UtcDaliPropertyNotificationStep");
757 
758  Actor actor = Actor::New();
759  Stage::GetCurrent().Add(actor);
760 
761  const float step = 100.0f;
762  // float
764  notification.NotifySignal().Connect( &TestCallback );
765 
766  // set initial position
767  actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
768  Wait(application, DEFAULT_WAIT_PERIOD);
769 
770  // test both directions
771  for( int i = 1 ; i < 10 ; ++i )
772  {
773  // Move x to negative position
774  gCallBackCalled = false;
775  actor.SetPosition(Vector3((i * step), 0.0f, 0.0f));
776  Wait(application, DEFAULT_WAIT_PERIOD);
778  }
779 
780  for( int i = 1 ; i < 10 ; ++i )
781  {
782  // Move x to negative position
783  gCallBackCalled = false;
784  actor.SetPosition(Vector3(-(i * step), 0.0f, 0.0f));
785  Wait(application, DEFAULT_WAIT_PERIOD);
787  }
788  END_TEST;
789 }
790 
792 {
793  TestApplication application;
794  tet_infoline(" UtcDaliPropertyNotificationStep");
795 
796  Actor actor = Actor::New();
797  Stage::GetCurrent().Add(actor);
798 
799  Dali::Vector<float> values;
800 
801  const float averageStep = 100.0f;
802 
803  for( int i = 1 ; i < 10 ; i++ )
804  {
805  values.PushBack(i * averageStep + (i % 2 == 0 ? -(averageStep * 0.2f) : (averageStep * 0.2f)));
806  }
807  // float
809  notification.NotifySignal().Connect( &TestCallback );
810 
811  // set initial position lower than first position in list
812  actor.SetPosition(Vector3(values[0] - averageStep, 0.0f, 0.0f));
813  Wait(application, DEFAULT_WAIT_PERIOD);
814 
815  for( unsigned int i = 0 ; i < values.Count() - 1 ; ++i )
816  {
817  gCallBackCalled = false;
818  // set position half way between the current values
819  float position = values[i] + (0.5f * (values[i + 1] - values[i]));
820  actor.SetPosition(Vector3(position, 0.0f, 0.0f));
821  Wait(application, DEFAULT_WAIT_PERIOD);
823  }
824  END_TEST;
825 }
826 
827 static bool gCallBack2Called = false;
829 {
830  gCallBack2Called = true;
831 }
832 
834 {
835  TestApplication application; // Reset all test adapter return codes
836 
837  Actor actor = Actor::New();
838  Stage::GetCurrent().Add(actor);
839  // this should complete in first frame
841  notification1.NotifySignal().Connect( &TestCallback );
842  // this should complete in second frame
844  notification2.NotifySignal().Connect( &TestCallback2 );
845  Animation animation = Animation::New( 0.032f ); // finishes in 32 ms
846  animation.AnimateTo( Property(actor, Actor::Property::POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), AlphaFunction::LINEAR );
847  animation.Play();
848 
849  // flush the queue
850  application.SendNotification();
851  // first frame
852  application.Render(RENDER_FRAME_INTERVAL);
853  // no notifications yet
856  gCallBackCalled = false;
857  gCallBack2Called = false;
858 
859  // dont serve the notifications but run another update & render
860  // this simulates situation where there is a notification in event side but it's not been picked up by event thread
861  // second frame
862  application.Render(RENDER_FRAME_INTERVAL);
865 
866  // serve the notifications
867  application.SendNotification();
870 
871  gCallBackCalled = false;
872  gCallBack2Called = false;
873  application.Render(RENDER_FRAME_INTERVAL);
874  application.SendNotification();
877 
878  END_TEST;
879 }
Dali Docs Home
Read more about Dali