/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali-toolkit/dali-toolkit.h>
DALI_TEST_CHECK( popup2 == popup );
// Additional check to ensure object is created by checking if it's registered.
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+ ObjectRegistry registry = application.GetCore().GetObjectRegistry();
DALI_TEST_CHECK( registry );
gObjectCreatedCallBackCalled = false;
// Create the Popup actor
Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
// Put in show state so it's layer is connected to popup (for ancestor check).
// Create the Popup actor
Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
// Put in show state so it's layer is connected to popup (for ancestor check).
popup.SetDisplayState( Popup::SHOWN );
// Create the Popup actor
Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetProperty( Toolkit::Popup::Property::ANIMATION_DURATION, 0.0f );
// Put in show state so it's layer is connected to popup (for ancestor check).
popup.SetDisplayState( Popup::SHOWN );
END_TEST;
}
+int UtcDaliPopupSetTitleAndFooter(void)
+{
+ ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
+ tet_infoline( " UtcDaliPopupSetTitleAndFooter" );
+
+ // Create the Popup actor
+ Popup popup = Popup::New();
+
+ // Put in show state so it's layer is connected to popup (for ancestor check).
+ popup.SetDisplayState( Popup::SHOWN );
+
+ // Add the title
+ TextLabel titleActor = TextLabel::New();
+ titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT, "title" );
+
+ DALI_TEST_CHECK( !popup.GetTitle() );
+ popup.SetTitle( titleActor );
+ TextLabel textActor = TextLabel::DownCast( popup.GetTitle() );
+ DALI_TEST_CHECK( textActor == titleActor );
+
+ std::string resultText;
+ DALI_TEST_CHECK( textActor.GetProperty( Toolkit::TextLabel::Property::TEXT ).Get( resultText ) );
+ DALI_TEST_CHECK( ( popup.GetTitle() ) && ( resultText == "title" ) );
+ // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
+ DALI_TEST_CHECK( HasAncestor( titleActor, popup ) );
+
+ // Add the footer
+ PushButton button = PushButton::New();
+ DALI_TEST_CHECK( !HasAncestor(button, popup) );
+ popup.SetFooter( button );
+ // Hide and then re-show popup to cause button to be rearranged and added to popup.
+ popup.SetDisplayState( Popup::HIDDEN );
+ popup.SetDisplayState( Popup::SHOWN );
+ DALI_TEST_CHECK( HasAncestor( button, popup ) );
+
+ END_TEST;
+}
+
int UtcDaliPopupSetStateP(void)
{
ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
Actor container = Actor::New();
PushButton button1 = PushButton::New();
PushButton button2 = PushButton::New();
- button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
- button2.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
+ button1.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() );
+ button2.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() );
container.Add( button1 );
container.Add( button2 );
popup.SetFooter( container );
// Create the Popup actor
Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetProperty( Popup::Property::TAIL_VISIBILITY, false );
popup.SetDisplayState( Popup::SHOWN );
popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
popup.SetProperty( Actor::Property::ANCHOR_POINT, ParentOrigin::CENTER );
popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
- popup.SetSize( 50.0f, 50.0f );
+ popup.SetProperty( Actor::Property::SIZE, Vector2( 50.0f, 50.0f ) );
popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.OutsideTouchedSignal().Connect( &OnPopupTouchedOutside );
popup.SetDisplayState( Popup::SHOWN );
Actor container = Actor::New();
PushButton button1 = PushButton::New();
- button1.SetSize( DEFAULT_BUTTON_SIZE.GetVectorXY() );
+ button1.SetProperty( Actor::Property::SIZE, DEFAULT_BUTTON_SIZE.GetVectorXY() );
container.Add( button1 );
popup.SetFooter( container );
DALI_TEST_CHECK( popup.GetProperty( Popup::Property::AUTO_HIDE_DELAY ).Get( getAutoHideDelay ) );
DALI_TEST_EQUALS( getAutoHideDelay, 200, TEST_LOCATION );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
DALI_TEST_EQUALS( gPopupState, Popup::HIDDEN, TEST_LOCATION );
Popup popup = Popup::New();
ConnectStateSignals( popup );
popup.SetTitle( TextLabel::New( "Title" ) );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
std::string animationModes[] = { "NONE", "ZOOM", "FADE", "CUSTOM" };
Actor placement = Actor::New();
placement.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
placement.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
- placement.SetSize( 1.0f, 1.0f );
+ placement.SetProperty( Actor::Property::SIZE, Vector2( 1.0f, 1.0f ) );
placement.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
- Stage::GetCurrent().Add( placement );
+ application.GetScene().Add( placement );
placement.Add( popup );
// Create the Popup actor
Popup popup = Popup::New();
popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
Actor backing = popup.FindChildByName( "popupBacking" );
DALI_TEST_CHECK( backing );
- DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 1.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
// Check enabled property.
popup.SetDisplayState( Popup::SHOWN );
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
popup.SetDisplayState( Popup::HIDDEN );
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
popup.SetProperty( Popup::Property::BACKING_ENABLED, false );
bool propertyResult;
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
popup.SetDisplayState( Popup::HIDDEN );
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( DevelActor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ DALI_TEST_EQUALS( backing.GetCurrentProperty< float >( Actor::Property::OPACITY ), 0.0f, Math::MACHINE_EPSILON_0, TEST_LOCATION );
// Check color property.
popup.SetProperty( Popup::Property::BACKING_ENABLED, true );
// Create the Popup actor
Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
// Check setting an image
popup.SetProperty( Toolkit::Popup::Property::POPUP_BACKGROUND_IMAGE, "invalid-image.png" );
DALI_TEST_CHECK( popup.GetProperty( Toolkit::Popup::Property::EXIT_ANIMATION ).Get( resultMap ) );
DALI_TEST_EQUALS( resultMap.Count(), 0u, TEST_LOCATION );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetDisplayState( Popup::SHOWN );
for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
- popup.SetSize( 100, 100 );
+ popup.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
// Create a button (to go underneath the popup).
PushButton button = Toolkit::PushButton::New();
button.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
button.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
- button.SetSize( 100, 100 );
+ button.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
button.ClickedSignal().Connect( &PushButtonClicked );
- Stage::GetCurrent().Add( button );
+ application.GetScene().Add( button );
button.Add( popup );
DALI_TEST_CHECK( !gPushButtonClicked );
+ // Perform a wheel event
+ Dali::Integration::WheelEvent wheelEvent( Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2( 10.0f, 10.0f ), 1, 1000u );
+ application.ProcessEvent( wheelEvent );
+ application.SendNotification();
+ application.Render();
+
// Enable touch transparency.
popup.SetProperty( Popup::Property::TOUCH_TRANSPARENT, true );
bool propertyResult;
Popup popup = Popup::New();
popup.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
popup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
- popup.SetSize( 100, 100 );
+ popup.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
popup.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
TextLabel content = TextLabel::New( "text" );
popup.SetContent( content );
DALI_TEST_CHECK( popup.GetProperty( Popup::Property::TAIL_POSITION ).Get( vectorResult ) );
DALI_TEST_EQUALS( vectorResult, tailPosition, TEST_LOCATION );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetDisplayState( Popup::SHOWN );
application.SendNotification();
popup.SetProperty( Popup::Property::ANIMATION_DURATION, 1.0f );
popup.SetTitle( Toolkit::TextLabel::New( "This is a Toast Popup.\nIt will auto-hide itself" ) );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetDisplayState( Toolkit::Popup::SHOWN );
for( int i = 0; i < RENDER_ANIMATION_TEST_DURATION_FRAMES; i++ )
ConnectStateSignals( popup );
popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetDisplayState( Toolkit::Popup::SHOWN );
application.SendNotification();
END_TEST;
}
-int UtcDaliPopupOnControlChildAdd(void)
+int UtcDaliPopupOnChildAdd(void)
{
ToolkitTestApplication application;
- tet_infoline( " UtcDaliPopupOnControlChildAdd" );
+ tet_infoline( " UtcDaliPopupOnChildAdd" );
// Create the Popup actor
Popup popup = Popup::New();
// Create the Popup actor
Popup popup = Popup::New();
popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );
- Stage::GetCurrent().Add( popup );
+ application.GetScene().Add( popup );
popup.SetDisplayState( Popup::SHOWN );
application.SendNotification();
popup.SetKeyInputFocus();
- application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", "", Device::Class::TOUCH, Device::Subclass::NONE ) );
application.SendNotification();
application.Render();