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.
20 // Need to override adaptor classes for toolkit test harness, so include
21 // test harness headers before dali headers.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include "dali-toolkit-test-utils/toolkit-timer.h"
25 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit/devel-api/controls/popup/popup.h>
28 #include <dali/devel-api/actors/actor-devel.h>
29 #include <dali/devel-api/scripting/scripting.h>
30 #include <dali/integration-api/events/key-event-integ.h>
31 #include <dali/integration-api/events/touch-event-integ.h>
32 #include <dali/integration-api/events/wheel-event-integ.h>
35 using namespace Toolkit;
37 void utc_dali_toolkit_popup_startup(void)
39 test_return_value = TET_UNDEF;
42 void utc_dali_toolkit_popup_cleanup(void)
44 test_return_value = TET_PASS;
49 static bool gObjectCreatedCallBackCalled;
51 static void TestCallback(BaseHandle handle)
53 gObjectCreatedCallBackCalled = true;
56 const int RENDER_FRAME_INTERVAL = 10; ///< Duration of each frame in ms.
57 const int RENDER_ANIMATION_TEST_DURATION_MS = 2000; ///< 2000ms to test animation.
58 const int RENDER_ANIMATION_TEST_DURATION_FRAMES = RENDER_ANIMATION_TEST_DURATION_MS / RENDER_FRAME_INTERVAL; ///< equivalent frames.
59 const Vector3 DEFAULT_BUTTON_SIZE(100.0f, 50.0f, 0.0f);
61 Dali::Integration::Point GetPointDown()
63 Dali::Integration::Point point;
64 point.SetState(PointState::DOWN);
65 point.SetScreenPosition(Vector2(10, 10));
69 Dali::Integration::Point GetPointUp()
71 Dali::Integration::Point point;
72 point.SetState(PointState::UP);
73 point.SetScreenPosition(Vector2(10, 10));
78 * Counts how many descendants root Actor has, including
81 * @param[in] root The root actor to count from.
82 * @return The number of descendants including root actor itself.
84 int DescendentCount(const Actor& root)
86 unsigned int numChildren = root.GetChildCount();
90 for(unsigned int i = 0; i < numChildren; ++i)
92 count += DescendentCount(root.GetChildAt(i));
98 bool HasAncestor(Actor child, Actor ancestor)
100 while(child && child != ancestor)
102 child = child.GetParent();
105 return (child == ancestor);
108 static Toolkit::Popup::DisplayState gPopupState = Toolkit::Popup::HIDDEN;
109 static bool gTouchedOutside;
113 static void OnPopupTouchedOutside()
115 gTouchedOutside = true;
118 static void OnPopupShowing()
120 gPopupState = Toolkit::Popup::SHOWING;
123 static void OnPopupShown()
125 gPopupState = Toolkit::Popup::SHOWN;
128 static void OnPopupHiding()
130 gPopupState = Toolkit::Popup::HIDING;
133 static void OnPopupHidden()
135 gPopupState = Toolkit::Popup::HIDDEN;
138 void ConnectStateSignals(Toolkit::Popup popup)
140 popup.ShowingSignal().Connect(&OnPopupShowing);
141 popup.ShownSignal().Connect(&OnPopupShown);
142 popup.HidingSignal().Connect(&OnPopupHiding);
143 popup.HiddenSignal().Connect(&OnPopupHidden);
146 void WaitAnimation(ToolkitTestApplication& application)
148 // Wait for a while (allow animation to complete), and then check state.
149 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
151 application.SendNotification();
152 application.Render(RENDER_FRAME_INTERVAL);
157 * A connection tracker is required when connecting to a signal with a functor.
159 class TestConnectionTrackerObject : public ConnectionTracker
164 * This functor is used to test the popup's signal connection.
166 struct PopupTestFunctor
177 // Generate a KeyEvent to send to Core.
178 Integration::KeyEvent GenerateKey(const std::string& keyName,
179 const std::string& logicalKey,
180 const std::string& keyString,
183 unsigned long timeStamp,
184 const Integration::KeyEvent::State& keyState,
185 const std::string& compose = "",
186 const std::string& deviceName = "",
187 const Device::Class::Type& deviceClass = Device::Class::NONE,
188 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE)
190 return Integration::KeyEvent(keyName,
203 } // Anonymous namespace
206 * This test checks popup creation.
208 int UtcDaliPopupNewP(void)
210 ToolkitTestApplication application;
211 tet_infoline(" UtcDaliPopupNewP");
213 // Create the Popup actor.
216 DALI_TEST_CHECK(!popup);
218 popup = Popup::New();
220 DALI_TEST_CHECK(popup);
224 DALI_TEST_CHECK(popup2 == popup);
226 // Additional check to ensure object is created by checking if it's registered.
227 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
228 DALI_TEST_CHECK(registry);
230 gObjectCreatedCallBackCalled = false;
231 registry.ObjectCreatedSignal().Connect(&TestCallback);
233 Popup popup = Popup::New();
235 DALI_TEST_CHECK(gObjectCreatedCallBackCalled);
240 * This test checks popup destruction.
242 int UtcDaliPopupDestructorP(void)
244 ToolkitTestApplication application;
245 tet_infoline(" UtcDaliPopupDestructorP");
247 Popup* popup = new Popup();
250 DALI_TEST_CHECK(true);
254 int UtcDaliPopupDownCastP(void)
256 ToolkitTestApplication application;
257 tet_infoline(" UtcDaliPopupDownCastP");
259 Handle handle = Popup::New();
261 Popup popup = Popup::DownCast(handle);
263 DALI_TEST_CHECK(popup == handle);
267 int UtcDaliPopupSetPropertyP(void)
269 ToolkitTestApplication application;
270 tet_infoline(" UtcDaliPopupSetProperty");
272 Popup popup = Popup::New();
275 std::string testString = "Hello World";
277 TextLabel textActorIn = TextLabel::New(testString);
279 Scripting::CreatePropertyMap(textActorIn, map);
280 popup.SetProperty(popup.GetPropertyIndex("title"), map);
281 TextLabel textActorOut = TextLabel::DownCast(popup.GetTitle());
282 std::string resultText;
283 DALI_TEST_CHECK(textActorOut.GetProperty(Toolkit::TextLabel::Property::TEXT).Get(resultText));
284 DALI_TEST_EQUALS(testString, resultText, TEST_LOCATION);
289 int UtcDaliPopupSetTitleP(void)
291 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
292 tet_infoline(" UtcDaliPopupSetTitleP");
294 // Create the Popup actor
295 Popup popup = Popup::New();
297 // Put in show state so it's layer is connected to popup (for ancestor check).
298 popup.SetDisplayState(Popup::SHOWN);
300 TextLabel titleActor = TextLabel::New();
301 titleActor.SetProperty(Toolkit::TextLabel::Property::TEXT, "title");
303 DALI_TEST_CHECK(!popup.GetTitle());
304 popup.SetTitle(titleActor);
305 TextLabel textActor = TextLabel::DownCast(popup.GetTitle());
306 DALI_TEST_CHECK(textActor == titleActor);
308 std::string resultText;
309 DALI_TEST_CHECK(textActor.GetProperty(Toolkit::TextLabel::Property::TEXT).Get(resultText));
311 DALI_TEST_CHECK((popup.GetTitle()) && (resultText == "title"));
312 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
313 DALI_TEST_CHECK(HasAncestor(titleActor, popup));
315 TextLabel titleActor2 = TextLabel::New();
316 titleActor2.SetProperty(Toolkit::TextLabel::Property::TEXT, "anothertitle");
317 popup.SetTitle(titleActor2);
318 DALI_TEST_CHECK(popup.GetTitle() != titleActor);
319 DALI_TEST_CHECK(popup.GetTitle() == titleActor2);
320 DALI_TEST_CHECK(TextLabel::DownCast(popup.GetTitle()).GetProperty(Toolkit::TextLabel::Property::TEXT).Get(resultText));
322 DALI_TEST_CHECK((popup.GetTitle()) && (resultText == "anothertitle"));
324 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
325 DALI_TEST_CHECK(HasAncestor(titleActor2, popup));
329 int UtcDaliPopupSetTitleN(void)
331 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
332 tet_infoline(" UtcDaliPopupSetTitleN");
334 // Create the Popup actor
335 Popup popup = Popup::New();
337 TextLabel titleActor = TextLabel::New("text");
338 popup.SetTitle(titleActor);
340 DALI_TEST_CHECK(popup.GetTitle());
342 // Set a bad title value.
343 // Confirm this has disabled the title.
345 popup.SetTitle(badActor);
347 DALI_TEST_CHECK(!popup.GetTitle());
352 int UtcDaliPopupSetContentP(void)
354 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
355 tet_infoline(" UtcDaliPopupSetContentP");
357 // Create the Popup actor
358 Popup popup = Popup::New();
359 application.GetScene().Add(popup);
360 popup.SetProperty(Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f);
362 // Put in show state so it's layer is connected to popup (for ancestor check).
363 popup.SetDisplayState(Popup::SHOWN);
365 PushButton button = PushButton::New();
366 DALI_TEST_CHECK(!HasAncestor(button, popup));
367 popup.SetFooter(button);
368 // Hide and then re-show popup to cause button to be rearranged and added to popup.
369 popup.SetDisplayState(Popup::HIDDEN);
370 popup.SetDisplayState(Popup::SHOWN);
371 DALI_TEST_CHECK(HasAncestor(button, popup));
375 int UtcDaliPopupSetContentN(void)
377 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
378 tet_infoline(" UtcDaliPopupSetContentN");
380 // Create the Popup actor
381 Popup popup = Popup::New();
383 TextLabel content = TextLabel::New("text");
384 popup.SetContent(content);
386 DALI_TEST_CHECK(popup.GetContent());
388 // Set a bad title value.
390 popup.SetContent(badActor);
392 DALI_TEST_CHECK(!popup.GetContent());
397 int UtcDaliPopupSetFooterP(void)
399 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
400 tet_infoline(" UtcDaliPopupSetFooterP");
402 // Create the Popup actor
403 Popup popup = Popup::New();
404 application.GetScene().Add(popup);
405 popup.SetProperty(Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f);
406 // Put in show state so it's layer is connected to popup (for ancestor check).
407 popup.SetDisplayState(Popup::SHOWN);
409 PushButton button = PushButton::New();
410 DALI_TEST_CHECK(!HasAncestor(button, popup));
411 popup.SetFooter(button);
412 // Hide and then re-show popup to cause button to be rearranged and added to popup.
413 popup.SetDisplayState(Popup::HIDDEN);
414 popup.SetDisplayState(Popup::SHOWN);
415 DALI_TEST_CHECK(HasAncestor(button, popup));
419 int UtcDaliPopupSetFooterN(void)
421 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
422 tet_infoline(" UtcDaliPopupSetFooterN");
424 // Create the Popup actor
425 Popup popup = Popup::New();
427 PushButton button = PushButton::New();
428 popup.SetFooter(button);
430 DALI_TEST_CHECK(popup.GetFooter());
432 // Set a bad title value.
434 popup.SetFooter(badActor);
436 DALI_TEST_CHECK(!popup.GetFooter());
441 int UtcDaliPopupSetControlFooterMultiple(void)
443 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
444 tet_infoline(" UtcDaliPopupSetControlFooterMultiple");
446 // Create the Popup actor
447 Popup popup = Popup::New();
448 application.GetScene().Add(popup);
449 popup.SetProperty(Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f);
450 // Put in show state so it's layer is connected to popup (for ancestor check).
451 popup.SetDisplayState(Popup::SHOWN);
453 Actor container = Actor::New();
454 PushButton button1 = PushButton::New();
455 PushButton button2 = PushButton::New();
456 DALI_TEST_CHECK(!HasAncestor(button1, popup));
457 DALI_TEST_CHECK(!HasAncestor(button2, popup));
458 container.Add(button1);
459 container.Add(button2);
460 popup.SetFooter(container);
462 // Hide and then re-show popup to cause button to be rearranged and added to popup.
463 popup.SetDisplayState(Popup::HIDDEN);
464 popup.SetDisplayState(Popup::SHOWN);
465 DALI_TEST_CHECK(HasAncestor(button1, popup));
466 DALI_TEST_CHECK(HasAncestor(button2, popup));
470 int UtcDaliPopupSetTitleAndFooter(void)
472 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
473 tet_infoline(" UtcDaliPopupSetTitleAndFooter");
475 // Create the Popup actor
476 Popup popup = Popup::New();
478 // Put in show state so it's layer is connected to popup (for ancestor check).
479 popup.SetDisplayState(Popup::SHOWN);
482 TextLabel titleActor = TextLabel::New();
483 titleActor.SetProperty(Toolkit::TextLabel::Property::TEXT, "title");
485 DALI_TEST_CHECK(!popup.GetTitle());
486 popup.SetTitle(titleActor);
487 TextLabel textActor = TextLabel::DownCast(popup.GetTitle());
488 DALI_TEST_CHECK(textActor == titleActor);
490 std::string resultText;
491 DALI_TEST_CHECK(textActor.GetProperty(Toolkit::TextLabel::Property::TEXT).Get(resultText));
492 DALI_TEST_CHECK((popup.GetTitle()) && (resultText == "title"));
493 // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
494 DALI_TEST_CHECK(HasAncestor(titleActor, popup));
497 PushButton button = PushButton::New();
498 DALI_TEST_CHECK(!HasAncestor(button, popup));
499 popup.SetFooter(button);
500 // Hide and then re-show popup to cause button to be rearranged and added to popup.
501 popup.SetDisplayState(Popup::HIDDEN);
502 popup.SetDisplayState(Popup::SHOWN);
503 DALI_TEST_CHECK(HasAncestor(button, popup));
508 int UtcDaliPopupSetStateP(void)
510 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
511 tet_infoline(" UtcDaliPopupSetStateP");
513 // Create the Popup actor
514 Popup popup = Popup::New();
516 popup.SetProperty(Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f);
518 DALI_TEST_EQUALS(popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION);
520 popup.SetDisplayState(Popup::SHOWN);
521 DALI_TEST_EQUALS(Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION);
523 popup.SetDisplayState(Popup::HIDDEN);
524 DALI_TEST_EQUALS(Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION);
528 int UtcDaliPopupSetStateN(void)
530 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
531 tet_infoline(" UtcDaliPopupSetStateN");
533 // Create the Popup actor
534 Popup popup = Popup::New();
536 popup.SetProperty(Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f);
538 DALI_TEST_EQUALS(popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION);
540 popup.SetDisplayState(Popup::SHOWN);
541 DALI_TEST_EQUALS(Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION);
543 // Test cancelling a show before it has finished.
544 popup.SetDisplayState(Popup::HIDDEN);
545 DALI_TEST_EQUALS(Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION);
549 int UtcDaliPopupDisplayStateSignal(void)
551 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
552 tet_infoline(" UtcDaliPopupDisplayStateSignal");
554 // Create the Popup actor
555 Popup popup = Popup::New();
556 ConnectStateSignals(popup);
558 popup.SetProperty(Toolkit::Popup::Property::ANIMATION_DURATION, 1.0f);
559 popup.SetDisplayState(Popup::SHOWN);
560 DALI_TEST_EQUALS(Popup::SHOWING, popup.GetDisplayState(), TEST_LOCATION);
561 DALI_TEST_EQUALS(gPopupState, Popup::SHOWING, TEST_LOCATION);
563 // Wait for a while (allow animation to complete), and then check state.
564 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
566 application.SendNotification();
567 application.Render(RENDER_FRAME_INTERVAL);
570 DALI_TEST_EQUALS(Popup::SHOWN, popup.GetDisplayState(), TEST_LOCATION);
571 DALI_TEST_EQUALS(gPopupState, Popup::SHOWN, TEST_LOCATION);
574 popup.SetDisplayState(Popup::HIDDEN);
575 DALI_TEST_EQUALS(Popup::HIDING, popup.GetDisplayState(), TEST_LOCATION);
576 DALI_TEST_EQUALS(gPopupState, Popup::HIDING, TEST_LOCATION);
578 // Wait for a while (allow animation to complete), and then check state.
579 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
581 application.SendNotification();
582 application.Render(RENDER_FRAME_INTERVAL);
585 DALI_TEST_EQUALS(Popup::HIDDEN, popup.GetDisplayState(), TEST_LOCATION);
586 DALI_TEST_EQUALS(gPopupState, Popup::HIDDEN, TEST_LOCATION);
591 int UtcDaliPopupShowHide(void)
593 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
594 tet_infoline(" UtcDaliPopupShowHide");
596 // Create the Popup actor
597 Popup popup = Popup::New();
598 ConnectStateSignals(popup);
600 Actor container = Actor::New();
601 PushButton button1 = PushButton::New();
602 PushButton button2 = PushButton::New();
603 button1.SetProperty(Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY());
604 button2.SetProperty(Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY());
605 container.Add(button1);
606 container.Add(button2);
607 popup.SetFooter(container);
610 // Note: in most popup animation implementations show would result in
611 // popup being onstage immediately following Show(). However we can't
612 // assume for all. e.g. If one creates a animation with a delay.
613 popup.SetDisplayState(Popup::SHOWN);
615 // Wait for a while (allow animation to complete), and then check state.
616 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
618 application.SendNotification();
619 application.Render(RENDER_FRAME_INTERVAL);
623 popup.SetDisplayState(Popup::HIDDEN);
625 // Wait for a while (allow animation to complete), and then check state.
626 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
628 application.SendNotification();
629 application.Render(RENDER_FRAME_INTERVAL);
632 DALI_TEST_EQUALS(gPopupState, Popup::HIDDEN, TEST_LOCATION);
636 int UtcDaliPopupPropertyTailVisibility(void)
638 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
639 tet_infoline(" UtcDaliPopupShowHideTail");
641 // Create the Popup actor
642 Popup popup = Popup::New();
643 application.GetScene().Add(popup);
645 popup.SetProperty(Popup::Property::TAIL_VISIBILITY, false);
646 popup.SetDisplayState(Popup::SHOWN);
648 int withoutTailCount = DescendentCount(popup);
650 popup.SetDisplayState(Popup::HIDDEN);
652 popup.SetProperty(Popup::Property::TAIL_POSITION, "BOTTOM_CENTER");
653 popup.SetProperty(Popup::Property::TAIL_VISIBILITY, true);
654 popup.SetDisplayState(Popup::SHOWN);
656 int withTailCount = DescendentCount(popup);
658 // There should be more actors if the Tail has been added.
659 DALI_TEST_CHECK(withTailCount > withoutTailCount);
662 popup.SetDisplayState(Popup::HIDDEN);
663 popup.SetProperty(Popup::Property::TAIL_VISIBILITY, false);
664 popup.SetDisplayState(Popup::SHOWN);
665 int withoutTailCount2 = DescendentCount(popup);
667 DALI_TEST_CHECK(withTailCount > withoutTailCount2);
671 int UtcDaliPopupOnTouchedOutsideSignal(void)
673 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
674 tet_infoline(" UtcDaliPopupOnTouchedOutside");
676 // Create the Popup actor
677 Popup popup = Popup::New();
678 popup.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
679 popup.SetProperty(Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER);
680 popup.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
681 popup.SetProperty(Actor::Property::SIZE, Vector2(50.0f, 50.0f));
682 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
683 application.GetScene().Add(popup);
684 popup.OutsideTouchedSignal().Connect(&OnPopupTouchedOutside);
685 popup.SetDisplayState(Popup::SHOWN);
687 application.SendNotification();
688 application.Render();
690 gTouchedOutside = false;
691 Dali::Integration::TouchEvent event;
693 event = Dali::Integration::TouchEvent();
694 event.AddPoint(GetPointDown());
695 application.ProcessEvent(event);
697 application.SendNotification();
698 application.Render();
700 event = Dali::Integration::TouchEvent();
701 event.AddPoint(GetPointUp());
702 application.ProcessEvent(event);
704 application.SendNotification();
705 application.Render();
707 // Confirm the signal is ignored if touch_transparent.
708 gTouchedOutside = false;
709 popup.SetProperty(Popup::Property::TOUCH_TRANSPARENT, true);
711 event = Dali::Integration::TouchEvent();
712 event.AddPoint(GetPointDown());
713 application.ProcessEvent(event);
715 application.SendNotification();
716 application.Render();
718 event = Dali::Integration::TouchEvent();
719 event.AddPoint(GetPointUp());
720 application.ProcessEvent(event);
722 application.SendNotification();
723 application.Render();
725 DALI_TEST_CHECK(!gTouchedOutside);
730 int UtcDaliPopupPropertyAutoHide(void)
732 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
733 tet_infoline(" UtcDaliPopupPropertyAutoHide");
735 // Create the Popup actor
736 Popup popup = Popup::New();
737 ConnectStateSignals(popup);
739 Actor container = Actor::New();
740 PushButton button1 = PushButton::New();
741 button1.SetProperty(Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY());
742 container.Add(button1);
743 popup.SetFooter(container);
745 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
746 float getAnimationDuration = 0.0f;
747 DALI_TEST_CHECK(popup.GetProperty(Popup::Property::ANIMATION_DURATION).Get(getAnimationDuration));
748 DALI_TEST_EQUALS(getAnimationDuration, 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
750 popup.SetProperty(Popup::Property::AUTO_HIDE_DELAY, 200);
751 int getAutoHideDelay = 0;
752 DALI_TEST_CHECK(popup.GetProperty(Popup::Property::AUTO_HIDE_DELAY).Get(getAutoHideDelay));
753 DALI_TEST_EQUALS(getAutoHideDelay, 200, TEST_LOCATION);
755 application.GetScene().Add(popup);
757 DALI_TEST_EQUALS(gPopupState, Popup::HIDDEN, TEST_LOCATION);
760 // Note: in most popup animation implementations show would result in
761 // popup being onstage immediately following Show(). However we can't
762 // assume for all. e.g. If one creates a animation with a delay.
763 popup.SetDisplayState(Popup::SHOWN);
765 DALI_TEST_EQUALS(gPopupState, Popup::SHOWN, TEST_LOCATION);
767 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
769 application.SendNotification();
770 application.Render(RENDER_FRAME_INTERVAL);
773 // Force the timer used by the popup to expire,
774 // this will cause the popup to hide automatically.
775 Dali::Timer timer = Timer::New(0);
776 timer.MockEmitSignal();
778 DALI_TEST_EQUALS(gPopupState, Popup::HIDDEN, TEST_LOCATION);
784 * This test checks all animation modes to confirm they all trigger all display states at the expected times.
786 int UtcDaliPopupPropertyAnimationMode(void)
788 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
789 tet_infoline(" UtcDaliPopupPropertyAnimationMode");
791 // Create the Popup actor
792 Popup popup = Popup::New();
793 ConnectStateSignals(popup);
794 popup.SetTitle(TextLabel::New("Title"));
795 application.GetScene().Add(popup);
797 std::string animationModes[] = {"NONE", "ZOOM", "FADE", "CUSTOM"};
799 // Try both default and zero animation duration, as zero has a special case for some animation types.
800 for(int j = 0; j <= 1; j++)
802 // On the second loop, set duration to zero.
805 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
808 // Loop through 4 animation modes.
809 for(int i = 0; i < 4; i++)
811 popup.SetProperty(Popup::Property::ANIMATION_MODE, animationModes[i]);
813 std::string checkMode;
814 DALI_TEST_CHECK(popup.GetProperty(Popup::Property::ANIMATION_MODE).Get(checkMode))
816 DALI_TEST_EQUALS(checkMode, animationModes[i], TEST_LOCATION);
818 popup.SetProperty(Toolkit::Popup::Property::DISPLAY_STATE, "SHOWN");
819 std::string resultState;
821 // Only wait for animation if it isn't instant.
824 DALI_TEST_EQUALS(gPopupState, Popup::SHOWING, TEST_LOCATION);
825 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::DISPLAY_STATE).Get(resultState));
826 DALI_TEST_EQUALS(resultState, "SHOWING", TEST_LOCATION);
827 WaitAnimation(application);
830 DALI_TEST_EQUALS(gPopupState, Popup::SHOWN, TEST_LOCATION);
831 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::DISPLAY_STATE).Get(resultState));
832 DALI_TEST_EQUALS(resultState, "SHOWN", TEST_LOCATION);
833 popup.SetDisplayState(Popup::HIDDEN);
837 DALI_TEST_EQUALS(gPopupState, Popup::HIDING, TEST_LOCATION);
838 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::DISPLAY_STATE).Get(resultState));
839 DALI_TEST_EQUALS(resultState, "HIDING", TEST_LOCATION);
840 WaitAnimation(application);
843 DALI_TEST_EQUALS(gPopupState, Popup::HIDDEN, TEST_LOCATION);
844 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::DISPLAY_STATE).Get(resultState));
845 DALI_TEST_EQUALS(resultState, "HIDDEN", TEST_LOCATION);
852 int UtcDaliPopupPropertyTitle(void)
854 ToolkitTestApplication application;
855 tet_infoline(" UtcDaliPopupPropertyTitle");
857 // Create the Popup actor
858 Popup popup = Popup::New();
860 std::string testLabelText = "TitleTest";
861 TextLabel titleLabel = TextLabel::New();
862 titleLabel.SetProperty(Toolkit::TextLabel::Property::TEXT, testLabelText);
863 Actor title = titleLabel;
865 Scripting::CreatePropertyMap(title, map);
866 popup.SetProperty(Toolkit::Popup::Property::TITLE, map);
868 Property::Map resultMap;
869 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::TITLE).Get(resultMap));
871 Property::Value* resultProperty = resultMap.Find("text");
872 DALI_TEST_CHECK(resultProperty);
874 std::string resultText;
875 DALI_TEST_CHECK(resultProperty->Get(resultText));
877 DALI_TEST_EQUALS(resultText, testLabelText, TEST_LOCATION);
882 int UtcDaliPopupPropertyContent(void)
884 ToolkitTestApplication application;
885 tet_infoline(" UtcDaliPopupPropertyContent");
887 // Create the Popup actor
888 Popup popup = Popup::New();
890 std::string testLabelText = "ContentTest";
891 TextLabel contentLabel = TextLabel::New();
892 contentLabel.SetProperty(Toolkit::TextLabel::Property::TEXT, testLabelText);
893 Actor content = contentLabel;
895 Scripting::CreatePropertyMap(content, map);
896 popup.SetProperty(Toolkit::Popup::Property::CONTENT, map);
898 Property::Map resultMap;
899 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::CONTENT).Get(resultMap));
901 Property::Value* resultProperty = resultMap.Find("text");
902 DALI_TEST_CHECK(resultProperty);
904 std::string resultText;
905 DALI_TEST_CHECK(resultProperty->Get(resultText));
907 DALI_TEST_EQUALS(resultText, testLabelText, TEST_LOCATION);
912 int UtcDaliPopupPropertyFooter(void)
914 ToolkitTestApplication application;
915 tet_infoline(" UtcDaliPopupPropertyFooter");
917 // Create the Popup actor
918 Popup popup = Popup::New();
920 std::string testLabelText = "FooterTest";
921 TextLabel footerLabel = TextLabel::New();
922 footerLabel.SetProperty(Toolkit::TextLabel::Property::TEXT, testLabelText);
923 Actor footer = footerLabel;
925 Scripting::CreatePropertyMap(footer, map);
926 popup.SetProperty(Toolkit::Popup::Property::FOOTER, map);
928 Property::Map resultMap;
929 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::FOOTER).Get(resultMap));
931 Property::Value* resultProperty = resultMap.Find("text");
932 DALI_TEST_CHECK(resultProperty);
934 std::string resultText;
935 DALI_TEST_CHECK(resultProperty->Get(resultText));
937 DALI_TEST_EQUALS(resultText, testLabelText, TEST_LOCATION);
942 int UtcDaliPopupPropertyContextualMode(void)
944 ToolkitTestApplication application;
945 tet_infoline(" UtcDaliPopupPropertyContextualMode");
947 // Create the Popup actor
948 Popup popup = Popup::New();
949 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
950 std::string testLabelText = "ContentTest";
952 TextLabel contentLabel = TextLabel::New();
954 popup.SetContent(contentLabel);
956 // Placement actor to parent the popup from so the popup's contextual position can be relative to it.
957 Actor placement = Actor::New();
958 placement.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
959 placement.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
960 placement.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
961 placement.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
962 application.GetScene().Add(placement);
964 placement.Add(popup);
966 // Test all contextual modes.
967 const char* mode[5] = {"NON_CONTEXTUAL", "ABOVE", "RIGHT", "BELOW", "LEFT"};
968 Vector2 offsetValues[5];
969 offsetValues[0] = Vector2(0.375f, 0.0f);
970 offsetValues[1] = Vector2(-0.125f, -10.5f);
971 offsetValues[2] = Vector2(10.875f, -0.5f);
972 offsetValues[3] = Vector2(-0.125f, 10.5f);
973 offsetValues[4] = Vector2(-10.875f, -0.5f);
975 for(int i = 0; i < 5; ++i)
977 popup.SetProperty(Toolkit::Popup::Property::CONTEXTUAL_MODE, mode[i]);
979 std::string propertyResult;
980 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::CONTEXTUAL_MODE).Get(propertyResult));
981 DALI_TEST_EQUALS(propertyResult, std::string(mode[i]), TEST_LOCATION);
983 popup.SetDisplayState(Popup::SHOWN);
984 application.SendNotification();
985 application.Render();
987 // Check the position of the label within the popup.
988 DALI_TEST_EQUALS(contentLabel.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).GetVectorXY(), offsetValues[i], TEST_LOCATION);
990 popup.SetDisplayState(Popup::HIDDEN);
991 application.SendNotification();
992 application.Render();
998 int UtcDaliPopupPropertyBacking(void)
1000 ToolkitTestApplication application;
1001 tet_infoline(" UtcDaliPopupPropertyBacking");
1003 // Create the Popup actor
1004 Popup popup = Popup::New();
1005 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
1006 application.GetScene().Add(popup);
1008 Actor backing = popup.FindChildByName("popupBacking");
1009 DALI_TEST_CHECK(backing);
1011 DALI_TEST_EQUALS(backing.GetCurrentProperty<float>(Actor::Property::OPACITY), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1013 // Check enabled property.
1014 popup.SetDisplayState(Popup::SHOWN);
1015 application.SendNotification();
1016 application.Render();
1018 DALI_TEST_EQUALS(backing.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1020 popup.SetDisplayState(Popup::HIDDEN);
1021 application.SendNotification();
1022 application.Render();
1024 DALI_TEST_EQUALS(backing.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1026 popup.SetProperty(Popup::Property::BACKING_ENABLED, false);
1027 bool propertyResult;
1028 DALI_TEST_CHECK(popup.GetProperty(Popup::Property::BACKING_ENABLED).Get(propertyResult));
1029 DALI_TEST_EQUALS(propertyResult, false, TEST_LOCATION);
1031 popup.SetDisplayState(Popup::SHOWN);
1032 application.SendNotification();
1033 application.Render();
1035 DALI_TEST_EQUALS(backing.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1037 popup.SetDisplayState(Popup::HIDDEN);
1038 application.SendNotification();
1039 application.Render();
1041 DALI_TEST_EQUALS(backing.GetCurrentProperty<float>(Actor::Property::OPACITY), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
1043 // Check color property.
1044 popup.SetProperty(Popup::Property::BACKING_ENABLED, true);
1045 popup.SetProperty(Popup::Property::BACKING_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
1047 popup.SetDisplayState(Popup::SHOWN);
1048 application.SendNotification();
1049 application.Render();
1051 Vector4 resultColor;
1052 popup.GetProperty(Popup::Property::BACKING_COLOR).Get(resultColor);
1053 DALI_TEST_EQUALS(resultColor, Vector4(1.0f, 0.0f, 0.0f, 1.0f), Math::MACHINE_EPSILON_0, TEST_LOCATION);
1058 int UtcDaliPopupPropertyBackgroundImage(void)
1060 ToolkitTestApplication application;
1061 tet_infoline(" UtcDaliPopupPropertyBackgroundImage");
1063 // Create the Popup actor
1064 Popup popup = Popup::New();
1065 application.GetScene().Add(popup);
1067 // Check setting an image
1068 popup.SetProperty(Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png");
1069 std::string resultString;
1070 popup.GetProperty(Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE).Get(resultString);
1071 DALI_TEST_EQUALS(resultString, "invalid-image.png", TEST_LOCATION);
1076 int UtcDaliPopupPropertyCustomAnimation(void)
1078 ToolkitTestApplication application;
1079 tet_infoline(" UtcDaliPopupPropertyCustomAnimation");
1081 // Create the Popup actor
1082 Popup popup = Popup::New();
1083 TextLabel content = TextLabel::New("text");
1084 popup.SetContent(content);
1086 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 1.0f);
1087 popup.SetProperty(Popup::Property::ANIMATION_MODE, "CUSTOM");
1089 Actor popupContainer = popup.FindChildByName("popupContainer");
1090 DALI_TEST_CHECK(popupContainer);
1092 Vector3 entryAnimationDestination(300.0f, 200.0f, 0.0f);
1093 Vector3 exitAnimationDestination(-300.0f, -200.0f, 0.0f);
1095 Property::Map animationMapEntry;
1096 animationMapEntry.Insert("actor", "customAnimationPopup");
1097 animationMapEntry.Insert("property", "position");
1098 animationMapEntry.Insert("value", entryAnimationDestination);
1099 animationMapEntry.Insert("alphaFunction", "EASE_OUT");
1101 Property::Array timePeriodMapEntry;
1102 timePeriodMapEntry.PushBack(0.0f);
1103 timePeriodMapEntry.PushBack(1.0f);
1105 animationMapEntry.Insert("timePeriod", timePeriodMapEntry);
1107 Property::Map animationMapExit;
1108 animationMapExit.Insert("actor", "customAnimationPopup");
1109 animationMapExit.Insert("property", "position");
1110 animationMapExit.Insert("value", exitAnimationDestination);
1111 animationMapExit.Insert("alphaFunction", "EASE_IN");
1113 Property::Array timePeriodMapExit;
1114 timePeriodMapExit.PushBack(0.0f);
1115 timePeriodMapExit.PushBack(1.0f);
1117 animationMapExit.Insert("timePeriod", timePeriodMapExit);
1119 popup.SetProperty(Toolkit::Popup::Property::ENTRY_ANIMATION, animationMapEntry);
1120 popup.SetProperty(Toolkit::Popup::Property::EXIT_ANIMATION, animationMapExit);
1122 Property::Map resultMap;
1123 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::ENTRY_ANIMATION).Get(resultMap));
1124 DALI_TEST_EQUALS(resultMap.Count(), 0u, TEST_LOCATION);
1125 DALI_TEST_CHECK(popup.GetProperty(Toolkit::Popup::Property::EXIT_ANIMATION).Get(resultMap));
1126 DALI_TEST_EQUALS(resultMap.Count(), 0u, TEST_LOCATION);
1128 application.GetScene().Add(popup);
1129 popup.SetDisplayState(Popup::SHOWN);
1131 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
1133 application.SendNotification();
1134 application.Render(RENDER_FRAME_INTERVAL);
1137 // Test the popup has animated to it's entry-transition destination.
1138 DALI_TEST_EQUALS(popupContainer.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), entryAnimationDestination, 0.1f, TEST_LOCATION);
1140 popup.SetDisplayState(Popup::HIDDEN);
1142 for(int j = 0; j < RENDER_ANIMATION_TEST_DURATION_FRAMES; j++)
1144 application.SendNotification();
1145 application.Render(RENDER_FRAME_INTERVAL);
1148 DALI_TEST_EQUALS(popupContainer.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION), exitAnimationDestination, 0.1f, TEST_LOCATION);
1153 static bool gPushButtonClicked;
1154 static bool PushButtonClicked(Button button)
1156 gPushButtonClicked = true;
1160 int UtcDaliPopupPropertyTouchTransparent(void)
1162 ToolkitTestApplication application;
1163 tet_infoline(" UtcDaliPopupPropertyTouchTransparent");
1165 // Create the Popup actor
1166 Popup popup = Popup::New();
1167 TextLabel content = TextLabel::New("text");
1168 popup.SetContent(content);
1169 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
1170 popup.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1171 popup.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1172 popup.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1173 popup.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1175 // Create a button (to go underneath the popup).
1176 PushButton button = Toolkit::PushButton::New();
1177 button.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1178 button.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1179 button.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1180 button.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1182 button.ClickedSignal().Connect(&PushButtonClicked);
1184 application.GetScene().Add(button);
1188 popup.SetDisplayState(Popup::SHOWN);
1189 application.SendNotification();
1190 application.Render();
1192 gPushButtonClicked = false;
1193 Dali::Integration::TouchEvent event;
1195 // Perform a click, the popup should block the click from hitting the button.
1196 event = Dali::Integration::TouchEvent();
1197 event.AddPoint(GetPointDown());
1198 application.ProcessEvent(event);
1199 application.SendNotification();
1200 application.Render();
1202 event = Dali::Integration::TouchEvent();
1203 event.AddPoint(GetPointUp());
1204 application.ProcessEvent(event);
1205 application.SendNotification();
1206 application.Render();
1208 DALI_TEST_CHECK(!gPushButtonClicked);
1210 // Perform a wheel event
1211 Dali::Integration::WheelEvent wheelEvent(Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2(10.0f, 10.0f), 1, 1000u);
1212 application.ProcessEvent(wheelEvent);
1213 application.SendNotification();
1214 application.Render();
1216 // Enable touch transparency.
1217 popup.SetProperty(Popup::Property::TOUCH_TRANSPARENT, true);
1218 bool propertyResult;
1219 DALI_TEST_CHECK(popup.GetProperty(Popup::Property::TOUCH_TRANSPARENT).Get(propertyResult));
1220 DALI_TEST_EQUALS(propertyResult, true, TEST_LOCATION);
1222 // Perform a click, the popup should allow the click to travel through to the button.
1223 event = Dali::Integration::TouchEvent();
1224 event.AddPoint(GetPointDown());
1225 application.ProcessEvent(event);
1226 application.SendNotification();
1227 application.Render();
1229 event = Dali::Integration::TouchEvent();
1230 event.AddPoint(GetPointUp());
1231 application.ProcessEvent(event);
1232 application.SendNotification();
1233 application.Render();
1235 DALI_TEST_CHECK(gPushButtonClicked);
1240 int UtcDaliPopupPropertyTail(void)
1242 ToolkitTestApplication application;
1243 tet_infoline(" UtcDaliPopupPropertyTail");
1245 // Create the Popup actor
1246 Popup popup = Popup::New();
1247 popup.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1248 popup.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1249 popup.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
1250 popup.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
1251 TextLabel content = TextLabel::New("text");
1252 popup.SetContent(content);
1254 std::string imageFilename = "invalid-image.jpg";
1255 popup.SetProperty(Popup::Property::TAIL_DOWN_IMAGE, imageFilename);
1256 popup.SetProperty(Popup::Property::TAIL_UP_IMAGE, imageFilename);
1257 popup.SetProperty(Popup::Property::TAIL_RIGHT_IMAGE, imageFilename);
1258 popup.SetProperty(Popup::Property::TAIL_LEFT_IMAGE, imageFilename);
1260 std::string resultString;
1261 popup.GetProperty(Toolkit::Popup::Property::TAIL_DOWN_IMAGE).Get(resultString);
1262 DALI_TEST_EQUALS(resultString, imageFilename, TEST_LOCATION);
1263 popup.GetProperty(Toolkit::Popup::Property::TAIL_UP_IMAGE).Get(resultString);
1264 DALI_TEST_EQUALS(resultString, imageFilename, TEST_LOCATION);
1265 popup.GetProperty(Toolkit::Popup::Property::TAIL_RIGHT_IMAGE).Get(resultString);
1266 DALI_TEST_EQUALS(resultString, imageFilename, TEST_LOCATION);
1267 popup.GetProperty(Toolkit::Popup::Property::TAIL_LEFT_IMAGE).Get(resultString);
1268 DALI_TEST_EQUALS(resultString, imageFilename, TEST_LOCATION);
1270 popup.SetProperty(Popup::Property::TAIL_VISIBILITY, true);
1272 DALI_TEST_CHECK(popup.GetProperty(Popup::Property::TAIL_VISIBILITY).Get(boolResult));
1273 DALI_TEST_EQUALS(boolResult, true, TEST_LOCATION);
1276 Vector3 tailPosition(ParentOrigin::TOP_CENTER);
1278 popup.SetProperty(Popup::Property::TAIL_POSITION, tailPosition);
1279 Vector3 vectorResult;
1280 DALI_TEST_CHECK(popup.GetProperty(Popup::Property::TAIL_POSITION).Get(vectorResult));
1281 DALI_TEST_EQUALS(vectorResult, tailPosition, TEST_LOCATION);
1283 application.GetScene().Add(popup);
1285 popup.SetDisplayState(Popup::SHOWN);
1286 application.SendNotification();
1287 application.Render();
1288 tailActor = popup.FindChildByName("tailImage");
1289 DALI_TEST_CHECK(tailActor);
1291 float baseValX = tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x;
1293 DALI_TEST_GREATER(baseValX, tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y, TEST_LOCATION);
1295 popup.SetDisplayState(Popup::HIDDEN);
1296 application.SendNotification();
1297 application.Render();
1299 tailPosition = ParentOrigin::CENTER_LEFT;
1300 popup.SetProperty(Popup::Property::TAIL_POSITION, tailPosition);
1302 popup.SetDisplayState(Popup::SHOWN);
1303 application.SendNotification();
1304 application.Render();
1305 tailActor = popup.FindChildByName("tailImage");
1306 DALI_TEST_CHECK(tailActor);
1308 float baseValY = tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y;
1309 DALI_TEST_GREATER(baseValX, tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x, TEST_LOCATION);
1311 popup.SetDisplayState(Popup::HIDDEN);
1312 application.SendNotification();
1313 application.Render();
1315 tailPosition = ParentOrigin::BOTTOM_CENTER;
1316 popup.SetProperty(Popup::Property::TAIL_POSITION, tailPosition);
1318 popup.SetDisplayState(Popup::SHOWN);
1319 application.SendNotification();
1320 application.Render();
1321 tailActor = popup.FindChildByName("tailImage");
1322 DALI_TEST_CHECK(tailActor);
1323 DALI_TEST_EQUALS(tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x, baseValX, TEST_LOCATION);
1324 DALI_TEST_GREATER(tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y, baseValY, TEST_LOCATION);
1326 popup.SetDisplayState(Popup::HIDDEN);
1327 application.SendNotification();
1328 application.Render();
1330 tailPosition = ParentOrigin::CENTER_RIGHT;
1331 popup.SetProperty(Popup::Property::TAIL_POSITION, tailPosition);
1333 popup.SetDisplayState(Popup::SHOWN);
1334 application.SendNotification();
1335 application.Render();
1336 tailActor = popup.FindChildByName("tailImage");
1337 DALI_TEST_CHECK(tailActor);
1338 DALI_TEST_GREATER(tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x, baseValX, TEST_LOCATION);
1339 DALI_TEST_EQUALS(tailActor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y, baseValY, TEST_LOCATION);
1341 popup.SetDisplayState(Popup::HIDDEN);
1342 application.SendNotification();
1343 application.Render();
1348 int UtcDaliPopupTypeToast(void)
1350 ToolkitTestApplication application;
1351 tet_infoline(" UtcDaliPopupTypeToast");
1353 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo("PopupToast");
1354 DALI_TEST_CHECK(typeInfo)
1356 BaseHandle baseHandle = typeInfo.CreateInstance();
1357 DALI_TEST_CHECK(baseHandle)
1359 Toolkit::Popup popup = Toolkit::Popup::DownCast(baseHandle);
1360 gPopupState = Toolkit::Popup::HIDDEN;
1361 ConnectStateSignals(popup);
1362 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 1.0f);
1364 popup.SetTitle(Toolkit::TextLabel::New("This is a Toast Popup.\nIt will auto-hide itself"));
1365 application.GetScene().Add(popup);
1366 popup.SetDisplayState(Toolkit::Popup::SHOWN);
1368 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
1370 application.SendNotification();
1371 application.Render(RENDER_FRAME_INTERVAL);
1374 // Check the toast popup is shown.
1375 DALI_TEST_EQUALS(gPopupState, Popup::SHOWN, TEST_LOCATION);
1377 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
1379 application.SendNotification();
1380 application.Render(RENDER_FRAME_INTERVAL);
1383 // Check the toast popup hides.
1384 Dali::Timer timer = Timer::New(0);
1385 timer.MockEmitSignal();
1387 for(int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++)
1389 application.SendNotification();
1390 application.Render(RENDER_FRAME_INTERVAL);
1393 DALI_TEST_EQUALS(gPopupState, Popup::HIDDEN, TEST_LOCATION);
1398 int UtcDaliPopupTypeRegistryCreation(void)
1400 ToolkitTestApplication application;
1401 tet_infoline(" UtcDaliPopupTypeRegistryCreation");
1403 TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo("Popup");
1404 DALI_TEST_CHECK(typeInfo)
1406 BaseHandle baseHandle = typeInfo.CreateInstance();
1407 DALI_TEST_CHECK(baseHandle)
1409 Toolkit::Popup popup = Toolkit::Popup::DownCast(baseHandle);
1410 gPopupState = Toolkit::Popup::HIDDEN;
1411 ConnectStateSignals(popup);
1412 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
1414 application.GetScene().Add(popup);
1415 popup.SetDisplayState(Toolkit::Popup::SHOWN);
1417 application.SendNotification();
1418 application.Render();
1420 // Check the popup is shown.
1421 DALI_TEST_EQUALS(gPopupState, Popup::SHOWN, TEST_LOCATION);
1426 int UtcDaliPopupPropertyTypeRegistryConnectSignal(void)
1428 ToolkitTestApplication application;
1429 tet_infoline(" UtcDaliPopupPropertyTypeRegistryConnectSignal");
1431 // Create the Popup actor
1432 Popup popup = Popup::New();
1434 TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject();
1435 // Note: The emmision of this signals has already been tested in other tests.
1436 DALI_TEST_CHECK(popup.ConnectSignal(testTracker, "touchedOutside", PopupTestFunctor()));
1437 DALI_TEST_CHECK(popup.ConnectSignal(testTracker, "showing", PopupTestFunctor()));
1438 DALI_TEST_CHECK(popup.ConnectSignal(testTracker, "shown", PopupTestFunctor()));
1439 DALI_TEST_CHECK(popup.ConnectSignal(testTracker, "hiding", PopupTestFunctor()));
1440 DALI_TEST_CHECK(popup.ConnectSignal(testTracker, "hidden", PopupTestFunctor()));
1442 // Test connecting to an invalid signal does not work.
1443 DALI_TEST_CHECK(!popup.ConnectSignal(testTracker, "invalid", PopupTestFunctor()));
1448 int UtcDaliPopupOnChildAdd(void)
1450 ToolkitTestApplication application;
1451 tet_infoline(" UtcDaliPopupOnChildAdd");
1453 // Create the Popup actor
1454 Popup popup = Popup::New();
1455 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
1456 std::string testLabelText = "ContentTest";
1457 TextLabel contentLabel = TextLabel::New(testLabelText);
1459 popup.Add(contentLabel);
1461 DALI_TEST_CHECK(HasAncestor(contentLabel, popup));
1466 int UtcDaliPopupOnKeyEvent(void)
1468 ToolkitTestApplication application;
1469 tet_infoline(" UtcDaliPopupOnKeyEvent");
1471 // Create the Popup actor
1472 Popup popup = Popup::New();
1473 popup.SetProperty(Popup::Property::ANIMATION_DURATION, 0.0f);
1474 application.GetScene().Add(popup);
1476 popup.SetDisplayState(Popup::SHOWN);
1477 application.SendNotification();
1478 application.Render();
1480 DALI_TEST_EQUALS(popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION);
1482 popup.SetKeyInputFocus();
1484 application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::TOUCH, Device::Subclass::NONE));
1485 application.SendNotification();
1486 application.Render();
1488 DALI_TEST_EQUALS(popup.GetDisplayState(), Popup::HIDDEN, TEST_LOCATION);
1493 int UtcDaliPopupSetPopupBackgroundBorderProperty(void)
1495 ToolkitTestApplication application;
1497 tet_infoline("Set the background border property of a popup & retrieve it");
1498 Popup popup = Popup::New();
1500 Rect<int> rect(40, 30, 20, 10);
1501 tet_infoline("Ensure value we want to set is different from what is already set");
1502 DALI_TEST_CHECK(rect != popup.GetProperty(Popup::Property::POPUP_BACKGROUND_BORDER).Get<Rect<int> >());
1504 tet_infoline("Set the property and retrieve it to make sure it's the value we set");
1505 popup.SetProperty(Popup::Property::POPUP_BACKGROUND_BORDER, rect);
1506 DALI_TEST_EQUALS(rect, popup.GetProperty(Popup::Property::POPUP_BACKGROUND_BORDER).Get<Rect<int> >(), TEST_LOCATION);
1508 tet_infoline("Set a vector4 as well which should also work");
1509 Vector4 vectorValue(10.0f, 20.0f, 30.0f, 40.0f);
1510 popup.SetProperty(Popup::Property::POPUP_BACKGROUND_BORDER, vectorValue);
1511 DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), popup.GetProperty(Popup::Property::POPUP_BACKGROUND_BORDER).Get<Rect<int> >(), TEST_LOCATION);