[dali_1.2.29] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-PushButton.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 #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 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
31 #include <dali-toolkit/devel-api/visuals/text-visual-properties.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
50 static const Vector2 INSIDE_TOUCH_POINT_POSITON  = Vector2( 240, 400 );
51 static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS  = Vector3( 200, 360, 0 );
52 static const Size BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS  = Size( 100, 100 );
53
54 static bool gPushButtonSelectedState = false;
55 bool PushButtonSelected( Button button )
56 {
57   gPushButtonSelectedState = button.IsSelected();
58   return true;
59 }
60
61 static bool gPushButtonPressed = false;
62
63 static bool PushButtonPressed( Button button )
64 {
65   gPushButtonPressed = true;
66   return true;
67 }
68
69 static bool gPushButtonReleased = false;
70
71 static bool PushButtonReleased( Button button )
72 {
73   gPushButtonReleased = true;
74   return true;
75 }
76
77 static bool gPushButtonClicked = false;
78
79 static bool PushButtonClicked( Button button )
80 {
81   gPushButtonClicked = true;
82   return gPushButtonClicked;
83 }
84
85 Dali::Integration::Point GetPointDownInside()
86 {
87   Dali::Integration::Point point;
88   point.SetState( PointState::DOWN );
89   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
90   return point;
91 }
92
93 Dali::Integration::Point GetPointUpInside()
94 {
95   Dali::Integration::Point point;
96   point.SetState( PointState::UP );
97   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
98   return point;
99 }
100
101 Dali::Integration::Point GetPointLeave()
102 {
103   Dali::Integration::Point point;
104   point.SetState( PointState::LEAVE );
105   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
106   return point;
107 }
108
109 Dali::Integration::Point GetPointEnter()
110 {
111   Dali::Integration::Point point;
112   point.SetState( PointState::MOTION );
113   point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
114   return point;
115 }
116
117 Dali::Integration::Point GetPointDownOutside()
118 {
119   Dali::Integration::Point point;
120   point.SetState( PointState::DOWN );
121   point.SetScreenPosition( Vector2( 10, 10 ) );
122   return point;
123 }
124
125 Dali::Integration::Point GetPointUpOutside()
126 {
127   Dali::Integration::Point point;
128   point.SetState( PointState::UP );
129   point.SetScreenPosition( Vector2( 10, 10 ) );
130   return point;
131 }
132
133 // Set up the position of the button for the default test events
134 void SetupButtonForTestTouchEvents( ToolkitTestApplication& application, Button& button, bool useDefaultImages )
135 {
136   button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
137   button.SetParentOrigin( ParentOrigin::TOP_LEFT );
138   button.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
139   if ( useDefaultImages )
140   {
141     const Vector2 TEST_IMAGE_SIZE = Vector2( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
142     TestPlatformAbstraction& platform = application.GetPlatform();
143     platform.SetClosestImageSize( TEST_IMAGE_SIZE );
144     button.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
145     button.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
146   }
147 }
148
149 } //namespace
150
151 int UtcDaliPushButtonConstructorP(void)
152 {
153   TestApplication application;
154
155   PushButton button;
156
157   DALI_TEST_CHECK( !button );
158   END_TEST;
159 }
160
161 int UtcDaliPushButtonCopyConstructorP(void)
162 {
163   TestApplication application;
164
165   // Initialize an object, ref count == 1
166   PushButton button = PushButton::New();
167
168   PushButton copy( button );
169   DALI_TEST_CHECK( copy );
170   END_TEST;
171 }
172
173 int UtcDaliPushButtonAssignmentOperatorP(void)
174 {
175   TestApplication application;
176
177   PushButton button = PushButton::New();
178
179   PushButton copy( button );
180   DALI_TEST_CHECK( copy );
181
182   DALI_TEST_CHECK( button == copy );
183   END_TEST;
184 }
185
186 int UtcDaliPushButtonNewP(void)
187 {
188   TestApplication application;
189
190   PushButton button = PushButton::New();
191
192   DALI_TEST_CHECK( button );
193   END_TEST;
194 }
195
196 int UtcDaliPushButtonDownCastP(void)
197 {
198   TestApplication application;
199
200   PushButton button = PushButton::New();
201
202   BaseHandle object(button);
203
204   PushButton button2 = PushButton::DownCast( object );
205   DALI_TEST_CHECK(button2);
206
207   PushButton button3 = DownCast< PushButton >(object);
208   DALI_TEST_CHECK(button3);
209   END_TEST;
210 }
211
212 int UtcDaliPushButtonDownCastN(void)
213 {
214   TestApplication application;
215
216   BaseHandle unInitializedObject;
217
218   PushButton button1 = PushButton::DownCast( unInitializedObject );
219   DALI_TEST_CHECK( !button1 );
220
221   PushButton button2 = DownCast< PushButton >( unInitializedObject );
222   DALI_TEST_CHECK( !button2 );
223   END_TEST;
224 }
225
226 int UtcDaliPushButtonSetGetAutoRepeating(void)
227 {
228   ToolkitTestApplication application;
229   tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
230
231   PushButton pushButton = PushButton::New();
232
233   pushButton.SetAutoRepeating( true );
234
235   DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
236
237   pushButton.SetAutoRepeating( false );
238
239   DALI_TEST_CHECK( !pushButton.IsAutoRepeating() );
240
241   pushButton.SetAutoRepeating( true );
242
243   DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
244   END_TEST;
245 }
246
247 int UtcDaliPushButtonSetAutoRepeating(void)
248 {
249   ToolkitTestApplication application;
250   tet_infoline("UtcDaliPushButtonSetAutoRepeating\n");
251   tet_infoline("Ensure setting AutoRepeating on a SELECTED Toggle button switches off Toggle\n");
252   PushButton pushButton = PushButton::New();
253
254   const bool INITIAL_TOGGLE_VALUE = true;
255   const bool INITIAL_SELECTED_VALUE = true;
256
257   pushButton.SetProperty( Button::Property::TOGGLABLE, INITIAL_TOGGLE_VALUE);
258   pushButton.SetProperty( Button::Property::SELECTED, INITIAL_SELECTED_VALUE );
259
260   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE  ), INITIAL_TOGGLE_VALUE , TEST_LOCATION );
261   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), INITIAL_SELECTED_VALUE , TEST_LOCATION );
262
263   pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
264
265   DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), !INITIAL_TOGGLE_VALUE , TEST_LOCATION );
266
267   END_TEST;
268 }
269
270 int UtcDaliPushButtonSetGetTogglableButton(void)
271 {
272   ToolkitTestApplication application;
273   tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
274
275   PushButton pushButton = PushButton::New();
276
277   pushButton.SetTogglableButton( true );
278
279   DALI_TEST_CHECK( pushButton.IsTogglableButton() );
280
281   pushButton.SetTogglableButton( false );
282
283   DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
284
285   pushButton.SetTogglableButton( true );
286
287   DALI_TEST_CHECK( pushButton.IsTogglableButton() );
288   END_TEST;
289 }
290
291 int UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton(void)
292 {
293   ToolkitTestApplication application;
294   tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
295
296   PushButton pushButton = PushButton::New();
297
298   pushButton.SetAutoRepeating( true );
299   pushButton.SetTogglableButton( true );
300
301   DALI_TEST_CHECK( pushButton.IsTogglableButton() );
302   DALI_TEST_CHECK( !pushButton.IsAutoRepeating() );
303
304   pushButton.SetTogglableButton( true );
305   pushButton.SetAutoRepeating( true );
306
307   DALI_TEST_CHECK( pushButton.IsAutoRepeating() );
308   DALI_TEST_CHECK( !pushButton.IsTogglableButton() );
309   END_TEST;
310 }
311
312 int UtcDaliPushButtonSetGetSelected01(void)
313 {
314   ToolkitTestApplication application;
315   tet_infoline(" UtcDaliPushButtonSetGetSelected01");
316
317   PushButton pushButton = PushButton::New();
318
319   pushButton.SetTogglableButton( true );
320   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
321
322   gPushButtonSelectedState = false;
323   pushButton.SetSelected( true );
324
325   DALI_TEST_CHECK( pushButton.IsSelected() );
326   DALI_TEST_CHECK( gPushButtonSelectedState );
327
328   pushButton.SetSelected( false );
329
330   DALI_TEST_CHECK( !pushButton.IsSelected() );
331   DALI_TEST_CHECK( !gPushButtonSelectedState );
332
333   pushButton.SetSelected( true );
334
335   DALI_TEST_CHECK( pushButton.IsSelected() );
336   DALI_TEST_CHECK( gPushButtonSelectedState );
337   END_TEST;
338 }
339
340 int UtcDaliPushButtonSetGetSelected02(void)
341 {
342   ToolkitTestApplication application;
343   tet_infoline(" UtcDaliPushButtonSetGetSelected02");
344
345   PushButton pushButton = PushButton::New();
346
347   pushButton.SetTogglableButton( false );
348   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
349
350   gPushButtonSelectedState = false;
351   pushButton.SetSelected( true );
352
353   DALI_TEST_CHECK( !pushButton.IsSelected() );
354   DALI_TEST_CHECK( !gPushButtonSelectedState );
355
356   pushButton.SetSelected( false );
357
358   DALI_TEST_CHECK( !pushButton.IsSelected() );
359   DALI_TEST_CHECK( !gPushButtonSelectedState );
360
361   pushButton.SetSelected( true );
362
363   DALI_TEST_CHECK( !pushButton.IsSelected() );
364   DALI_TEST_CHECK( !gPushButtonSelectedState );
365   END_TEST;
366 }
367
368 int UtcDaliPushButtonSetGetAutorepeatingDelayValues01(void)
369 {
370   ToolkitTestApplication application;
371   tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
372
373   PushButton pushButton = PushButton::New();
374
375   pushButton.SetAutoRepeating( true );
376
377   pushButton.SetInitialAutoRepeatingDelay( 1.f );
378   DALI_TEST_EQUALS( pushButton.GetInitialAutoRepeatingDelay(), 1.f, TEST_LOCATION );
379
380   pushButton.SetNextAutoRepeatingDelay( 1.f );
381   DALI_TEST_EQUALS( pushButton.GetNextAutoRepeatingDelay(), 1.f, TEST_LOCATION );
382   END_TEST;
383 }
384
385 int UtcDaliPushButtonSetGetAutorepeatingDelayValues02(void)
386 {
387   ToolkitTestApplication application;
388   tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
389
390   PushButton pushButton = PushButton::New();
391
392   bool assert1( false );
393   bool assert2( false );
394
395   pushButton.SetAutoRepeating( true );
396
397   try
398   {
399     pushButton.SetInitialAutoRepeatingDelay( -1.f );
400   }
401   catch( Dali::DaliException& e )
402   {
403     DALI_TEST_PRINT_ASSERT( e );
404     DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
405     assert1 = true;
406   }
407
408   try
409   {
410     pushButton.SetNextAutoRepeatingDelay( -1.f );
411   }
412   catch( Dali::DaliException& e )
413   {
414     DALI_TEST_PRINT_ASSERT( e );
415     DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
416     assert2 = true;
417   }
418
419   DALI_TEST_CHECK( assert1 && assert2 );
420   END_TEST;
421 }
422
423 int UtcDaliPushButtonSetLabelText(void)
424 {
425   ToolkitTestApplication application;
426   tet_infoline(" UtcDaliPushButtonSetLabelText");
427
428   const std::string STR( "Hola!" );
429
430   PushButton pushButton = PushButton::New();
431
432   pushButton.SetProperty( Toolkit::Button::Property::LABEL,
433                           Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
434                                          .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
435                         );
436
437   application.SendNotification();
438   application.Render();
439
440   pushButton.SetLabelText( STR );
441
442   DALI_TEST_EQUALS( pushButton.GetLabelText(), STR, TEST_LOCATION );
443
444   END_TEST;
445 }
446
447 int UtcDaliPushButtonPressed(void)
448 {
449   ToolkitTestApplication application;
450   tet_infoline(" UtcDaliPushButtonPressed");
451
452   PushButton pushButton = PushButton::New();
453   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
454   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
455   pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
456   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
457
458   Stage::GetCurrent().Add( pushButton );
459
460   application.SendNotification();
461   application.Render();
462
463   gPushButtonPressed = false;
464
465   // connect to its touch signal
466   pushButton.PressedSignal().Connect( &PushButtonPressed );
467
468   Dali::Integration::TouchEvent eventDown;
469   eventDown.AddPoint( GetPointDownInside() );
470
471   // flush the queue and render once
472   application.SendNotification();
473   application.Render();
474   application.ProcessEvent( eventDown );
475
476   DALI_TEST_CHECK( gPushButtonPressed );
477   END_TEST;
478 }
479
480 int UtcDaliPushButtonReleased(void)
481 {
482   ToolkitTestApplication application;
483   tet_infoline(" UtcDaliPushButtonReleased");
484
485   PushButton pushButton = PushButton::New();
486   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
487   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
488   pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
489   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
490
491   Stage::GetCurrent().Add( pushButton );
492
493   application.SendNotification();
494   application.Render();
495
496   // connect to its touch signal
497   pushButton.ReleasedSignal().Connect( &PushButtonReleased );
498
499   Dali::Integration::TouchEvent event;
500
501   // Test1. Touch point down and up inside the button.
502
503   gPushButtonReleased = false;
504   event = Dali::Integration::TouchEvent();
505   event.AddPoint( GetPointDownInside() );
506   application.ProcessEvent( event );
507
508   event = Dali::Integration::TouchEvent();
509   event.AddPoint( GetPointUpInside() );
510   application.ProcessEvent( event );
511
512   DALI_TEST_CHECK( gPushButtonReleased );
513
514   // Test2. Touch point down and up outside the button.
515
516   gPushButtonReleased = false;
517   event = Dali::Integration::TouchEvent();
518   event.AddPoint( GetPointDownOutside() );
519   application.ProcessEvent( event );
520
521   event = Dali::Integration::TouchEvent();
522   event.AddPoint( GetPointUpOutside() );
523   application.ProcessEvent( event );
524
525   DALI_TEST_CHECK( !gPushButtonReleased );
526
527   // Test3. Touch point down inside and up outside the button.
528
529   gPushButtonReleased = false;
530   event = Dali::Integration::TouchEvent();
531   event.AddPoint( GetPointDownInside() );
532   application.ProcessEvent( event );
533
534   event = Dali::Integration::TouchEvent();
535   event.AddPoint( GetPointLeave() );
536   application.ProcessEvent( event );
537
538   event = Dali::Integration::TouchEvent();
539   event.AddPoint( GetPointUpOutside() );
540   application.ProcessEvent( event );
541
542   DALI_TEST_CHECK( gPushButtonReleased );
543
544   // Test4. Touch point down outside and up inside the button.
545
546   gPushButtonReleased = false;
547   event = Dali::Integration::TouchEvent();
548   event.AddPoint( GetPointDownOutside() );
549   application.ProcessEvent( event );
550
551   event = Dali::Integration::TouchEvent();
552   event.AddPoint( GetPointEnter() );
553   application.ProcessEvent( event );
554
555   event = Dali::Integration::TouchEvent();
556   event.AddPoint( GetPointUpInside() );
557   application.ProcessEvent( event );
558
559   DALI_TEST_CHECK( !gPushButtonReleased );
560   END_TEST;
561 }
562
563 int UtcDaliPushButtonSelected(void)
564 {
565   ToolkitTestApplication application;
566   tet_infoline(" UtcDaliPushButtonSelected");
567
568   PushButton pushButton = PushButton::New();
569   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
570   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
571   pushButton.SetPosition( BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
572   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
573
574   Stage::GetCurrent().Add( pushButton );
575
576   application.SendNotification();
577   application.Render();
578
579   // connect to its touch signal
580   pushButton.StateChangedSignal().Connect( &PushButtonSelected );
581
582   Dali::Integration::TouchEvent event;
583
584   // Test1. No togglable button.
585
586   gPushButtonSelectedState = false;
587   event = Dali::Integration::TouchEvent();
588   event.AddPoint( GetPointDownInside() );
589   application.ProcessEvent( event );
590
591   event = Dali::Integration::TouchEvent();
592   event.AddPoint( GetPointUpInside() );
593   application.ProcessEvent( event );
594
595   DALI_TEST_CHECK( !gPushButtonSelectedState );
596
597   // Set togglable property.
598   pushButton.SetTogglableButton( true );
599
600   // Test2. Touch point down and up inside the button twice.
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   event = Dali::Integration::TouchEvent();
613   event.AddPoint( GetPointDownInside() );
614   application.ProcessEvent( event );
615
616   event = Dali::Integration::TouchEvent();
617   event.AddPoint( GetPointUpInside() );
618   application.ProcessEvent( event );
619
620   DALI_TEST_CHECK( !gPushButtonSelectedState );
621
622   // Test3. Touch point down and up outside the button.
623
624   gPushButtonSelectedState = false;
625   event = Dali::Integration::TouchEvent();
626   event.AddPoint( GetPointDownOutside() );
627   application.ProcessEvent( event );
628
629   event = Dali::Integration::TouchEvent();
630   event.AddPoint( GetPointUpOutside() );
631   application.ProcessEvent( event );
632
633   DALI_TEST_CHECK( !gPushButtonSelectedState );
634
635   // Test4. Touch point down inside and up outside the button.
636   //        State changes on Button down
637   gPushButtonSelectedState = false;
638   event = Dali::Integration::TouchEvent();
639   event.AddPoint( GetPointDownInside() );
640   application.ProcessEvent( event );
641
642   event = Dali::Integration::TouchEvent();
643   event.AddPoint( GetPointLeave() );
644   application.ProcessEvent( event );
645
646   event = Dali::Integration::TouchEvent();
647   event.AddPoint( GetPointUpOutside() );
648   application.ProcessEvent( event );
649
650   DALI_TEST_CHECK( gPushButtonSelectedState );
651
652   // Test5. Touch point down outside and up inside the button.
653   // Start in unselected state
654   pushButton.SetProperty( Button::Property::SELECTED, false );
655   DALI_TEST_CHECK( !pushButton.IsSelected());
656
657   gPushButtonSelectedState = false;
658   event = Dali::Integration::TouchEvent();
659   event.AddPoint( GetPointDownOutside() );
660   application.ProcessEvent( event );
661
662   event = Dali::Integration::TouchEvent();
663   event.AddPoint( GetPointEnter() );
664   application.ProcessEvent( event );
665
666   event = Dali::Integration::TouchEvent();
667   event.AddPoint( GetPointUpInside() );
668   application.ProcessEvent( event );
669
670   DALI_TEST_CHECK( !gPushButtonSelectedState );
671   END_TEST;
672 }
673
674 int UtcDaliPushButtonPropertySetIconAlignment(void)
675 {
676   ToolkitTestApplication application;
677   tet_infoline(" UtcDaliPushButtonPropertySetIconAlignment");
678
679   PushButton pushButton = PushButton::New();
680   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
681   DALI_TEST_EQUALS( pushButton.GetProperty<std::string>( Toolkit::PushButton::Property::ICON_ALIGNMENT ), "TOP", TEST_LOCATION );
682
683   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
684   DALI_TEST_EQUALS( pushButton.GetProperty<std::string>( Toolkit::PushButton::Property::ICON_ALIGNMENT ), "RIGHT", TEST_LOCATION );
685
686   END_TEST;
687 }
688
689 int UtcDaliPushButtonPropertySetLabelPadding(void)
690 {
691   ToolkitTestApplication application;
692   tet_infoline(" UtcDaliPushButtonPropertySetLabelPadding");
693
694   PushButton pushButton = PushButton::New();
695   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
696   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 );
697
698   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
699   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 );
700
701   END_TEST;
702 }
703
704 int UtcDaliPushButtonPropertySetIconPadding(void)
705 {
706   ToolkitTestApplication application;
707   tet_infoline(" UtcDaliPushButtonPropertySetIconPadding");
708
709   PushButton pushButton = PushButton::New();
710   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
711   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 );
712
713   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
714   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 );
715
716   END_TEST;
717 }
718
719 int UtcDaliPushButtonPaddingLayout(void)
720 {
721   ToolkitTestApplication application;
722   tet_infoline(" UtcDaliPushButtonPaddingLayout");
723
724   // This test creates padding for an icon and a label.
725   // The icon and label are each enabled and disabled to confirm the correct padding is used.
726   PushButton pushButton = PushButton::New();
727
728   const Vector4 TEST_ICON_PADDING( 20.0f, 20.0f, 20.0f, 20.0f );
729   const Vector4 TEST_LABEL_PADDING( 10.0f, 10.0f, 10.0f ,10.0f );
730   const Vector2 TEST_IMAGE_SIZE = Vector2( 5.0f, 5.0f);
731
732   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
733   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
734   pushButton.SetPosition( 0.0f, 0.0f );
735   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
736
737   Stage::GetCurrent().Add( pushButton );
738
739   application.SendNotification();
740   application.Render();
741
742   // First test the size is zero.
743   // No padding should be added as there is no label or icon.
744   Vector2 size( Vector2::ZERO );
745   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
746   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
747   tet_printf( "Button Natural Size(%f,%f)\n", pushButton.GetNaturalSize().width, pushButton.GetNaturalSize().height );
748
749   DALI_TEST_EQUALS( size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
750
751   // Check label only padding
752   pushButton.SetLabelText( "Label" );
753
754   application.SendNotification();
755   application.Render();
756
757   Vector2 sizeWithLabelWithoutPadding( Vector2::ZERO );
758   sizeWithLabelWithoutPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
759   sizeWithLabelWithoutPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
760
761   tet_printf( "Button RelayoutSize label without padding (%f,%f)\n", sizeWithLabelWithoutPadding.width, sizeWithLabelWithoutPadding.height );
762
763   // Add label padding to label
764   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
765   application.SendNotification();
766   application.Render();
767
768   Vector2 sizeLabelAndPadding( Vector2::ZERO );
769   sizeLabelAndPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
770   sizeLabelAndPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
771   tet_printf( "Button RelayoutSize after label padding(%f,%f)\n", sizeLabelAndPadding.width, sizeLabelAndPadding.height );
772
773   // If control size has increased beyond size of just label then padding has been applied
774   DALI_TEST_GREATER( sizeLabelAndPadding.width, sizeWithLabelWithoutPadding.width+TEST_LABEL_PADDING.x, TEST_LOCATION );
775   DALI_TEST_GREATER( sizeLabelAndPadding.height, sizeWithLabelWithoutPadding.height+TEST_LABEL_PADDING.w, TEST_LOCATION );
776
777   // Re-initialise the button so we can setup icon-only padding.
778   pushButton.Unparent();
779   pushButton = PushButton::New();
780
781   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
782   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
783   pushButton.SetPosition( 0.0f, 0.0f );
784   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
785
786   Stage::GetCurrent().Add( pushButton );
787
788   TestPlatformAbstraction& platform = application.GetPlatform();
789   platform.SetClosestImageSize( TEST_IMAGE_SIZE );
790
791   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
792   pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
793   pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
794
795   application.SendNotification();
796   application.Render();
797
798   // Size of button with just icon
799   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
800   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
801   tet_printf( "Button RelayoutSize with icon(%f,%f)\n", size.width, size.height );
802
803   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
804
805   application.SendNotification();
806   application.Render();
807   DALI_TEST_EQUALS( size, TEST_IMAGE_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
808
809   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
810   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
811   tet_printf( "Button RelayoutSize after icon padding(%f,%f)\n", size.width, size.height );
812   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 );
813   DALI_TEST_EQUALS( size, expectedIconAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
814
815   // Now test padding for both label and icon simultaneously.
816   pushButton.SetLabelText( "Label" );
817   application.SendNotification();
818   application.Render();
819
820   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
821   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
822   tet_printf( "Button RelayoutSize after label added(%f,%f)\n", size.width, size.height );
823
824   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
825
826   application.SendNotification();
827   application.Render();
828
829   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
830   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
831   tet_printf( "Button RelayoutSize after icon and label padding(%f,%f)\n", size.width, size.height );
832
833   DALI_TEST_EQUALS( size.width, sizeLabelAndPadding.width + expectedIconAndPaddingSize.width, TEST_LOCATION );
834   DALI_TEST_GREATER( size.height, expectedIconAndPaddingSize.width, TEST_LOCATION ); // Test height of control is greater than icon and padding. As Text set to larger values.
835
836   END_TEST;
837 }
838
839 int UtcDaliPushButtonAlignmentLayout(void)
840 {
841   ToolkitTestApplication application;
842   tet_infoline(" UtcDaliPushButtonAlignmentLayout");
843
844   /*
845    * This test checks different alignments for the icon against the label.
846    * The icon is then moved around the label in each of it's alignments.
847    * The final relayed out size is checked to confirm the layout has been done correctly.
848    *
849    * There is an Icon which has 0 width and height, but with 75 padding on all sides.
850    *  - Therefore total width and height are both 150.
851    *
852    * There is a Label which has "an unknown" width and height, but with 30 padding on all sides.
853    *  - Therefore total width and height are 60+x and 60+y respectively.
854    *    Where x & y are the width and height of the text.
855    *
856    * The width of the button will always expand to the largest of the icon and label sizes (plus padding).
857    * So We use the padding to help us determine the orientation is correct for each alignment.
858    *
859    * |<- 150 ->|         |<-- 60+x -->|
860    *
861    * +---------+   -
862    * |         |   ^     +------------+   -
863    * |         |   |     |            |   ^
864    * |  Icon   |  150    |   Label    |  60+y
865    * |         |   |     |            |   v
866    * |         |   v     +------------+   -
867    * +---------+   -
868    */
869
870   const Vector4 TEST_ICON_PADDING( 70.0f, 70.0f, 70.0f, 70.0f );
871   const Vector4 TEST_LABEL_PADDING( 30.0f, 30.0f, 30.0f, 30.0f );
872   const Vector2 TEST_IMAGE_SIZE = Vector2( 10.0f, 10.0f);
873
874   PushButton pushButton = PushButton::New();
875
876   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
877   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
878   pushButton.SetPosition( 0.0f, 0.0f );
879   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
880
881   Stage::GetCurrent().Add( pushButton );
882
883   // Add a label and get size of control
884   pushButton.SetLabelText( "Label" );
885   application.SendNotification();
886   application.Render();
887
888   // First get the size of control with just label
889   Vector2 justLabelSize( Vector2::ZERO );
890   justLabelSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
891   justLabelSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
892   tet_printf( "Button RelayoutSize with just label and no padding(%f,%f)\n", justLabelSize.width, justLabelSize.height );
893
894   pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
895   application.SendNotification();
896   application.Render();
897
898   // Size of Label and Padding
899   Vector2 expectedLabelAndPaddingSize( Vector2::ZERO );
900   expectedLabelAndPaddingSize.width = justLabelSize.width + TEST_LABEL_PADDING.x + TEST_LABEL_PADDING.y;
901   expectedLabelAndPaddingSize.height = justLabelSize.height + TEST_LABEL_PADDING.w + TEST_LABEL_PADDING.z;
902
903   Vector2 labelAndPaddingSize( Vector2::ZERO );
904   labelAndPaddingSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
905   labelAndPaddingSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
906
907   DALI_TEST_EQUALS( labelAndPaddingSize, expectedLabelAndPaddingSize , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
908
909   const Vector2 testImageWithPaddingSize = Vector2 ( ( TEST_IMAGE_SIZE.width + TEST_ICON_PADDING.x + TEST_ICON_PADDING.y ),
910                                                      ( TEST_IMAGE_SIZE.height + TEST_ICON_PADDING.w + TEST_ICON_PADDING.z ) );
911
912   TestPlatformAbstraction& platform = application.GetPlatform();
913   platform.SetClosestImageSize( TEST_IMAGE_SIZE );
914
915   // Add Icon and set its alignment
916   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
917   pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
918   pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
919   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
920
921   application.SendNotification();
922   application.Render();
923
924   Vector2 size( Vector2::ZERO );
925   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
926   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
927
928   /*
929    * Test Icon right alignment.
930    * Height grows to largest of Icon or Label (+ padding).
931    * Normally this will be Icons height, except with very large font sizes.
932    *
933    *  +------------+---------+
934    *  |............+         |
935    *  |            |         |
936    *  |   Label    |  Icon   |
937    *  |            |         |
938    *  |............+         |
939    *  +------------+---------+
940    */
941   DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
942   DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
943
944   // Now test left alignment matches right for size.
945   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "LEFT" );
946
947   application.SendNotification();
948   application.Render();
949
950   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
951   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
952
953   /*
954    * Test Icon left alignment.
955    * Height grows to largest of Icon or Label (+ padding).
956    * Normally this will be Icons height, except with very large font sizes.
957    *
958    *  +---------+------------+
959    *  |         +............|
960    *  |         |            |
961    *  |  Icon   |   Label    |
962    *  |         |            |
963    *  |         +............|
964    *  +---------+------------+
965    */
966   DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
967   DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
968
969   tet_infoline(" Test Icon TOP alignment - Width grows to largest of Icon or label (plus padding)");
970   /*
971    *
972    *  +---------+
973    *  |         |
974    *  |         |
975    *  |  Icon   |
976    *  |         |
977    *  |         |
978    *  +---------+
979    *  |         |
980    *  |  Label  |
981    *  |         |
982    *  +---------+
983    *
984    */
985
986   tet_infoline("SetProperty on ICON_ALIGNMENT should relayout the Button");
987   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
988
989   application.SendNotification();
990   application.Render();
991
992   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
993   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
994
995   tet_printf("Natural width (%f)\n",pushButton.GetNaturalSize().width);
996   tet_printf("Natural height (%f)\n",pushButton.GetNaturalSize().height);
997
998   tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Image and Padding size (%f,%f)\n", testImageWithPaddingSize.width, testImageWithPaddingSize.height );
999   tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Text and Padding size (%f,%f)\n", labelAndPaddingSize.width, labelAndPaddingSize.height );
1000
1001   DALI_TEST_EQUALS( size.width, ( std::max( testImageWithPaddingSize.width, labelAndPaddingSize.width ) ) , TEST_LOCATION );
1002
1003   DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1004
1005   /*
1006    * Test Icon bottom alignment.
1007    * Width grows to largest of Icon or Label (+ padding).
1008    *
1009    *  +---------+
1010    *  |         |
1011    *  |  Label  |
1012    *  |         |
1013    *  +---------+
1014    *  |         |
1015    *  |         |
1016    *  |  Icon   |
1017    *  |         |
1018    *  |         |
1019    *  +---------+
1020    */
1021   tet_infoline(" Test Icon BOTTOM alignment - Width grows to largest of Icon or label (plus padding)");
1022   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "BOTTOM" );
1023
1024   application.SendNotification();
1025   application.Render();
1026
1027   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
1028   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
1029
1030   DALI_TEST_EQUALS( size.width, ( std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width )) , TEST_LOCATION );
1031   DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1032
1033   END_TEST;
1034 }
1035
1036 int UtcDaliPushButtonSetUnSelectedVisual01P(void)
1037 {
1038   tet_infoline(" Test adding a visual for the UNSELECTED_VISUAL property, removing Button from stage and counting renderers\n");
1039   ToolkitTestApplication application;
1040
1041   PushButton pushButton = PushButton::New();
1042   pushButton.SetSize( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
1043
1044   Stage::GetCurrent().Add( pushButton );
1045
1046   Property::Map propertyMap;
1047   propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
1048   propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1049
1050   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
1051
1052   tet_infoline(" UNSELECTED_VISUAL Added to button\n");
1053
1054   application.SendNotification();
1055   application.Render(0);
1056
1057   unsigned int rendererCount = pushButton.GetRendererCount();
1058   tet_printf("After adding UNSELECTED_BACKGROUND_VISUAL the renderer count is(%d)\n", rendererCount );
1059
1060   DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1 , TEST_LOCATION );
1061
1062   tet_printf("Remove button from stage\n" );
1063
1064   Stage::GetCurrent().Remove( pushButton );
1065
1066   rendererCount = pushButton.GetRendererCount();
1067   tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1068
1069   DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
1070
1071   tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1072
1073   Property::Map propertyMap2;
1074   propertyMap2.Insert(Visual::Property::TYPE,  Visual::COLOR);
1075   propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, Color::RED);
1076   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, propertyMap2 );
1077
1078   tet_printf("Added UNSELECTED_VISUAL and add button back to Stage\n");
1079
1080   Stage::GetCurrent().Add( pushButton );
1081
1082   tet_printf("With UNSELECTED_BACKGROUND_VISUAL and UNSELECTED_ICON the renderer count is(%d)\n", pushButton.GetRendererCount() );
1083
1084   DALI_TEST_EQUALS( pushButton.GetRendererCount(), 2, TEST_LOCATION );
1085
1086   END_TEST;
1087 }
1088
1089 int UtcDaliPushButtonSetSelectedVisualN(void)
1090 {
1091   tet_infoline(" Test adding a broken visual for the UNSELECTED_VISUAL property");
1092
1093   ToolkitTestApplication application;
1094
1095   PushButton pushButton = PushButton::New();
1096
1097   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1098   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
1099   pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1100
1101   Stage::GetCurrent().Add( pushButton );
1102   application.SendNotification();
1103   application.Render(0);
1104
1105   unsigned int preRendererCount = pushButton.GetRendererCount();
1106   tet_printf("RendererCount prior to adding visual(%d)\n",preRendererCount);
1107   DALI_TEST_EQUALS( preRendererCount, 0, TEST_LOCATION );
1108
1109   Stage::GetCurrent().Remove( pushButton );
1110   application.SendNotification();
1111   application.Render(0);
1112
1113   Property::Map colorMap;
1114   const int BROKEN_VISUAL_TYPE = 999999999;
1115
1116   colorMap.Insert(Visual::Property::TYPE,  BROKEN_VISUAL_TYPE);
1117   colorMap.Insert(BorderVisual::Property::COLOR,  Color::BLUE);
1118   colorMap.Insert(BorderVisual::Property::SIZE,  5.f);
1119   pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, colorMap );
1120
1121   Stage::GetCurrent().Add( pushButton );
1122   application.SendNotification();
1123   application.Render(0);
1124
1125   unsigned int postRendererCount  = pushButton.GetRendererCount();
1126   tet_printf("RendererCount post broken visual (%d)\n", postRendererCount);
1127   DALI_TEST_EQUALS( postRendererCount, 0, TEST_LOCATION );
1128
1129   END_TEST;
1130 }
1131
1132 int UtcDaliPushButtonSetButtonImageP(void)
1133 {
1134   ToolkitTestApplication application;
1135
1136   PushButton button = PushButton::New();
1137   Stage::GetCurrent().Add( button );
1138
1139   try
1140   {
1141     button.SetButtonImage( ImageView::New() );
1142     DALI_TEST_CHECK( true );
1143   }
1144   catch(...)
1145   {
1146     DALI_TEST_CHECK( false );
1147   }
1148
1149   END_TEST;
1150 }
1151
1152 int UtcDaliPushButtonSetBackgroundImageP(void)
1153 {
1154   ToolkitTestApplication application;
1155
1156   PushButton button = PushButton::New();
1157   Stage::GetCurrent().Add( button );
1158
1159   try
1160   {
1161     button.SetBackgroundImage( ImageView::New() );
1162     DALI_TEST_CHECK( true );
1163   }
1164   catch(...)
1165   {
1166     DALI_TEST_CHECK( false );
1167   }
1168
1169   END_TEST;
1170 }
1171
1172 int UtcDaliPushButtonSetSelectedImageP(void)
1173 {
1174   ToolkitTestApplication application;
1175
1176   PushButton button = PushButton::New();
1177   Stage::GetCurrent().Add( button );
1178
1179   try
1180   {
1181     button.SetSelectedImage( ImageView::New() );
1182     DALI_TEST_CHECK( true );
1183   }
1184   catch(...)
1185   {
1186     DALI_TEST_CHECK( false );
1187   }
1188
1189   END_TEST;
1190 }
1191
1192 int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
1193 {
1194   ToolkitTestApplication application;
1195
1196   PushButton button = PushButton::New();
1197   Stage::GetCurrent().Add( button );
1198
1199   try
1200   {
1201     button.SetSelectedBackgroundImage( ImageView::New() );
1202     DALI_TEST_CHECK( true );
1203   }
1204   catch(...)
1205   {
1206     DALI_TEST_CHECK( false );
1207   }
1208
1209   END_TEST;
1210 }
1211
1212 int UtcDaliPushButtonSetDisabledBackgroundImageP(void)
1213 {
1214   ToolkitTestApplication application;
1215
1216   PushButton button = PushButton::New();
1217   Stage::GetCurrent().Add( button );
1218
1219   try
1220   {
1221     button.SetDisabledBackgroundImage( ImageView::New() );
1222     DALI_TEST_CHECK( true );
1223   }
1224   catch(...)
1225   {
1226     DALI_TEST_CHECK( false );
1227   }
1228
1229   END_TEST;
1230 }
1231
1232
1233 int UtcDaliPushButtonSetDisabledImageP(void)
1234 {
1235   ToolkitTestApplication application;
1236
1237   PushButton button = PushButton::New();
1238   Stage::GetCurrent().Add( button );
1239
1240   try
1241   {
1242     button.SetDisabledImage( ImageView::New() );
1243     DALI_TEST_CHECK( true );
1244   }
1245   catch(...)
1246   {
1247     DALI_TEST_CHECK( false );
1248   }
1249
1250   END_TEST;
1251 }
1252
1253 int UtcDaliPushButtonSetDisabledSelectedImageP(void)
1254 {
1255   ToolkitTestApplication application;
1256
1257   PushButton button = PushButton::New();
1258   Stage::GetCurrent().Add( button );
1259
1260   try
1261   {
1262     button.SetDisabledSelectedImage( ImageView::New() );
1263     DALI_TEST_CHECK( true );
1264   }
1265   catch(...)
1266   {
1267     DALI_TEST_CHECK( false );
1268   }
1269
1270   END_TEST;
1271 }
1272
1273 int UtcDaliPushButtonToggleSignalP(void)
1274 {
1275   ToolkitTestApplication application;
1276   tet_infoline(" UtcDaliButtonToggleSignalP Ensure Signals emitted");
1277
1278   PushButton button = PushButton::New();
1279   button.SetProperty( Button::Property::TOGGLABLE, true);
1280
1281   SetupButtonForTestTouchEvents( application, button, true );
1282
1283   Stage::GetCurrent().Add( button );
1284
1285   application.SendNotification();
1286   application.Render();
1287
1288   // connect to its signal
1289   button.ClickedSignal().Connect( &PushButtonClicked );
1290   gPushButtonClicked = false;
1291
1292   tet_infoline(" Touch down and up within button");
1293   Dali::Integration::TouchEvent event;
1294   event = Dali::Integration::TouchEvent();
1295   event.AddPoint( GetPointDownInside() );
1296   application.ProcessEvent( event );
1297
1298   event = Dali::Integration::TouchEvent();
1299   event.AddPoint( GetPointUpInside() );
1300   application.ProcessEvent( event );
1301
1302   DALI_TEST_EQUALS( gPushButtonClicked, true, TEST_LOCATION );
1303
1304   END_TEST;
1305 }