2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
31 #include <dali/devel-api/adaptor-framework/image-loading.h>
34 using namespace Toolkit;
36 void utc_dali_toolkit_pushbutton_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_toolkit_pushbutton_cleanup(void)
43 test_return_value = TET_PASS;
48 static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
50 static const Vector2 INSIDE_TOUCH_POINT_POSITON = Vector2( 240, 400 );
51 static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS = Vector3( 200, 360, 0 );
52 static const Size BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS = Size( 100, 100 );
54 static bool gPushButtonSelectedState = false;
55 bool PushButtonSelected( Button button )
57 gPushButtonSelectedState = button.GetProperty<bool>(button.GetPropertyIndex("selected") );
61 static bool gPushButtonPressed = false;
63 static bool PushButtonPressed( Button button )
65 gPushButtonPressed = true;
69 static bool gPushButtonReleased = false;
71 static bool PushButtonReleased( Button button )
73 gPushButtonReleased = true;
77 static bool gPushButtonClicked = false;
79 static bool PushButtonClicked( Button button )
81 gPushButtonClicked = true;
82 return gPushButtonClicked;
85 Dali::Integration::Point GetPointDownInside()
87 Dali::Integration::Point point;
88 point.SetState( PointState::DOWN );
89 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
93 Dali::Integration::Point GetPointUpInside()
95 Dali::Integration::Point point;
96 point.SetState( PointState::UP );
97 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
101 Dali::Integration::Point GetPointLeave()
103 Dali::Integration::Point point;
104 point.SetState( PointState::LEAVE );
105 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
109 Dali::Integration::Point GetPointEnter()
111 Dali::Integration::Point point;
112 point.SetState( PointState::MOTION );
113 point.SetScreenPosition( INSIDE_TOUCH_POINT_POSITON );
117 Dali::Integration::Point GetPointDownOutside()
119 Dali::Integration::Point point;
120 point.SetState( PointState::DOWN );
121 point.SetScreenPosition( Vector2( 10, 10 ) );
125 Dali::Integration::Point GetPointUpOutside()
127 Dali::Integration::Point point;
128 point.SetState( PointState::UP );
129 point.SetScreenPosition( Vector2( 10, 10 ) );
133 // Set up the position of the button for the default test events
134 void SetupButtonForTestTouchEvents( ToolkitTestApplication& application, Button& button, bool useDefaultImages )
136 button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
137 button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
138 button.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
139 if ( useDefaultImages )
141 const Vector2 TEST_IMAGE_SIZE = Vector2( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
142 TestPlatformAbstraction& platform = application.GetPlatform();
143 platform.SetClosestImageSize( TEST_IMAGE_SIZE );
144 button.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
145 button.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, TEST_IMAGE_ONE );
149 static std::string GetButtonText( Button button )
151 Property::Value value = button.GetProperty( Toolkit::Button::Property::LABEL );
153 Property::Map *labelProperty = value.GetMap();
155 std::string textLabel;
159 Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT );
160 value->Get( textLabel );
168 int UtcDaliPushButtonConstructorP(void)
170 TestApplication application;
174 DALI_TEST_CHECK( !button );
178 int UtcDaliPushButtonCopyConstructorP(void)
180 TestApplication application;
182 // Initialize an object, ref count == 1
183 PushButton button = PushButton::New();
185 PushButton copy( button );
186 DALI_TEST_CHECK( copy );
190 int UtcDaliPushButtonMoveConstructor(void)
192 ToolkitTestApplication application;
194 PushButton button = PushButton::New();
195 DALI_TEST_EQUALS( 1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION );
196 DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), false , TEST_LOCATION );
197 button.SetProperty( Button::Property::TOGGLABLE, true );
198 DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
200 PushButton moved = std::move( button );
201 DALI_TEST_CHECK( moved );
202 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
203 DALI_TEST_EQUALS( moved.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
204 DALI_TEST_CHECK( !button );
209 int UtcDaliPushButtonAssignmentOperatorP(void)
211 TestApplication application;
213 PushButton button = PushButton::New();
215 PushButton copy( button );
216 DALI_TEST_CHECK( copy );
218 DALI_TEST_CHECK( button == copy );
222 int UtcDaliPushButtonMoveAssignment(void)
224 ToolkitTestApplication application;
226 PushButton button = PushButton::New();
227 DALI_TEST_EQUALS( 1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION );
228 DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), false , TEST_LOCATION );
229 button.SetProperty( Button::Property::TOGGLABLE, true );
230 DALI_TEST_EQUALS( button.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
233 moved = std::move( button );
234 DALI_TEST_CHECK( moved );
235 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
236 DALI_TEST_EQUALS( moved.GetProperty<bool>( Button::Property::TOGGLABLE ), true , TEST_LOCATION );
237 DALI_TEST_CHECK( !button );
242 int UtcDaliPushButtonNewP(void)
244 TestApplication application;
246 PushButton button = PushButton::New();
248 DALI_TEST_CHECK( button );
252 int UtcDaliPushButtonDownCastP(void)
254 TestApplication application;
256 PushButton button = PushButton::New();
258 BaseHandle object(button);
260 PushButton button2 = PushButton::DownCast( object );
261 DALI_TEST_CHECK(button2);
263 PushButton button3 = DownCast< PushButton >(object);
264 DALI_TEST_CHECK(button3);
268 int UtcDaliPushButtonDownCastN(void)
270 TestApplication application;
272 BaseHandle unInitializedObject;
274 PushButton button1 = PushButton::DownCast( unInitializedObject );
275 DALI_TEST_CHECK( !button1 );
277 PushButton button2 = DownCast< PushButton >( unInitializedObject );
278 DALI_TEST_CHECK( !button2 );
282 int UtcDaliPushButtonAutoRepeatingProperty(void)
284 ToolkitTestApplication application;
285 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
287 PushButton pushButton = PushButton::New();
289 pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), true );
290 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
292 pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), false );
293 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
295 pushButton.SetProperty( pushButton.GetPropertyIndex("autoRepeating"), true );
296 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
301 int UtcDaliPushButtonSetAutoRepeating(void)
303 ToolkitTestApplication application;
304 tet_infoline("UtcDaliPushButtonSetAutoRepeating\n");
305 tet_infoline("Ensure setting AutoRepeating on a SELECTED Toggle button switches off Toggle\n");
306 PushButton pushButton = PushButton::New();
308 const bool INITIAL_TOGGLE_VALUE = true;
309 const bool INITIAL_SELECTED_VALUE = true;
311 pushButton.SetProperty( Button::Property::TOGGLABLE, INITIAL_TOGGLE_VALUE);
312 pushButton.SetProperty( Button::Property::SELECTED, INITIAL_SELECTED_VALUE );
314 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), INITIAL_TOGGLE_VALUE , TEST_LOCATION );
315 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), INITIAL_SELECTED_VALUE , TEST_LOCATION );
317 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
319 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), !INITIAL_TOGGLE_VALUE , TEST_LOCATION );
324 int UtcDaliPushButtonTogglableProperty(void)
326 ToolkitTestApplication application;
327 tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
329 PushButton pushButton = PushButton::New();
331 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
332 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
334 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), false );
335 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), false, TEST_LOCATION );
337 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
338 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
343 int UtcDaliPushButtonAutoRepeatingPropertyAndTogglableButton(void)
345 ToolkitTestApplication application;
346 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
348 PushButton pushButton = PushButton::New();
350 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
351 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
353 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), true, TEST_LOCATION );
354 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), false, TEST_LOCATION );
356 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
357 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
359 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("autoRepeating")), true, TEST_LOCATION );
360 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("togglable")), false, TEST_LOCATION );
364 int UtcDaliPushButtonSelectedProperty01(void)
366 ToolkitTestApplication application;
367 tet_infoline(" UtcDaliPushButtonSetGetSelected01");
369 PushButton pushButton = PushButton::New();
371 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), true );
373 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
375 gPushButtonSelectedState = false;
376 pushButton.SetProperty( Button::Property::SELECTED, true );
378 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), true , TEST_LOCATION );
379 DALI_TEST_CHECK( gPushButtonSelectedState );
381 pushButton.SetProperty( Button::Property::SELECTED, false );
383 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
384 DALI_TEST_CHECK( !gPushButtonSelectedState );
386 pushButton.SetProperty( Button::Property::SELECTED, true );
388 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), true , TEST_LOCATION );
389 DALI_TEST_CHECK( gPushButtonSelectedState );
393 int UtcDaliPushButtonSelectedProperty02(void)
395 ToolkitTestApplication application;
396 tet_infoline(" UtcDaliPushButtonSetGetSelected02");
398 PushButton pushButton = PushButton::New();
400 pushButton.SetProperty( pushButton.GetPropertyIndex("togglable"), false );
401 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
403 gPushButtonSelectedState = false;
404 pushButton.SetProperty( Button::Property::SELECTED, true );
406 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
407 DALI_TEST_CHECK( !gPushButtonSelectedState );
409 pushButton.SetProperty( Button::Property::SELECTED, false );
411 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
412 DALI_TEST_CHECK( !gPushButtonSelectedState );
414 pushButton.SetProperty( Button::Property::SELECTED, true );
416 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false , TEST_LOCATION );
417 DALI_TEST_CHECK( !gPushButtonSelectedState );
421 int UtcDaliPushButtonAutorepeatingDelayPropertyValues01(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
426 PushButton pushButton = PushButton::New();
428 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
430 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 1.f );
432 DALI_TEST_EQUALS( pushButton.GetProperty<float>(pushButton.GetPropertyIndex("initialAutoRepeatingDelay") ), 1.f, TEST_LOCATION );
437 int UtcDaliPushButtonAutorepeatingDelayPropertyValues02(void)
439 ToolkitTestApplication application;
440 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
442 PushButton pushButton = PushButton::New();
444 bool assert1( false );
445 bool assert2( false );
447 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
451 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, -1.f );
453 catch( Dali::DaliException& e )
455 DALI_TEST_PRINT_ASSERT( e );
456 DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
462 pushButton.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, -1.f );
464 catch( Dali::DaliException& e )
466 DALI_TEST_PRINT_ASSERT( e );
467 DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
471 DALI_TEST_CHECK( assert1 && assert2 );
475 int UtcDaliPushButtonLabelProperty(void)
477 ToolkitTestApplication application;
478 tet_infoline(" UtcDaliPushButtonSetLabelText");
480 const std::string STR( "Hola!" );
482 PushButton pushButton = PushButton::New();
484 application.SendNotification();
485 application.Render();
487 pushButton.SetProperty( Toolkit::Button::Property::LABEL,
488 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
489 .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
493 pushButton.SetProperty( Toolkit::Button::Property::LABEL, STR );
495 DALI_TEST_EQUALS( GetButtonText( pushButton ), STR, TEST_LOCATION );
500 int UtcDaliPushButtonPressed(void)
502 ToolkitTestApplication application;
503 tet_infoline(" UtcDaliPushButtonPressed");
505 PushButton pushButton = PushButton::New();
506 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
507 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
508 pushButton.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
509 pushButton.SetProperty( Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
511 application.GetScene().Add( pushButton );
513 application.SendNotification();
514 application.Render();
516 gPushButtonPressed = false;
518 // connect to its touch signal
519 pushButton.PressedSignal().Connect( &PushButtonPressed );
521 Dali::Integration::TouchEvent eventDown;
522 eventDown.AddPoint( GetPointDownInside() );
524 // flush the queue and render once
525 application.SendNotification();
526 application.Render();
527 application.ProcessEvent( eventDown );
529 DALI_TEST_CHECK( gPushButtonPressed );
533 int UtcDaliPushButtonReleased(void)
535 ToolkitTestApplication application;
536 tet_infoline(" UtcDaliPushButtonReleased");
538 PushButton pushButton = PushButton::New();
539 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
540 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
541 pushButton.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
542 pushButton.SetProperty( Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
544 application.GetScene().Add( pushButton );
546 application.SendNotification();
547 application.Render();
549 // connect to its touch signal
550 pushButton.ReleasedSignal().Connect( &PushButtonReleased );
552 Dali::Integration::TouchEvent event;
554 // Test1. Touch point down and up inside the button.
556 gPushButtonReleased = false;
557 event = Dali::Integration::TouchEvent();
558 event.AddPoint( GetPointDownInside() );
559 application.ProcessEvent( event );
561 event = Dali::Integration::TouchEvent();
562 event.AddPoint( GetPointUpInside() );
563 application.ProcessEvent( event );
565 DALI_TEST_CHECK( gPushButtonReleased );
567 // Test2. Touch point down and up outside the button.
569 gPushButtonReleased = false;
570 event = Dali::Integration::TouchEvent();
571 event.AddPoint( GetPointDownOutside() );
572 application.ProcessEvent( event );
574 event = Dali::Integration::TouchEvent();
575 event.AddPoint( GetPointUpOutside() );
576 application.ProcessEvent( event );
578 DALI_TEST_CHECK( !gPushButtonReleased );
580 // Test3. Touch point down inside and up outside the button.
582 gPushButtonReleased = false;
583 event = Dali::Integration::TouchEvent();
584 event.AddPoint( GetPointDownInside() );
585 application.ProcessEvent( event );
587 event = Dali::Integration::TouchEvent();
588 event.AddPoint( GetPointLeave() );
589 application.ProcessEvent( event );
591 event = Dali::Integration::TouchEvent();
592 event.AddPoint( GetPointUpOutside() );
593 application.ProcessEvent( event );
595 DALI_TEST_CHECK( gPushButtonReleased );
597 // Test4. Touch point down outside and up inside the button.
599 gPushButtonReleased = false;
600 event = Dali::Integration::TouchEvent();
601 event.AddPoint( GetPointDownOutside() );
602 application.ProcessEvent( event );
604 event = Dali::Integration::TouchEvent();
605 event.AddPoint( GetPointEnter() );
606 application.ProcessEvent( event );
608 event = Dali::Integration::TouchEvent();
609 event.AddPoint( GetPointUpInside() );
610 application.ProcessEvent( event );
612 DALI_TEST_CHECK( !gPushButtonReleased );
616 int UtcDaliPushButtonSelected(void)
618 ToolkitTestApplication application;
619 tet_infoline(" UtcDaliPushButtonSelected");
621 PushButton pushButton = PushButton::New();
622 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
623 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
624 pushButton.SetProperty( Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS );
625 pushButton.SetProperty( Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS );
627 application.GetScene().Add( pushButton );
629 application.SendNotification();
630 application.Render();
632 // connect to its touch signal
633 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
635 Dali::Integration::TouchEvent event;
637 // Test1. No togglable button.
639 gPushButtonSelectedState = false;
640 event = Dali::Integration::TouchEvent();
641 event.AddPoint( GetPointDownInside() );
642 application.ProcessEvent( event );
644 event = Dali::Integration::TouchEvent();
645 event.AddPoint( GetPointUpInside() );
646 application.ProcessEvent( event );
648 DALI_TEST_CHECK( !gPushButtonSelectedState );
650 // Set togglable property.
651 pushButton.SetProperty( Button::Property::TOGGLABLE, true );
653 // Test2. Touch point down and up inside the button twice.
654 gPushButtonSelectedState = false;
655 event = Dali::Integration::TouchEvent();
656 event.AddPoint( GetPointDownInside() );
657 application.ProcessEvent( event );
659 event = Dali::Integration::TouchEvent();
660 event.AddPoint( GetPointUpInside() );
661 application.ProcessEvent( event );
663 DALI_TEST_CHECK( gPushButtonSelectedState );
665 event = Dali::Integration::TouchEvent();
666 event.AddPoint( GetPointDownInside() );
667 application.ProcessEvent( event );
669 event = Dali::Integration::TouchEvent();
670 event.AddPoint( GetPointUpInside() );
671 application.ProcessEvent( event );
673 DALI_TEST_CHECK( !gPushButtonSelectedState );
675 // Test3. Touch point down and up outside the button.
677 gPushButtonSelectedState = false;
678 event = Dali::Integration::TouchEvent();
679 event.AddPoint( GetPointDownOutside() );
680 application.ProcessEvent( event );
682 event = Dali::Integration::TouchEvent();
683 event.AddPoint( GetPointUpOutside() );
684 application.ProcessEvent( event );
686 DALI_TEST_CHECK( !gPushButtonSelectedState );
688 // Test4. Touch point down inside and up outside the button.
689 // State changes on Button down
690 gPushButtonSelectedState = false;
691 event = Dali::Integration::TouchEvent();
692 event.AddPoint( GetPointDownInside() );
693 application.ProcessEvent( event );
695 event = Dali::Integration::TouchEvent();
696 event.AddPoint( GetPointLeave() );
697 application.ProcessEvent( event );
699 event = Dali::Integration::TouchEvent();
700 event.AddPoint( GetPointUpOutside() );
701 application.ProcessEvent( event );
703 DALI_TEST_CHECK( gPushButtonSelectedState );
705 // Test5. Touch point down outside and up inside the button.
706 // Start in unselected state
707 pushButton.SetProperty( Button::Property::SELECTED, false );
709 DALI_TEST_EQUALS( pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("selected") ),false , TEST_LOCATION );
711 gPushButtonSelectedState = false;
712 event = Dali::Integration::TouchEvent();
713 event.AddPoint( GetPointDownOutside() );
714 application.ProcessEvent( event );
716 event = Dali::Integration::TouchEvent();
717 event.AddPoint( GetPointEnter() );
718 application.ProcessEvent( event );
720 event = Dali::Integration::TouchEvent();
721 event.AddPoint( GetPointUpInside() );
722 application.ProcessEvent( event );
724 DALI_TEST_CHECK( !gPushButtonSelectedState );
728 int UtcDaliPushButtonPropertySetLabelPadding(void)
730 ToolkitTestApplication application;
731 tet_infoline(" UtcDaliPushButtonPropertySetLabelPadding");
733 PushButton pushButton = PushButton::New();
734 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
735 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 );
737 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
738 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 );
743 int UtcDaliPushButtonPropertySetIconPadding(void)
745 ToolkitTestApplication application;
746 tet_infoline(" UtcDaliPushButtonPropertySetIconPadding");
748 PushButton pushButton = PushButton::New();
749 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
750 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 );
752 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
753 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 );
758 int UtcDaliPushButtonPaddingLayout(void)
760 ToolkitTestApplication application;
761 tet_infoline(" UtcDaliPushButtonPaddingLayout");
763 // This test creates padding for an icon and a label.
764 // The icon and label are each enabled and disabled to confirm the correct padding is used.
765 PushButton pushButton = PushButton::New();
767 const Vector4 TEST_ICON_PADDING( 20.0f, 20.0f, 20.0f, 20.0f );
768 const Vector4 TEST_LABEL_PADDING( 10.0f, 10.0f, 10.0f, 10.0f );
770 // Get actual size of test image
771 ImageDimensions testImageSize = Dali::GetClosestImageSize( TEST_IMAGE_ONE );
772 const Vector2 TEST_IMAGE_SIZE( testImageSize.GetWidth(), testImageSize.GetHeight() );
774 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
775 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
776 pushButton.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
777 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
779 application.GetScene().Add( pushButton );
781 application.SendNotification();
782 application.Render();
784 // First test the size is zero.
785 // No padding should be added as there is no label or icon.
786 Vector2 size( Vector2::ZERO );
787 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
788 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
789 tet_printf( "Button Natural Size(%f,%f)\n", pushButton.GetNaturalSize().width, pushButton.GetNaturalSize().height );
791 DALI_TEST_EQUALS( size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
793 // Check label only padding
794 pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
796 application.SendNotification();
797 application.Render();
799 Vector2 sizeWithLabelWithoutPadding( Vector2::ZERO );
800 sizeWithLabelWithoutPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
801 sizeWithLabelWithoutPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
803 tet_printf( "Button RelayoutSize label without padding (%f,%f)\n", sizeWithLabelWithoutPadding.width, sizeWithLabelWithoutPadding.height );
805 // Add label padding to label
806 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
807 application.SendNotification();
808 application.Render();
810 Vector2 sizeLabelAndPadding( Vector2::ZERO );
811 sizeLabelAndPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
812 sizeLabelAndPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
813 tet_printf( "Button RelayoutSize after label padding(%f,%f)\n", sizeLabelAndPadding.width, sizeLabelAndPadding.height );
815 // If control size has increased beyond size of just label then padding has been applied
816 DALI_TEST_GREATER( sizeLabelAndPadding.width, sizeWithLabelWithoutPadding.width+TEST_LABEL_PADDING.x, TEST_LOCATION );
817 DALI_TEST_GREATER( sizeLabelAndPadding.height, sizeWithLabelWithoutPadding.height+TEST_LABEL_PADDING.w, TEST_LOCATION );
819 // Re-initialise the button so we can setup icon-only padding.
820 pushButton.Unparent();
821 pushButton = PushButton::New();
823 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
824 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
825 pushButton.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
826 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
828 application.GetScene().Add( pushButton );
831 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BEGIN" );
832 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE );
833 pushButton.SetProperty( Toolkit::Button::Property::SELECTED_VISUAL, TEST_IMAGE_ONE );
835 application.SendNotification();
836 application.Render();
838 // Size of button with just icon
839 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
840 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
841 tet_printf( "Button RelayoutSize with icon(%f,%f)\n", size.width, size.height );
843 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
845 application.SendNotification();
846 application.Render();
847 DALI_TEST_EQUALS( size, TEST_IMAGE_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
849 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
850 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
851 tet_printf( "Button RelayoutSize after icon padding(%f,%f)\n", size.width, size.height );
852 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 );
853 DALI_TEST_EQUALS( size, expectedIconAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
855 // Now test padding for both label and icon simultaneously.
856 pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
858 application.SendNotification();
859 application.Render();
861 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
862 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
863 tet_printf( "Button RelayoutSize after label added(%f,%f)\n", size.width, size.height );
865 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
867 application.SendNotification();
868 application.Render();
870 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
871 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
872 tet_printf( "Button RelayoutSize after icon and label padding(%f,%f)\n", size.width, size.height );
874 DALI_TEST_EQUALS( size.width, sizeLabelAndPadding.width + expectedIconAndPaddingSize.width, TEST_LOCATION );
875 // Test height of control is same as icon and padding, as Text is smaller than icon
876 DALI_TEST_EQUALS( size.height, expectedIconAndPaddingSize.height, TEST_LOCATION );
881 int UtcDaliPushButtonAlignmentLayout(void)
883 ToolkitTestApplication application;
884 tet_infoline(" UtcDaliPushButtonAlignmentLayout");
887 * This test checks different alignments for the icon against the label.
888 * The icon is then moved around the label in each of it's alignments.
889 * The final relayed out size is checked to confirm the layout has been done correctly.
891 * There is an Icon which has 0 width and height, but with 75 padding on all sides.
892 * - Therefore total width and height are both 150.
894 * There is a Label which has "an unknown" width and height, but with 30 padding on all sides.
895 * - Therefore total width and height are 60+x and 60+y respectively.
896 * Where x & y are the width and height of the text.
898 * The width of the button will always expand to the largest of the icon and label sizes (plus padding).
899 * So We use the padding to help us determine the orientation is correct for each alignment.
901 * |<- 150 ->| |<-- 60+x -->|
904 * | | ^ +------------+ -
906 * | Icon | 150 | Label | 60+y
908 * | | v +------------+ -
912 const Vector4 TEST_ICON_PADDING( 70.0f, 70.0f, 70.0f, 70.0f );
913 const Vector4 TEST_LABEL_PADDING( 30.0f, 30.0f, 30.0f, 30.0f );
915 // Get actual size of test image
916 ImageDimensions testImageSize = Dali::GetClosestImageSize( TEST_IMAGE_ONE );
917 const Vector2 TEST_IMAGE_SIZE( testImageSize.GetWidth(), testImageSize.GetHeight() );
919 PushButton pushButton = PushButton::New();
921 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
922 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
923 pushButton.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
924 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
926 application.GetScene().Add( pushButton );
928 // Add a label and get size of control
929 pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Label" );
930 application.SendNotification();
931 application.Render();
933 // First get the size of control with just label
934 Vector2 justLabelSize( Vector2::ZERO );
935 justLabelSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
936 justLabelSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
937 tet_printf( "Button RelayoutSize with just label and no padding(%f,%f)\n", justLabelSize.width, justLabelSize.height );
939 pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
940 application.SendNotification();
941 application.Render();
943 // Size of Label and Padding
944 Vector2 expectedLabelAndPaddingSize( Vector2::ZERO );
945 expectedLabelAndPaddingSize.width = justLabelSize.width + TEST_LABEL_PADDING.x + TEST_LABEL_PADDING.y;
946 expectedLabelAndPaddingSize.height = justLabelSize.height + TEST_LABEL_PADDING.w + TEST_LABEL_PADDING.z;
948 Vector2 labelAndPaddingSize( Vector2::ZERO );
949 labelAndPaddingSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
950 labelAndPaddingSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
952 DALI_TEST_EQUALS( labelAndPaddingSize, expectedLabelAndPaddingSize , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
954 const Vector2 testImageWithPaddingSize = Vector2 ( ( TEST_IMAGE_SIZE.width + TEST_ICON_PADDING.x + TEST_ICON_PADDING.y ),
955 ( TEST_IMAGE_SIZE.height + TEST_ICON_PADDING.w + TEST_ICON_PADDING.z ) );
957 // Add Icon and set its alignment
958 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BEGIN" );
959 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE );
960 pushButton.SetProperty( Toolkit::Button::Property::SELECTED_VISUAL, TEST_IMAGE_ONE );
961 pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
963 application.SendNotification();
964 application.Render();
966 Vector2 size( Vector2::ZERO );
967 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
968 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
971 * Test Icon right alignment.
972 * Height grows to largest of Icon or Label (+ padding).
973 * Normally this will be Icons height, except with very large font sizes.
975 * +------------+---------+
981 * +------------+---------+
983 DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
984 DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
986 // Now test left alignment matches right for size.
987 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END" );
989 application.SendNotification();
990 application.Render();
992 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
993 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
996 * Test Icon left alignment.
997 * Height grows to largest of Icon or Label (+ padding).
998 * Normally this will be Icons height, except with very large font sizes.
1000 * +---------+------------+
1006 * +---------+------------+
1008 DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
1009 DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1011 tet_infoline(" Test Icon TOP alignment - Width grows to largest of Icon or label (plus padding)");
1028 tet_infoline("SetProperty on LABEL_RELATIVE_ALIGNMENT should relayout the Button");
1029 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BOTTOM" );
1031 application.SendNotification();
1032 application.Render();
1034 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
1035 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
1037 tet_printf("Natural width (%f)\n",pushButton.GetNaturalSize().width);
1038 tet_printf("Natural height (%f)\n",pushButton.GetNaturalSize().height);
1040 tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Image and Padding size (%f,%f)\n", testImageWithPaddingSize.width, testImageWithPaddingSize.height );
1041 tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Text and Padding size (%f,%f)\n", labelAndPaddingSize.width, labelAndPaddingSize.height );
1043 DALI_TEST_EQUALS( size.width, ( std::max( testImageWithPaddingSize.width, labelAndPaddingSize.width ) ) , TEST_LOCATION );
1045 DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1048 * Test Icon bottom alignment.
1049 * Width grows to largest of Icon or Label (+ padding).
1063 tet_infoline(" Test Icon BOTTOM alignment - Width grows to largest of Icon or label (plus padding)");
1064 pushButton.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "TOP" );
1066 application.SendNotification();
1067 application.Render();
1069 size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
1070 size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
1072 DALI_TEST_EQUALS( size.width, ( std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width )) , TEST_LOCATION );
1073 DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
1078 int UtcDaliPushButtonSetUnSelectedVisual01P(void)
1080 tet_infoline(" Test adding a visual for the UNSELECTED_VISUAL property, removing Button from stage and counting renderers\n");
1081 ToolkitTestApplication application;
1083 PushButton pushButton = PushButton::New();
1084 pushButton.SetProperty( Actor::Property::SIZE, Vector2( BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS ) );
1086 application.GetScene().Add( pushButton );
1088 Property::Map propertyMap;
1089 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
1090 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1092 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
1094 tet_infoline(" UNSELECTED_VISUAL Added to button\n");
1096 application.SendNotification();
1097 application.Render(0);
1099 unsigned int rendererCount = pushButton.GetRendererCount();
1100 tet_printf("After adding UNSELECTED_BACKGROUND_VISUAL the renderer count is(%d)\n", rendererCount );
1102 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1 , TEST_LOCATION );
1104 tet_printf("Remove button from stage\n" );
1106 application.GetScene().Remove( pushButton );
1108 rendererCount = pushButton.GetRendererCount();
1109 tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1111 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
1113 tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
1115 Property::Map propertyMap2;
1116 propertyMap2.Insert(Visual::Property::TYPE, Visual::COLOR);
1117 propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, Color::RED);
1118 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, propertyMap2 );
1120 tet_printf("Added UNSELECTED_VISUAL and add button back to Stage\n");
1122 application.GetScene().Add( pushButton );
1124 tet_printf("With UNSELECTED_BACKGROUND_VISUAL and UNSELECTED_VISUAL the renderer count is(%d)\n", pushButton.GetRendererCount() );
1126 DALI_TEST_EQUALS( pushButton.GetRendererCount(), 2, TEST_LOCATION );
1131 int UtcDaliPushButtonSetSelectedVisualN(void)
1133 tet_infoline(" Test adding a broken visual for the UNSELECTED_VISUAL property");
1135 ToolkitTestApplication application;
1137 PushButton pushButton = PushButton::New();
1139 pushButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1140 pushButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1141 pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
1143 application.GetScene().Add( pushButton );
1144 application.SendNotification();
1145 application.Render(0);
1147 unsigned int preRendererCount = pushButton.GetRendererCount();
1148 tet_printf("RendererCount prior to adding visual(%d)\n",preRendererCount);
1149 DALI_TEST_EQUALS( preRendererCount, 0, TEST_LOCATION );
1151 application.GetScene().Remove( pushButton );
1152 application.SendNotification();
1153 application.Render(0);
1155 Property::Map colorMap;
1156 const int BROKEN_VISUAL_TYPE = 999999999;
1158 colorMap.Insert(Visual::Property::TYPE, BROKEN_VISUAL_TYPE);
1159 colorMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
1160 colorMap.Insert(BorderVisual::Property::SIZE, 5.f);
1161 pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, colorMap );
1163 application.GetScene().Add( pushButton );
1164 application.SendNotification();
1165 application.Render(0);
1167 unsigned int postRendererCount = pushButton.GetRendererCount();
1168 tet_printf("RendererCount post broken visual (%d)\n", postRendererCount);
1169 DALI_TEST_EQUALS( postRendererCount, 0, TEST_LOCATION );
1174 int UtcDaliPushButtonToggleSignalP(void)
1176 ToolkitTestApplication application;
1177 tet_infoline(" UtcDaliButtonToggleSignalP Ensure Signals emitted");
1179 PushButton button = PushButton::New();
1180 button.SetProperty( Button::Property::TOGGLABLE, true);
1182 SetupButtonForTestTouchEvents( application, button, true );
1184 application.GetScene().Add( button );
1186 application.SendNotification();
1187 application.Render();
1189 // connect to its signal
1190 button.ClickedSignal().Connect( &PushButtonClicked );
1191 gPushButtonClicked = false;
1193 tet_infoline(" Touch down and up within button");
1194 Dali::Integration::TouchEvent event;
1195 event = Dali::Integration::TouchEvent();
1196 event.AddPoint( GetPointDownInside() );
1197 application.ProcessEvent( event );
1199 event = Dali::Integration::TouchEvent();
1200 event.AddPoint( GetPointUpInside() );
1201 application.ProcessEvent( event );
1203 DALI_TEST_EQUALS( gPushButtonClicked, true, TEST_LOCATION );
1208 // Deprecated API Tests
1210 int UtcDaliPushButtonSetGetAutoRepeating(void)
1212 ToolkitTestApplication application;
1213 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
1215 PushButton pushButton = PushButton::New();
1217 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1219 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
1221 pushButton.SetProperty( Button::Property::AUTO_REPEATING, false );
1223 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), false, TEST_LOCATION );
1225 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1227 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
1231 int UtcDaliPushButtonSetGetTogglableButton(void)
1233 ToolkitTestApplication application;
1234 tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
1236 PushButton pushButton = PushButton::New();
1238 pushButton.SetProperty( Button::Property::TOGGLABLE, true );
1240 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), true, TEST_LOCATION );
1242 pushButton.SetProperty( Button::Property::TOGGLABLE, false );
1244 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), false, TEST_LOCATION );
1246 pushButton.SetProperty( Button::Property::TOGGLABLE, true );
1248 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), true, TEST_LOCATION );
1252 int UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton(void)
1254 ToolkitTestApplication application;
1255 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
1257 PushButton pushButton = PushButton::New();
1259 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1260 pushButton.SetProperty( Button::Property::TOGGLABLE, true);
1262 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), true, TEST_LOCATION );
1263 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), false, TEST_LOCATION );
1265 pushButton.SetProperty( Button::Property::TOGGLABLE, true);
1266 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1268 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::AUTO_REPEATING ), true, TEST_LOCATION );
1269 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), false, TEST_LOCATION );
1274 int UtcDaliPushButtonSetGetSelected01(void)
1276 ToolkitTestApplication application;
1277 tet_infoline(" UtcDaliPushButtonSetGetSelected01");
1279 PushButton pushButton = PushButton::New();
1281 pushButton.SetProperty( Button::Property::TOGGLABLE, true);
1282 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
1284 gPushButtonSelectedState = false;
1285 pushButton.SetProperty( Button::Property::SELECTED, true );
1287 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), true, TEST_LOCATION );
1288 DALI_TEST_CHECK( gPushButtonSelectedState );
1290 pushButton.SetProperty( Button::Property::SELECTED, false );
1292 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), false, TEST_LOCATION );
1293 DALI_TEST_CHECK( !gPushButtonSelectedState );
1295 pushButton.SetProperty( Button::Property::SELECTED, true );
1297 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), true, TEST_LOCATION );
1298 DALI_TEST_CHECK( gPushButtonSelectedState );
1302 int UtcDaliPushButtonSetGetSelected02(void)
1304 ToolkitTestApplication application;
1305 tet_infoline(" UtcDaliPushButtonSetGetSelected02");
1307 PushButton pushButton = PushButton::New();
1309 tet_infoline(" Set Toggle feature off");
1310 pushButton.SetProperty( Button::Property::TOGGLABLE, false);
1311 pushButton.StateChangedSignal().Connect( &PushButtonSelected );
1313 gPushButtonSelectedState = false;
1314 tet_infoline(" Try to set to selected, expecting failure as not a toggle button");
1315 pushButton.SetProperty( Button::Property::SELECTED, true );
1317 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), false, TEST_LOCATION );
1318 DALI_TEST_CHECK( !gPushButtonSelectedState );
1320 pushButton.SetProperty( Button::Property::SELECTED, false );
1322 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED), false, TEST_LOCATION );
1323 DALI_TEST_CHECK( !gPushButtonSelectedState );
1325 pushButton.SetProperty( Button::Property::SELECTED, true );
1327 DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED ), false, TEST_LOCATION );
1328 DALI_TEST_CHECK( !gPushButtonSelectedState );
1333 int UtcDaliPushButtonSetGetAutorepeatingDelayValues01(void)
1335 ToolkitTestApplication application;
1336 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
1338 PushButton pushButton = PushButton::New();
1340 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1342 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 1.f);
1343 DALI_TEST_EQUALS( pushButton.GetProperty<float>( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), 1.f, TEST_LOCATION );
1345 pushButton.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 1.f);
1347 DALI_TEST_EQUALS( pushButton.GetProperty<float>( Button::Property::NEXT_AUTO_REPEATING_DELAY ), 1.f, TEST_LOCATION );
1351 int UtcDaliPushButtonSetGetAutorepeatingDelayValues02(void)
1353 ToolkitTestApplication application;
1354 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
1356 PushButton pushButton = PushButton::New();
1358 bool assert1( false );
1359 bool assert2( false );
1361 pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
1365 pushButton.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, -1.f );
1367 catch( Dali::DaliException& e )
1369 DALI_TEST_PRINT_ASSERT( e );
1370 DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
1376 pushButton.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, -1.f );
1378 catch( Dali::DaliException& e )
1380 DALI_TEST_PRINT_ASSERT( e );
1381 DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
1385 DALI_TEST_CHECK( assert1 && assert2 );
1389 int UtcDaliPushButtonSetLabelText(void)
1391 ToolkitTestApplication application;
1392 tet_infoline(" UtcDaliPushButtonSetLabelText");
1394 const std::string STR( "Hola!" );
1396 PushButton pushButton = PushButton::New();
1398 pushButton.SetProperty( Toolkit::Button::Property::LABEL,
1399 Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
1400 .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
1403 application.SendNotification();
1404 application.Render();
1406 pushButton.SetProperty( Button::Property::LABEL, STR );
1408 DALI_TEST_EQUALS(GetButtonText( pushButton ), STR, TEST_LOCATION);