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-VideoView.cpp;h=b0aa75ef3225a00d1fa7fd67ca5754e33c125c87;hp=89b78bf04ce110a0a8632383e94921f0790fac68;hb=171ba217fec865f3237638d2990c0c0e3eaf9fac;hpb=c01f2590ed7bb00d9b3600511d08dc420261ed46 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp old mode 100755 new mode 100644 index 89b78bf..b0aa75e --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 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. @@ -21,6 +21,7 @@ #include #include #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -31,6 +32,7 @@ const char* const TEST_FILE( "test.mp4" ); const char* const VOLUME_LEFT( "volumeLeft" ); const char* const VOLUME_RIGHT( "volumeRight" ); const char* const RENDERING_TYPE( "renderingTarget" ); +const char* const DUMMY_STRING( "dummy string" ); const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n @@ -106,7 +108,8 @@ int UtcDaliVideoViewNew(void) Toolkit::VideoView view = Toolkit::VideoView::New(); DALI_TEST_CHECK( view ); - Toolkit::VideoView view2 = Toolkit::VideoView::New( "" ); + const std::string url( DUMMY_STRING ); + Toolkit::VideoView view2 = Toolkit::VideoView::New( url ); DALI_TEST_CHECK( view2 ); END_TEST; } @@ -152,7 +155,7 @@ int UtcDaliVideoViewProperty1b(void) Toolkit::VideoView view = Toolkit::VideoView::New(); DALI_TEST_CHECK( view ); - Stage stage = Stage::GetCurrent(); + Integration::Scene stage = application.GetScene(); std::string file; Property::Map map; @@ -271,6 +274,43 @@ int UtcDaliVideoViewCopyAndAssignment(void) END_TEST; } +int UtcDaliVideoViewMoveConstructor(void) +{ + ToolkitTestApplication application; + + VideoView view = Toolkit::VideoView::New(); + DALI_TEST_EQUALS( 1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + view.SetProperty( VideoView::Property::LOOPING, true ); + DALI_TEST_CHECK( view.GetProperty( VideoView::Property::LOOPING ) ); + + VideoView moved = std::move( view ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( moved.GetProperty( VideoView::Property::LOOPING ) ); + DALI_TEST_CHECK( !view ); + + END_TEST; +} + +int UtcDaliVideoViewMoveAssignment(void) +{ + ToolkitTestApplication application; + + VideoView view = Toolkit::VideoView::New(); + DALI_TEST_EQUALS( 1, view.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + view.SetProperty( VideoView::Property::LOOPING, true ); + DALI_TEST_CHECK( view.GetProperty( VideoView::Property::LOOPING ) ); + + VideoView moved; + moved = std::move( view ); + DALI_TEST_CHECK( moved ); + DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION ); + DALI_TEST_CHECK( moved.GetProperty( VideoView::Property::LOOPING ) ); + DALI_TEST_CHECK( !view ); + + END_TEST; +} + int UtcDaliVideoViewTypeRegistry(void) { ToolkitTestApplication application; @@ -358,7 +398,7 @@ int UtcDaliVideoViewCustomShaderForCoverage(void) bool isUnderlay = videoView.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); DALI_TEST_CHECK( !isUnderlay ); - Stage::GetCurrent().Add( videoView ); + application.GetScene().Add( videoView ); videoView.SetProperty( VideoView::Property::VIDEO, "testvideo" ); Property::Map customShader; @@ -387,7 +427,7 @@ int UtcDaliVideoViewMethodsForCoverage2(void) windowSurfaceTarget.Insert( RENDERING_TYPE, "windowSurfaceTarget" ); - Stage::GetCurrent().Add( videoView ); + application.GetScene().Add( videoView ); application.SendNotification(); application.Render(); @@ -406,7 +446,7 @@ int UtcDaliVideoViewMethodsForCoverage2(void) Vector3 vector(100.0f, 100.0f, 0.0f); DALI_TEST_CHECK(vector != videoView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE )); - videoView.SetSize( vector ); + videoView.SetProperty( Actor::Property::SIZE, vector ); application.SendNotification(); application.Render(); @@ -426,7 +466,7 @@ int UtcDaliVideoViewPropertyUnderlay(void) VideoView view = VideoView::New(); DALI_TEST_CHECK( view ); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); view.Play(); application.SendNotification(); @@ -474,7 +514,7 @@ int UtcDaliVideoViewPropertyPlayPosition(void) VideoView view = VideoView::New(); DALI_TEST_CHECK( view ); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); view.Play(); application.SendNotification(); @@ -501,7 +541,7 @@ int UtcDaliVideoViewNew2(void) VideoView view = VideoView::New( true ); DALI_TEST_CHECK( view ); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); view.Play(); application.SendNotification(); @@ -510,7 +550,7 @@ int UtcDaliVideoViewNew2(void) VideoView view2 = VideoView::New( "", false ); DALI_TEST_CHECK( view2 ); - Stage::GetCurrent().Add( view2 ); + application.GetScene().Add( view2 ); view2.Play(); application.SendNotification(); @@ -527,7 +567,7 @@ int UtcDaliVideoViewPropertyDisplayMode(void) VideoView view = VideoView::New(); DALI_TEST_CHECK( view ); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); view.Play(); application.SendNotification(); @@ -546,7 +586,7 @@ int UtcDaliVideoViewCustomShader(void) ToolkitTestApplication application; tet_infoline( "VideoView with custom shader" ); - VideoView view = VideoView::New(); + VideoView view = VideoView::New( false ); DALI_TEST_CHECK( view ); ToolkitApplication::DECODED_IMAGES_SUPPORTED = true; @@ -555,7 +595,7 @@ int UtcDaliVideoViewCustomShader(void) bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); DALI_TEST_CHECK( !isUnderlay ); - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); view.SetProperty( VideoView::Property::VIDEO, "testvideo" ); /* insert custom shader */ @@ -573,7 +613,7 @@ int UtcDaliVideoViewCustomShader(void) view.SetProperty( VideoView::Property::VIDEO, map ); /* do render for check custom shader */ - Stage::GetCurrent().Add( view ); + application.GetScene().Add( view ); view.Play(); application.SendNotification(); @@ -597,3 +637,153 @@ int UtcDaliVideoViewCustomShader(void) END_TEST; } + +// Functor to test whether a Finish signal is emitted +struct AnimationFinishCheck +{ + AnimationFinishCheck(bool& signalReceived) + : mSignalReceived(signalReceived) + { + } + + void operator()(Animation& animation) + { + mSignalReceived = true; + } + + void Reset() + { + mSignalReceived = false; + } + + void CheckSignalReceived() + { + if (!mSignalReceived) + { + tet_printf("Expected Finish signal was not received\n"); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } + } + + void CheckSignalNotReceived() + { + if (mSignalReceived) + { + tet_printf("Unexpected Finish signal was received\n"); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } + } + + bool& mSignalReceived; // owned by individual tests +}; + +int UtcDaliVideoViewSyncAniamtionForCoverage(void) +{ + ToolkitTestApplication application; + + VideoView videoView = DevelVideoView::New( Dali::VideoSyncMode::ENABLED ); + DALI_TEST_CHECK( videoView ); + + application.GetScene().Add( videoView ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + // Start the animation + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(videoView, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + DevelVideoView::PlayAnimation( videoView, animation ); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(2u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, videoView.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION ); + + // Restart the animation, with a different duration + finishCheck.Reset(); + + END_TEST; +} + +int UtcDaliVideoViewASyncAniamtionForCoverage(void) +{ + ToolkitTestApplication application; + + VideoView videoView = DevelVideoView::New( Dali::VideoSyncMode::DISABLED ); + DALI_TEST_CHECK( videoView ); + + application.GetScene().Add( videoView ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + + // Start the animation + Vector3 targetPosition(10.0f, 10.0f, 10.0f); + animation.AnimateTo(Property(videoView, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); + DevelVideoView::PlayAnimation( videoView, animation ); + + bool signalReceived(false); + AnimationFinishCheck finishCheck(signalReceived); + animation.FinishedSignal().Connect(&application, finishCheck); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*1000.0f) - 1u/*just less than the animation duration*/); + + // We didn't expect the animation to finish yet + application.SendNotification(); + finishCheck.CheckSignalNotReceived(); + + application.Render(2u/*just beyond the animation duration*/); + + // We did expect the animation to finish + application.SendNotification(); + finishCheck.CheckSignalReceived(); + DALI_TEST_EQUALS( targetPosition, videoView.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), TEST_LOCATION ); + + // Restart the animation, with a different duration + finishCheck.Reset(); + + END_TEST; +} + +int UtcDaliVideoViewResizeWithSynchronization(void) +{ + ToolkitTestApplication application; + VideoView videoView = DevelVideoView::New( Dali::VideoSyncMode::ENABLED ); + DALI_TEST_CHECK( videoView ); + + application.GetScene().Add( videoView ); + + Vector3 vector(50.0f, 200.0f, 0.0f); + videoView.SetProperty( Actor::Property::SIZE, vector ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(vector == videoView.GetCurrentProperty< Vector3 >( Actor::Property::SIZE )); + + END_TEST; +}