-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
#include <iostream>
#include <stdlib.h>
// 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/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/mouse-wheel-event-integ.h>
+#include <dali/integration-api/events/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/hover-event-integ.h>
+
+#include <dali-toolkit/devel-api/styling/style-manager.h>
#include "dummy-control.h"
DALI_TEST_CHECK( !Control::DownCast(control) );
- control = ControlImpl::New();
+ control = Toolkit::Internal::Control::New();
DALI_TEST_CHECK( Control::DownCast(control) );
END_TEST;
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) );
- 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.SetSize( Vector2(100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
// Ensure full code coverage
{
DummyControl dummy = DummyControl::New();
- dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ Actor actor = Actor::New();
dummy.Add(actor);
DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
application.SendNotification();
DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
- Actor actor = RenderableActor::New();
+ Actor actor = Actor::New();
dummy.Add(actor);
DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );
END_TEST;
}
-int UtcDaliControlImplSizeSet(void)
+int UtcDaliControlImplSizeSetP(void)
{
ToolkitTestApplication application;
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.SetSize( 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( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
Stage::GetCurrent().Remove(dummy);
}
- // Ensure full code coverage
+ END_TEST;
+}
+
+int UtcDaliControlImplSizeSet2P(void)
+{
+ ToolkitTestApplication application;
+
{
DummyControl dummy = DummyControl::New();
Stage::GetCurrent().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.GetCurrentSize().GetVectorXY() );
- application.Render();
application.SendNotification();
+ application.Render();
dummy.SetSize(size);
- application.Render();
application.SendNotification();
application.Render();
- application.SendNotification();
- DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
+ DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
Stage::GetCurrent().Remove(dummy);
}
END_TEST;
}
+
int UtcDaliControlImplSizeAnimation(void)
{
ToolkitTestApplication application;
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();
Stage::GetCurrent().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();
DummyControl dummy = DummyControl::New( true );
DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
- dummy.SetSize(100.0f, 100.0f);
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
{
DummyControl dummy = DummyControl::New();
- dummy.SetSize(100.0f, 100.0f);
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
END_TEST;
}
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-int UtcDaliControlImplKeyEvent(void)
+int UtcDaliControlImplHoverEvent(void)
{
ToolkitTestApplication application;
DummyControl dummy = DummyControl::New( true );
DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
- dummy.SetKeyInputFocus();
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
- Integration::KeyEvent keyEvent;
- application.ProcessEvent(keyEvent);
- DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION );
+ Integration::HoverEvent event(1);
+ TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
+ event.AddPoint( point );
+ application.ProcessEvent( event );
+ DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION );
Stage::GetCurrent().Remove(dummy);
}
{
DummyControl dummy = DummyControl::New();
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
- dummy.SetKeyInputFocus();
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- Integration::KeyEvent keyEvent;
- application.ProcessEvent(keyEvent);
+ Integration::HoverEvent event(1);
+ TouchPoint point( 1, TouchPoint::Motion, 20.0f, 20.0f );
+ event.AddPoint( point );
+ application.ProcessEvent( event );
Stage::GetCurrent().Remove(dummy);
}
END_TEST;
}
-int UtcDaliControlImplStyleChange(void)
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+int UtcDaliControlImplKeyEvent(void)
{
ToolkitTestApplication application;
- DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ {
+ DummyControl dummy = DummyControl::New( true );
+ DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
- Stage::GetCurrent().Add(dummy);
+ Stage::GetCurrent().Add(dummy);
+ dummy.SetKeyInputFocus();
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
- // Add a Control and normal Actor as children
- DummyControl dummyChild = DummyControl::New();
- dummy.Add(dummyChild);
+ 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);
+ }
- Actor actor = Actor::New();
- dummy.Add(actor);
+ // Ensure full code coverage
+ {
+ DummyControl dummy = DummyControl::New();
+
+ Stage::GetCurrent().Add(dummy);
+ dummy.SetKeyInputFocus();
- DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, false, TEST_LOCATION );
- StyleChange styleChange;
- styleChange.defaultFontChange = true;
- Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor();
- styleMonitor.EmitStyleChangeSignal(styleChange);
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, true, TEST_LOCATION );
+ Integration::KeyEvent keyEvent;
+ application.ProcessEvent(keyEvent);
- Stage::GetCurrent().Remove(dummy);
+ Stage::GetCurrent().Remove(dummy);
+ }
END_TEST;
}
}
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;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+namespace
+{
+static bool WheelEventCallback(Actor actor, const WheelEvent& event)
+{
+ return false;
+}
+}
+
+int UtcDaliControlImplWheelEvent(void)
+{
+ ToolkitTestApplication application;
+
+ {
+ DummyControl dummy = DummyControl::New( true );
+ DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(dummy);
+
+ dummy.WheelEventSignal().Connect(&WheelEventCallback);
+
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION );
+
+ // simulate a wheel event
+ Vector2 screenCoordinates( 10.0f, 10.0f );
+ Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
+ application.ProcessEvent( event );
+ DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove(dummy);
+ }
+
+ // Ensure full code coverage
+ {
+ DummyControl dummy = DummyControl::New();
+
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(dummy);
+
+ dummy.WheelEventSignal().Connect(&WheelEventCallback);
+
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ // simulate a wheel event
+ Vector2 screenCoordinates( 20.0f, 20.0f );
+ Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
+ application.ProcessEvent( event );
+
+ Stage::GetCurrent().Remove(dummy);
+ }
+ END_TEST;
+}
+
+int UtcDaliControlImplSetStyleName(void)
+{
+ ToolkitTestApplication application;
+
+ {
+ DummyControl dummy = DummyControl::New( true );
+
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ Stage::GetCurrent().Add(dummy);
+
+ dummy.SetStyleName("TestStyle");
+
+ DALI_TEST_CHECK( dummy.GetStyleName() == "TestStyle" );
+
+ Stage::GetCurrent().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 UtcDaliControlImplOnAccessibilityTouchP(void)
+{
+ ToolkitTestApplication application;
+ Control dummy = Control::New();
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
+ TouchEvent touch;
+ DALI_TEST_EQUALS( false, controlImpl.OnAccessibilityTouch( touch ), 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("accessibility-activated", 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;
+}
+
+
+
+