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=f290cb2deec18ac99b6b26d9820db36e6115ba75;hb=HEAD;hpb=9dfe326faf6f6376bb7f4415a8ca35792c669d4c diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index f290cb2..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,21 +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 + using namespace Dali; using namespace Toolkit; - void utc_dali_toolkit_button_startup(void) { test_return_value = TET_UNDEF; @@ -42,338 +44,568 @@ 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; } -Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height ) +static bool ChildButtonCallback(Button button) { - BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 ); + gIsCalledChildButtonCallback = true; + return false; +} + +static std::string GetButtonText(Button button) +{ + Property::Value value = button.GetProperty(Toolkit::Button::Property::LABEL); - // Create the image - PixelBuffer* pixbuf = imageData.GetBuffer(); - unsigned int size = width * height; + Property::Map* labelProperty = value.GetMap(); - for( size_t i = 0; i < size; i++ ) - { - pixbuf[i*4+0] = 0xFF * color.r; - pixbuf[i*4+1] = 0xFF * color.g; - pixbuf[i*4+2] = 0xFF * color.b; - pixbuf[i*4+3] = 0xFF * color.a; - } + std::string textLabel; + + if(labelProperty) + { + Property::Value* value = labelProperty->Find(Toolkit::TextVisual::Property::TEXT); + value->Get(textLabel); + } + + return textLabel; +} - imageData.Update(); +struct CallbackFunctor +{ + CallbackFunctor(bool* callbackFlag) + : mCallbackFlag(callbackFlag) + { + } + + void operator()() + { + *mCallbackFlag = true; + } + bool* mCallbackFlag; +}; + +Dali::Integration::Point GetPointDownInside() +{ + Dali::Integration::Point point; + 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)); + return point; +} + +Dali::Integration::Point GetPointLeave() +{ + Dali::Integration::Point point; + 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)); + return point; +} - return imageData; +Dali::Integration::Point GetPointDownOutside() +{ + Dali::Integration::Point point; + point.SetState(PointState::DOWN); + point.SetScreenPosition(Vector2(10, 10)); + return point; } -const Dali::TouchPoint pointDownInside( 0, TouchPoint::Down, 240, 400 ); -const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 ); -const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 ); -const Dali::TouchPoint pointEnter( 0, TouchPoint::Motion, 240, 400 ); -const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10, 10 ); -const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10, 10 ); +Dali::Integration::Point GetPointUpOutside() +{ + Dali::Integration::Point point; + 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