Add api for get the internal media player handle of the VideoView
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-VideoView.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 8baed37..a38ec18
@@ -20,6 +20,7 @@
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/public-api/controls/video-view/video-view.h>
+#include <dali-toolkit/devel-api/controls/video-view/video-view-devel.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -48,9 +49,10 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
   }\n
 );
 
+const char* fragmentShaderPrefix( "#extension GL_OES_EGL_image_external:require\n" );
 const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
   varying mediump vec2 vTexCoord;\n
-  uniform sampler2D sTexture;\n
+  uniform samplerExternalOES sTexture;\n
   uniform lowp vec4 uColor;\n
   \n
   void main()\n
@@ -300,6 +302,9 @@ int UtcDaliVideoViewMethodsForCoverage(void)
   videoView.Stop();
   videoView.Forward(10);
   videoView.Backward(10);
+
+  Toolkit::DevelVideoView::GetMediaPlayer( videoView );
+
   VideoView::VideoViewSignalType& signal = videoView.FinishedSignal();
   DALI_TEST_EQUALS( 0, signal.GetConnectionCount(), TEST_LOCATION );
 
@@ -347,6 +352,12 @@ int UtcDaliVideoViewCustomShaderForCoverage(void)
   VideoView videoView = VideoView::New();
   DALI_TEST_CHECK( videoView );
 
+  ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
+
+  videoView.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+  bool isUnderlay = videoView.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+  DALI_TEST_CHECK( !isUnderlay );
+
   Stage::GetCurrent().Add( videoView );
   videoView.SetProperty( VideoView::Property::VIDEO, "testvideo" );
 
@@ -409,6 +420,7 @@ int UtcDaliVideoViewMethodsForCoverage2(void)
 int UtcDaliVideoViewPropertyUnderlay(void)
 {
   ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewPropertyUnderlay");
   ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
 
   VideoView view = VideoView::New();
@@ -453,3 +465,135 @@ int UtcDaliVideoViewPropertyUnderlay(void)
 
   END_TEST;
 }
+
+int UtcDaliVideoViewPropertyPlayPosition(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewPropertyPlayPosition");
+
+  VideoView view = VideoView::New();
+  DALI_TEST_CHECK( view );
+
+  Stage::GetCurrent().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  int playPos = view.GetProperty( Toolkit::VideoView::Property::PLAY_POSITION ).Get< int >();
+  DALI_TEST_CHECK( playPos == 0 );
+
+  view.SetProperty( Toolkit::VideoView::Property::PLAY_POSITION, 10 );
+  playPos = view.GetProperty( Toolkit::VideoView::Property::PLAY_POSITION ).Get< int >();
+  // Actually setting play position will be async
+  // Actual platform result may be different.
+  DALI_TEST_CHECK( playPos == 10 );
+
+  END_TEST;
+}
+
+// For coverage.
+int UtcDaliVideoViewNew2(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewNew2");
+
+  VideoView view = VideoView::New( true );
+  DALI_TEST_CHECK( view );
+
+  Stage::GetCurrent().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  VideoView view2 = VideoView::New( "", false );
+  DALI_TEST_CHECK( view2 );
+
+  Stage::GetCurrent().Add( view2 );
+  view2.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
+int UtcDaliVideoViewPropertyDisplayMode(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliVideoViewPropertyDisplayMode");
+
+  VideoView view = VideoView::New();
+  DALI_TEST_CHECK( view );
+
+  Stage::GetCurrent().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  view.SetProperty( Toolkit::VideoView::Property::DISPLAY_MODE, Toolkit::VideoView::DisplayMode::DST_ROI );
+  int displayMode = view.GetProperty( Toolkit::VideoView::Property::DISPLAY_MODE ).Get< int >();
+  DALI_TEST_CHECK( displayMode == Toolkit::VideoView::DisplayMode::DST_ROI );
+
+  END_TEST;
+}
+
+
+int UtcDaliVideoViewCustomShader(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "VideoView with custom shader" );
+
+  VideoView view = VideoView::New();
+  DALI_TEST_CHECK( view );
+
+  ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
+
+  view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+  bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+  DALI_TEST_CHECK( !isUnderlay );
+
+  Stage::GetCurrent().Add( view );
+  view.SetProperty( VideoView::Property::VIDEO, "testvideo" );
+
+  /* insert custom shader */
+  Property::Map customShader;
+  std::string fragmentShaderString;
+  fragmentShaderString.reserve( strlen( fragmentShaderPrefix ) + strlen( FRAGMENT_SHADER ) );
+  fragmentShaderString.append( fragmentShaderPrefix );
+  fragmentShaderString.append( FRAGMENT_SHADER );
+  customShader.Insert( "vertexShader", VERTEX_SHADER );
+  customShader.Insert( "fragmentShader", fragmentShaderString );
+
+  Property::Map map;
+  map.Insert( "shader", customShader );
+
+  view.SetProperty( VideoView::Property::VIDEO, map );
+
+  /* do render for check custom shader */
+  Stage::GetCurrent().Add( view );
+  view.Play();
+
+  application.SendNotification();
+  application.Render();
+
+  /* get renderer */
+  DALI_TEST_CHECK( view.GetRendererCount() == 1u );
+  Renderer renderer = view.GetRendererAt( 0 );
+  Shader shader = renderer.GetShader();
+  DALI_TEST_CHECK( shader );
+
+  Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
+  Property::Map* shaderMap = value.GetMap();
+  DALI_TEST_CHECK( shaderMap );
+
+  Property::Value* fragment = shaderMap->Find( "fragment" ); // fragment key name from shader-impl.cpp
+  DALI_TEST_EQUALS( fragmentShaderString, fragment->Get<std::string>(), TEST_LOCATION );
+
+  Property::Value* vertex = shaderMap->Find( "vertex" ); // vertex key name from shader-impl.cpp
+  DALI_TEST_EQUALS( VERTEX_SHADER, vertex->Get<std::string>(), TEST_LOCATION );
+
+  END_TEST;
+}