Fix text outline property related native TCT
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-PushButton.cpp
1 /*
2  * Copyright (c) 2017 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 #include <stdlib.h>
20
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24
25 #include <dali.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit/dali-toolkit.h>
28
29 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
30
31 #include <dali/devel-api/adaptor-framework/image-loading.h>
32
33 using namespace Dali;
34 using namespace Toolkit;
35
36 void utc_dali_toolkit_pushbutton_startup(void)
37 {
38   test_return_value = TET_UNDEF;
39 }
40
41 void utc_dali_toolkit_pushbutton_cleanup(void)
42 {
43   test_return_value = TET_PASS;
44 }
45
46 namespace
47 {
48 static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
49 static const char* TEST_IMAGE_TWO = TEST_RESOURCE_DIR "/icon-delete.jpg";
50
51 static const Vector2 INSIDE_TOUCH_POINT_POSITON  = Vector2( 240, 400 );
52 static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS  = Vector3( 200, 360, 0 );
53 static const Size BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS  = Size( 100, 100 );
54
55 static bool gPushButtonSelectedState = false;
56 bool PushButtonSelected( Button button )
57 {
58   gPushButtonSelectedState = button.GetProperty<bool>(button.GetPropertyIndex("selected") );
59   return true;
60 }
61
62 static bool gPushButtonPressed = false;
63
64 static bool PushButtonPressed( Button button )
65 {
66   gPushButtonPressed = true;
67   return true;
68 }
69
70 static bool gPushButtonReleased = false;
71
72 static bool PushButtonReleased( Button button )
73 {
74   gPushButtonReleased = true;
75   return true;
76 }
77
78 static bool gPushButtonClicked = false;
79
80 static bool PushButtonClicked( Button button )
81 {
82   gPushButtonClicked = true;
83   return gPushButtonClicked;
84 }
85
86 Dali::Integration::Point GetPointDownInside()
87 {
88   Dali::Integration::Point point;
89   point.SetState( PointState::DOWN );
90   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
91   return point;
92 }
93
94 Dali::Integration::Point GetPointUpInside()
95 {
96   Dali::Integration::Point point;
97   point.SetState( PointState::UP );
98   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
99   return point;
100 }
101
102 Dali::Integration::Point GetPointLeave()
103 {
104   Dali::Integration::Point point;
105   point.SetState( PointState::LEAVE );
106   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
107   return point;
108 }
109
110 Dali::Integration::Point GetPointEnter()
111 {
112   Dali::Integration::Point point;
113   point.SetState( PointState::MOTION );
114   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
115   return point;
116 }
117
118 Dali::Integration::Point GetPointDownOutside()
119 {
120   Dali::Integration::Point point;
121   point.SetState( PointState::DOWN );
122   point.SetScreenPosition( Vector2( 10, 10 ) );
123   return point;
124 }
125
126 Dali::Integration::Point GetPointUpOutside()
127 {
128   Dali::Integration::Point point;
129   point.SetState( PointState::UP );
130   point.SetScreenPosition( Vector2( 10, 10 ) );
131   return point;
132 }
133
134 // Set up the position of the button for the default test events
135 void SetupButtonForTestTouchEvents( ToolkitTestApplication& application, Button& button, bool useDefaultImages )
136 {
137   button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
138   button.SetParentOrigin( ParentOrigin::TOP_LEFT );
139   button.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
140   if ( useDefaultImages )
141   {
142     const Vector2 TEST_IMAGE_SIZE = Vector2( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
143     TestPlatformAbstraction& platform = application.GetPlatform();
144     platform.SetClosestImageSize( TEST_IMAGE_SIZE );
145     button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
146     button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
147   }
148 }
149
150 static std::string GetButtonText( Button button )
151 {
152   Property::Value value = button.GetProperty( Toolkit::Button::Property::LABEL );
153
154   Property::Map *labelProperty = value.GetMap();
155
156   std::string textLabel;
157
158   if ( labelProperty )
159   {
160     Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT );
161     value->Get( textLabel );
162   }
163
164   return textLabel;
165 }
166
167 } //namespace
168
169 int UtcDaliPushButtonConstructorP(void)
170 {
171   TestApplication application;
172
173   PushButton button;
174
175   DALI_TEST_CHECK( !button );
176   END_TEST;
177 }
178
179 int UtcDaliPushButtonCopyConstructorP(void)
180 {
181   TestApplication application;
182
183   // Initialize an object, ref count == 1
184   PushButton button = PushButton::New();
185
186   PushButton copy( button );
187   DALI_TEST_CHECK( copy );
188   END_TEST;
189 }
190
191 int UtcDaliPushButtonAssignmentOperatorP(void)
192 {
193   TestApplication application;
194
195   PushButton button = PushButton::New();
196
197   PushButton copy( button );
198   DALI_TEST_CHECK( copy );
199
200   DALI_TEST_CHECK( button == copy );
201   END_TEST;
202 }
203
204 int UtcDaliPushButtonNewP(void)
205 {
206   TestApplication application;
207
208   PushButton button = PushButton::New();
209
210   DALI_TEST_CHECK( button );
211   END_TEST;
212 }
213
214 int UtcDaliPushButtonDownCastP(void)
215 {
216   TestApplication application;
217
218   PushButton button = PushButton::New();
219
220   BaseHandle object(button);
221
222   PushButton button2 = PushButton::DownCast( object );
223   DALI_TEST_CHECK(button2);
224
225   PushButton button3 = DownCast< PushButton >(object);
226   DALI_TEST_CHECK(button3);
227   END_TEST;
228 }
229
230 int UtcDaliPushButtonDownCastN(void)
231 {
232   TestApplication application;
233
234   BaseHandle unInitializedObject;
235
236   PushButton button1 = PushButton::DownCast( unInitializedObject );
237   DALI_TEST_CHECK( !button1 );
238
239   PushButton button2 = DownCast< PushButton >( unInitializedObject );
240   DALI_TEST_CHECK( !button2 );
241   END_TEST;
242 }
243
244 int UtcDaliPushButtonAutoRepeatingProperty(void)
245 {
246   ToolkitTestApplication application;
247   tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
248
249   PushButton pushButton = PushButton::New();
250
251   pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), true );
252   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
253
254   pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), false );
255   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
256
257   pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), true );
258   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
259
260     END_TEST;
261 }
262
263 int UtcDaliPushButtonSetAutoRepeating(void)
264 {
265   ToolkitTestApplication application;
266   tet_infoline("UtcDaliPushButtonSetAutoRepeating\n");
267   tet_infoline("Ensure setting AutoRepeating on a SELECTED Toggle button switches off Toggle\n");
268   PushButton pushButton = PushButton::New();
269
270   const bool INITIAL_TOGGLE_VALUE = true;
271   const bool INITIAL_SELECTED_VALUE = true;
272
273   pushButton.SetProperty( Button::Property::TOGGLABLE, INITIAL_TOGGLE_VALUE);
274   pushButton.SetProperty( Button::Property::SELECTED, INITIAL_SELECTED_VALUE );
275
276   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE  ), INITIAL_TOGGLE_VALUE , TEST_LOCATION );
277   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), INITIAL_SELECTED_VALUE , TEST_LOCATION );
278
279   pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
280
281   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), !INITIAL_TOGGLE_VALUE , TEST_LOCATION );
282
283   END_TEST;
284 }
285
286 int UtcDaliPushButtonTogglableProperty(void)
287 {
288   ToolkitTestApplication application;
289   tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
290
291   PushButton pushButton = PushButton::New();
292
293   pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
294   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
295
296   pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), false );
297   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), false, TEST_LOCATION );
298
299   pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
300   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
301
302   END_TEST;
303 }
304
305 int UtcDaliPushButtonAutoRepeatingPropertyAndTogglableButton(void)
306 {
307   ToolkitTestApplication application;
308   tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
309
310   PushButton pushButton = PushButton::New();
311
312   pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
313   pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
314
315   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
316   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
317
318   pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
319   pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
320
321   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
322   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), false, TEST_LOCATION );
323   END_TEST;
324 }
325
326 int UtcDaliPushButtonSelectedProperty01(void)
327 {
328   ToolkitTestApplication application;
329   tet_infoline(" UtcDaliPushButtonSetGetSelected01");
330
331   PushButton pushButton = PushButton::New();
332
333   pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
334
335   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
336
337   gPushButtonSelectedState = false;
338   pushButton.SetProperty( Button::Property::SELECTED, true );
339
340   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), true , TEST_LOCATION );
341   DALI_TEST_CHECK( gPushButtonSelectedState );
342
343   pushButton.SetProperty( Button::Property::SELECTED, false );
344
345   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), false , TEST_LOCATION );
346   DALI_TEST_CHECK( !gPushButtonSelectedState );
347
348   pushButton.SetProperty( Button::Property::SELECTED, true );
349
350   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), true , TEST_LOCATION );
351   DALI_TEST_CHECK( gPushButtonSelectedState );
352   END_TEST;
353 }
354
355 int UtcDaliPushButtonSelectedProperty02(void)
356 {
357   ToolkitTestApplication application;
358   tet_infoline(" UtcDaliPushButtonSetGetSelected02");
359
360   PushButton pushButton = PushButton::New();
361
362   pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), false );
363   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
364
365   gPushButtonSelectedState = false;
366   pushButton.SetProperty( Button::Property::SELECTED, true );
367
368   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), false , TEST_LOCATION );
369   DALI_TEST_CHECK( !gPushButtonSelectedState );
370
371   pushButton.SetProperty( Button::Property::SELECTED, false );
372
373   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), false , TEST_LOCATION );
374   DALI_TEST_CHECK( !gPushButtonSelectedState );
375
376   pushButton.SetProperty( Button::Property::SELECTED, true );
377
378   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), false , TEST_LOCATION );
379   DALI_TEST_CHECK( !gPushButtonSelectedState );
380   END_TEST;
381 }
382
383 int UtcDaliPushButtonAutorepeatingDelayPropertyValues01(void)
384 {
385   ToolkitTestApplication application;
386   tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
387
388   PushButton pushButton = PushButton::New();
389
390   pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
391
392   pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 1.f );
393
394   DALI_TEST_EQUALS( pushButton.GetProperty<float>(pushButton.GetPropertyIndex("initialAutoRepeatingDelay") ), 1.f, TEST_LOCATION );
395
396   END_TEST;
397 }
398
399 int UtcDaliPushButtonAutorepeatingDelayPropertyValues02(void)
400 {
401   ToolkitTestApplication application;
402   tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
403
404   PushButton pushButton = PushButton::New();
405
406   bool assert1( false );
407   bool assert2( false );
408
409   pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
410
411   try
412   {
413     pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, -1.f );
414   }
415   catch( Dali::DaliException& e )
416   {
417     DALI_TEST_PRINT_ASSERT( e );
418     DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
419     assert1 = true;
420   }
421
422   try
423   {
424     pushButton.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, -1.f );
425   }
426   catch( Dali::DaliException& e )
427   {
428     DALI_TEST_PRINT_ASSERT( e );
429     DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
430     assert2 = true;
431   }
432
433   DALI_TEST_CHECK( assert1 && assert2 );
434   END_TEST;
435 }
436
437 int UtcDaliPushButtonLabelProperty(void)
438 {
439   ToolkitTestApplication application;
440   tet_infoline(" UtcDaliPushButtonSetLabelText");
441
442   const std::string STR( "Hola!" );
443
444   PushButton pushButton = PushButton::New();
445
446   application.SendNotification();
447   application.Render();
448
449   pushButton.SetProperty( Toolkit::Button::Property::LABEL,
450                             Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
451                                            .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
452                           );
453
454
455   pushButton.SetProperty( Toolkit::Button::Property::LABEL, STR );
456
457   DALI_TEST_EQUALS( GetButtonText( pushButton ), STR, TEST_LOCATION );
458
459   END_TEST;
460 }
461
462 int UtcDaliPushButtonPressed(void)
463 {
464   ToolkitTestApplication application;
465   tet_infoline(" UtcDaliPushButtonPressed");
466
467   PushButton pushButton = PushButton::New();
468   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
469   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
470   pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
471   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
472
473   Stage::GetCurrent().Add( pushButton );
474
475   application.SendNotification();
476   application.Render();
477
478   gPushButtonPressed = false;
479
480   // connect to its touch signal
481   pushButton.PressedSignal().Connect( &PushButtonPressed );
482
483   Dali::Integration::TouchEvent eventDown;
484   eventDown.AddPoint( GetPointDownInside() );
485
486   // flush the queue and render once
487   application.SendNotification();
488   application.Render();
489   application.ProcessEvent( eventDown );
490
491   DALI_TEST_CHECK( gPushButtonPressed );
492   END_TEST;
493 }
494
495 int UtcDaliPushButtonReleased(void)
496 {
497   ToolkitTestApplication application;
498   tet_infoline(" UtcDaliPushButtonReleased");
499
500   PushButton pushButton = PushButton::New();
501   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
502   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
503   pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
504   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
505
506   Stage::GetCurrent().Add( pushButton );
507
508   application.SendNotification();
509   application.Render();
510
511   // connect to its touch signal
512   pushButton.ReleasedSignal().Connect( &PushButtonReleased );
513
514   Dali::Integration::TouchEvent event;
515
516   // Test1. Touch point down and up inside the button.
517
518   gPushButtonReleased = false;
519   event = Dali::Integration::TouchEvent();
520   event.AddPoint( GetPointDownInside() );
521   application.ProcessEvent( event );
522
523   event = Dali::Integration::TouchEvent();
524   event.AddPoint( GetPointUpInside() );
525   application.ProcessEvent( event );
526
527   DALI_TEST_CHECK( gPushButtonReleased );
528
529   // Test2. Touch point down and up outside the button.
530
531   gPushButtonReleased = false;
532   event = Dali::Integration::TouchEvent();
533   event.AddPoint( GetPointDownOutside() );
534   application.ProcessEvent( event );
535
536   event = Dali::Integration::TouchEvent();
537   event.AddPoint( GetPointUpOutside() );
538   application.ProcessEvent( event );
539
540   DALI_TEST_CHECK( !gPushButtonReleased );
541
542   // Test3. Touch point down inside and up outside the button.
543
544   gPushButtonReleased = false;
545   event = Dali::Integration::TouchEvent();
546   event.AddPoint( GetPointDownInside() );
547   application.ProcessEvent( event );
548
549   event = Dali::Integration::TouchEvent();
550   event.AddPoint( GetPointLeave() );
551   application.ProcessEvent( event );
552
553   event = Dali::Integration::TouchEvent();
554   event.AddPoint( GetPointUpOutside() );
555   application.ProcessEvent( event );
556
557   DALI_TEST_CHECK( gPushButtonReleased );
558
559   // Test4. Touch point down outside and up inside the button.
560
561   gPushButtonReleased = false;
562   event = Dali::Integration::TouchEvent();
563   event.AddPoint( GetPointDownOutside() );
564   application.ProcessEvent( event );
565
566   event = Dali::Integration::TouchEvent();
567   event.AddPoint( GetPointEnter() );
568   application.ProcessEvent( event );
569
570   event = Dali::Integration::TouchEvent();
571   event.AddPoint( GetPointUpInside() );
572   application.ProcessEvent( event );
573
574   DALI_TEST_CHECK( !gPushButtonReleased );
575   END_TEST;
576 }
577
578 int UtcDaliPushButtonSelected(void)
579 {
580   ToolkitTestApplication application;
581   tet_infoline(" UtcDaliPushButtonSelected");
582
583   PushButton pushButton = PushButton::New();
584   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
585   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
586   pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
587   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
588
589   Stage::GetCurrent().Add( pushButton );
590
591   application.SendNotification();
592   application.Render();
593
594   // connect to its touch signal
595   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
596
597   Dali::Integration::TouchEvent event;
598
599   // Test1. No togglable button.
600
601   gPushButtonSelectedState = false;
602   event = Dali::Integration::TouchEvent();
603   event.AddPoint( GetPointDownInside() );
604   application.ProcessEvent( event );
605
606   event = Dali::Integration::TouchEvent();
607   event.AddPoint( GetPointUpInside() );
608   application.ProcessEvent( event );
609
610   DALI_TEST_CHECK( !gPushButtonSelectedState );
611
612   // Set togglable property.
613   pushButton.SetProperty( Button::Property::TOGGLABLE, true );
614
615   // Test2. Touch point down and up inside the button twice.
616   gPushButtonSelectedState = false;
617   event = Dali::Integration::TouchEvent();
618   event.AddPoint( GetPointDownInside() );
619   application.ProcessEvent( event );
620
621   event = Dali::Integration::TouchEvent();
622   event.AddPoint( GetPointUpInside() );
623   application.ProcessEvent( event );
624
625   DALI_TEST_CHECK( gPushButtonSelectedState );
626
627   event = Dali::Integration::TouchEvent();
628   event.AddPoint( GetPointDownInside() );
629   application.ProcessEvent( event );
630
631   event = Dali::Integration::TouchEvent();
632   event.AddPoint( GetPointUpInside() );
633   application.ProcessEvent( event );
634
635   DALI_TEST_CHECK( !gPushButtonSelectedState );
636
637   // Test3. Touch point down and up outside the button.
638
639   gPushButtonSelectedState = false;
640   event = Dali::Integration::TouchEvent();
641   event.AddPoint( GetPointDownOutside() );
642   application.ProcessEvent( event );
643
644   event = Dali::Integration::TouchEvent();
645   event.AddPoint( GetPointUpOutside() );
646   application.ProcessEvent( event );
647
648   DALI_TEST_CHECK( !gPushButtonSelectedState );
649
650   // Test4. Touch point down inside and up outside the button.
651   //        State changes on Button down
652   gPushButtonSelectedState = false;
653   event = Dali::Integration::TouchEvent();
654   event.AddPoint( GetPointDownInside() );
655   application.ProcessEvent( event );
656
657   event = Dali::Integration::TouchEvent();
658   event.AddPoint( GetPointLeave() );
659   application.ProcessEvent( event );
660
661   event = Dali::Integration::TouchEvent();
662   event.AddPoint( GetPointUpOutside() );
663   application.ProcessEvent( event );
664
665   DALI_TEST_CHECK( gPushButtonSelectedState );
666
667   // Test5. Touch point down outside and up inside the button.
668   // Start in unselected state
669   pushButton.SetProperty( Button::Property::SELECTED, false );
670
671   DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("selected") ),false , TEST_LOCATION );
672
673   gPushButtonSelectedState = false;
674   event = Dali::Integration::TouchEvent();
675   event.AddPoint( GetPointDownOutside() );
676   application.ProcessEvent( event );
677
678   event = Dali::Integration::TouchEvent();
679   event.AddPoint( GetPointEnter() );
680   application.ProcessEvent( event );
681
682   event = Dali::Integration::TouchEvent();
683   event.AddPoint( GetPointUpInside() );
684   application.ProcessEvent( event );
685
686   DALI_TEST_CHECK( !gPushButtonSelectedState );
687   END_TEST;
688 }
689
690 int UtcDaliPushButtonPropertySetIconAlignment(void)
691 {
692   ToolkitTestApplication application;
693   tet_infoline(" UtcDaliPushButtonPropertySetIconAlignment");
694
695   PushButton pushButton = PushButton::New();
696   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
697   DALI_TEST_EQUALS( pushButton.GetProperty<std::string>( Toolkit::PushButton::Property::ICON_ALIGNMENT ), "TOP", TEST_LOCATION );
698
699   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
700   DALI_TEST_EQUALS( pushButton.GetProperty<std::string>( Toolkit::PushButton::Property::ICON_ALIGNMENT ), "RIGHT", TEST_LOCATION );
701
702   END_TEST;
703 }
704
705 int UtcDaliPushButtonPropertySetLabelPadding(void)
706 {
707   ToolkitTestApplication application;
708   tet_infoline(" UtcDaliPushButtonPropertySetLabelPadding");
709
710   PushButton pushButton = PushButton::New();
711   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
712   DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::LABEL_PADDING ), Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713
714   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
715   DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::LABEL_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
716
717   END_TEST;
718 }
719
720 int UtcDaliPushButtonPropertySetIconPadding(void)
721 {
722   ToolkitTestApplication application;
723   tet_infoline(" UtcDaliPushButtonPropertySetIconPadding");
724
725   PushButton pushButton = PushButton::New();
726   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
727   DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::ICON_PADDING ), Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
728
729   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
730   DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::ICON_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
731
732   END_TEST;
733 }
734
735 int UtcDaliPushButtonPaddingLayout(void)
736 {
737   ToolkitTestApplication application;
738   tet_infoline(" UtcDaliPushButtonPaddingLayout");
739
740   // This test creates padding for an icon and a label.
741   // The icon and label are each enabled and disabled to confirm the correct padding is used.
742   PushButton pushButton = PushButton::New();
743
744   const Vector4 TEST_ICON_PADDING( 20.0f, 20.0f, 20.0f, 20.0f );
745   const Vector4 TEST_LABEL_PADDING( 10.0f, 10.0f, 10.0f, 10.0f );
746
747   // Get actual size of test image
748   ImageDimensions testImageSize = Dali::GetClosestImageSize( TEST_IMAGE_ONE );
749   const Vector2 TEST_IMAGE_SIZE( testImageSize.GetWidth(), testImageSize.GetHeight() );
750
751   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
752   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
753   pushButton.SetPosition( 0.0f, 0.0f );
754   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
755
756   Stage::GetCurrent().Add( pushButton );
757
758   application.SendNotification();
759   application.Render();
760
761   // First test the size is zero.
762   // No padding should be added as there is no label or icon.
763   Vector2 size( Vector2::ZERO );
764   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
765   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
766   tet_printf( "Button Natural Size(%f,%f)\n", pushButton.GetNaturalSize().width, pushButton.GetNaturalSize().height );
767
768   DALI_TEST_EQUALS( size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
769
770   // Check label only padding
771   pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
772
773   application.SendNotification();
774   application.Render();
775
776   Vector2 sizeWithLabelWithoutPadding( Vector2::ZERO );
777   sizeWithLabelWithoutPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
778   sizeWithLabelWithoutPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
779
780   tet_printf( "Button RelayoutSize label without padding (%f,%f)\n", sizeWithLabelWithoutPadding.width, sizeWithLabelWithoutPadding.height );
781
782   // Add label padding to label
783   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
784   application.SendNotification();
785   application.Render();
786
787   Vector2 sizeLabelAndPadding( Vector2::ZERO );
788   sizeLabelAndPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
789   sizeLabelAndPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
790   tet_printf( "Button RelayoutSize after label padding(%f,%f)\n", sizeLabelAndPadding.width, sizeLabelAndPadding.height );
791
792   // If control size has increased beyond size of just label then padding has been applied
793   DALI_TEST_GREATER( sizeLabelAndPadding.width, sizeWithLabelWithoutPadding.width+TEST_LABEL_PADDING.x, TEST_LOCATION );
794   DALI_TEST_GREATER( sizeLabelAndPadding.height, sizeWithLabelWithoutPadding.height+TEST_LABEL_PADDING.w, TEST_LOCATION );
795
796   // Re-initialise the button so we can setup icon-only padding.
797   pushButton.Unparent();
798   pushButton = PushButton::New();
799
800   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
801   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
802   pushButton.SetPosition( 0.0f, 0.0f );
803   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
804
805   Stage::GetCurrent().Add( pushButton );
806
807
808   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
809   pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
810   pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
811
812   application.SendNotification();
813   application.Render();
814
815   // Size of button with just icon
816   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
817   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
818   tet_printf( "Button RelayoutSize with icon(%f,%f)\n", size.width, size.height );
819
820   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
821
822   application.SendNotification();
823   application.Render();
824   DALI_TEST_EQUALS( size, TEST_IMAGE_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
825
826   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
827   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
828   tet_printf( "Button RelayoutSize after icon padding(%f,%f)\n", size.width, size.height );
829   const Vector2 expectedIconAndPaddingSize( TEST_ICON_PADDING.x+TEST_ICON_PADDING.y+TEST_IMAGE_SIZE.width, TEST_ICON_PADDING.w + TEST_ICON_PADDING.z + TEST_IMAGE_SIZE.height );
830   DALI_TEST_EQUALS( size, expectedIconAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
831
832   // Now test padding for both label and icon simultaneously.
833   pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
834
835   application.SendNotification();
836   application.Render();
837
838   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
839   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
840   tet_printf( "Button RelayoutSize after label added(%f,%f)\n", size.width, size.height );
841
842   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
843
844   application.SendNotification();
845   application.Render();
846
847   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
848   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
849   tet_printf( "Button RelayoutSize after icon and label padding(%f,%f)\n", size.width, size.height );
850
851   DALI_TEST_EQUALS( size.width, sizeLabelAndPadding.width + expectedIconAndPaddingSize.width, TEST_LOCATION );
852   // Test height of control is same as icon and padding, as Text is smaller than icon
853   DALI_TEST_EQUALS( size.height, expectedIconAndPaddingSize.height, TEST_LOCATION );
854
855   END_TEST;
856 }
857
858 int UtcDaliPushButtonAlignmentLayout(void)
859 {
860   ToolkitTestApplication application;
861   tet_infoline(" UtcDaliPushButtonAlignmentLayout");
862
863   /*
864    * This test checks different alignments for the icon against the label.
865    * The icon is then moved around the label in each of it's alignments.
866    * The final relayed out size is checked to confirm the layout has been done correctly.
867    *
868    * There is an Icon which has 0 width and height, but with 75 padding on all sides.
869    *  - Therefore total width and height are both 150.
870    *
871    * There is a Label which has "an unknown" width and height, but with 30 padding on all sides.
872    *  - Therefore total width and height are 60+x and 60+y respectively.
873    *    Where x & y are the width and height of the text.
874    *
875    * The width of the button will always expand to the largest of the icon and label sizes (plus padding).
876    * So We use the padding to help us determine the orientation is correct for each alignment.
877    *
878    * |<- 150 ->|         |<-- 60+x -->|
879    *
880    * +---------+   -
881    * |         |   ^     +------------+   -
882    * |         |   |     |            |   ^
883    * |  Icon   |  150    |   Label    |  60+y
884    * |         |   |     |            |   v
885    * |         |   v     +------------+   -
886    * +---------+   -
887    */
888
889   const Vector4 TEST_ICON_PADDING( 70.0f, 70.0f, 70.0f, 70.0f );
890   const Vector4 TEST_LABEL_PADDING( 30.0f, 30.0f, 30.0f, 30.0f );
891
892   // Get actual size of test image
893   ImageDimensions testImageSize = Dali::GetClosestImageSize( TEST_IMAGE_ONE );
894   const Vector2 TEST_IMAGE_SIZE( testImageSize.GetWidth(), testImageSize.GetHeight() );
895
896   PushButton pushButton = PushButton::New();
897
898   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
899   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
900   pushButton.SetPosition( 0.0f, 0.0f );
901   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
902
903   Stage::GetCurrent().Add( pushButton );
904
905   // Add a label and get size of control
906   pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
907   application.SendNotification();
908   application.Render();
909
910   // First get the size of control with just label
911   Vector2 justLabelSize( Vector2::ZERO );
912   justLabelSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
913   justLabelSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
914   tet_printf( "Button RelayoutSize with just label and no padding(%f,%f)\n", justLabelSize.width, justLabelSize.height );
915
916   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
917   application.SendNotification();
918   application.Render();
919
920   // Size of Label and Padding
921   Vector2 expectedLabelAndPaddingSize( Vector2::ZERO );
922   expectedLabelAndPaddingSize.width = justLabelSize.width + TEST_LABEL_PADDING.x + TEST_LABEL_PADDING.y;
923   expectedLabelAndPaddingSize.height = justLabelSize.height + TEST_LABEL_PADDING.w + TEST_LABEL_PADDING.z;
924
925   Vector2 labelAndPaddingSize( Vector2::ZERO );
926   labelAndPaddingSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
927   labelAndPaddingSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
928
929   DALI_TEST_EQUALS( labelAndPaddingSize, expectedLabelAndPaddingSize , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
930
931   const Vector2 testImageWithPaddingSize = Vector2 ( ( TEST_IMAGE_SIZE.width + TEST_ICON_PADDING.x + TEST_ICON_PADDING.y ),
932                                                      ( TEST_IMAGE_SIZE.height + TEST_ICON_PADDING.w + TEST_ICON_PADDING.z ) );
933
934   // Add Icon and set its alignment
935   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
936   pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
937   pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
938   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
939
940   application.SendNotification();
941   application.Render();
942
943   Vector2 size( Vector2::ZERO );
944   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
945   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
946
947   /*
948    * Test Icon right alignment.
949    * Height grows to largest of Icon or Label (+ padding).
950    * Normally this will be Icons height, except with very large font sizes.
951    *
952    *  +------------+---------+
953    *  |............+         |
954    *  |            |         |
955    *  |   Label    |  Icon   |
956    *  |            |         |
957    *  |............+         |
958    *  +------------+---------+
959    */
960   DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
961   DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
962
963   // Now test left alignment matches right for size.
964   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "LEFT" );
965
966   application.SendNotification();
967   application.Render();
968
969   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
970   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
971
972   /*
973    * Test Icon left alignment.
974    * Height grows to largest of Icon or Label (+ padding).
975    * Normally this will be Icons height, except with very large font sizes.
976    *
977    *  +---------+------------+
978    *  |         +............|
979    *  |         |            |
980    *  |  Icon   |   Label    |
981    *  |         |            |
982    *  |         +............|
983    *  +---------+------------+
984    */
985   DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
986   DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
987
988   tet_infoline(" Test Icon TOP alignment - Width grows to largest of Icon or label (plus padding)");
989   /*
990    *
991    *  +---------+
992    *  |         |
993    *  |         |
994    *  |  Icon   |
995    *  |         |
996    *  |         |
997    *  +---------+
998    *  |         |
999    *  |  Label  |
1000    *  |         |
1001    *  +---------+
1002    *
1003    */
1004
1005   tet_infoline("SetProperty on ICON_ALIGNMENT should relayout the Button");
1006   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
1007
1008   application.SendNotification();
1009   application.Render();
1010
1011   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
1012   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
1013
1014   tet_printf("Natural width (%f)\n",pushButton.GetNaturalSize().width);
1015   tet_printf("Natural height (%f)\n",pushButton.GetNaturalSize().height);
1016
1017   tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Image and Padding size (%f,%f)\n", testImageWithPaddingSize.width, testImageWithPaddingSize.height );
1018   tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Text and Padding size (%f,%f)\n", labelAndPaddingSize.width, labelAndPaddingSize.height );
1019
1020   DALI_TEST_EQUALS( size.width, ( std::max( testImageWithPaddingSize.width, labelAndPaddingSize.width ) ) , TEST_LOCATION );
1021
1022   DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1023
1024   /*
1025    * Test Icon bottom alignment.
1026    * Width grows to largest of Icon or Label (+ padding).
1027    *
1028    *  +---------+
1029    *  |         |
1030    *  |  Label  |
1031    *  |         |
1032    *  +---------+
1033    *  |         |
1034    *  |         |
1035    *  |  Icon   |
1036    *  |         |
1037    *  |         |
1038    *  +---------+
1039    */
1040   tet_infoline(" Test Icon BOTTOM alignment - Width grows to largest of Icon or label (plus padding)");
1041   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "BOTTOM" );
1042
1043   application.SendNotification();
1044   application.Render();
1045
1046   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
1047   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
1048
1049   DALI_TEST_EQUALS( size.width, ( std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width )) , TEST_LOCATION );
1050   DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1051
1052   END_TEST;
1053 }
1054
1055 int UtcDaliPushButtonSetUnSelectedVisual01P(void)
1056 {
1057   tet_infoline(" Test adding a visual for the UNSELECTED_VISUAL property, removing Button from stage and counting renderers\n");
1058   ToolkitTestApplication application;
1059
1060   PushButton pushButton = PushButton::New();
1061   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
1062
1063   Stage::GetCurrent().Add( pushButton );
1064
1065   Property::Map propertyMap;
1066   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
1067   propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1068
1069   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
1070
1071   tet_infoline(" UNSELECTED_VISUAL Added to button\n");
1072
1073   application.SendNotification();
1074   application.Render(0);
1075
1076   unsigned int rendererCount = pushButton.GetRendererCount();
1077   tet_printf("After adding UNSELECTED_BACKGROUND_VISUAL the renderer count is(%d)\n", rendererCount );
1078
1079   DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1 , TEST_LOCATION );
1080
1081   tet_printf("Remove button from stage\n" );
1082
1083   Stage::GetCurrent().Remove( pushButton );
1084
1085   rendererCount = pushButton.GetRendererCount();
1086   tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1087
1088   DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
1089
1090   tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1091
1092   Property::Map propertyMap2;
1093   propertyMap2.Insert(Visual::Property::TYPE,  Visual::COLOR);
1094   propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, Color::RED);
1095   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, propertyMap2 );
1096
1097   tet_printf("Added UNSELECTED_VISUAL and add button back to Stage\n");
1098
1099   Stage::GetCurrent().Add( pushButton );
1100
1101   tet_printf("With UNSELECTED_BACKGROUND_VISUAL and UNSELECTED_ICON the renderer count is(%d)\n", pushButton.GetRendererCount() );
1102
1103   DALI_TEST_EQUALS( pushButton.GetRendererCount(), 2, TEST_LOCATION );
1104
1105   END_TEST;
1106 }
1107
1108 int UtcDaliPushButtonSetSelectedVisualN(void)
1109 {
1110   tet_infoline(" Test adding a broken visual for the UNSELECTED_VISUAL property");
1111
1112   ToolkitTestApplication application;
1113
1114   PushButton pushButton = PushButton::New();
1115
1116   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1117   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
1118   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1119
1120   Stage::GetCurrent().Add( pushButton );
1121   application.SendNotification();
1122   application.Render(0);
1123
1124   unsigned int preRendererCount = pushButton.GetRendererCount();
1125   tet_printf("RendererCount prior to adding visual(%d)\n",preRendererCount);
1126   DALI_TEST_EQUALS( preRendererCount, 0, TEST_LOCATION );
1127
1128   Stage::GetCurrent().Remove( pushButton );
1129   application.SendNotification();
1130   application.Render(0);
1131
1132   Property::Map colorMap;
1133   const int BROKEN_VISUAL_TYPE = 999999999;
1134
1135   colorMap.Insert(Visual::Property::TYPE,  BROKEN_VISUAL_TYPE);
1136   colorMap.Insert(BorderVisual::Property::COLOR,  Color::BLUE);
1137   colorMap.Insert(BorderVisual::Property::SIZE,  5.f);
1138   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, colorMap );
1139
1140   Stage::GetCurrent().Add( pushButton );
1141   application.SendNotification();
1142   application.Render(0);
1143
1144   unsigned int postRendererCount  = pushButton.GetRendererCount();
1145   tet_printf("RendererCount post broken visual (%d)\n", postRendererCount);
1146   DALI_TEST_EQUALS( postRendererCount, 0, TEST_LOCATION );
1147
1148   END_TEST;
1149 }
1150
1151 int UtcDaliPushButtonSetButtonImageP(void)
1152 {
1153   ToolkitTestApplication application;
1154
1155   PushButton button = PushButton::New();
1156   Stage::GetCurrent().Add( button );
1157
1158   try
1159   {
1160     button.SetButtonImage( ImageView::New() );
1161     DALI_TEST_CHECK( true );
1162   }
1163   catch(...)
1164   {
1165     DALI_TEST_CHECK( false );
1166   }
1167
1168   END_TEST;
1169 }
1170
1171 int UtcDaliPushButtonSetBackgroundImageP(void)
1172 {
1173   ToolkitTestApplication application;
1174
1175   PushButton button = PushButton::New();
1176   Stage::GetCurrent().Add( button );
1177
1178   try
1179   {
1180     button.SetBackgroundImage( ImageView::New() );
1181     DALI_TEST_CHECK( true );
1182   }
1183   catch(...)
1184   {
1185     DALI_TEST_CHECK( false );
1186   }
1187
1188   END_TEST;
1189 }
1190
1191 int UtcDaliPushButtonSetSelectedImageP(void)
1192 {
1193   ToolkitTestApplication application;
1194
1195   PushButton button = PushButton::New();
1196   Stage::GetCurrent().Add( button );
1197
1198   try
1199   {
1200     button.SetSelectedImage( ImageView::New() );
1201     DALI_TEST_CHECK( true );
1202   }
1203   catch(...)
1204   {
1205     DALI_TEST_CHECK( false );
1206   }
1207
1208   END_TEST;
1209 }
1210
1211 int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
1212 {
1213   ToolkitTestApplication application;
1214
1215   PushButton button = PushButton::New();
1216   Stage::GetCurrent().Add( button );
1217
1218   try
1219   {
1220     button.SetSelectedBackgroundImage( ImageView::New() );
1221     DALI_TEST_CHECK( true );
1222   }
1223   catch(...)
1224   {
1225     DALI_TEST_CHECK( false );
1226   }
1227
1228   END_TEST;
1229 }
1230
1231 int UtcDaliPushButtonSetDisabledBackgroundImageP(void)
1232 {
1233   ToolkitTestApplication application;
1234
1235   PushButton button = PushButton::New();
1236   Stage::GetCurrent().Add( button );
1237
1238   try
1239   {
1240     button.SetDisabledBackgroundImage( ImageView::New() );
1241     DALI_TEST_CHECK( true );
1242   }
1243   catch(...)
1244   {
1245     DALI_TEST_CHECK( false );
1246   }
1247
1248   END_TEST;
1249 }
1250
1251
1252 int UtcDaliPushButtonSetDisabledImageP(void)
1253 {
1254   ToolkitTestApplication application;
1255
1256   PushButton button = PushButton::New();
1257   Stage::GetCurrent().Add( button );
1258
1259   try
1260   {
1261     button.SetDisabledImage( ImageView::New() );
1262     DALI_TEST_CHECK( true );
1263   }
1264   catch(...)
1265   {
1266     DALI_TEST_CHECK( false );
1267   }
1268
1269   END_TEST;
1270 }
1271
1272 int UtcDaliPushButtonSetDisabledSelectedImageP(void)
1273 {
1274   ToolkitTestApplication application;
1275
1276   PushButton button = PushButton::New();
1277   Stage::GetCurrent().Add( button );
1278
1279   try
1280   {
1281     button.SetDisabledSelectedImage( ImageView::New() );
1282     DALI_TEST_CHECK( true );
1283   }
1284   catch(...)
1285   {
1286     DALI_TEST_CHECK( false );
1287   }
1288
1289   END_TEST;
1290 }
1291
1292 int UtcDaliPushButtonToggleSignalP(void)
1293 {
1294   ToolkitTestApplication application;
1295   tet_infoline(" UtcDaliButtonToggleSignalP Ensure Signals emitted");
1296
1297   PushButton button = PushButton::New();
1298   button.SetProperty( Button::Property::TOGGLABLE, true);
1299
1300   SetupButtonForTestTouchEvents( application, button, true );
1301
1302   Stage::GetCurrent().Add( button );
1303
1304   application.SendNotification();
1305   application.Render();
1306
1307   // connect to its signal
1308   button.ClickedSignal().Connect( &PushButtonClicked );
1309   gPushButtonClicked = false;
1310
1311   tet_infoline(" Touch down and up within button");
1312   Dali::Integration::TouchEvent event;
1313   event = Dali::Integration::TouchEvent();
1314   event.AddPoint( GetPointDownInside() );
1315   application.ProcessEvent( event );
1316
1317   event = Dali::Integration::TouchEvent();
1318   event.AddPoint( GetPointUpInside() );
1319   application.ProcessEvent( event );
1320
1321   DALI_TEST_EQUALS( gPushButtonClicked, true, TEST_LOCATION );
1322
1323   END_TEST;
1324 }
1325
1326 // Deprecated API Tests
1327
1328 int UtcDaliPushButtonSetGetAutoRepeating(void)
1329 {
1330   ToolkitTestApplication application;
1331   tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
1332
1333   PushButton pushButton = PushButton::New();
1334
1335   pushButton.SetAutoRepeating( true );
1336
1337   DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
1338
1339   pushButton.SetAutoRepeating( false );
1340
1341   DALI_TEST_CHECK( !pushButton.IsAutoRepeating() );
1342
1343   pushButton.SetAutoRepeating( true );
1344
1345   DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
1346   END_TEST;
1347 }
1348
1349 int UtcDaliPushButtonSetGetTogglableButton(void)
1350 {
1351   ToolkitTestApplication application;
1352   tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
1353
1354   PushButton pushButton = PushButton::New();
1355
1356   pushButton.SetTogglableButton( true );
1357
1358   DALI_TEST_CHECK( pushButton.IsTogglableButton() );
1359
1360   pushButton.SetTogglableButton( false );
1361
1362   DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
1363
1364   pushButton.SetTogglableButton( true );
1365
1366   DALI_TEST_CHECK( pushButton.IsTogglableButton() );
1367   END_TEST;
1368 }
1369
1370 int UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton(void)
1371 {
1372   ToolkitTestApplication application;
1373   tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
1374
1375   PushButton pushButton = PushButton::New();
1376
1377   pushButton.SetAutoRepeating( true );
1378   pushButton.SetTogglableButton( true );
1379
1380   DALI_TEST_CHECK( pushButton.IsTogglableButton() );
1381   DALI_TEST_CHECK( !pushButton.IsAutoRepeating() );
1382
1383   pushButton.SetTogglableButton( true );
1384   pushButton.SetAutoRepeating( true );
1385
1386   DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
1387   DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
1388   END_TEST;
1389 }
1390
1391 int UtcDaliPushButtonSetGetSelected01(void)
1392 {
1393   ToolkitTestApplication application;
1394   tet_infoline(" UtcDaliPushButtonSetGetSelected01");
1395
1396   PushButton pushButton = PushButton::New();
1397
1398   pushButton.SetTogglableButton( true );
1399   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
1400
1401   gPushButtonSelectedState = false;
1402   pushButton.SetSelected( true );
1403
1404   DALI_TEST_CHECK( pushButton.IsSelected() );
1405   DALI_TEST_CHECK( gPushButtonSelectedState );
1406
1407   pushButton.SetSelected( false );
1408
1409   DALI_TEST_CHECK( !pushButton.IsSelected() );
1410   DALI_TEST_CHECK( !gPushButtonSelectedState );
1411
1412   pushButton.SetSelected( true );
1413
1414   DALI_TEST_CHECK( pushButton.IsSelected() );
1415   DALI_TEST_CHECK( gPushButtonSelectedState );
1416   END_TEST;
1417 }
1418
1419 int UtcDaliPushButtonSetGetSelected02(void)
1420 {
1421   ToolkitTestApplication application;
1422   tet_infoline(" UtcDaliPushButtonSetGetSelected02");
1423
1424   PushButton pushButton = PushButton::New();
1425
1426   pushButton.SetTogglableButton( false );
1427   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
1428
1429   gPushButtonSelectedState = false;
1430   pushButton.SetSelected( true );
1431
1432   DALI_TEST_CHECK( !pushButton.IsSelected() );
1433   DALI_TEST_CHECK( !gPushButtonSelectedState );
1434
1435   pushButton.SetSelected( false );
1436
1437   DALI_TEST_CHECK( !pushButton.IsSelected() );
1438   DALI_TEST_CHECK( !gPushButtonSelectedState );
1439
1440   pushButton.SetSelected( true );
1441
1442   DALI_TEST_CHECK( !pushButton.IsSelected() );
1443   DALI_TEST_CHECK( !gPushButtonSelectedState );
1444   END_TEST;
1445 }
1446
1447 int UtcDaliPushButtonSetGetAutorepeatingDelayValues01(void)
1448 {
1449   ToolkitTestApplication application;
1450   tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
1451
1452   PushButton pushButton = PushButton::New();
1453
1454   pushButton.SetAutoRepeating( true );
1455
1456   pushButton.SetInitialAutoRepeatingDelay( 1.f );
1457   DALI_TEST_EQUALS( pushButton.GetInitialAutoRepeatingDelay(), 1.f, TEST_LOCATION );
1458
1459   pushButton.SetNextAutoRepeatingDelay( 1.f );
1460   DALI_TEST_EQUALS( pushButton.GetNextAutoRepeatingDelay(), 1.f, TEST_LOCATION );
1461   END_TEST;
1462 }
1463
1464 int UtcDaliPushButtonSetGetAutorepeatingDelayValues02(void)
1465 {
1466   ToolkitTestApplication application;
1467   tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
1468
1469   PushButton pushButton = PushButton::New();
1470
1471   bool assert1( false );
1472   bool assert2( false );
1473
1474   pushButton.SetAutoRepeating( true );
1475
1476   try
1477   {
1478     pushButton.SetInitialAutoRepeatingDelay( -1.f );
1479   }
1480   catch( Dali::DaliException& e )
1481   {
1482     DALI_TEST_PRINT_ASSERT( e );
1483     DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
1484     assert1 = true;
1485   }
1486
1487   try
1488   {
1489     pushButton.SetNextAutoRepeatingDelay( -1.f );
1490   }
1491   catch( Dali::DaliException& e )
1492   {
1493     DALI_TEST_PRINT_ASSERT( e );
1494     DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
1495     assert2 = true;
1496   }
1497
1498   DALI_TEST_CHECK( assert1 && assert2 );
1499   END_TEST;
1500 }
1501
1502 int UtcDaliPushButtonSetLabelText(void)
1503 {
1504   ToolkitTestApplication application;
1505   tet_infoline(" UtcDaliPushButtonSetLabelText");
1506
1507   const std::string STR( "Hola!" );
1508
1509   PushButton pushButton = PushButton::New();
1510
1511   pushButton.SetProperty( Toolkit::Button::Property::LABEL,
1512                           Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
1513                                          .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
1514                         );
1515
1516   application.SendNotification();
1517   application.Render();
1518
1519   pushButton.SetLabelText( STR );
1520
1521   DALI_TEST_EQUALS( pushButton.GetLabelText(), STR, TEST_LOCATION );
1522
1523   END_TEST;
1524 }
1525
1526 int UtcDaliPushButtonSetButtonImageDeprecatedP(void)
1527 {
1528   ToolkitTestApplication application;
1529   Image setButtonImage = ResourceImage::New( TEST_IMAGE_ONE);
1530   PushButton pushButton = PushButton::New();
1531   pushButton.SetButtonImage( setButtonImage );
1532   Image retreivedButtonImage = ImageView::DownCast(pushButton.GetButtonImage()).GetImage();
1533   DALI_TEST_EQUALS( retreivedButtonImage, setButtonImage ,  TEST_LOCATION );
1534
1535   END_TEST;
1536 }
1537
1538 int UtcDaliPushButtonSetSelectedImageDeprecatedP(void)
1539 {
1540   ToolkitTestApplication application;
1541   Image setButtonImage = ResourceImage::New( TEST_IMAGE_ONE);
1542   PushButton pushButton = PushButton::New();
1543   pushButton.SetSelectedImage( setButtonImage );
1544   Image retreivedButtonImage = ImageView::DownCast(pushButton.GetSelectedImage()).GetImage();
1545   DALI_TEST_EQUALS( retreivedButtonImage, setButtonImage ,  TEST_LOCATION );
1546
1547   END_TEST;
1548 }
1549
1550 int UtcDaliPushButtonGetButtonImageURLDeprecatedP(void)
1551 {
1552   tet_infoline(" UtcDaliPushButtonGetButtonImageURLDeprecatedP Testing mix use of API");
1553
1554   ToolkitTestApplication application;
1555
1556   PushButton pushButton = PushButton::New();
1557   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
1558
1559   ImageView retreivedButtonImageView = ImageView::DownCast(pushButton.GetButtonImage());
1560   Image retreivedButtonImage = retreivedButtonImageView.GetImage();
1561   ResourceImage resourceImage = ResourceImage::DownCast( retreivedButtonImage );
1562
1563   DALI_TEST_EQUALS( resourceImage.GetUrl(), TEST_IMAGE_ONE ,  TEST_LOCATION );
1564
1565   END_TEST;
1566 }
1567
1568 int UtcDaliPushButtonGetSelectedImageURLDeprecatedP(void)
1569 {
1570   tet_infoline(" UtcDaliPushButtonGetSelectedImageURLDeprecatedP Testing mix use of API");
1571
1572   ToolkitTestApplication application;
1573
1574   PushButton pushButton = PushButton::New();
1575
1576   pushButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
1577
1578   Image retreivedButtonImage = ImageView::DownCast(pushButton.GetSelectedImage()).GetImage();
1579   ResourceImage resourceImage = ResourceImage::DownCast( retreivedButtonImage );
1580   DALI_TEST_EQUALS( resourceImage.GetUrl(), TEST_IMAGE_ONE ,  TEST_LOCATION );
1581
1582   END_TEST;
1583 }
1584
1585 int UtcDaliPushButtonSetSelectedImageWithActorDeprecatedP(void)
1586 {
1587   tet_infoline(" UtcDaliPushButton SetSelectedImage With ImageView (Actor)");
1588
1589   ToolkitTestApplication application;
1590
1591   Image image = ResourceImage::New( TEST_IMAGE_ONE );
1592
1593   DALI_TEST_CHECK( image );
1594
1595   ImageView imgViewSet = ImageView::New(image);
1596
1597   DALI_TEST_CHECK(imgViewSet );
1598
1599   PushButton pushButton = PushButton::New();
1600
1601   DALI_TEST_CHECK( pushButton );
1602
1603   pushButton.SetSelectedImage( imgViewSet );
1604
1605   ImageView imageView = ImageView::DownCast( pushButton.GetSelectedImage());
1606
1607   DALI_TEST_CHECK( imageView );
1608
1609   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1610   Property::Map map;
1611   value.Get( map );
1612   DALI_TEST_CHECK( !map.Empty() );
1613   DALI_TEST_EQUALS( map[ "filename" ].Get<std::string>(), TEST_IMAGE_ONE , TEST_LOCATION );
1614
1615   END_TEST;
1616 }
1617
1618 int UtcDaliPushButtonSetButtonImageWithActorDeprecatedP(void)
1619 {
1620   tet_infoline(" UtcDaliPushButton SetButtonImage With ImageView (Actor)");
1621
1622   ToolkitTestApplication application;
1623
1624   Image image = ResourceImage::New( TEST_IMAGE_ONE );
1625
1626   DALI_TEST_CHECK( image );
1627
1628   ImageView imgViewSet = ImageView::New(image);
1629
1630   DALI_TEST_CHECK(imgViewSet );
1631
1632   PushButton pushButton = PushButton::New();
1633
1634   DALI_TEST_CHECK( pushButton );
1635
1636   pushButton.SetButtonImage( imgViewSet );
1637
1638   ImageView imageView = ImageView::DownCast( pushButton.GetButtonImage());
1639
1640   DALI_TEST_CHECK( imageView );
1641
1642   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1643   Property::Map map;
1644   value.Get( map );
1645   DALI_TEST_CHECK( !map.Empty() );
1646   DALI_TEST_EQUALS( map[ "filename" ].Get<std::string>(), TEST_IMAGE_ONE , TEST_LOCATION );
1647
1648   END_TEST;
1649 }
1650
1651 int UtcDaliPushButtonSetBackgroundImageWithActorDeprecatedP(void)
1652 {
1653   tet_infoline(" UtcDaliPushButton SetBackgroundImage With ImageView (Actor)");
1654
1655   ToolkitTestApplication application;
1656
1657   Image image = ResourceImage::New( TEST_IMAGE_ONE );
1658
1659   DALI_TEST_CHECK( image );
1660
1661   ImageView imgViewSet = ImageView::New(image);
1662
1663   DALI_TEST_CHECK(imgViewSet );
1664
1665   PushButton pushButton = PushButton::New();
1666
1667   DALI_TEST_CHECK( pushButton );
1668
1669   pushButton.SetBackgroundImage( imgViewSet );
1670
1671   ImageView imageView = ImageView::DownCast( pushButton.GetButtonImage());
1672
1673   DALI_TEST_CHECK( imageView );
1674
1675   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1676   Property::Map map;
1677   value.Get( map );
1678   DALI_TEST_CHECK( !map.Empty() );
1679   DALI_TEST_EQUALS( map[ "filename" ].Get<std::string>(), TEST_IMAGE_ONE , TEST_LOCATION );
1680
1681   END_TEST;
1682 }
1683
1684
1685 int UtcDaliPushButtonSetSelectedBackgroundImageWithActorDeprecatedP(void)
1686 {
1687   tet_infoline(" UtcDaliPushButton SetSelectedBackgroundImage With ImageView (Actor)");
1688
1689   ToolkitTestApplication application;
1690
1691   Image image = ResourceImage::New( TEST_IMAGE_ONE );
1692
1693   DALI_TEST_CHECK( image );
1694
1695   ImageView imgViewSet = ImageView::New(image);
1696
1697   DALI_TEST_CHECK(imgViewSet );
1698
1699   PushButton pushButton = PushButton::New();
1700
1701   DALI_TEST_CHECK( pushButton );
1702
1703   pushButton.SetSelectedBackgroundImage( imgViewSet );
1704
1705   ImageView imageView = ImageView::DownCast( pushButton.GetSelectedImage());
1706
1707   DALI_TEST_CHECK( imageView );
1708
1709   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
1710   Property::Map map;
1711   value.Get( map );
1712   DALI_TEST_CHECK( !map.Empty() );
1713   DALI_TEST_EQUALS( map[ "filename" ].Get<std::string>(), TEST_IMAGE_ONE , TEST_LOCATION );
1714
1715   END_TEST;
1716 }
1717
1718 int UtcDaliPushButtonSetDisabledBackgroundImageWithActorDeprecatedP(void)
1719 {
1720   tet_infoline(" UtcDaliPushButton SetDisabledBackgroundImage With ImageView (Actor)");
1721
1722   ToolkitTestApplication application;
1723
1724   Image image = ResourceImage::New( TEST_IMAGE_ONE );
1725
1726   DALI_TEST_CHECK( image );
1727
1728   ImageView imgViewSet = ImageView::New(image);
1729
1730   DALI_TEST_CHECK(imgViewSet );
1731
1732   PushButton pushButton = PushButton::New();
1733
1734   DALI_TEST_CHECK( pushButton );
1735
1736   pushButton.SetDisabledBackgroundImage( imgViewSet );
1737
1738   Property::Value value = pushButton.GetProperty( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL );
1739   Property::Map map;
1740   value.Get( map );
1741
1742   Property::Value* urlValue = map.Find( ImageVisual::Property::URL );
1743
1744   std::string urlString;
1745   urlValue->Get( urlString );
1746   DALI_TEST_EQUALS( urlString , TEST_IMAGE_ONE , TEST_LOCATION );
1747
1748   END_TEST;
1749 }
1750
1751 int UtcDaliPushButtonSetDisabledImageWithActorDeprecatedP(void)
1752 {
1753   tet_infoline(" UtcDaliPushButton SetDisabledImage With ImageView (Actor)");
1754
1755   ToolkitTestApplication application;
1756
1757   Image image = ResourceImage::New( TEST_IMAGE_ONE );
1758
1759   DALI_TEST_CHECK( image );
1760
1761   ImageView imgViewSet = ImageView::New(image);
1762
1763   DALI_TEST_CHECK(imgViewSet );
1764
1765   PushButton pushButton = PushButton::New();
1766
1767   DALI_TEST_CHECK( pushButton );
1768
1769   pushButton.SetDisabledImage( imgViewSet );
1770
1771   Property::Value value = pushButton.GetProperty( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL );
1772
1773   Property::Map map;
1774   value.Get( map );
1775
1776   Property::Value* urlValue = map.Find( ImageVisual::Property::URL );
1777
1778   std::string urlString;
1779   urlValue->Get( urlString );
1780   DALI_TEST_EQUALS( urlString , TEST_IMAGE_ONE , TEST_LOCATION );
1781
1782   END_TEST;
1783 }
1784
1785 int UtcDaliPushButtonSetDisabledSelectedImageWithActorDeprecatedP(void)
1786 {
1787   tet_infoline(" UtcDaliPushButton SetDisabledSelectedImage With ImageView (Actor)");
1788
1789   ToolkitTestApplication application;
1790
1791   Image image = ResourceImage::New( TEST_IMAGE_ONE );
1792
1793   DALI_TEST_CHECK( image );
1794
1795   ImageView imgViewSet = ImageView::New(image);
1796
1797   DALI_TEST_CHECK(imgViewSet );
1798
1799   PushButton pushButton = PushButton::New();
1800
1801   DALI_TEST_CHECK( pushButton );
1802
1803   pushButton.SetDisabledSelectedImage( imgViewSet );
1804
1805   Property::Value value = pushButton.GetProperty( Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL );
1806
1807   Property::Map map;
1808   value.Get( map );
1809
1810   Property::Value* urlValue = map.Find( ImageVisual::Property::URL );
1811
1812   std::string urlString;
1813   urlValue->Get( urlString );
1814   DALI_TEST_EQUALS( urlString , TEST_IMAGE_ONE , TEST_LOCATION );
1815
1816   END_TEST;
1817 }
1818
1819 int UtcDaliPushButtonReplaceButtonImageP2(void)
1820 {
1821   tet_infoline("Set button image then replace with new image and query url");
1822
1823   ToolkitTestApplication application;
1824
1825   ResourceImage setImage = ResourceImage::New( TEST_IMAGE_ONE );
1826   DALI_TEST_CHECK(setImage);
1827
1828   Actor imgActorSet = ImageView::New(setImage);
1829   DALI_TEST_CHECK(imgActorSet);
1830
1831   PushButton pushButton = PushButton::New();
1832   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_TWO );
1833
1834
1835   Stage::GetCurrent().Add( pushButton );
1836
1837   pushButton.SetButtonImage( imgActorSet );
1838   application.SendNotification();
1839   application.Render();
1840
1841   tet_infoline("Get button image before it has been able to load");
1842
1843   ImageView imageView = ImageView::DownCast(pushButton.GetButtonImage());
1844
1845   ResourceImage getImage = ResourceImage::DownCast( imageView.GetImage() );
1846
1847   tet_infoline("Check if url matches last assignment even if not loaded yet");
1848   DALI_TEST_EQUALS( getImage.GetUrl(), setImage.GetUrl() , TEST_LOCATION );
1849
1850   END_TEST;
1851 }