X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Button.cpp;h=83ebfb67868ac91860c8bf27d02beaabcc4b99b2;hp=92e64ecc62868e89f8405dcbeeea48f4d81f477a;hb=HEAD;hpb=946461ac1b49e996d9155c95130ec5aa1b08f77d diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index 92e64ec..76a10fc 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -15,16 +15,16 @@ * */ -#include #include +#include // Need to override adaptor classes for toolkit test harness, so include // test harness headers before dali headers. #include #include "dali-toolkit-test-utils/toolkit-timer.h" -#include #include +#include #include #include @@ -32,7 +32,6 @@ using namespace Dali; using namespace Toolkit; - void utc_dali_toolkit_button_startup(void) { test_return_value = TET_UNDEF; @@ -45,33 +44,33 @@ void utc_dali_toolkit_button_cleanup(void) namespace { -static bool gIsCalledButtonCallback = false; +static bool gIsCalledButtonCallback = false; static bool gIsCalledChildButtonCallback = false; -static bool ButtonCallback( Button button ) +static bool ButtonCallback(Button button) { gIsCalledButtonCallback = true; return false; } -static bool ChildButtonCallback( Button button ) +static bool ChildButtonCallback(Button button) { gIsCalledChildButtonCallback = true; return false; } -static std::string GetButtonText( Button button ) +static std::string GetButtonText(Button button) { - Property::Value value = button.GetProperty( Toolkit::Button::Property::LABEL ); + Property::Value value = button.GetProperty(Toolkit::Button::Property::LABEL); - Property::Map *labelProperty = value.GetMap(); + Property::Map* labelProperty = value.GetMap(); std::string textLabel; - if ( labelProperty ) + if(labelProperty) { - Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT ); - value->Get( textLabel ); + Property::Value* value = labelProperty->Find(Toolkit::TextVisual::Property::TEXT); + value->Get(textLabel); } return textLabel; @@ -80,7 +79,7 @@ static std::string GetButtonText( Button button ) struct CallbackFunctor { CallbackFunctor(bool* callbackFlag) - : mCallbackFlag( callbackFlag ) + : mCallbackFlag(callbackFlag) { } @@ -94,48 +93,48 @@ struct CallbackFunctor Dali::Integration::Point GetPointDownInside() { Dali::Integration::Point point; - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 240, 400 ) ); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(240, 400)); return point; } Dali::Integration::Point GetPointUpInside() { Dali::Integration::Point point; - point.SetState( PointState::UP ); - point.SetScreenPosition( Vector2( 240, 400 ) ); + point.SetState(PointState::UP); + point.SetScreenPosition(Vector2(240, 400)); return point; } Dali::Integration::Point GetPointLeave() { Dali::Integration::Point point; - point.SetState( PointState::LEAVE ); - point.SetScreenPosition( Vector2( 240, 400 ) ); + point.SetState(PointState::LEAVE); + point.SetScreenPosition(Vector2(240, 400)); return point; } Dali::Integration::Point GetPointEnter() { Dali::Integration::Point point; - point.SetState( PointState::MOTION ); - point.SetScreenPosition( Vector2( 240, 400 ) ); + point.SetState(PointState::MOTION); + point.SetScreenPosition(Vector2(240, 400)); return point; } Dali::Integration::Point GetPointDownOutside() { Dali::Integration::Point point; - point.SetState( PointState::DOWN ); - point.SetScreenPosition( Vector2( 10, 10 ) ); + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(10, 10)); return point; } Dali::Integration::Point GetPointUpOutside() { Dali::Integration::Point point; - point.SetState( PointState::UP ); - point.SetScreenPosition( Vector2( 10, 10 ) ); + point.SetState(PointState::UP); + point.SetScreenPosition(Vector2(10, 10)); return point; } @@ -143,66 +142,105 @@ Dali::Integration::Point GetPointUpOutside() int UtcDaliButtonConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; Button button; - DALI_TEST_CHECK( !button ); + DALI_TEST_CHECK(!button); END_TEST; } int UtcDaliButtonCopyConstructorP(void) { - TestApplication application; + ToolkitTestApplication application; // Initialize an object, ref count == 1 Button button = PushButton::New(); - Button copy( button ); - DALI_TEST_CHECK( copy ); + Button copy(button); + DALI_TEST_CHECK(copy); + END_TEST; +} + +int UtcDaliButtonMoveConstructor(void) +{ + ToolkitTestApplication application; + + Button button = PushButton::New(); + DALI_TEST_EQUALS(1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(button.GetProperty(Button::Property::TOGGLABLE), false, TEST_LOCATION); + button.SetProperty(Button::Property::TOGGLABLE, true); + DALI_TEST_EQUALS(button.GetProperty(Button::Property::TOGGLABLE), true, TEST_LOCATION); + + Button moved = std::move(button); + DALI_TEST_CHECK(moved); + DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(moved.GetProperty(Button::Property::TOGGLABLE), true, TEST_LOCATION); + DALI_TEST_CHECK(!button); + END_TEST; } int UtcDaliButtonAssignmentOperatorP(void) { - TestApplication application; + ToolkitTestApplication application; Button button = PushButton::New(); - Button copy( button ); - DALI_TEST_CHECK( copy ); + Button copy(button); + DALI_TEST_CHECK(copy); + + DALI_TEST_CHECK(button == copy); + END_TEST; +} + +int UtcDaliButtonMoveAssignment(void) +{ + ToolkitTestApplication application; + + Button button = PushButton::New(); + DALI_TEST_EQUALS(1, button.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(button.GetProperty(Button::Property::TOGGLABLE), false, TEST_LOCATION); + button.SetProperty(Button::Property::TOGGLABLE, true); + DALI_TEST_EQUALS(button.GetProperty(Button::Property::TOGGLABLE), true, TEST_LOCATION); + + Button moved; + moved = std::move(button); + DALI_TEST_CHECK(moved); + DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION); + DALI_TEST_EQUALS(moved.GetProperty(Button::Property::TOGGLABLE), true, TEST_LOCATION); + DALI_TEST_CHECK(!button); - DALI_TEST_CHECK( button == copy ); END_TEST; } int UtcDaliButtonDownCastP(void) { - TestApplication application; + ToolkitTestApplication application; Button button = PushButton::New(); BaseHandle object(button); - Button button2 = Button::DownCast( object ); + Button button2 = Button::DownCast(object); DALI_TEST_CHECK(button2); - Button button3 = DownCast< Button >(object); + Button button3 = DownCast