From 7d0d9d1e016d3d8a657db52b8f8d27bbc897fba1 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Tue, 16 Jul 2019 14:43:52 +0900 Subject: [PATCH] [ThumbnailExtractor][TCSACR-250] Add sync thumbnail extract API Change-Id: I079771fb4daa4581d4233107734d070f65337674 --- .../ThumbnailExtractor/TSThumbnailExtractor.cs | 263 +++++++++++++++++++++ 1 file changed, 263 insertions(+) mode change 100755 => 100644 tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ThumbnailExtractor/TSThumbnailExtractor.cs diff --git a/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ThumbnailExtractor/TSThumbnailExtractor.cs b/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ThumbnailExtractor/TSThumbnailExtractor.cs old mode 100755 new mode 100644 index 199d3eb..878b522 --- a/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ThumbnailExtractor/TSThumbnailExtractor.cs +++ b/tct-suite-vs/Tizen.MultimediaUtil.Tests/testcase/ThumbnailExtractor/TSThumbnailExtractor.cs @@ -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(() => 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(() => 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(() => 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( + () => 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( + () => 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( + () => 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( + () => 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( + () => 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( + () => 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( + () => 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( + () => 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( + () => 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( + () => 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( + () => ThumbnailExtractor.Extract(PathInvalidFormat, new Size(432, 240), ResultPath)); + } } } -- 2.7.4