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