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