[NUI] Revert "Make PixelBuffer & PixelData as Disposable"
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 18 Jan 2023 14:28:40 +0000 (23:28 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 19 Jan 2023 02:13:03 +0000 (11:13 +0900)
Revert patch of PR #4897

This reverts commit 0e6528a5f7c4ae6523b8dd0c19b2c211c31178f3.

src/Tizen.NUI/src/public/Images/PixelBuffer.cs
src/Tizen.NUI/src/public/Images/PixelData.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/Images/TSImageLoader.cs [new file with mode: 0644]

index 38bfa06..efb90df 100755 (executable)
@@ -34,7 +34,7 @@ namespace Tizen.NUI
     /// <since_tizen> 5 </since_tizen>
     /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
     [EditorBrowsable(EditorBrowsableState.Never)]
-    public class PixelBuffer : Disposable
+    public class PixelBuffer : BaseHandle
     {
 
         /// <summary>
index 64698e2..b488f5e 100755 (executable)
@@ -34,7 +34,7 @@ namespace Tizen.NUI
     /// <since_tizen> 5 </since_tizen>
     /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
     [EditorBrowsable(EditorBrowsableState.Never)]
-    public class PixelData : Disposable
+    public class PixelData : BaseHandle
     {
 
         /// <summary>
diff --git a/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/Images/TSImageLoader.cs b/test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/Images/TSImageLoader.cs
new file mode 100644 (file)
index 0000000..0a5eefa
--- /dev/null
@@ -0,0 +1,98 @@
+using global::System;
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using Tizen.NUI;
+
+namespace Tizen.NUI.Devel.Tests
+{
+    using tlog = Tizen.Log;
+
+    [TestFixture]
+    [Description("public/Images/ImageLoader")]
+    public class ImageLoaderTest
+    {
+        private const string tag = "NUITEST";
+        private string image_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "Image.png";
+
+        [SetUp]
+        public void Init()
+        {
+            tlog.Info(tag, "Init() is called!");
+        }
+
+        [TearDown]
+        public void Destroy()
+        {
+            tlog.Info(tag, "Destroy() is called!");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("ImageLoader LoadImageFromFile.")]
+        [Property("SPEC", "Tizen.NUI.ImageLoader.LoadImageFromFile M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "guowei.wang@samsung.com")]
+        public void ImageLoaderLoadImageFromFile()
+        {
+            tlog.Debug(tag, $"ImageLoaderLoadImageFromFile START");
+
+            {
+                var testingTarget = ImageLoader.LoadImageFromFile(image_path);
+                Assert.IsNotNull(testingTarget, "Can't create success object PixelBuffer.");
+                Assert.IsInstanceOf<PixelBuffer>(testingTarget, "Should return PixelBuffer instance.");
+
+                Assert.AreEqual(false, PixelBuffer.ReferenceEquals(testingTarget, null), "Valid image's load result should not be null!");
+                Assert.AreEqual(false, testingTarget == null, "Valid image's load result compare with null should be false!");
+                Assert.AreEqual(true, (bool)testingTarget, "Valid image's load result bool operator should be true!");
+                Assert.AreEqual(false, !testingTarget, "Valid image's load result not operator should be false!");
+
+                testingTarget.Dispose();
+            }
+
+            {
+                var testingTarget = ImageLoader.LoadImageFromFile("invalid.jpg");
+                Assert.AreEqual(false, PixelBuffer.ReferenceEquals(testingTarget, null), "Invalid image's load result should not be null!");
+                Assert.AreEqual(true, testingTarget == null, "Invalid image's load result compare with null should be true!");
+                Assert.AreEqual(false, (bool)testingTarget, "Invalid image's load result bool operator should be false!");
+                Assert.AreEqual(true, !testingTarget, "Invalid image's load result not operator should be true!");
+
+                testingTarget.Dispose();
+            }
+            tlog.Debug(tag, $"ImageLoaderLoadImageFromFile END (OK)");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("ImageLoader LoadImageFromFile. With Size.")]
+        [Property("SPEC", "Tizen.NUI.ImageLoader.LoadImageFromFile M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "guowei.wang@samsung.com")]
+        public void ImageLoaderLoadImageFromFileWithSize()
+        {
+            tlog.Debug(tag, $"ImageLoaderLoadImageFromFileWithSize START");
+
+            using (Size2D size2d = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height))
+            {
+                var testingTarget = ImageLoader.LoadImageFromFile(image_path, size2d);
+                Assert.IsNotNull(testingTarget, "Can't create success object PixelBuffer.");
+                Assert.IsInstanceOf<PixelBuffer>(testingTarget, "Should return PixelBuffer instance.");
+
+                testingTarget.Dispose();
+            }
+
+            // size is null
+            try
+            {
+                var testingTarget = ImageLoader.LoadImageFromFile(image_path, null);
+                Assert.Fail("Didn't through exception. Failed!");
+            }
+            catch (ArgumentNullException)
+            {
+                tlog.Debug(tag, $"ImageLoaderLoadImageFromFileWithSize END (OK)");
+                Assert.Pass("Catch ArgumentNullException, Pass!");
+            }
+        }
+    }
+}