/*
- * Copyright (c) 2019 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-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-
+#include <dali/integration-api/events/wheel-event-integ.h>
using namespace Dali;
using namespace Toolkit;
static bool gObjectCreatedCallBackCalled;
static bool gOnLayoutActivatedCalled; ///< Whether the LayoutActivated signal was invoked.
static bool gOnScrollUpdateCalled;
+static bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked.
static void TestCallback(BaseHandle handle)
{
gOnScrollUpdateCalled = true;
}
+static bool OnWheelEvent( Actor actor, const Dali::WheelEvent& wheelEvent )
+{
+ gOnWheelEventCalled = true;
+ return false;
+}
+
Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time )
{
Integration::TouchEvent touchEvent;
virtual Actor NewItem(unsigned int itemId)
{
// Create a renderable actor for this item
- Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
- Actor actor = CreateRenderableActor(image);
-
- return actor;
+ return ImageView::New( TEST_IMAGE_FILE_NAME );
}
};
DALI_TEST_CHECK(view);
//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;
END_TEST;
}
+int UtcDaliItemViewCopyConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ TestItemFactory factory;
+ ItemView itemView = ItemView::New( factory );
+ DALI_TEST_CHECK( itemView );
+
+ ItemView copy( itemView );
+ DALI_TEST_CHECK( copy );
+
+ END_TEST;
+}
+
+int UtcDaliItemViewCopyAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ TestItemFactory factory;
+ ItemView itemView = ItemView::New( factory );
+ DALI_TEST_CHECK( itemView );
+
+ ItemView copy;
+ copy = itemView;
+ DALI_TEST_CHECK( copy );
+ DALI_TEST_EQUALS( itemView, copy, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliItemViewMoveConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ TestItemFactory factory;
+ ItemView itemView = ItemView::New( factory );
+ DALI_TEST_EQUALS( 1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ itemView.SetProperty( Actor::Property::SENSITIVE, false );
+ DALI_TEST_CHECK( false == itemView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+
+ ItemView moved = std::move( itemView );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+ DALI_TEST_CHECK( !itemView );
+
+ END_TEST;
+}
+
+int UtcDaliItemViewMoveAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ TestItemFactory factory;
+ ItemView itemView = ItemView::New( factory );
+ DALI_TEST_EQUALS( 1, itemView.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ itemView.SetProperty( Actor::Property::SENSITIVE, false );
+ DALI_TEST_CHECK( false == itemView.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+
+ ItemView moved;
+ moved = std::move( itemView );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+ DALI_TEST_CHECK( !itemView );
+
+ END_TEST;
+}
+
int UtcDaliItemViewDownCast(void)
{
ToolkitTestApplication application;
DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
// Activate the depth layout
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(1, stageSize, 0.5f);
// Check the current active layout is the depth layout
DALI_TEST_CHECK(view.GetActiveLayout() == NULL);
// Activate the grid layout
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
// Check the current active layout is the grid layout
view.AddLayout(*gridLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
// Get the item given the item ID
view.AddLayout(*gridLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
// Get the item given the item ID 2 and 3
view.AddLayout(*depthLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.0f);
// Check the current layout position for the 10th items is 9.0f
view.SetProperty( Dali::Actor::Property::NAME,"view actor");
view.AddLayout(*layout);
- view.SetSize(vec);
+ view.SetProperty( Actor::Property::SIZE, vec );
- Stage::GetCurrent().Add(view);
+ application.GetScene().Add(view);
layout->SetOrientation(ControlOrientation::Down);
view.ActivateLayout(0, vec, 0.0f);
tet_result(TET_FAIL);
}
- Stage::GetCurrent().Remove(view);
+ application.GetScene().Remove(view);
END_TEST;
}
view.AddLayout(*gridLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.0f);
// Get the specified item where new item to be inserted before that
view.AddLayout(*depthLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
unsigned int itemCount = view.GetChildCount();
view.AddLayout(*spiralLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
Actor newActor = Actor::New();
view.AddLayout(*spiralLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
ItemContainer replaceList;
view.AddLayout(*spiralLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
ItemRange itemRange(0, 0);
view.AddLayout(*spiralLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
Vector3 anchorPoint(10.0f, 10.0f, 0.0f);
view.AddLayout(*gridLayout);
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.5f);
Vector3 parentOrigin(10.0f, 10.0f, 0.0f);
ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
view.AddLayout(*gridLayout);
- Stage::GetCurrent().Add( view );
+ application.GetScene().Add( view );
// Connect the layout activated signal
view.LayoutActivatedSignal().Connect( &OnLayoutActivated );
application.Render();
// Activate the grid layout so that the items will be created and added to ItemView
- Vector3 stageSize(Dali::Stage::GetCurrent().GetSize());
+ Vector3 stageSize(application.GetScene().GetSize());
view.ActivateLayout(0, stageSize, 0.1f);
// Wait for 0.1 second
int UtcDaliItemViewOvershootVertical(void)
{
ToolkitTestApplication application;
- Dali::Stage stage = Dali::Stage::GetCurrent();
+ Dali::Integration::Scene stage = application.GetScene();
// Create the ItemView actor
TestItemFactory factory;
int UtcDaliItemViewOvershootHorizontal(void)
{
ToolkitTestApplication application;
- Dali::Stage stage = Dali::Stage::GetCurrent();
+ Dali::Integration::Scene stage = application.GetScene();
// Create the ItemView actor
TestItemFactory factory;
int UtcDaliItemEnableDisableRefresh(void)
{
ToolkitTestApplication application;
- Dali::Stage stage = Dali::Stage::GetCurrent();
+ Dali::Integration::Scene stage = application.GetScene();
// Create the ItemView actor
TestItemFactory factory;
END_TEST;
}
+
+int UtcDaliItemViewWheelEvent(void)
+{
+ ToolkitTestApplication application;
+ Dali::Integration::Scene stage = application.GetScene();
+
+ // Create the ItemView actor
+ TestItemFactory factory;
+ ItemView view = ItemView::New( factory );
+
+ // Create a grid layout and add it to ItemView
+ ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
+ view.AddLayout( *gridLayout );
+ stage.Add( view );
+
+ // Activate the grid layout so that the items will be created and added to ItemView
+ Vector3 stageSize( stage.GetSize() );
+ view.ActivateLayout (0, stageSize, 0.5f );
+
+ //Connect to wheel event signal
+ view.WheelEventSignal().Connect( &OnWheelEvent );
+
+ DALI_TEST_CHECK( !gOnWheelEventCalled );
+
+ // Render and notify
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+
+ // 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 );
+ DALI_TEST_CHECK( gOnWheelEventCalled );
+
+ END_TEST;
+}