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=a2bf49d7d70128041326b8d83a253d52129c06f0;hb=HEAD;hpb=caf7677175a0e8b9c690d4f2ab73adc295f22c0e diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index a2bf49d..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) 2014 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,26 +15,23 @@ * */ -#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 -#include -#include using namespace Dali; using namespace Toolkit; - void utc_dali_toolkit_button_startup(void) { test_return_value = TET_UNDEF; @@ -47,22 +44,42 @@ void utc_dali_toolkit_button_cleanup(void) namespace { -static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg"; +static bool gIsCalledButtonCallback = false; +static bool gIsCalledChildButtonCallback = false; -static bool gIsCalledButtonCallback = false; - -const int RENDER_FRAME_INTERVAL = 16; - -static bool ButtonCallback( Button button ) +static bool ButtonCallback(Button button) { gIsCalledButtonCallback = true; return false; } +static bool ChildButtonCallback(Button button) +{ + gIsCalledChildButtonCallback = true; + return false; +} + +static std::string GetButtonText(Button button) +{ + Property::Value value = button.GetProperty(Toolkit::Button::Property::LABEL); + + Property::Map* labelProperty = value.GetMap(); + + std::string textLabel; + + if(labelProperty) + { + Property::Value* value = labelProperty->Find(Toolkit::TextVisual::Property::TEXT); + value->Get(textLabel); + } + + return textLabel; +} + struct CallbackFunctor { CallbackFunctor(bool* callbackFlag) - : mCallbackFlag( callbackFlag ) + : mCallbackFlag(callbackFlag) { } @@ -76,141 +93,179 @@ 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; } -static float ANIMATION_TIME( 0.5f ); - } // namespace 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