[Non-ACR][NUI][Fix VideoView TC fail] 45/229245/3
authorDongsug Song <dongsug.song@samsung.com>
Fri, 13 Mar 2020 08:03:52 +0000 (17:03 +0900)
committerDongsug Song <dongsug.song@samsung.com>
Wed, 1 Apr 2020 05:19:34 +0000 (14:19 +0900)
Change-Id: Id4a0deb9b90784f592713383ba3828a171ffce02

tct-suite-vs/Tizen.NUI.Tests/testcase/TSVideoView.cs

index 1e36673..6110933 100755 (executable)
@@ -16,9 +16,8 @@ namespace Tizen.NUI.Tests
     public class VideoViewTests
     {
         private string TAG = "NUI";
-        private string _videoPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "demoVideo.mp4";
+        private string videoPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "demoVideo.mp4";
         private bool _flagOnFinished;
-        private VideoView _videoView;
 
         private void OnFinished(object obj, VideoView.FinishedEventArgs args)
         {
@@ -28,19 +27,11 @@ namespace Tizen.NUI.Tests
         [SetUp]
         public void Init()
         {
-            Tizen.Log.Info(TAG, "Init() is called!");
-            App.MainTitleChangeText("VideoViewTests");
-            App.MainTitleChangeBackgroundColor(null);
-            _videoView = new VideoView();
-            Window.Instance.Add(_videoView);
         }
 
         [TearDown]
         public void Destroy()
         {
-            Tizen.Log.Info(TAG, "Destroy() is called!");
-            _videoView.Dispose();
-            _videoView = null;
         }
 
         [Test]
@@ -54,8 +45,10 @@ namespace Tizen.NUI.Tests
         public void VideoView_INIT_WITH_NULL()
         {
             /* TEST CODE */
-            Assert.IsNotNull(_videoView, "_videoView is null.");
-            Assert.IsInstanceOf<VideoView>(_videoView, "Should return VideoView instance.");
+            var videoView = new VideoView();
+            Assert.IsNotNull(videoView, "videoView is null.");
+            Assert.IsInstanceOf<VideoView>(videoView, "Should return VideoView instance.");
+            videoView.Dispose();
         }
 
         [Test]
@@ -85,8 +78,10 @@ namespace Tizen.NUI.Tests
         public void ResourceUrl_SET_GET_VALUE()
         {
             /* TEST CODE */
-            _videoView.ResourceUrl = _videoPath;
-            Assert.AreEqual(_videoPath, _videoView.ResourceUrl, "videoview.ResourceUrl should equal to the setted value.");
+            var videoView = new VideoView();
+            videoView.ResourceUrl = videoPath;
+            Assert.AreEqual(videoPath, videoView.ResourceUrl, "videoview.ResourceUrl should equal to the setted value.");
+            videoView.Dispose();
         }
 
         [Test]
@@ -101,7 +96,11 @@ namespace Tizen.NUI.Tests
             /* TEST CODE */
             try
             {
-                _videoView.Play();
+                var videoView = new VideoView();
+                videoView.ResourceUrl = videoPath;
+                videoView.Play();
+                videoView.Stop();
+                videoView.Dispose();
             }
             catch (Exception e)
             {
@@ -123,7 +122,12 @@ namespace Tizen.NUI.Tests
             /* TEST CODE */
             try
             {
-                _videoView.Pause();
+                var videoView = new VideoView();
+                videoView.ResourceUrl = videoPath;
+                videoView.Play();
+                videoView.Pause();
+                videoView.Stop();
+                videoView.Dispose();
             }
             catch (Exception e)
             {
@@ -145,7 +149,11 @@ namespace Tizen.NUI.Tests
             /* TEST CODE */
             try
             {
-                _videoView.Stop();
+                var videoView = new VideoView();
+                videoView.ResourceUrl = videoPath;
+                videoView.Play();
+                videoView.Stop();
+                videoView.Dispose();
             }
             catch (Exception e)
             {
@@ -167,7 +175,12 @@ namespace Tizen.NUI.Tests
             /* TEST CODE */
             try
             {
-                _videoView.Forward(1000);
+                var videoView = new VideoView();
+                videoView.ResourceUrl = videoPath;
+                videoView.Play();
+                videoView.Forward(100);
+                videoView.Stop();
+                videoView.Dispose();
             }
             catch (Exception e)
             {
@@ -189,7 +202,12 @@ namespace Tizen.NUI.Tests
             /* TEST CODE */
             try
             {
-                _videoView.Backward(1000);
+                var videoView = new VideoView();
+                videoView.ResourceUrl = videoPath;
+                videoView.Play();
+                videoView.Backward(100);
+                videoView.Stop();
+                videoView.Dispose();
             }
             catch (Exception e)
             {
@@ -209,14 +227,17 @@ namespace Tizen.NUI.Tests
         public void Video_SET_GET_VALUE()
         {
             /* TEST CODE */
+            var videoView = new VideoView();
             PropertyMap propertyMap = new PropertyMap();
-            propertyMap.Insert(Tizen.NUI.Visual.Property.Type, new PropertyValue((int)Tizen.NUI.Visual.Type.Text));
-            propertyMap.Insert(Tizen.NUI.TextVisualProperty.Text, new PropertyValue("Hello Goodbye"));
-            _videoView.Video = propertyMap;
-            PropertyValue propertyvalue3 = _videoView.Video.GetValue(1);
+            propertyMap.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
+            propertyMap.Insert(TextVisualProperty.Text, new PropertyValue("Hello Goodbye"));
+            videoView.Video = propertyMap;
+            PropertyValue propertyvalue3 = videoView.Video.GetValue(1);
             string tempvalue = "";
             propertyvalue3.Get(out tempvalue);
             Assert.AreEqual("Hello Goodbye", tempvalue, "Video function does not work");
+            //videoView.Stop();
+            videoView.Dispose();
         }
 
         [Test]
@@ -226,16 +247,19 @@ namespace Tizen.NUI.Tests
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "PRW")]
         [Property("AUTHOR", "Zaijuan Sui, z6177.sui@samsung.com")]
-        public void Looping_SET_GET_VALUE()
+        public async Task Looping_SET_GET_VALUE()
         {
             /* TEST CODE */
-            Window.Instance.GetDefaultLayer().Add(_videoView);
+            var videoView = new VideoView();
+            Window.Instance.GetDefaultLayer().Add(videoView);
+            await Task.Delay(1000);
 
-            _videoView.Looping = true;
-            Assert.AreEqual(true, _videoView.Looping, "Looping function does not work");
-
-            _videoView.Looping = false;
-            Assert.AreEqual(false, _videoView.Looping, "Looping function does not work");
+            videoView.Looping = true;
+            Assert.AreEqual(true, videoView.Looping, "Looping function does not work");
+            videoView.Looping = false;
+            Assert.AreEqual(false, videoView.Looping, "Looping function does not work");
+            videoView.Unparent();
+            videoView.Dispose();
         }
 
         [Test]
@@ -245,29 +269,34 @@ namespace Tizen.NUI.Tests
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "PRW")]
         [Property("AUTHOR", "Feng Jin, feng16.jin@samsung.com")]
-        public void Underlay_SET_GET_VALUE()
+        public async Task Underlay_SET_GET_VALUE()
         {
             /* TEST CODE */
-            Window.Instance.GetDefaultLayer().Add(_videoView);
+            var videoView = new VideoView();
+            videoView.ResourceUrl = videoPath;
+            Window.Instance.GetDefaultLayer().Add(videoView);
+            await Task.Delay(1000);
 
             bool isSupportRawVideo = false;
             if (Tizen.System.Information.TryGetValue<bool>("tizen.org/feature/multimedia.raw_video", out isSupportRawVideo))
             {
                 if (isSupportRawVideo)
                 {
-                    _videoView.Underlay = false;
-                    Assert.AreEqual(false, _videoView.Underlay, "Underlay function does not work");
+                    videoView.Underlay = false;
+                    Assert.AreEqual(false, videoView.Underlay, "Underlay function does not work");
                 }
                 else
                 {
-                    _videoView.Underlay = true;
-                    Assert.AreEqual(true, _videoView.Underlay, "Underlay function does not work");
+                    videoView.Underlay = true;
+                    Assert.AreEqual(true, videoView.Underlay, "Underlay function does not work");
                 }
             }
-           else
-           {
-               Tizen.Log.Error(TAG, "Error checking if raw_video is supported(systeminfo)");
-           }
+            else
+            {
+                Tizen.Log.Error(TAG, "Error checking if raw_video is supported(systeminfo)");
+            }
+            videoView.Unparent();
+            videoView.Dispose();
         }
 
         [Test]
@@ -277,16 +306,24 @@ namespace Tizen.NUI.Tests
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "PRW")]
         [Property("AUTHOR", "Zaijuan Sui, z6177.sui@samsung.com")]
-        public void Muted_SET_GET_VALUE()
+        public async Task Muted_SET_GET_VALUE()
         {
             /* TEST CODE */
-            Window.Instance.GetDefaultLayer().Add(_videoView);
+            var videoView = new VideoView();
+            Window.Instance.GetDefaultLayer().Add(videoView);
+            await Task.Delay(1000);
+
+            videoView.Size2D = new Size2D(200, 200);
+            videoView.ResourceUrl = videoPath;
 
-            _videoView.Muted = true;
-            Assert.AreEqual(true, _videoView.Muted, "Muted function does not work");
+            videoView.Muted = true;
+            Assert.AreEqual(true, videoView.Muted, "Muted function does not work");
 
-            _videoView.Muted = false;
-            Assert.AreEqual(false, _videoView.Muted, "Muted function does not work");
+            videoView.Muted = false;
+            Assert.AreEqual(false, videoView.Muted, "Muted function does not work");
+
+            videoView.Unparent();
+            videoView.Dispose();
         }
 
         [Test]
@@ -296,41 +333,61 @@ namespace Tizen.NUI.Tests
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "PRW")]
         [Property("AUTHOR", "Zaijuan Sui, z6177.sui@samsung.com")]
-        public void Volume_SET_GET_VALUE()
+        public async Task Volume_SET_GET_VALUE()
         {
             /* TEST CODE */
+            var videoView = new VideoView();
+            Window.Instance.GetDefaultLayer().Add(videoView);
+            await Task.Delay(1000);
+
+            videoView.Size2D = new Size2D(200, 200);
+            videoView.ResourceUrl = videoPath;
+
             PropertyMap propertyMap = new PropertyMap();
             propertyMap.Add("volumeLeft", new PropertyValue(0.3f));
             // left/right volumes can not be different
             propertyMap.Add("volumeRight", new PropertyValue(0.3f));
 
-            _videoView.Volume = propertyMap;
+            videoView.Volume = propertyMap;
             float left;
             float right;
-            _videoView.Volume.Find(0, "volumeLeft").Get(out left);
-            _videoView.Volume.Find(1, "volumeRight").Get(out right);
-
-            Tizen.Log.Debug("NUI", $"Volume_SET_GET_VALUE: left={left}");
-            Tizen.Log.Debug("NUI", $"Volume_SET_GET_VALUE: right={right}");
+            videoView.Volume.Find(0, "volumeLeft").Get(out left);
+            videoView.Volume.Find(1, "volumeRight").Get(out right);
 
             Assert.AreEqual(0.3f, left, "values must be equal");
             Assert.AreEqual(0.3f, right, "values must be equal");
+
+            videoView.Dispose();
         }
 
         [Test]
         [Category("P1")]
-        [Description("Test Dispose, try to dispose the VideoView.")]
-        [Property("SPEC", "Tizen.NUI.BaseComponents.VideoView.Dispose M")]
+        [Description("Test Finished. Check whether the Finished event triggered when the scroll complete")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.VideoView.Finished E")]
         [Property("SPEC_URL", "-")]
-        [Property("CRITERIA", "MR MCST")]
-        [Property("AUTHOR", "Feng Jin, feng16.jin@samsung.com")]
-        public void Dispose_TEST()
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
+        public async Task Finished_CHECK_EVENT()
         {
             /* TEST CODE */
+            var videoView = new VideoView();
+            videoView.Size2D = new Size2D(200, 200);
+            videoView.ResourceUrl = videoPath;
+            videoView.Underlay = false;
+            Window.Instance.GetDefaultLayer().Add(videoView);
+            await Task.Delay(3000);
+
+            //Assert.IsInstanceOf<VideoView>(videoView, "Should be an instance of VideoView type.");
+
             try
             {
-                VideoView videoView = new VideoView();
-                videoView.Dispose();
+                _flagOnFinished = false;
+                videoView.Finished += OnFinished;
+                Assert.False(_flagOnFinished, "_flagOnFinished should false initial");
+                videoView.Play();
+                await Task.Delay(2000);
+                Assert.True(_flagOnFinished, "_flagOnFinished should be true after Finished triggered");
+                videoView.Unparent();
             }
             catch (Exception e)
             {
@@ -338,28 +395,27 @@ namespace Tizen.NUI.Tests
                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
                 Assert.Fail("Caught Exception" + e.ToString());
             }
+            finally
+            {
+                videoView.Finished -= OnFinished;
+            }
+            videoView.Dispose();
         }
 
         [Test]
         [Category("P1")]
-        [Description("Test Finished. Check whether the Finished event triggered when the scroll complete")]
-        [Property("SPEC", "Tizen.NUI.BaseComponents.VideoView.Finished E")]
+        [Description("Test Dispose, try to dispose the VideoView.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.VideoView.Dispose M")]
         [Property("SPEC_URL", "-")]
-        [Property("CRITERIA", "EVL")]
-        [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
-        public async Task Finished_CHECK_EVENT()
+        [Property("CRITERIA", "MR MCST")]
+        [Property("AUTHOR", "Feng Jin, feng16.jin@samsung.com")]
+        public void Dispose_TEST()
         {
             /* TEST CODE */
-            _videoView.ResourceUrl = _videoPath;
-            Assert.IsInstanceOf<VideoView>(_videoView, "Should be an instance of VideoView type.");
             try
             {
-                _flagOnFinished = false;
-                Assert.False(_flagOnFinished, "_flagOnFinished should false initial");
-                _videoView.Finished += OnFinished;
-                _videoView.Play();
-                await Task.Delay(1000);
-                Assert.True(_flagOnFinished, "_flagOnFinished should be true after Finished triggered");
+                VideoView videoView = new VideoView();
+                videoView.Dispose();
             }
             catch (Exception e)
             {
@@ -367,10 +423,8 @@ namespace Tizen.NUI.Tests
                 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
                 Assert.Fail("Caught Exception" + e.ToString());
             }
-            finally
-            {
-                _videoView.Finished -= OnFinished;
-            }
         }
+
+
     }
 }