2 * Copyright (c) 2022 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>
25 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali/integration-api/events/touch-event-integ.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);
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 ToolkitTestApplication application;
174 DALI_TEST_CHECK(!button);
178 int UtcDaliPushButtonCopyConstructorP(void)
180 ToolkitTestApplication 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 ToolkitTestApplication 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 ToolkitTestApplication application;
246 PushButton button = PushButton::New();
248 DALI_TEST_CHECK(button);
252 int UtcDaliPushButtonDownCastP(void)
254 ToolkitTestApplication 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 ToolkitTestApplication 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();
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).Add(Toolkit::TextVisual::Property::POINT_SIZE, 15.0f));
490 pushButton.SetProperty(Toolkit::Button::Property::LABEL, STR);
492 DALI_TEST_EQUALS(GetButtonText(pushButton), STR, TEST_LOCATION);
497 int UtcDaliPushButtonPressed(void)
499 ToolkitTestApplication application;
500 tet_infoline(" UtcDaliPushButtonPressed");
502 PushButton pushButton = PushButton::New();
503 pushButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
504 pushButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
505 pushButton.SetProperty(Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS);
506 pushButton.SetProperty(Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS);
508 application.GetScene().Add(pushButton);
510 application.SendNotification();
511 application.Render();
513 gPushButtonPressed = false;
515 // connect to its touch signal
516 pushButton.PressedSignal().Connect(&PushButtonPressed);
518 Dali::Integration::TouchEvent eventDown;
519 eventDown.AddPoint(GetPointDownInside());
521 // flush the queue and render once
522 application.SendNotification();
523 application.Render();
524 application.ProcessEvent(eventDown);
526 DALI_TEST_CHECK(gPushButtonPressed);
530 int UtcDaliPushButtonReleased(void)
532 ToolkitTestApplication application;
533 tet_infoline(" UtcDaliPushButtonReleased");
535 PushButton pushButton = PushButton::New();
536 pushButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
537 pushButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
538 pushButton.SetProperty(Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS);
539 pushButton.SetProperty(Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS);
541 application.GetScene().Add(pushButton);
543 application.SendNotification();
544 application.Render();
546 // connect to its touch signal
547 pushButton.ReleasedSignal().Connect(&PushButtonReleased);
549 Dali::Integration::TouchEvent event;
551 // Test1. Touch point down and up inside the button.
553 gPushButtonReleased = false;
554 event = Dali::Integration::TouchEvent();
555 event.AddPoint(GetPointDownInside());
556 application.ProcessEvent(event);
558 event = Dali::Integration::TouchEvent();
559 event.AddPoint(GetPointUpInside());
560 application.ProcessEvent(event);
562 DALI_TEST_CHECK(gPushButtonReleased);
564 // Test2. Touch point down and up outside the button.
566 gPushButtonReleased = false;
567 event = Dali::Integration::TouchEvent();
568 event.AddPoint(GetPointDownOutside());
569 application.ProcessEvent(event);
571 event = Dali::Integration::TouchEvent();
572 event.AddPoint(GetPointUpOutside());
573 application.ProcessEvent(event);
575 DALI_TEST_CHECK(!gPushButtonReleased);
577 // Test3. Touch point down inside and up outside the button.
579 gPushButtonReleased = false;
580 event = Dali::Integration::TouchEvent();
581 event.AddPoint(GetPointDownInside());
582 application.ProcessEvent(event);
584 event = Dali::Integration::TouchEvent();
585 event.AddPoint(GetPointLeave());
586 application.ProcessEvent(event);
588 event = Dali::Integration::TouchEvent();
589 event.AddPoint(GetPointUpOutside());
590 application.ProcessEvent(event);
592 DALI_TEST_CHECK(gPushButtonReleased);
594 // Test4. Touch point down outside and up inside the button.
596 gPushButtonReleased = false;
597 event = Dali::Integration::TouchEvent();
598 event.AddPoint(GetPointDownOutside());
599 application.ProcessEvent(event);
601 event = Dali::Integration::TouchEvent();
602 event.AddPoint(GetPointEnter());
603 application.ProcessEvent(event);
605 event = Dali::Integration::TouchEvent();
606 event.AddPoint(GetPointUpInside());
607 application.ProcessEvent(event);
609 DALI_TEST_CHECK(!gPushButtonReleased);
613 int UtcDaliPushButtonSelected(void)
615 ToolkitTestApplication application;
616 tet_infoline(" UtcDaliPushButtonSelected");
618 PushButton pushButton = PushButton::New();
619 pushButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
620 pushButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
621 pushButton.SetProperty(Actor::Property::POSITION, BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS);
622 pushButton.SetProperty(Actor::Property::SIZE, BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS);
624 application.GetScene().Add(pushButton);
626 application.SendNotification();
627 application.Render();
629 // connect to its touch signal
630 pushButton.StateChangedSignal().Connect(&PushButtonSelected);
632 Dali::Integration::TouchEvent event;
634 // Test1. No togglable button.
636 gPushButtonSelectedState = false;
637 event = Dali::Integration::TouchEvent();
638 event.AddPoint(GetPointDownInside());
639 application.ProcessEvent(event);
641 event = Dali::Integration::TouchEvent();
642 event.AddPoint(GetPointUpInside());
643 application.ProcessEvent(event);
645 DALI_TEST_CHECK(!gPushButtonSelectedState);
647 // Set togglable property.
648 pushButton.SetProperty(Button::Property::TOGGLABLE, true);
650 // Test2. Touch point down and up inside the button twice.
651 gPushButtonSelectedState = false;
652 event = Dali::Integration::TouchEvent();
653 event.AddPoint(GetPointDownInside());
654 application.ProcessEvent(event);
656 event = Dali::Integration::TouchEvent();
657 event.AddPoint(GetPointUpInside());
658 application.ProcessEvent(event);
660 DALI_TEST_CHECK(gPushButtonSelectedState);
662 event = Dali::Integration::TouchEvent();
663 event.AddPoint(GetPointDownInside());
664 application.ProcessEvent(event);
666 event = Dali::Integration::TouchEvent();
667 event.AddPoint(GetPointUpInside());
668 application.ProcessEvent(event);
670 DALI_TEST_CHECK(!gPushButtonSelectedState);
672 // Test3. Touch point down and up outside the button.
674 gPushButtonSelectedState = false;
675 event = Dali::Integration::TouchEvent();
676 event.AddPoint(GetPointDownOutside());
677 application.ProcessEvent(event);
679 event = Dali::Integration::TouchEvent();
680 event.AddPoint(GetPointUpOutside());
681 application.ProcessEvent(event);
683 DALI_TEST_CHECK(!gPushButtonSelectedState);
685 // Test4. Touch point down inside and up outside the button.
686 // State changes on Button down
687 gPushButtonSelectedState = false;
688 event = Dali::Integration::TouchEvent();
689 event.AddPoint(GetPointDownInside());
690 application.ProcessEvent(event);
692 event = Dali::Integration::TouchEvent();
693 event.AddPoint(GetPointLeave());
694 application.ProcessEvent(event);
696 event = Dali::Integration::TouchEvent();
697 event.AddPoint(GetPointUpOutside());
698 application.ProcessEvent(event);
700 DALI_TEST_CHECK(gPushButtonSelectedState);
702 // Test5. Touch point down outside and up inside the button.
703 // Start in unselected state
704 pushButton.SetProperty(Button::Property::SELECTED, false);
706 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(pushButton.GetPropertyIndex("selected")), false, TEST_LOCATION);
708 gPushButtonSelectedState = false;
709 event = Dali::Integration::TouchEvent();
710 event.AddPoint(GetPointDownOutside());
711 application.ProcessEvent(event);
713 event = Dali::Integration::TouchEvent();
714 event.AddPoint(GetPointEnter());
715 application.ProcessEvent(event);
717 event = Dali::Integration::TouchEvent();
718 event.AddPoint(GetPointUpInside());
719 application.ProcessEvent(event);
721 DALI_TEST_CHECK(!gPushButtonSelectedState);
725 int UtcDaliPushButtonPropertySetLabelPadding(void)
727 ToolkitTestApplication application;
728 tet_infoline(" UtcDaliPushButtonPropertySetLabelPadding");
730 PushButton pushButton = PushButton::New();
731 pushButton.SetProperty(Toolkit::PushButton::Property::LABEL_PADDING, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
732 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);
734 pushButton.SetProperty(Toolkit::PushButton::Property::LABEL_PADDING, Vector4(10.0f, 10.0f, 10.0f, 10.0f));
735 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);
740 int UtcDaliPushButtonPropertySetIconPadding(void)
742 ToolkitTestApplication application;
743 tet_infoline(" UtcDaliPushButtonPropertySetIconPadding");
745 PushButton pushButton = PushButton::New();
746 pushButton.SetProperty(Toolkit::PushButton::Property::ICON_PADDING, Vector4(1.0f, 1.0f, 1.0f, 1.0f));
747 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);
749 pushButton.SetProperty(Toolkit::PushButton::Property::ICON_PADDING, Vector4(10.0f, 10.0f, 10.0f, 10.0f));
750 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);
755 int UtcDaliPushButtonPaddingLayout(void)
757 ToolkitTestApplication application;
758 tet_infoline(" UtcDaliPushButtonPaddingLayout");
760 // This test creates padding for an icon and a label.
761 // The icon and label are each enabled and disabled to confirm the correct padding is used.
762 PushButton pushButton = PushButton::New();
764 const Vector4 TEST_ICON_PADDING(20.0f, 20.0f, 20.0f, 20.0f);
765 const Vector4 TEST_LABEL_PADDING(10.0f, 10.0f, 10.0f, 10.0f);
767 // Get actual size of test image
768 ImageDimensions testImageSize = Dali::GetClosestImageSize(TEST_IMAGE_ONE);
769 const Vector2 TEST_IMAGE_SIZE(testImageSize.GetWidth(), testImageSize.GetHeight());
771 pushButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
772 pushButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
773 pushButton.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
774 pushButton.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
776 application.GetScene().Add(pushButton);
778 application.SendNotification();
779 application.Render();
781 // First test the size is zero.
782 // No padding should be added as there is no label or icon.
783 Vector2 size(Vector2::ZERO);
784 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
785 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
786 tet_printf("Button Natural Size(%f,%f)\n", pushButton.GetNaturalSize().width, pushButton.GetNaturalSize().height);
788 DALI_TEST_EQUALS(size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
790 // Check label only padding
791 pushButton.SetProperty(Toolkit::Button::Property::LABEL, "Label");
793 application.SendNotification();
794 application.Render();
796 Vector2 sizeWithLabelWithoutPadding(Vector2::ZERO);
797 sizeWithLabelWithoutPadding.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
798 sizeWithLabelWithoutPadding.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
800 tet_printf("Button RelayoutSize label without padding (%f,%f)\n", sizeWithLabelWithoutPadding.width, sizeWithLabelWithoutPadding.height);
802 // Add label padding to label
803 pushButton.SetProperty(Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING);
804 application.SendNotification();
805 application.Render();
807 Vector2 sizeLabelAndPadding(Vector2::ZERO);
808 sizeLabelAndPadding.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
809 sizeLabelAndPadding.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
810 tet_printf("Button RelayoutSize after label padding(%f,%f)\n", sizeLabelAndPadding.width, sizeLabelAndPadding.height);
812 // If control size has increased beyond size of just label then padding has been applied
813 DALI_TEST_GREATER(sizeLabelAndPadding.width, sizeWithLabelWithoutPadding.width + TEST_LABEL_PADDING.x, TEST_LOCATION);
814 DALI_TEST_GREATER(sizeLabelAndPadding.height, sizeWithLabelWithoutPadding.height + TEST_LABEL_PADDING.w, TEST_LOCATION);
816 // Re-initialise the button so we can setup icon-only padding.
817 pushButton.Unparent();
818 pushButton = PushButton::New();
820 pushButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
821 pushButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
822 pushButton.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
823 pushButton.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
825 application.GetScene().Add(pushButton);
827 pushButton.SetProperty(Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BEGIN");
828 pushButton.SetProperty(Toolkit::Button::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE);
829 pushButton.SetProperty(Toolkit::Button::Property::SELECTED_VISUAL, TEST_IMAGE_ONE);
831 application.SendNotification();
832 application.Render();
834 // Size of button with just icon
835 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
836 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
837 tet_printf("Button RelayoutSize with icon(%f,%f)\n", size.width, size.height);
839 pushButton.SetProperty(Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING);
841 application.SendNotification();
842 application.Render();
843 DALI_TEST_EQUALS(size, TEST_IMAGE_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
845 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
846 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
847 tet_printf("Button RelayoutSize after icon padding(%f,%f)\n", size.width, size.height);
848 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);
849 DALI_TEST_EQUALS(size, expectedIconAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
851 // Now test padding for both label and icon simultaneously.
852 pushButton.SetProperty(Toolkit::Button::Property::LABEL, "Label");
854 application.SendNotification();
855 application.Render();
857 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
858 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
859 tet_printf("Button RelayoutSize after label added(%f,%f)\n", size.width, size.height);
861 pushButton.SetProperty(Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING);
863 application.SendNotification();
864 application.Render();
866 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
867 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
868 tet_printf("Button RelayoutSize after icon and label padding(%f,%f)\n", size.width, size.height);
870 DALI_TEST_EQUALS(size.width, sizeLabelAndPadding.width + expectedIconAndPaddingSize.width, TEST_LOCATION);
871 // Test height of control is same as icon and padding, as Text is smaller than icon
872 DALI_TEST_EQUALS(size.height, expectedIconAndPaddingSize.height, TEST_LOCATION);
877 int UtcDaliPushButtonAlignmentLayout(void)
879 ToolkitTestApplication application;
880 tet_infoline(" UtcDaliPushButtonAlignmentLayout");
883 * This test checks different alignments for the icon against the label.
884 * The icon is then moved around the label in each of it's alignments.
885 * The final relayed out size is checked to confirm the layout has been done correctly.
887 * There is an Icon which has 0 width and height, but with 75 padding on all sides.
888 * - Therefore total width and height are both 150.
890 * There is a Label which has "an unknown" width and height, but with 30 padding on all sides.
891 * - Therefore total width and height are 60+x and 60+y respectively.
892 * Where x & y are the width and height of the text.
894 * The width of the button will always expand to the largest of the icon and label sizes (plus padding).
895 * So We use the padding to help us determine the orientation is correct for each alignment.
897 * |<- 150 ->| |<-- 60+x -->|
900 * | | ^ +------------+ -
902 * | Icon | 150 | Label | 60+y
904 * | | v +------------+ -
908 const Vector4 TEST_ICON_PADDING(70.0f, 70.0f, 70.0f, 70.0f);
909 const Vector4 TEST_LABEL_PADDING(30.0f, 30.0f, 30.0f, 30.0f);
911 // Get actual size of test image
912 ImageDimensions testImageSize = Dali::GetClosestImageSize(TEST_IMAGE_ONE);
913 const Vector2 TEST_IMAGE_SIZE(testImageSize.GetWidth(), testImageSize.GetHeight());
915 PushButton pushButton = PushButton::New();
917 pushButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
918 pushButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
919 pushButton.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
920 pushButton.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
922 application.GetScene().Add(pushButton);
924 // Add a label and get size of control
925 pushButton.SetProperty(Toolkit::Button::Property::LABEL, "Label");
926 application.SendNotification();
927 application.Render();
929 // First get the size of control with just label
930 Vector2 justLabelSize(Vector2::ZERO);
931 justLabelSize.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
932 justLabelSize.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
933 tet_printf("Button RelayoutSize with just label and no padding(%f,%f)\n", justLabelSize.width, justLabelSize.height);
935 pushButton.SetProperty(Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING);
936 application.SendNotification();
937 application.Render();
939 // Size of Label and Padding
940 Vector2 expectedLabelAndPaddingSize(Vector2::ZERO);
941 expectedLabelAndPaddingSize.width = justLabelSize.width + TEST_LABEL_PADDING.x + TEST_LABEL_PADDING.y;
942 expectedLabelAndPaddingSize.height = justLabelSize.height + TEST_LABEL_PADDING.w + TEST_LABEL_PADDING.z;
944 Vector2 labelAndPaddingSize(Vector2::ZERO);
945 labelAndPaddingSize.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
946 labelAndPaddingSize.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
948 DALI_TEST_EQUALS(labelAndPaddingSize, expectedLabelAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
950 const Vector2 testImageWithPaddingSize = Vector2((TEST_IMAGE_SIZE.width + TEST_ICON_PADDING.x + TEST_ICON_PADDING.y),
951 (TEST_IMAGE_SIZE.height + TEST_ICON_PADDING.w + TEST_ICON_PADDING.z));
953 // Add Icon and set its alignment
954 pushButton.SetProperty(Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BEGIN");
955 pushButton.SetProperty(Toolkit::Button::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE);
956 pushButton.SetProperty(Toolkit::Button::Property::SELECTED_VISUAL, TEST_IMAGE_ONE);
957 pushButton.SetProperty(Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING);
959 application.SendNotification();
960 application.Render();
962 Vector2 size(Vector2::ZERO);
963 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
964 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
967 * Test Icon right alignment.
968 * Height grows to largest of Icon or Label (+ padding).
969 * Normally this will be Icons height, except with very large font sizes.
971 * +------------+---------+
977 * +------------+---------+
979 DALI_TEST_EQUALS(size.width, (testImageWithPaddingSize.width + labelAndPaddingSize.width), TEST_LOCATION);
980 DALI_TEST_EQUALS(size.height, (std::max(testImageWithPaddingSize.height, labelAndPaddingSize.height)), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
982 // Now test left alignment matches right for size.
983 pushButton.SetProperty(Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END");
985 application.SendNotification();
986 application.Render();
988 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
989 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
992 * Test Icon left alignment.
993 * Height grows to largest of Icon or Label (+ padding).
994 * Normally this will be Icons height, except with very large font sizes.
996 * +---------+------------+
1002 * +---------+------------+
1004 DALI_TEST_EQUALS(size.width, (testImageWithPaddingSize.width + labelAndPaddingSize.width), TEST_LOCATION);
1005 DALI_TEST_EQUALS(size.height, (std::max(testImageWithPaddingSize.height, labelAndPaddingSize.height)), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1007 tet_infoline(" Test Icon TOP alignment - Width grows to largest of Icon or label (plus padding)");
1024 tet_infoline("SetProperty on LABEL_RELATIVE_ALIGNMENT should relayout the Button");
1025 pushButton.SetProperty(Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "BOTTOM");
1027 application.SendNotification();
1028 application.Render();
1030 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
1031 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
1033 tet_printf("Natural width (%f)\n", pushButton.GetNaturalSize().width);
1034 tet_printf("Natural height (%f)\n", pushButton.GetNaturalSize().height);
1036 tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Image and Padding size (%f,%f)\n", testImageWithPaddingSize.width, testImageWithPaddingSize.height);
1037 tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Text and Padding size (%f,%f)\n", labelAndPaddingSize.width, labelAndPaddingSize.height);
1039 DALI_TEST_EQUALS(size.width, (std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width)), TEST_LOCATION);
1041 DALI_TEST_EQUALS(size.height, (testImageWithPaddingSize.height + labelAndPaddingSize.height), TEST_LOCATION);
1044 * Test Icon bottom alignment.
1045 * Width grows to largest of Icon or Label (+ padding).
1059 tet_infoline(" Test Icon BOTTOM alignment - Width grows to largest of Icon or label (plus padding)");
1060 pushButton.SetProperty(Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "TOP");
1062 application.SendNotification();
1063 application.Render();
1065 size.width = pushButton.GetRelayoutSize(Dimension::WIDTH);
1066 size.height = pushButton.GetRelayoutSize(Dimension::HEIGHT);
1068 DALI_TEST_EQUALS(size.width, (std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width)), TEST_LOCATION);
1069 DALI_TEST_EQUALS(size.height, (testImageWithPaddingSize.height + labelAndPaddingSize.height), TEST_LOCATION);
1074 int UtcDaliPushButtonSetUnSelectedVisual01P(void)
1076 tet_infoline(" Test adding a visual for the UNSELECTED_VISUAL property, removing Button from stage and counting renderers\n");
1077 ToolkitTestApplication application;
1079 PushButton pushButton = PushButton::New();
1080 pushButton.SetProperty(Actor::Property::SIZE, Vector2(BUTTON_SIZE_TO_GET_INSIDE_TOUCH_EVENTS));
1082 application.GetScene().Add(pushButton);
1084 Property::Map propertyMap;
1085 propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
1086 propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
1088 pushButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap);
1090 tet_infoline(" UNSELECTED_VISUAL Added to button\n");
1092 application.SendNotification();
1093 application.Render(0);
1095 unsigned int rendererCount = pushButton.GetRendererCount();
1096 tet_printf("After adding UNSELECTED_BACKGROUND_VISUAL the renderer count is(%d)\n", rendererCount);
1098 DALI_TEST_EQUALS(pushButton.GetRendererCount(), 1, TEST_LOCATION);
1100 tet_printf("Remove button from stage\n");
1102 application.GetScene().Remove(pushButton);
1104 rendererCount = pushButton.GetRendererCount();
1105 tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount);
1107 DALI_TEST_EQUALS(pushButton.GetRendererCount(), 0, TEST_LOCATION);
1109 tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount);
1111 Property::Map propertyMap2;
1112 propertyMap2.Insert(Visual::Property::TYPE, Visual::COLOR);
1113 propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, Color::RED);
1114 pushButton.SetProperty(Toolkit::Button::Property::UNSELECTED_VISUAL, propertyMap2);
1116 tet_printf("Added UNSELECTED_VISUAL and add button back to Stage\n");
1118 application.GetScene().Add(pushButton);
1120 tet_printf("With UNSELECTED_BACKGROUND_VISUAL and UNSELECTED_VISUAL the renderer count is(%d)\n", pushButton.GetRendererCount());
1122 DALI_TEST_EQUALS(pushButton.GetRendererCount(), 2, TEST_LOCATION);
1127 int UtcDaliPushButtonSetSelectedVisualN(void)
1129 tet_infoline(" Test adding a broken visual for the UNSELECTED_VISUAL property");
1131 ToolkitTestApplication application;
1133 PushButton pushButton = PushButton::New();
1135 pushButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1136 pushButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1137 pushButton.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS);
1139 application.GetScene().Add(pushButton);
1140 application.SendNotification();
1141 application.Render(0);
1143 unsigned int preRendererCount = pushButton.GetRendererCount();
1144 tet_printf("RendererCount prior to adding visual(%d)\n", preRendererCount);
1145 DALI_TEST_EQUALS(preRendererCount, 0, TEST_LOCATION);
1147 application.GetScene().Remove(pushButton);
1148 application.SendNotification();
1149 application.Render(0);
1151 Property::Map colorMap;
1152 const int BROKEN_VISUAL_TYPE = 999999999;
1154 colorMap.Insert(Visual::Property::TYPE, BROKEN_VISUAL_TYPE);
1155 colorMap.Insert(BorderVisual::Property::COLOR, Color::BLUE);
1156 colorMap.Insert(BorderVisual::Property::SIZE, 5.f);
1157 pushButton.SetProperty(Toolkit::Button::Property::UNSELECTED_VISUAL, colorMap);
1159 application.GetScene().Add(pushButton);
1160 application.SendNotification();
1161 application.Render(0);
1163 unsigned int postRendererCount = pushButton.GetRendererCount();
1164 tet_printf("RendererCount post broken visual (%d)\n", postRendererCount);
1165 DALI_TEST_EQUALS(postRendererCount, 0, TEST_LOCATION);
1170 int UtcDaliPushButtonToggleSignalP(void)
1172 ToolkitTestApplication application;
1173 tet_infoline(" UtcDaliButtonToggleSignalP Ensure Signals emitted");
1175 PushButton button = PushButton::New();
1176 button.SetProperty(Button::Property::TOGGLABLE, true);
1178 SetupButtonForTestTouchEvents(application, button, true);
1180 application.GetScene().Add(button);
1182 application.SendNotification();
1183 application.Render();
1185 // connect to its signal
1186 button.ClickedSignal().Connect(&PushButtonClicked);
1187 gPushButtonClicked = false;
1189 tet_infoline(" Touch down and up within button");
1190 Dali::Integration::TouchEvent event;
1191 event = Dali::Integration::TouchEvent();
1192 event.AddPoint(GetPointDownInside());
1193 application.ProcessEvent(event);
1195 event = Dali::Integration::TouchEvent();
1196 event.AddPoint(GetPointUpInside());
1197 application.ProcessEvent(event);
1199 DALI_TEST_EQUALS(gPushButtonClicked, true, TEST_LOCATION);
1204 // Deprecated API Tests
1206 int UtcDaliPushButtonSetGetAutoRepeating(void)
1208 ToolkitTestApplication application;
1209 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeating");
1211 PushButton pushButton = PushButton::New();
1213 pushButton.SetProperty(Button::Property::AUTO_REPEATING, true);
1215 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::AUTO_REPEATING), true, TEST_LOCATION);
1217 pushButton.SetProperty(Button::Property::AUTO_REPEATING, false);
1219 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::AUTO_REPEATING), false, TEST_LOCATION);
1221 pushButton.SetProperty(Button::Property::AUTO_REPEATING, true);
1223 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::AUTO_REPEATING), true, TEST_LOCATION);
1227 int UtcDaliPushButtonSetGetTogglableButton(void)
1229 ToolkitTestApplication application;
1230 tet_infoline(" UtcDaliPushButtonSetGetTogglableButton");
1232 PushButton pushButton = PushButton::New();
1234 pushButton.SetProperty(Button::Property::TOGGLABLE, true);
1236 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::TOGGLABLE), true, TEST_LOCATION);
1238 pushButton.SetProperty(Button::Property::TOGGLABLE, false);
1240 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::TOGGLABLE), false, TEST_LOCATION);
1242 pushButton.SetProperty(Button::Property::TOGGLABLE, true);
1244 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::TOGGLABLE), true, TEST_LOCATION);
1248 int UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton(void)
1250 ToolkitTestApplication application;
1251 tet_infoline(" UtcDaliPushButtonSetGetAutoRepeatingAndTogglableButton");
1253 PushButton pushButton = PushButton::New();
1255 pushButton.SetProperty(Button::Property::AUTO_REPEATING, true);
1256 pushButton.SetProperty(Button::Property::TOGGLABLE, true);
1258 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::TOGGLABLE), true, TEST_LOCATION);
1259 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::AUTO_REPEATING), false, TEST_LOCATION);
1261 pushButton.SetProperty(Button::Property::TOGGLABLE, true);
1262 pushButton.SetProperty(Button::Property::AUTO_REPEATING, true);
1264 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::AUTO_REPEATING), true, TEST_LOCATION);
1265 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::TOGGLABLE), false, TEST_LOCATION);
1270 int UtcDaliPushButtonSetGetSelected01(void)
1272 ToolkitTestApplication application;
1273 tet_infoline(" UtcDaliPushButtonSetGetSelected01");
1275 PushButton pushButton = PushButton::New();
1277 pushButton.SetProperty(Button::Property::TOGGLABLE, true);
1278 pushButton.StateChangedSignal().Connect(&PushButtonSelected);
1280 gPushButtonSelectedState = false;
1281 pushButton.SetProperty(Button::Property::SELECTED, true);
1283 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::SELECTED), true, TEST_LOCATION);
1284 DALI_TEST_CHECK(gPushButtonSelectedState);
1286 pushButton.SetProperty(Button::Property::SELECTED, false);
1288 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::SELECTED), false, TEST_LOCATION);
1289 DALI_TEST_CHECK(!gPushButtonSelectedState);
1291 pushButton.SetProperty(Button::Property::SELECTED, true);
1293 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::SELECTED), true, TEST_LOCATION);
1294 DALI_TEST_CHECK(gPushButtonSelectedState);
1298 int UtcDaliPushButtonSetGetSelected02(void)
1300 ToolkitTestApplication application;
1301 tet_infoline(" UtcDaliPushButtonSetGetSelected02");
1303 PushButton pushButton = PushButton::New();
1305 tet_infoline(" Set Toggle feature off");
1306 pushButton.SetProperty(Button::Property::TOGGLABLE, false);
1307 pushButton.StateChangedSignal().Connect(&PushButtonSelected);
1309 gPushButtonSelectedState = false;
1310 tet_infoline(" Try to set to selected, expecting failure as not a toggle button");
1311 pushButton.SetProperty(Button::Property::SELECTED, true);
1313 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::SELECTED), false, TEST_LOCATION);
1314 DALI_TEST_CHECK(!gPushButtonSelectedState);
1316 pushButton.SetProperty(Button::Property::SELECTED, false);
1318 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::SELECTED), false, TEST_LOCATION);
1319 DALI_TEST_CHECK(!gPushButtonSelectedState);
1321 pushButton.SetProperty(Button::Property::SELECTED, true);
1323 DALI_TEST_EQUALS(pushButton.GetProperty<bool>(Button::Property::SELECTED), false, TEST_LOCATION);
1324 DALI_TEST_CHECK(!gPushButtonSelectedState);
1329 int UtcDaliPushButtonSetGetAutorepeatingDelayValues01(void)
1331 ToolkitTestApplication application;
1332 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues01");
1334 PushButton pushButton = PushButton::New();
1336 pushButton.SetProperty(Button::Property::AUTO_REPEATING, true);
1338 pushButton.SetProperty(Button::Property::INITIAL_AUTO_REPEATING_DELAY, 1.f);
1339 DALI_TEST_EQUALS(pushButton.GetProperty<float>(Button::Property::INITIAL_AUTO_REPEATING_DELAY), 1.f, TEST_LOCATION);
1341 pushButton.SetProperty(Button::Property::NEXT_AUTO_REPEATING_DELAY, 1.f);
1343 DALI_TEST_EQUALS(pushButton.GetProperty<float>(Button::Property::NEXT_AUTO_REPEATING_DELAY), 1.f, TEST_LOCATION);
1347 int UtcDaliPushButtonSetGetAutorepeatingDelayValues02(void)
1349 ToolkitTestApplication application;
1350 tet_infoline(" UtcDaliPushButtonSetGetAutorepeatingDelayValues02");
1352 PushButton pushButton = PushButton::New();
1354 bool assert1(false);
1355 bool assert2(false);
1357 pushButton.SetProperty(Button::Property::AUTO_REPEATING, true);
1361 pushButton.SetProperty(Button::Property::INITIAL_AUTO_REPEATING_DELAY, -1.f);
1363 catch(Dali::DaliException& e)
1365 DALI_TEST_PRINT_ASSERT(e);
1366 DALI_TEST_EQUALS(e.condition, "initialAutoRepeatingDelay > 0.f", TEST_LOCATION);
1372 pushButton.SetProperty(Button::Property::NEXT_AUTO_REPEATING_DELAY, -1.f);
1374 catch(Dali::DaliException& e)
1376 DALI_TEST_PRINT_ASSERT(e);
1377 DALI_TEST_EQUALS(e.condition, "nextAutoRepeatingDelay > 0.f", TEST_LOCATION);
1381 DALI_TEST_CHECK(assert1 && assert2);
1385 int UtcDaliPushButtonSetLabelText(void)
1387 ToolkitTestApplication application;
1388 tet_infoline(" UtcDaliPushButtonSetLabelText");
1390 const std::string STR("Hola!");
1392 PushButton pushButton = PushButton::New();
1394 pushButton.SetProperty(Toolkit::Button::Property::LABEL,
1395 Property::Map().Add(Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT).Add(Toolkit::TextVisual::Property::POINT_SIZE, 15.0f));
1397 application.SendNotification();
1398 application.Render();
1400 pushButton.SetProperty(Button::Property::LABEL, STR);
1402 DALI_TEST_EQUALS(GetButtonText(pushButton), STR, TEST_LOCATION);