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=f290cb2deec18ac99b6b26d9820db36e6115ba75;hp=5127cfb3671dc0fe9a1d12affa25542b798b4ef4;hb=2bba426880bd73a3b763623a3b32c3bd23b7dd90;hpb=1c5674a11a51310ee689d6daf4e6b7d94dec607e diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index 5127cfb..f290cb2 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp @@ -50,6 +50,27 @@ static bool ButtonCallback( Button button ) return false; } +Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height ) +{ + BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 ); + + // Create the image + PixelBuffer* pixbuf = imageData.GetBuffer(); + unsigned int size = width * height; + + 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; + } + + imageData.Update(); + + return imageData; +} + 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 ); @@ -289,9 +310,9 @@ int UtcDaliButtonSetLabelStringP(void) Button button = PushButton::New(); - button.SetLabel( "Button Label" ); + button.SetLabelText( "Button Label" ); - DALI_TEST_CHECK( button.GetLabel() ); + DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION ); END_TEST; } @@ -301,10 +322,59 @@ int UtcDaliButtonSetLabelActorP(void) Button button = PushButton::New(); - TextLabel textLabel = TextLabel::New( "Button Label" ); - button.SetLabel( textLabel ); + button.SetLabelText( "Button Label" ); + + DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION ); + END_TEST; +} + +int UtcDaliButtonSetUnselectedImageP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliButtonSetUnselectedImageP"); + + PushButton pushButton = PushButton::New(); + Stage::GetCurrent().Add( pushButton ); + + application.SendNotification(); + application.Render(); + + pushButton.SetSize( Vector2( 20.0f, 20.0f ) ); + pushButton.SetUnselectedImage( "Image.jpg" ); + + application.SendNotification(); + application.Render(); + + Vector3 size = pushButton.GetCurrentSize(); + + DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION ); + DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliButtonSetSelectedImageP(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliButtonSetButtonImage"); + + PushButton pushButton = PushButton::New(); + Stage::GetCurrent().Add( pushButton ); + + application.SendNotification(); + application.Render(); + + pushButton.SetSize( Vector2( 20.0f, 20.0f ) ); + pushButton.SetSelectedImage( "Image.jpg" ); + + application.SendNotification(); + application.Render(); + + Vector3 size = pushButton.GetCurrentSize(); + + DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION ); + DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION ); - DALI_TEST_CHECK( button.GetLabel() ); END_TEST; } @@ -524,8 +594,10 @@ int UtcDaliButtonSetProperty(void) pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), false); DALI_TEST_CHECK( false == pushButton.IsDisabled() ); + pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true); DALI_TEST_CHECK( true == pushButton.IsDisabled() ); + END_TEST; } @@ -534,26 +606,17 @@ int UtcDaliButtonSize(void) ToolkitTestApplication application; tet_infoline(" UtcDaliButtonSize"); - ImageActor image01 = ImageActor::New(CreateBufferImage()); - image01.SetSize( 100, 50 ); - - PushButton pushButton; - - Vector3 size; - - // Test1 Size is set through Actor API - // First an image is set, then SetSize is called. - pushButton = PushButton::New(); + PushButton pushButton = PushButton::New(); Stage::GetCurrent().Add( pushButton ); - pushButton.SetBackgroundImage( image01 ); + pushButton.SetBackgroundImage( "Image.jpg" ); pushButton.SetSize( 10.f, 10.f ); application.SendNotification(); application.Render(); - size = pushButton.GetCurrentSize(); + Vector3 size = pushButton.GetCurrentSize(); DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION ); DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );