[ThumbnailExtractor][TCSACR-250] Add sync thumbnail extract API 27/210127/3
authorHaesu Gwon <haesu.gwon@samsung.com>
Tue, 16 Jul 2019 05:43:52 +0000 (14:43 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Wed, 17 Jul 2019 02:29:38 +0000 (11:29 +0900)
Change-Id: I079771fb4daa4581d4233107734d070f65337674

tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ThumbnailExtractor/TSThumbnailExtractor.cs [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 199d3eb..878b522
@@ -13,7 +13,9 @@ namespace Tizen.Multimedia.Util.Tests
         private const string Path = "/opt/usr/home/owner/share/res/test_thumbnail.jpg";
         private const string PathDefaultSize = "/opt/usr/home/owner/share/res/test_thumb_size.jpg";
         private const string PathInvalid = "/opt/usr/home/owner/share/res/";
+        private const string PathInvalidFormat = "/opt/usr/home/owner/share/res/test_tiff.tiff";
         private const string PathNotSupported = "/opt/usr/home/owner/share/res/unknown_format";
+        private const string ResultPath = "/opt/usr/home/owner/share/res/generated_thumbnail.jpg";
 
         private CancellationTokenSource cts;
 
@@ -22,6 +24,11 @@ namespace Tizen.Multimedia.Util.Tests
         {
             if (cts != null)
                 cts.Dispose();
+
+            if (File.Exists(ResultPath))
+            {
+                File.Delete(ResultPath);
+            }
         }
 
         [Test]
@@ -163,5 +170,261 @@ namespace Tizen.Multimedia.Util.Tests
 
             Assert.That(() => cts.Cancel(), Throws.Nothing);
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Extract thumbnail with default size")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_CHECK_RETURNS()
+        {
+            // The resolution of input image is 900x500, so it has different ratio with 320x240.
+            // So, the resolution of generated thumbnail will be changed.
+            Assert.That(() => ThumbnailExtractor.Extract(Path).Size,
+                Is.Not.EqualTo(new Size(320, 240)));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws ArgumentNullException if path is null")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_NULL_PATH()
+        {
+            Assert.Throws<ArgumentNullException>(() => ThumbnailExtractor.Extract(null));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileNotFoundException if file doesn't exist")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_INVALID_PATH()
+        {
+            Assert.Throws<FileNotFoundException>(() => ThumbnailExtractor.Extract(PathInvalid));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileFormatException if invalid file format")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_INVALID_FILE_FORMAT()
+        {
+            Assert.Throws<FileFormatException>(() => ThumbnailExtractor.Extract(PathInvalidFormat));
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Extract thumbnail with valid size")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, Size")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_SIZE_CHECK_RETURNS()
+        {
+            var thumbSize = new Size(432, 240);
+
+            Assert.That(() => ThumbnailExtractor.Extract(Path, thumbSize).Size,
+                Is.EqualTo(thumbSize));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws ArgumentNullException if path is null")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_SIZE_WITH_NULL_PATH()
+        {
+            Assert.Throws<ArgumentNullException>(
+                () => ThumbnailExtractor.Extract(null, new Size(432, 240)));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws ArgumentOutOfRangeException if size is out of range")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_SIZE_WITH_OUT_OF_RANGE_WIDTH_HEIGHT()
+        {
+            Assert.Throws<ArgumentOutOfRangeException>(
+                () => ThumbnailExtractor.Extract(Path, new Size(0, 0)));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileNotFoundException if file doesn't exist")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_SIZE_WITH_INVALID_PATH()
+        {
+            Assert.Throws<FileNotFoundException>(
+                () => ThumbnailExtractor.Extract(PathInvalid, new Size(432, 240)));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileFormatException if invalid file format")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_SIZE_WITH_INVALID_FILE_FORMAT()
+        {
+            Assert.Throws<FileFormatException>(
+                () => ThumbnailExtractor.Extract(PathInvalidFormat, new Size(432, 240)));
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Extract thumbnail with default size and save it to result path")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_CHECK_FILE_EXIST()
+        {
+            Assert.That(() => ThumbnailExtractor.Extract(Path, ResultPath), Throws.Nothing);
+
+            Assert.That(File.Exists(ResultPath), Is.True);
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws ArgumentNullException if path is null")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_WITH_NULL_PATH()
+        {
+            Assert.Throws<ArgumentNullException>(
+                () => ThumbnailExtractor.Extract(null, ResultPath));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileNotFoundException if file doesn't exist")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_WITH_INVALID_PATH()
+        {
+            Assert.Throws<FileNotFoundException>(
+                () => ThumbnailExtractor.Extract(PathInvalid, ResultPath));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileFormatException if invalid file format")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_WITH_INVALID_FILE_FORMAT()
+        {
+            Assert.Throws<FileFormatException>(
+                () => ThumbnailExtractor.Extract(PathInvalidFormat, ResultPath));
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Extract thumbnail with size and save it to result path")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, Size, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_AND_SIZE_CHECK_FILE_EXIST()
+        {
+            Assert.That(() => ThumbnailExtractor.Extract(Path, new Size(432, 240), ResultPath),
+                Throws.Nothing);
+
+            Assert.That(File.Exists(ResultPath), Is.True);
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws ArgumentNullException if path is null")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_AND_SIZE_WITH_NULL_PATH()
+        {
+            Assert.Throws<ArgumentNullException>(
+                () => ThumbnailExtractor.Extract(null, new Size(432, 240), ResultPath));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws ArgumentOutOfRangeException if size is out of range")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_AND_SIZE_WITH_OUT_OF_RANGE_WIDTH_HEIGHT()
+        {
+            Assert.Throws<ArgumentOutOfRangeException>(
+                () => ThumbnailExtractor.Extract(Path, new Size(0, 0), ResultPath));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileNotFoundException if file doesn't exist")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_AND_SIZE_WITH_INVALID_PATH()
+        {
+            Assert.Throws<FileNotFoundException>(
+                () => ThumbnailExtractor.Extract(PathInvalid, new Size(432, 240), ResultPath));
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws FileFormatException if invalid file format")]
+        [Property("SPEC", "Tizen.Multimedia.Util.ThumbnailExtractor.Extract M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, Size, string")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Extract_WITH_RESULTPATH_AND_SIZE_WITH_INVALID_FILE_FORMAT()
+        {
+            Assert.Throws<FileFormatException>(
+                () => ThumbnailExtractor.Extract(PathInvalidFormat, new Size(432, 240), ResultPath));
+        }
     }
 }