/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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 <iostream>
#include <stdlib.h>
+#include <iostream>
// Need to override adaptor classes for toolkit test harness, so include
// test harness headers before dali headers.
#include <dali-toolkit-test-suite-utils.h>
+#include "toolkit-style-monitor.h"
-#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali.h>
+#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/mouse-wheel-event-integ.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
-#include <dali/integration-api/events/pinch-gesture-event.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
#include "dummy-control.h"
int UtcDaliControlImplNew(void)
{
- ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
+ ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
Control control;
- DALI_TEST_CHECK( !Control::DownCast(control) );
+ DALI_TEST_CHECK(!Control::DownCast(control));
control = Toolkit::Internal::Control::New();
- DALI_TEST_CHECK( Control::DownCast(control) );
+ DALI_TEST_CHECK(Control::DownCast(control));
END_TEST;
}
-
int UtcDaliControlImplEnableGestureDetector(void)
{
ToolkitTestApplication application;
// Enable individually
{
- DummyControl dummy = DummyControl::New();
+ DummyControl dummy = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
- dummyImpl.EnableGestureDetection(Gesture::Pinch);
- DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetPinchGestureDetector());
+ dummyImpl.EnableGestureDetection(GestureType::PINCH);
+ DALI_TEST_CHECK(dummyImpl.GetPinchGestureDetector());
- DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
- dummyImpl.EnableGestureDetection(Gesture::Pan);
- DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetPanGestureDetector());
+ dummyImpl.EnableGestureDetection(GestureType::PAN);
+ DALI_TEST_CHECK(dummyImpl.GetPanGestureDetector());
- DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
- dummyImpl.EnableGestureDetection(Gesture::Tap);
- DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetTapGestureDetector());
+ dummyImpl.EnableGestureDetection(GestureType::TAP);
+ DALI_TEST_CHECK(dummyImpl.GetTapGestureDetector());
- DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
- dummyImpl.EnableGestureDetection(Gesture::LongPress);
- DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetLongPressGestureDetector());
+ dummyImpl.EnableGestureDetection(GestureType::LONG_PRESS);
+ DALI_TEST_CHECK(dummyImpl.GetLongPressGestureDetector());
}
// Enable All
{
- DummyControl dummy = DummyControl::New();
+ DummyControl dummy = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetPinchGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetPanGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetTapGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetLongPressGestureDetector());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.EnableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(dummyImpl.GetPinchGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetPanGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetTapGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetLongPressGestureDetector());
// Enable when already enabled
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.EnableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(dummyImpl.GetPinchGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetPanGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetTapGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetLongPressGestureDetector());
}
END_TEST;
}
// Disable individually
{
- DummyControl dummy = DummyControl::New();
+ DummyControl dummy = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.EnableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
- dummyImpl.DisableGestureDetection(Gesture::Pinch);
- DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
+ DALI_TEST_CHECK(dummyImpl.GetPinchGestureDetector());
+ dummyImpl.DisableGestureDetection(GestureType::PINCH);
+ DALI_TEST_CHECK(!dummyImpl.GetPinchGestureDetector());
- DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
- dummyImpl.DisableGestureDetection(Gesture::Pan);
- DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
+ DALI_TEST_CHECK(dummyImpl.GetPanGestureDetector());
+ dummyImpl.DisableGestureDetection(GestureType::PAN);
+ DALI_TEST_CHECK(!dummyImpl.GetPanGestureDetector());
- DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
- dummyImpl.DisableGestureDetection(Gesture::Tap);
- DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
+ DALI_TEST_CHECK(dummyImpl.GetTapGestureDetector());
+ dummyImpl.DisableGestureDetection(GestureType::TAP);
+ DALI_TEST_CHECK(!dummyImpl.GetTapGestureDetector());
- DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
- dummyImpl.DisableGestureDetection(Gesture::LongPress);
- DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(dummyImpl.GetLongPressGestureDetector());
+ dummyImpl.DisableGestureDetection(GestureType::LONG_PRESS);
+ DALI_TEST_CHECK(!dummyImpl.GetLongPressGestureDetector());
}
// Disable All
{
- DummyControl dummy = DummyControl::New();
+ DummyControl dummy = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.EnableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- DALI_TEST_CHECK( dummyImpl.GetPinchGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetPanGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetTapGestureDetector() );
- DALI_TEST_CHECK( dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(dummyImpl.GetPinchGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetPanGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetTapGestureDetector());
+ DALI_TEST_CHECK(dummyImpl.GetLongPressGestureDetector());
- dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.DisableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetPinchGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetPanGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetTapGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetLongPressGestureDetector());
}
// Disable When not enabled
{
- DummyControl dummy = DummyControl::New();
+ DummyControl dummy = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetPinchGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetPanGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetTapGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetLongPressGestureDetector());
- dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.DisableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- DALI_TEST_CHECK( !dummyImpl.GetPinchGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetPanGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetTapGestureDetector() );
- DALI_TEST_CHECK( !dummyImpl.GetLongPressGestureDetector() );
+ DALI_TEST_CHECK(!dummyImpl.GetPinchGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetPanGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetTapGestureDetector());
+ DALI_TEST_CHECK(!dummyImpl.GetLongPressGestureDetector());
}
// Ensure control is detached if gesture detector is not deleted
{
- DummyControl dummy = DummyControl::New();
+ DummyControl dummy = DummyControl::New();
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.EnableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
- PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
- TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
+ PinchGestureDetector pinch = dummyImpl.GetPinchGestureDetector();
+ PanGestureDetector pan = dummyImpl.GetPanGestureDetector();
+ TapGestureDetector tap = dummyImpl.GetTapGestureDetector();
LongPressGestureDetector longPress = dummyImpl.GetLongPressGestureDetector();
- DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS(0 == pinch.GetAttachedActorCount(), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(0 == pan.GetAttachedActorCount(), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(0 == tap.GetAttachedActorCount(), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(0 == longPress.GetAttachedActorCount(), false, TEST_LOCATION);
- dummyImpl.DisableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ dummyImpl.DisableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- DALI_TEST_EQUALS( pinch.GetAttachedActors().empty(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( pan.GetAttachedActors().empty(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( tap.GetAttachedActors().empty(), true, TEST_LOCATION );
- DALI_TEST_EQUALS( longPress.GetAttachedActors().empty(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS(0 == pinch.GetAttachedActorCount(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(0 == pan.GetAttachedActorCount(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(0 == tap.GetAttachedActorCount(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(0 == longPress.GetAttachedActorCount(), true, TEST_LOCATION);
}
END_TEST;
}
// Check gesture actually happens
{
DummyControl dummy = DummyControl::New(true);
- dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
+ dummy.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(dummy);
+ dummy.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(dummy);
// Render and notify a couple of times
application.SendNotification();
application.SendNotification();
application.Render();
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
-
- DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
- Integration::PinchGestureEvent pinch(Gesture::Started);
- pinch.scale = 10.0f;
- pinch.speed = 50.0f;
- pinch.centerPoint = Vector2(20.0f, 20.0f);
- application.ProcessEvent(pinch);
- DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
-
- DALI_TEST_CHECK( dummyImpl.panCalled == false );
- Integration::PanGestureEvent pan(Gesture::Possible);
- pan.previousPosition = Vector2(10.0f, 20.0f);
- pan.currentPosition = Vector2(20.0f, 20.0f);
- pan.timeDelta = 10;
- pan.numberOfTouches = 1u;
- application.ProcessEvent(pan);
- pan.state = Gesture::Started;
- application.ProcessEvent(pan);
- DALI_TEST_CHECK( dummyImpl.panCalled == true );
-
- DALI_TEST_CHECK( dummyImpl.tapCalled == false );
- Integration::TapGestureEvent tap(Gesture::Possible);
- tap.numberOfTaps = 1u;
- tap.numberOfTouches = 1u;
- tap.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(tap);
- tap.state = Gesture::Started;
- application.ProcessEvent(tap);
- DALI_TEST_CHECK( dummyImpl.tapCalled == true );
-
- DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
- Integration::LongPressGestureEvent longPress(Gesture::Possible);
- longPress.numberOfTouches = 1u;
- longPress.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(longPress);
- longPress.state = Gesture::Started;
- application.ProcessEvent(longPress);
- DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
- longPress.state = Gesture::Finished;
- application.ProcessEvent(longPress);
-
- Stage::GetCurrent().Remove(dummy);
- }
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
+ dummyImpl.EnableGestureDetection(GestureType::Value(GestureType::PINCH | GestureType::PAN | GestureType::TAP | GestureType::LONG_PRESS));
- // Ensure full code coverage
- {
- DummyControl dummy = DummyControl::New();
- dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
+ DALI_TEST_CHECK(dummyImpl.pinchCalled == false);
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(dummy);
+ TestGeneratePinch(application);
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
+ DALI_TEST_CHECK(dummyImpl.pinchCalled == true);
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+ DALI_TEST_CHECK(dummyImpl.panCalled == false);
- DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
- Integration::PinchGestureEvent pinch(Gesture::Started);
- pinch.scale = 10.0f;
- pinch.speed = 50.0f;
- pinch.centerPoint = Vector2(20.0f, 20.0f);
- application.ProcessEvent(pinch);
+ TestGenerateMiniPan(application);
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
- DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
-
- Integration::PanGestureEvent pan(Gesture::Possible);
- pan.previousPosition = Vector2(10.0f, 20.0f);
- pan.currentPosition = Vector2(20.0f, 20.0f);
- pan.timeDelta = 10;
- pan.numberOfTouches = 1u;
- application.ProcessEvent(pan);
- pan.state = Gesture::Started;
- application.ProcessEvent(pan);
-
- Integration::TapGestureEvent tap(Gesture::Possible);
- tap.numberOfTaps = 1u;
- tap.numberOfTouches = 1u;
- tap.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(tap);
- tap.state = Gesture::Started;
- application.ProcessEvent(tap);
-
- Integration::LongPressGestureEvent longPress(Gesture::Possible);
- longPress.numberOfTouches = 1u;
- longPress.point = Vector2(50.0f, 50.0f);
- application.ProcessEvent(longPress);
- longPress.state = Gesture::Started;
- application.ProcessEvent(longPress);
- longPress.state = Gesture::Finished;
- application.ProcessEvent(longPress);
-
- Stage::GetCurrent().Remove(dummy);
+ DALI_TEST_CHECK(dummyImpl.panCalled == true);
+
+ DALI_TEST_CHECK(dummyImpl.tapCalled == false);
+
+ TestGenerateTap(application);
+
+ DALI_TEST_CHECK(dummyImpl.tapCalled == true);
+
+ DALI_TEST_CHECK(dummyImpl.longPressCalled == false);
+
+ TestGenerateLongPress(application);
+
+ DALI_TEST_CHECK(dummyImpl.longPressCalled == true);
+
+ application.GetScene().Remove(dummy);
}
+
END_TEST;
}
ToolkitTestApplication application;
{
- DummyControl dummy = DummyControl::New( true );
- Stage::GetCurrent().Add(dummy);
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New(true);
+ application.GetScene().Add(dummy);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
- DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ DALI_TEST_EQUALS(dummyImpl.childAddCalled, false, TEST_LOCATION);
+ DALI_TEST_EQUALS(dummy.GetChildCount(), 0u, TEST_LOCATION);
+ Actor actor = Actor::New();
dummy.Add(actor);
- DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummyImpl.childAddCalled, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(dummy.GetChildCount(), 1u, TEST_LOCATION);
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
- dummy.Remove( actor );
- DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
- DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummyImpl.childRemoveCalled, false, TEST_LOCATION);
+ dummy.Remove(actor);
+ DALI_TEST_EQUALS(dummyImpl.childRemoveCalled, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(dummy.GetChildCount(), 0u, TEST_LOCATION);
application.Render();
application.SendNotification();
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
// Ensure full code coverage
{
DummyControl dummy = DummyControl::New();
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ DALI_TEST_EQUALS(dummy.GetChildCount(), 0u, TEST_LOCATION);
+ Actor actor = Actor::New();
dummy.Add(actor);
- DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummy.GetChildCount(), 1u, TEST_LOCATION);
application.Render();
application.SendNotification();
- dummy.Remove( actor );
- DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
+ dummy.Remove(actor);
+ DALI_TEST_EQUALS(dummy.GetChildCount(), 0u, TEST_LOCATION);
application.Render();
application.SendNotification();
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
END_TEST;
}
ToolkitTestApplication application;
{
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
- DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
- Stage::GetCurrent().Add(dummy);
+ DALI_TEST_EQUALS(dummyImpl.stageConnectionCalled, false, TEST_LOCATION);
+ application.GetScene().Add(dummy);
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummyImpl.stageConnectionCalled, true, TEST_LOCATION);
- DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
- Stage::GetCurrent().Remove(dummy);
+ DALI_TEST_EQUALS(dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION);
+ application.GetScene().Remove(dummy);
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION);
}
// Ensure full code coverage
{
- unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
- DummyControl dummy = DummyControl::New();
+ unsigned int stageChildren = application.GetScene().GetLayer(0).GetChildCount();
+ DummyControl dummy = DummyControl::New();
- DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
- Stage::GetCurrent().Add(dummy);
+ DALI_TEST_EQUALS(application.GetScene().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION);
+ application.GetScene().Add(dummy);
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );
+ DALI_TEST_EQUALS(application.GetScene().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION);
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
+ DALI_TEST_EQUALS(application.GetScene().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION);
}
END_TEST;
}
-int UtcDaliControlImplSizeSet(void)
+int UtcDaliControlImplSizeSetP(void)
{
ToolkitTestApplication application;
{
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION );
- Vector3 size(100.0f, 200.0f, 0.0f);
- dummy.SetSize(size);
+ DALI_TEST_EQUALS(dummyImpl.sizeSetCalled, false, TEST_LOCATION); // Size not set, no onSizeSet called
+ Vector2 size(100.0f, 200.0f);
+ dummy.SetProperty(Actor::Property::SIZE, size);
+
+ DALI_TEST_EQUALS(dummyImpl.sizeSetCalled, false, TEST_LOCATION); // Size is going to get negotiated, no onSizeSet called
- application.Render();
application.SendNotification();
application.Render();
- application.SendNotification();
- DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
- DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS(size, dummy.GetCurrentProperty<Vector3>(Actor::Property::SIZE).GetVectorXY(), TEST_LOCATION);
+ DALI_TEST_EQUALS(dummyImpl.sizeSetCalled, true, TEST_LOCATION);
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
- // Ensure full code coverage
+ END_TEST;
+}
+
+int UtcDaliControlImplSizeSet2P(void)
+{
+ ToolkitTestApplication application;
+
{
DummyControl dummy = DummyControl::New();
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
- Vector3 size(100.0f, 200.0f, 0.0f);
- DALI_TEST_CHECK( size != dummy.GetCurrentSize() );
+ Vector2 size(100.0f, 200.0f);
+ DALI_TEST_CHECK(size != dummy.GetCurrentProperty<Vector3>(Actor::Property::SIZE).GetVectorXY());
- application.Render();
application.SendNotification();
+ application.Render();
- dummy.SetSize(size);
+ dummy.SetProperty(Actor::Property::SIZE, size);
- application.Render();
application.SendNotification();
application.Render();
- application.SendNotification();
- DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
+ DALI_TEST_EQUALS(size, dummy.GetCurrentProperty<Vector3>(Actor::Property::SIZE).GetVectorXY(), TEST_LOCATION);
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
END_TEST;
}
ToolkitTestApplication application;
{
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
- DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummyImpl.sizeAnimationCalled, false, TEST_LOCATION);
Animation animation = Animation::New(1.0f);
- animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
+ animation.AnimateTo(Property(dummy, Actor::Property::SIZE), Vector3(100.0f, 150.0f, 200.0f));
animation.Play();
application.Render();
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummyImpl.sizeAnimationCalled, true, TEST_LOCATION);
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
// Ensure full code coverage
{
DummyControl dummy = DummyControl::New();
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
Animation animation = Animation::New(1.0f);
- animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
+ animation.AnimateTo(Property(dummy, Actor::Property::SIZE), Vector3(100.0f, 150.0f, 200.0f));
animation.Play();
application.Render();
application.Render();
application.SendNotification();
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
END_TEST;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
-int UtcDaliControlImplTouchEvent(void)
+int UtcDaliControlImplKeyEvent(void)
{
ToolkitTestApplication application;
{
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
- dummy.SetSize(100.0f, 100.0f);
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
+ dummy.SetKeyInputFocus();
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
- Integration::TouchEvent touchEvent(1);
- TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
- touchEvent.AddPoint(point);
- application.ProcessEvent(touchEvent);
- DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS(dummyImpl.keyEventCalled, false, TEST_LOCATION);
+ Integration::KeyEvent keyEvent;
+ application.ProcessEvent(keyEvent);
+ DALI_TEST_EQUALS(dummyImpl.keyEventCalled, true, TEST_LOCATION);
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
// Ensure full code coverage
{
DummyControl dummy = DummyControl::New();
- dummy.SetSize(100.0f, 100.0f);
- dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
+ dummy.SetKeyInputFocus();
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- Integration::TouchEvent touchEvent(1);
- TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
- touchEvent.AddPoint(point);
- application.ProcessEvent(touchEvent);
+ Integration::KeyEvent keyEvent;
+ application.ProcessEvent(keyEvent);
- Stage::GetCurrent().Remove(dummy);
+ application.GetScene().Remove(dummy);
}
END_TEST;
}
-///////////////////////////////////////////////////////////////////////////////////////////////////
+int UtcDaliControlImplKeyInputFocusGained(void)
+{
+ ToolkitTestApplication application;
+ {
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
-int UtcDaliControlImplKeyEvent(void)
+ application.GetScene().Add(dummy);
+
+ DALI_TEST_EQUALS(dummyImpl.keyInputFocusGained, false, TEST_LOCATION);
+
+ dummy.SetKeyInputFocus();
+
+ DALI_TEST_EQUALS(dummyImpl.keyInputFocusGained, true, TEST_LOCATION);
+
+ application.GetScene().Remove(dummy);
+ }
+
+ // Ensure full code coverage
+ {
+ DummyControl dummy = DummyControl::New();
+
+ application.GetScene().Add(dummy);
+ dummy.SetKeyInputFocus();
+ application.GetScene().Remove(dummy);
+ }
+ END_TEST;
+}
+
+int UtcDaliControlImplKeyInputFocusLost(void)
{
ToolkitTestApplication application;
{
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
- Stage::GetCurrent().Add(dummy);
- dummy.SetKeyInputFocus();
+ application.GetScene().Add(dummy);
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
+ DALI_TEST_EQUALS(dummyImpl.keyInputFocusLost, false, TEST_LOCATION);
- DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
- Integration::KeyEvent keyEvent;
- application.ProcessEvent(keyEvent);
- DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
+ dummy.SetKeyInputFocus();
+ dummy.ClearKeyInputFocus();
- Stage::GetCurrent().Remove(dummy);
+ DALI_TEST_EQUALS(dummyImpl.keyInputFocusLost, true, TEST_LOCATION);
+
+ application.GetScene().Remove(dummy);
}
// Ensure full code coverage
{
DummyControl dummy = DummyControl::New();
- Stage::GetCurrent().Add(dummy);
+ application.GetScene().Add(dummy);
dummy.SetKeyInputFocus();
+ dummy.ClearKeyInputFocus();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
- Integration::KeyEvent keyEvent;
- application.ProcessEvent(keyEvent);
+ dummyImpl.IsKeyboardNavigationSupported();
+ dummyImpl.IsKeyboardFocusGroup();
+
+ application.GetScene().Remove(dummy);
+ }
+ END_TEST;
+}
+
+int UtcDaliControlImplTypeRegistry(void)
+{
+ ToolkitTestApplication application;
+
+ // Register Type
+ TypeInfo type;
+ type = TypeRegistry::Get().GetTypeInfo("Control");
+ DALI_TEST_CHECK(type);
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK(handle);
+
+ // Check if it's a control
+ DALI_TEST_CHECK(Control::DownCast(handle));
+ END_TEST;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+int UtcDaliControlImplSetStyleName(void)
+{
+ ToolkitTestApplication application;
+
+ {
+ DummyControl dummy = DummyControl::New(true);
+
+ dummy.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ dummy.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(dummy);
+
+ dummy.SetStyleName("TestStyle");
+
+ DALI_TEST_CHECK(dummy.GetStyleName() == "TestStyle");
+
+ application.GetScene().Remove(dummy);
+ }
+ END_TEST;
+}
+
+int UtcDaliControlImplOnStyleChangeN(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(dummy);
+
+ // test that style manager is being used, passing an empty handle does nothing but does not crash either
+ Dali::Toolkit::StyleManager styleManager;
+ controlImpl.OnStyleChange(styleManager, StyleChange::THEME_CHANGE);
+ // no crash so test passes
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplOnAccessibilityPanP(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(dummy);
+
+ PanGesture pan;
+ DALI_TEST_EQUALS(false, controlImpl.OnAccessibilityPan(pan), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplOnAccessibilityActivatedP(void)
+{
+ ToolkitTestApplication application;
+
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(dummy);
+ DALI_TEST_EQUALS(false, controlImpl.OnAccessibilityActivated(), TEST_LOCATION);
+
+ // Invoke the control's activate action
+ TypeInfo type = TypeRegistry::Get().GetTypeInfo("Control");
+ DALI_TEST_CHECK(type);
+
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK(handle);
+
+ Property::Map attributes;
+ DALI_TEST_EQUALS(false, handle.DoAction("accessibilityActivated", attributes), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplGetNextKeyboardFocusableActorP(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation(dummy);
+
+ Actor currentFocusedActor;
+ Actor result = controlImpl.GetNextKeyboardFocusableActor(currentFocusedActor, Control::KeyboardFocus::LEFT, false);
+
+ DALI_TEST_EQUALS(result, currentFocusedActor, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterThenReRegisterVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index = 1;
+
+ DALI_TEST_CHECK(!dummyImpl.GetVisual(index));
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(index, visual);
+
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index) == visual);
+
+ Property::Map newMap;
+ newMap[Visual::Property::TYPE] = Visual::COLOR;
+ newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ visual = visualFactory.CreateVisual(newMap);
+ DALI_TEST_CHECK(visual);
+
+ // ReRegister with altered color visual
+ dummyImpl.RegisterVisual(index, visual);
+
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index) == visual);
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterVisaulThenReRegisterToSelf(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index = 1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(index, visual);
+
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index) == visual);
+
+ // ReRegister to self
+ dummyImpl.RegisterVisual(index, visual);
+
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index) == visual);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterVisualToSelf(void)
+{
+ ToolkitTestApplication application;
+
+ Test::ObjectDestructionTracker objectDestructionTracker(application.GetCore().GetObjectRegistry());
+
+ {
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+ objectDestructionTracker.Start(dummy);
- Stage::GetCurrent().Remove(dummy);
+ Property::Index index = 1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+
+ // Register to self
+ dummyImpl.RegisterVisual(index, visual);
+
+ DALI_TEST_EQUALS(objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION); // Control not destroyed yet
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index) == visual);
}
+
+ DALI_TEST_EQUALS(objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION); // Should be destroyed
+
END_TEST;
}
-int UtcDaliControlImplStyleChange(void)
+int UtcDaliControlImplRegisterTwoVisuals(void)
{
ToolkitTestApplication application;
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index = 1;
+ Property::Index index2 = 2;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Toolkit::Visual::Base secondVisual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(index, visual);
+
+ Property::Map newMap;
+ newMap[Visual::Property::TYPE] = Visual::COLOR;
+ newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ secondVisual = visualFactory.CreateVisual(newMap);
+ DALI_TEST_CHECK(secondVisual);
+
+ // ReRegister with altered color visual
+ dummyImpl.RegisterVisual(index2, secondVisual);
+
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index) == visual);
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index2) == secondVisual);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterUnregisterVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index = 1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
- Stage::GetCurrent().Add(dummy);
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(index, visual);
+
+ tet_infoline("Add control with visual to stage and check renderer count is 1");
+ application.GetScene().Add(dummy);
+ application.SendNotification();
application.Render();
+
+ DALI_TEST_CHECK(dummyImpl.GetVisual(index) == visual);
+ DALI_TEST_EQUALS(dummy.GetRendererCount(), 1, TEST_LOCATION);
+
+ // Unregister visual
+ dummyImpl.UnregisterVisual(index);
+
+ tet_infoline("Remove control with visual from stage and check renderer count is 0");
+ application.GetScene().Remove(dummy);
application.SendNotification();
application.Render();
+
+ DALI_TEST_EQUALS(dummy.GetRendererCount(), 0, TEST_LOCATION);
+ DALI_TEST_CHECK(!dummyImpl.GetVisual(index));
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterDisabledVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY = 1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(TEST_PROPERTY, visual, false);
+
+ DALI_TEST_CHECK(dummyImpl.GetVisual(TEST_PROPERTY) == visual);
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY) == false);
+
+ application.GetScene().Add(dummy);
+
+ // Render and notify
application.SendNotification();
+ application.Render();
- // Add a Control and normal Actor as children
- DummyControl dummyChild = DummyControl::New();
- dummy.Add(dummyChild);
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY) == false);
- Actor actor = Actor::New();
- dummy.Add(actor);
+ DALI_TEST_CHECK(dummy.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
- DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, false, TEST_LOCATION );
- StyleChange styleChange;
- styleChange.defaultFontChange = true;
- Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor();
- styleMonitor.EmitStyleChangeSignal(styleChange);
+ dummyImpl.EnableVisual(TEST_PROPERTY, true);
- DALI_TEST_EQUALS( dummyImpl.fontChangeCalled, true, TEST_LOCATION );
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY) == true);
- Stage::GetCurrent().Remove(dummy);
END_TEST;
}
-int UtcDaliControlImplKeyInputFocusGained(void)
+int UtcDaliControlImplDisableRegisteredVisual(void)
{
ToolkitTestApplication application;
- {
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- Stage::GetCurrent().Add(dummy);
+ Property::Index TEST_PROPERTY = 1;
- DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, false, TEST_LOCATION );
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
- dummy.SetKeyInputFocus();
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
- DALI_TEST_EQUALS( dummyImpl.keyInputFocusGained, true, TEST_LOCATION );
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
- Stage::GetCurrent().Remove(dummy);
- }
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(TEST_PROPERTY, visual);
- // Ensure full code coverage
- {
- DummyControl dummy = DummyControl::New();
+ application.GetScene().Add(dummy);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY) == true);
+
+ DALI_TEST_CHECK(dummy.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
+
+ dummyImpl.EnableVisual(TEST_PROPERTY, false);
+
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY) == false);
- Stage::GetCurrent().Add(dummy);
- dummy.SetKeyInputFocus();
- Stage::GetCurrent().Remove(dummy);
- }
END_TEST;
}
-int UtcDaliControlImplKeyInputFocusLost(void)
+int UtcDaliControlImplEnabledVisualParentRemovedFromStage(void)
{
+ // Visual enabled but then parent removed from stage, test ensures visual/renderer are also removed from stage.
+ // Then adding parent back to stage should automatically put visual/renderer back
+
ToolkitTestApplication application;
- {
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
- Stage::GetCurrent().Add(dummy);
+ Property::Index TEST_PROPERTY = 1;
- DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, false, TEST_LOCATION );
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
- dummy.SetKeyInputFocus();
- dummy.ClearKeyInputFocus();
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
- DALI_TEST_EQUALS( dummyImpl.keyInputFocusLost, true, TEST_LOCATION );
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
- Stage::GetCurrent().Remove(dummy);
- }
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(TEST_PROPERTY, visual, false);
- // Ensure full code coverage
- {
- DummyControl dummy = DummyControl::New();
+ application.GetScene().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
- Stage::GetCurrent().Add(dummy);
- dummy.SetKeyInputFocus();
- dummy.ClearKeyInputFocus();
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY) == false);
+ DALI_TEST_CHECK(dummy.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
+ dummyImpl.EnableVisual(TEST_PROPERTY, true);
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(dummy.GetRendererCount() == 1u);
- dummyImpl.OnAccessibilityValueChange( true );
- dummyImpl.IsKeyboardNavigationSupported();
- dummyImpl.IsKeyboardFocusGroup();
+ // Remove control from stage, visual should be removed from stage too
+ application.GetScene().Remove(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(dummy.GetRendererCount() == 0u);
+
+ application.GetScene().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(dummy.GetRendererCount() == 1u);
+
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY) == true);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterTwoVisualsAndEnableOnlyOne(void)
+{
+ // Register 2 visuals and enable by default
+ // Disable 1 visual
+ // Remove control from stage then put it back
+ // Check that only 1 visual/renderer is staged.
+
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY1 = 1;
+ Property::Index TEST_PROPERTY2 = 2;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual1;
+ Toolkit::Visual::Base visual2;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ Property::Map map2;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ visual1 = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual1);
+
+ visual2 = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual2);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual(TEST_PROPERTY1, visual1);
+ // Register second index with a color visual
+ dummyImpl.RegisterVisual(TEST_PROPERTY2, visual2);
+
+ application.GetScene().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(dummy.GetRendererCount() == 2u);
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY1) == true);
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY1) == true);
+ DALI_TEST_CHECK(dummy.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE) == true);
+ dummyImpl.EnableVisual(TEST_PROPERTY2, false);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(dummy.GetRendererCount() == 1u);
+
+ // Remove control from stage, visual should be removed from stage too
+ application.GetScene().Remove(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(dummy.GetRendererCount() == 0u);
+
+ application.GetScene().Add(dummy);
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK(dummy.GetRendererCount() == 1u);
+
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY1) == true);
+ DALI_TEST_CHECK(dummyImpl.IsVisualEnabled(TEST_PROPERTY2) == false);
+
+ END_TEST;
+}
+int UtcDaliControlImplAutoClippingWithVisuals(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled");
+
+ DummyControl control = DummyControl::New();
+ DummyControlImpl& controlImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+ controlImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false);
+
+ DALI_TEST_EQUALS(0, control.GetRendererCount(), TEST_LOCATION);
+
+ control.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
+
+ application.GetScene().Add(control);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(0, control.GetRendererCount(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplAutoClippingWithVisualsAlreadyOnStage(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("Test to ensure a renderer does NOT get added when we've already registered a visual which we haven't enabled and we're already on the stage");
+
+ DummyControl control = DummyControl::New();
+ DummyControlImpl& controlImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+ visual = visualFactory.CreateVisual(map);
+ DALI_TEST_CHECK(visual);
+ controlImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual, false);
+
+ DALI_TEST_EQUALS(0, control.GetRendererCount(), TEST_LOCATION);
+
+ application.GetScene().Add(control);
+
+ application.SendNotification();
+ application.Render();
+
+ control.SetProperty(Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(0, control.GetRendererCount(), TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplOnPinch(void)
+{
+ ToolkitTestApplication application;
+
+ Control control = Control::New();
+ control.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ application.GetScene().Add(control);
+
+ application.SendNotification();
+ application.Render();
+
+ Toolkit::Internal::Control& impl = Toolkit::Internal::GetImplementation(control);
+ impl.EnableGestureDetection(GestureType::PINCH);
+
+ // Scale becomes 0.6666666
+ TestStartPinch(application, Vector2(5.0f, 20.0f), Vector2(35.0f, 20.0f), Vector2(10.0f, 20.0f), Vector2(30.0f, 20.0f), 100);
+
+ DALI_TEST_EQUALS(0.666f, control.GetProperty(Actor::Property::SCALE_X).Get<float>(), 0.01f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+// For ResourceReady
+namespace
+{
+static bool gOnRelayoutCallBackCalled = false;
+void OnRelayoutCallback(Actor actor)
+{
+ gOnRelayoutCallBackCalled = true;
+}
+
+static bool gResourceReadyCalled = false;
+void OnResourceReady(Control control)
+{
+ gResourceReadyCalled = true;
+}
+} // namespace
+
+int UtcDaliControlImplResourceReady(void)
+{
+ ToolkitTestApplication application;
+
+ gOnRelayoutCallBackCalled = false;
+ gResourceReadyCalled = false;
+ Control control = Control::New();
+ control.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f));
+ control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ control.OnRelayoutSignal().Connect(OnRelayoutCallback);
+ control.ResourceReadySignal().Connect(OnResourceReady);
+ application.GetScene().Add(control);
+
+ // Sanity check
+ DALI_TEST_CHECK(!gOnRelayoutCallBackCalled);
+ DALI_TEST_CHECK(!gResourceReadyCalled);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, true, TEST_LOCATION);
+ gOnRelayoutCallBackCalled = false;
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
+ Toolkit::Internal::Control& impl = Toolkit::Internal::GetImplementation(control);
+ // ResourceReady is true when there is no visual in the default Toolkit::Internal::Control.
+ DALI_TEST_EQUALS(impl.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
+ impl.SetResourceReady();
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
+ gResourceReadyCalled = false;
+ DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
+ impl.SetResourceReady();
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION);
- Stage::GetCurrent().Remove(dummy);
- }
END_TEST;
}