From: Haesu Gwon Date: Thu, 29 Mar 2018 11:52:50 +0000 (+0900) Subject: [MediaVision][Non-ACR] refactoring X-Git-Tag: public_m1_final~92 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F27%2F174627%2F2;p=test%2Ftct%2Fcsharp%2Fapi.git [MediaVision][Non-ACR] refactoring Change-Id: I3bd75dd0bd71499b4222ed3186d1ea7e398697ef Signed-off-by: Haesu Gwon --- diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.csproj b/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.csproj old mode 100755 new mode 100644 index 5cb9eb0d0..f159eed97 --- a/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.csproj +++ b/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.csproj @@ -34,6 +34,7 @@ + diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.sln b/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.sln old mode 100755 new mode 100644 index 1fe512470..844c5dbe6 --- a/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.sln +++ b/tct-suite-vs/Tizen.MediaVision.Tests/Tizen.MediaVision.Tests.sln @@ -10,6 +10,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunitlite", "..\nunitlite\n EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTemplate", "..\Template\AutoTemplate\AutoTemplate.csproj", "{B11ABB0C-C3C1-4B5C-8251-A15628A775F3}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Multimedia.Support.Library", "..\Tizen.Multimedia.Support.Library\Tizen.Multimedia.Support.Library.csproj", "{80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -58,10 +60,28 @@ Global {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.Build.0 = Release|Any CPU {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.NUI|Any CPU.ActiveCfg = Debug|Any CPU - {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.NUI|Any CPU.Build.0 = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.ActiveCfg = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.Build.0 = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.ActiveCfg = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.Build.0 = Debug|Any CPU {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.Build.0 = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.ActiveCfg = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.Build.0 = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x86.ActiveCfg = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x86.Build.0 = Release|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Debug|x64.ActiveCfg = Debug|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Debug|x64.Build.0 = Debug|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Debug|x86.ActiveCfg = Debug|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Debug|x86.Build.0 = Debug|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Release|Any CPU.Build.0 = Release|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Release|x64.ActiveCfg = Release|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Release|x64.Build.0 = Release|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Release|x86.ActiveCfg = Release|Any CPU + {80EAC7DC-0D5E-4C2F-90C9-B521BDED2A8D}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcode.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcode.cs old mode 100755 new mode 100644 index 47948180e..e0734733d --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcode.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcode.cs @@ -14,27 +14,22 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.Barcode test class")] public class BarcodeTests { - private static string message = "0123455"; - private static BarcodeType type = BarcodeType.QR; + private const string _message = "0123455"; + private const BarcodeType _barcodeType = BarcodeType.QR; + private static Barcode _barcode = null; - private static Point[] points = new Point[4] - { + private static Quadrangle _region = new Quadrangle( + new Point[4] { new Point(2, 2), new Point(2, 202), new Point(202, 2), - new Point(202, 202) - }; - - private static Quadrangle region = new Quadrangle(points); + new Point(202, 202)} + ); [SetUp] public static void Init() { - } - - [TearDown] - public static void Destroy() - { + _barcode = new Barcode(_region, _message, _barcodeType); } [Test] @@ -46,9 +41,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Barcode_INIT() { - Barcode barcode = new Barcode(region, message, type); - Assert.IsInstanceOf(barcode, "Should be of type Barcode"); - Assert.IsNotNull(barcode, "barcode should not be null after calling constructor."); + Assert.IsInstanceOf(_barcode, "Should be of type Barcode"); } [Test] @@ -60,8 +53,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Region_READ_ONLY() { - Barcode barcode = new Barcode(region, message, type); - Assert.AreEqual(region, barcode.Region, "Return value should be {0}", region.ToString()); + Assert.AreEqual(_region, _barcode.Region, "Return value should be {0}", _region.ToString()); } [Test] @@ -73,8 +65,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Message_READ_ONLY() { - Barcode barcode = new Barcode(region, message, type); - Assert.AreEqual(message, barcode.Message, "Message value should be {0}", message); + Assert.AreEqual(_message, _barcode.Message, "Message value should be {0}", _message); } [Test] @@ -86,9 +77,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Type_READ_ONLY() { - Barcode barcode = new Barcode(region, message, type); - Assert.AreEqual(type, barcode.Type, "Type should be {0}", type); + Assert.AreEqual(_barcodeType, _barcode.Type, "Type should be {0}", _barcodeType); } } - } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetectionConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetectionConfiguration.cs old mode 100755 new mode 100644 index 27ac65081..720f5ff09 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetectionConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetectionConfiguration.cs @@ -6,9 +6,8 @@ // it only in accordance with the terms of the license agreement // you entered into with Samsung. -using System; using NUnit.Framework; -using Tizen.System; +using System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,32 +15,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.BarcodeDetectionConfiguration test class")] public class BarcodeDetectionConfigurationTests { - private static BarcodeDetectionConfiguration config = null; + private static BarcodeDetectionConfiguration _config = null; [SetUp] public static void Init() { - bool isBarcodeDetecteSupported = false; - Information.TryGetValue("http://tizen.org/feature/vision.barcode_detection", out isBarcodeDetecteSupported); - try { - config = new BarcodeDetectionConfiguration(); + _config = new BarcodeDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.BarcodeDetection) == false) { - if (isBarcodeDetecteSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support BarcodeDetection"); - else - Assert.Pass("BarcodeDetection is not supported"); + Assert.Pass("BarcodeDetection is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -53,8 +45,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void BarcodeDetectionConfiguration_INIT() { - Assert.IsInstanceOf(config, "Should be of type BarcodeDetectionConfiguration"); - Assert.IsNotNull(config, "BarcodeDetectionConfiguration should not be null after calling constructor."); + Assert.IsInstanceOf(_config, "Should be of type BarcodeDetectionConfiguration"); + Assert.IsNotNull(_config, "BarcodeDetectionConfiguration should not be null after calling constructor."); } [Test] @@ -66,8 +58,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Target_SET_GET_ENUM_ALL() { - config.Target = BarcodeDetectionTarget.All; - Assert.AreEqual(config.Target, BarcodeDetectionTarget.All, "BarcodeDetectionTarget value should be All"); + _config.Target = BarcodeDetectionTarget.All; + Assert.AreEqual(_config.Target, BarcodeDetectionTarget.All, "BarcodeDetectionTarget value should be All"); } [Test] @@ -79,8 +71,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Target_SET_GET_ENUM_BARCODE1D() { - config.Target = BarcodeDetectionTarget.Barcode1D; - Assert.AreEqual(config.Target, BarcodeDetectionTarget.Barcode1D, "BarcodeDetectionTarget value should be Barcode1D"); + _config.Target = BarcodeDetectionTarget.Barcode1D; + Assert.AreEqual(_config.Target, BarcodeDetectionTarget.Barcode1D, "BarcodeDetectionTarget value should be Barcode1D"); } [Test] @@ -92,8 +84,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Target_SET_GET_ENUM_BARCODE2D() { - config.Target = BarcodeDetectionTarget.Barcode2D; - Assert.AreEqual(config.Target, BarcodeDetectionTarget.Barcode2D, "BarcodeDetectionTarget value should be Barcode1D"); + _config.Target = BarcodeDetectionTarget.Barcode2D; + Assert.AreEqual(_config.Target, BarcodeDetectionTarget.Barcode2D, "BarcodeDetectionTarget value should be Barcode1D"); } [Test] @@ -105,7 +97,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Target_CHECK_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.Target = BarcodeDetectionTarget.Barcode2D + 1); + Assert.Throws(() => _config.Target = BarcodeDetectionTarget.Barcode2D + 1); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetector.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetector.cs old mode 100755 new mode 100644 index 62cae32db..1ce54f762 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetector.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeDetector.cs @@ -9,7 +9,6 @@ using NUnit.Framework; using System; using System.Threading.Tasks; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,31 +16,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.BarcodeDetector test class")] public class BarcodeDetectorTests { - private static BarcodeDetectionConfiguration config = null; - private static bool isNotSupportedTC = false; + private static BarcodeDetectionConfiguration _config = null; + [SetUp] public static void Init() { - bool isBarcodeDetecteSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.barcode_detection", out isBarcodeDetecteSupported); - try { - config = new BarcodeDetectionConfiguration(); + _config = new BarcodeDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.BarcodeDetection) == false) { - if (!isBarcodeDetecteSupported) - isNotSupportedTC = true; + Assert.Pass("BarcodeDetection is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -54,17 +47,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle")] public static async Task DetectAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "barcode/barcode.jpg")) { - Point point = new Point(0, 0); - Size size = new Size((int)source.Width, (int)source.Height); - Rectangle roi = new Rectangle(point, size); + var roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height)); var barcodeLists = await BarcodeDetector.DetectAsync(source, roi); - foreach (Barcode barcode in barcodeLists) + foreach (var barcode in barcodeLists) { Assert.AreEqual(barcode.Type, BarcodeType.QR, "Invalid type of detected barcodes"); Assert.AreEqual(barcode.Message, "0123455", "Invalid message of detected barcodes"); @@ -82,19 +70,14 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle, BarcodeDetectionConfiguration")] public static async Task DetectAsync_with_Configuration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "barcode/barcode.jpg")) { - config.Target = BarcodeDetectionTarget.All; + _config.Target = BarcodeDetectionTarget.All; - Point point = new Point(0, 0); - Size size = new Size((int)source.Width, (int)source.Height); - Rectangle roi = new Rectangle(point, size); - var barcodeLists = await BarcodeDetector.DetectAsync(source, roi, config); + var roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height)); + var barcodeLists = await BarcodeDetector.DetectAsync(source, roi, _config); - foreach (Barcode barcode in barcodeLists) + foreach (var barcode in barcodeLists) { Assert.AreEqual(barcode.Type, BarcodeType.QR, "Invalid type of detected barcodes"); Assert.AreEqual(barcode.Message, "0123455", "Invalid message of detected barcodes"); @@ -112,10 +95,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle")] public static async Task DetectAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - Rectangle roi = new Rectangle(new Point(0, 0), new Size(300, 300)); + var roi = new Rectangle(new Point(0, 0), new Size(300, 300)); await AssertHelper.ThrowsAsync(() => BarcodeDetector.DetectAsync(null, roi)); } @@ -129,12 +109,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle, BarcodeDetectionConfiguration")] public static async Task DetectAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - config.Target = BarcodeDetectionTarget.All; - Rectangle roi = new Rectangle(new Point(0, 0), new Size(300, 300)); - await AssertHelper.ThrowsAsync(() => BarcodeDetector.DetectAsync(null, roi, config)); + _config.Target = BarcodeDetectionTarget.All; + var roi = new Rectangle(new Point(0, 0), new Size(300, 300)); + await AssertHelper.ThrowsAsync(() => BarcodeDetector.DetectAsync(null, roi, _config)); } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerationConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerationConfiguration.cs old mode 100755 new mode 100644 index 69dbcbfa7..f58ee984b --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerationConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerationConfiguration.cs @@ -9,7 +9,6 @@ using System; using NUnit.Framework; using Tizen.Common; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,32 +16,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.BarcodeGenerationConfiguration test class")] public class BarcodeGenerationConfigurationTests { - private static BarcodeGenerationConfiguration config = null; + private static BarcodeGenerationConfiguration _config = null; [SetUp] public static void Init() { - bool isBarcodeGenerateSupported = false; - Information.TryGetValue("http://tizen.org/feature/vision.barcode_generation", out isBarcodeGenerateSupported); - try { - config = new BarcodeGenerationConfiguration(); + _config = new BarcodeGenerationConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.BarcodeGeneration) == false) { - if (isBarcodeGenerateSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support BarcodeGeneration"); - else - Assert.Pass("BarcodeGeneration is not supported"); + Assert.Pass("BarcodeGeneration is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -54,8 +46,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void BarcodeGenerationConfiguration_INIT() { - Assert.IsInstanceOf(config, "Should be of type BarcodeGenerationConfiguration"); - Assert.IsNotNull(config, "BarcodeGenerationConfiguration should not be null after calling constructor."); + Assert.IsInstanceOf(_config, "Should be of type BarcodeGenerationConfiguration"); + Assert.IsNotNull(_config, "BarcodeGenerationConfiguration should not be null after calling constructor."); } [Test] @@ -67,8 +59,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void TextVisibility_SET_GET_ENUM_INVISIBLE() { - config.TextVisibility = Visibility.Invisible; - Assert.AreEqual(config.TextVisibility, Visibility.Invisible, "TextVisibility value should be Invisible"); + _config.TextVisibility = Visibility.Invisible; + Assert.AreEqual(_config.TextVisibility, Visibility.Invisible, "TextVisibility value should be Invisible"); } [Test] @@ -80,7 +72,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void TextVisibility_CHECK_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.TextVisibility = Visibility.Visible + 1); + Assert.Throws(() => _config.TextVisibility = Visibility.Visible + 1); } [Test] @@ -92,8 +84,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void TextVisibility_SET_GET_ENUM_VISIBLE() { - config.TextVisibility = Visibility.Visible; - Assert.AreEqual(config.TextVisibility, Visibility.Visible, "TextAttribute value should be Visible"); + _config.TextVisibility = Visibility.Visible; + Assert.AreEqual(_config.TextVisibility, Visibility.Visible, "TextAttribute value should be Visible"); } [Test] @@ -105,8 +97,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void ForegroundColor_READ_WRITE() { - config.ForegroundColor = Color.Black; - Assert.AreEqual(config.ForegroundColor, Color.Black, "Foreground should be Black"); + _config.ForegroundColor = Color.Black; + Assert.AreEqual(_config.ForegroundColor, Color.Black, "Foreground should be Black"); } [Test] @@ -118,8 +110,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void BackgroundColor_READ_WRITE() { - config.BackgroundColor = Color.White; - Assert.AreEqual(config.BackgroundColor, Color.White, "BackgroundColor should be White"); + _config.BackgroundColor = Color.White; + Assert.AreEqual(_config.BackgroundColor, Color.White, "BackgroundColor should be White"); } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerator.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerator.cs old mode 100755 new mode 100644 index e28d41793..db5df775c --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerator.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeGenerator.cs @@ -9,7 +9,6 @@ using System; using NUnit.Framework; using Tizen.Common; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,30 +16,26 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.BarcodeGenerator test class")] public class BarcodeGeneratorTests { - private static BarcodeGenerationConfiguration config = null; + private static BarcodeGenerationConfiguration _config = null; + private const string _mediaPath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/sample-barcode"; [SetUp] public static void Init() { - bool isBarcodeGenerateSupported = false; - Information.TryGetValue("http://tizen.org/feature/vision.barcode_generation", out isBarcodeGenerateSupported); - try { - config = new BarcodeGenerationConfiguration(); + _config = new BarcodeGenerationConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.BarcodeGeneration) == false) { - if (isBarcodeGenerateSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support BarcodeGeneration"); - else - Assert.Pass("BarcodeGeneration is not supported"); + Assert.Pass("BarcodeGeneration is not supported"); } } [TearDown] public static void Destroy() { + _config?.Dispose(); } [Test] @@ -53,7 +48,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, QrConfiguration")] public static void GenerateSource_QRCode_CHECK_RETURN_VALUE() { - QrConfiguration qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 30); + var qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 30); Assert.AreEqual(qrConfig.Mode, QrMode.Numeric, "Mode should be numeric"); Assert.AreEqual(qrConfig.ErrorCorrectionLevel, ErrorCorrectionLevel.Medium, "ErrorCorrectionLevel should be Medium"); @@ -91,7 +86,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, QrConfiguration")] public static void GenerateSource_QRCode_CHECK_ARGUMENT_EXCEPTION() { - QrConfiguration qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 20); + var qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 20); Assert.Throws(() => BarcodeGenerator.GenerateSource("abcdef", qrConfig)); } @@ -105,12 +100,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, QrConfiguration, BarcodeGenerationConfiguration")] public static void GenerateSource_QRCode_with_Configuration_CHECk_RETURN_VALUE() { - config.TextVisibility = Visibility.Invisible; - config.ForegroundColor = Color.Black; - config.BackgroundColor = Color.White; + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.White; - QrConfiguration qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 30); - using (var source = BarcodeGenerator.GenerateSource("0123455", qrConfig, config)) + var qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 30); + using (var source = BarcodeGenerator.GenerateSource("0123455", qrConfig, _config)) { Assert.IsTrue(source.Width > 0, "Invalid width of media source generated"); Assert.IsTrue(source.Height > 0, "Invalid height of media source generated"); @@ -129,11 +124,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, QrConfiguration, BarcodeGenerationConfiguration")] public static void GenerateSource_QRCode_with_Configuration_CHECK_NULL_ARGUMENT_EXEPTION() { - config.TextVisibility = Visibility.Invisible; - config.ForegroundColor = Color.Black; - config.BackgroundColor = Color.White; + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.White; - Assert.Throws(() => BarcodeGenerator.GenerateSource("0123455", null, config)); + Assert.Throws(() => BarcodeGenerator.GenerateSource("0123455", null, _config)); } @@ -146,14 +141,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, QrConfiguration, BarcodeGenerationConfiguration")] public static void GenerateSource_QRCode_with_Configuration_CHECK_ARGUMENT_EXEPTION() { - BarcodeGenerationConfiguration config = new BarcodeGenerationConfiguration(); - config.TextVisibility = Visibility.Invisible; - config.ForegroundColor = Color.Black; - config.BackgroundColor = Color.White; + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.White; - QrConfiguration qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 20); + var qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 20); - Assert.Throws(() => BarcodeGenerator.GenerateSource("abcdef", qrConfig, config)); + Assert.Throws(() => BarcodeGenerator.GenerateSource("abcdef", qrConfig, _config)); } [Test] @@ -211,11 +205,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, BarcodeType, BarcodeGenerationConfiguration")] public static void GenerateSource_Barcode1D_with_Configuration_CHECK_RETURN_VALUE() { - config.TextVisibility = Visibility.Invisible; - config.ForegroundColor = Color.Black; - config.BackgroundColor = Color.White; + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.White; - using (var source = BarcodeGenerator.GenerateSource("0123455", BarcodeType.Code128, config)) + using (var source = BarcodeGenerator.GenerateSource("0123455", BarcodeType.Code128, _config)) { Assert.IsTrue(source.Width > 0, "Invalid width of media source generated"); Assert.IsTrue(source.Height > 0, "Invalid height of media source generated"); @@ -234,11 +228,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, BarcodeType, BarcodeGenerationConfiguration")] public static void GenerateSource_Barcode1D_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - config.TextVisibility = Visibility.Invisible; - config.ForegroundColor = Color.Black; - config.BackgroundColor = Color.White; + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.White; - Assert.Throws(() => BarcodeGenerator.GenerateSource(null, BarcodeType.Code128, config)); + Assert.Throws(() => BarcodeGenerator.GenerateSource(null, BarcodeType.Code128, _config)); } [Test] @@ -251,11 +245,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "String, BarcodeType, BarcodeGenerationConfiguration")] public static void GenerateSource_Barcode1D_with_Configuration_CHECK_ARGUMENT_EXCEPTION() { - config.TextVisibility = Visibility.Invisible; - config.ForegroundColor = Color.Black; - config.BackgroundColor = Color.White; + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.White; - Assert.Throws(() => BarcodeGenerator.GenerateSource("0123455", BarcodeType.QR, config)); + Assert.Throws(() => BarcodeGenerator.GenerateSource("0123455", BarcodeType.QR, _config)); } [Test] @@ -268,14 +262,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, QrConfiguration, BarcodeImageConfiguration")] public static void GenerateImage_QRCode_CHECK_NULL_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; + var imageConfig = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); - string message = "0123455"; - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(500, 400, path, format); - - Assert.Throws( () => BarcodeGenerator.GenerateImage(message, null, imageConfig)); + Assert.Throws(() => BarcodeGenerator.GenerateImage("0123455", null, imageConfig)); } [Test] @@ -288,16 +277,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, QrConfiguration, BarcodeImageConfiguration")] public static void GenerateImage_QRCode_CHECK_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; - - string message = "abcdef"; - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(500, 400, path, format); + var imageConfig = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); QrConfiguration qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 20); - Assert.Throws(() => BarcodeGenerator.GenerateImage(message, qrConfig, imageConfig)); + Assert.Throws(() => BarcodeGenerator.GenerateImage("abcdef", qrConfig, imageConfig)); } [Test] @@ -310,19 +294,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, QrConfiguration, BarcodeImageConfiguration, BarcodeGenerationConfiguration")] public static void GenerateImage_QRCode_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.Yellow; - string message = "0123455"; + var imageConfig = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); - config.ForegroundColor = Tizen.Common.Color.Black; - config.BackgroundColor = Tizen.Common.Color.Yellow; - config.TextVisibility = Visibility.Invisible; - - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(500, 400, path, format); - - Assert.Throws(() => BarcodeGenerator.GenerateImage(message, null, imageConfig, config)); + Assert.Throws(() => BarcodeGenerator.GenerateImage("0123455", null, imageConfig, _config)); } [Test] @@ -335,20 +313,14 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, QrConfiguration, BarcodeImageConfiguration, BarcodeGenerationConfiguration")] public static void GenerateImage_QRCode_with_Configuration_CHECK_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; - - string message = "abcdef"; - config.ForegroundColor = Tizen.Common.Color.Black; - config.BackgroundColor = Tizen.Common.Color.Yellow; - config.TextVisibility = Visibility.Invisible; - - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(500, 400, path, format); + _config.TextVisibility = Visibility.Invisible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.Yellow; - QrConfiguration qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 20); + var imageConfig = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); + var qrConfig = new QrConfiguration(QrMode.Numeric, ErrorCorrectionLevel.Medium, 20); - Assert.Throws(() => BarcodeGenerator.GenerateImage(message, qrConfig, imageConfig, config)); + Assert.Throws(() => BarcodeGenerator.GenerateImage("abcdef", qrConfig, imageConfig, _config)); } [Test] @@ -361,15 +333,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, BarcodeType, BarcodeImageConfiguration")] public static void GenerateImage_Barcode1D_CHECK_NULL_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; - - BarcodeType type = BarcodeType.Code128; - - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(300, 100, path, format); + var imageConfig = new BarcodeImageConfiguration(300, 100, _mediaPath, BarcodeImageFormat.Jpeg); - Assert.Throws(() => BarcodeGenerator.GenerateImage(null, type, imageConfig)); + Assert.Throws(() => BarcodeGenerator.GenerateImage(null, BarcodeType.Code128, imageConfig)); } [Test] @@ -382,16 +348,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, BarcodeType, BarcodeImageConfiguration")] public static void GenerateImage_Barcode1D_CHECK_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; - - string message = "0123455"; - BarcodeType type = BarcodeType.QR; - - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(300, 100, path, format); + var imageConfig = new BarcodeImageConfiguration(300, 100, _mediaPath, BarcodeImageFormat.Jpeg); - Assert.Throws(() => BarcodeGenerator.GenerateImage(message, type, imageConfig)); + Assert.Throws(() => BarcodeGenerator.GenerateImage("0123455", BarcodeType.QR, imageConfig)); } [Test] @@ -404,19 +363,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, type, BarcodeImageConfiguration, BarcodeGenerationConfiguration")] public static void GenerateImage_Barcode1D_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; + _config.TextVisibility = Visibility.Visible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.Yellow; - config.ForegroundColor = Tizen.Common.Color.Black; - config.BackgroundColor = Tizen.Common.Color.Yellow; - config.TextVisibility = Visibility.Visible; + var imageConfig = new BarcodeImageConfiguration(300, 100, _mediaPath, BarcodeImageFormat.Jpeg); - BarcodeType type = BarcodeType.Code128; - - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(300, 100, path, format); - - Assert.Throws(() => BarcodeGenerator.GenerateImage(null, type, imageConfig, config)); + Assert.Throws(() => BarcodeGenerator.GenerateImage(null, BarcodeType.Code128, imageConfig, _config)); } [Test] @@ -429,20 +382,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string, type, BarcodeImageConfiguration, BarcodeGenerationConfiguration")] public static void GenerateImage_Barcode1D_with_Configuration_CHECK_ARGUMENT_EXCEPTION() { - string mediapath = "/opt/usr/home/owner/apps_rw/Tizen.MediaVision.Manual.Tests/shared/trusted/"; - string path = mediapath + "sample-barcode"; - - config.ForegroundColor = Tizen.Common.Color.Black; - config.BackgroundColor = Tizen.Common.Color.Yellow; - config.TextVisibility = Visibility.Visible; - - string message = "0123455"; - BarcodeType type = BarcodeType.QR; + _config.TextVisibility = Visibility.Visible; + _config.ForegroundColor = Color.Black; + _config.BackgroundColor = Color.Yellow; - BarcodeImageFormat format = BarcodeImageFormat.Jpeg; - BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(300, 100, path, format); + var imageConfig = new BarcodeImageConfiguration(300, 100, _mediaPath, BarcodeImageFormat.Jpeg); - Assert.Throws(() => BarcodeGenerator.GenerateImage(message, type, imageConfig, config)); + Assert.Throws(() => BarcodeGenerator.GenerateImage("0123455", BarcodeType.QR, imageConfig, _config)); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeImageConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeImageConfiguration.cs old mode 100755 new mode 100644 index daa36f640..7b3af9b55 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeImageConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSBarcodeImageConfiguration.cs @@ -15,15 +15,7 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.BarcodeImageConfiguration test class")] public class BarcodeImageConfigurationTests { - [SetUp] - public static void Init() - { - } - - [TearDown] - public static void Destroy() - { - } + private const string _mediaPath = "/opt/usr/test-barcode-generate-new"; [Test] [Category("P1")] @@ -35,7 +27,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "int, int, String, BarcodeImageFormat")] public static void BarcodeImageConfiguration_Width_Height_INIT() { - var obj = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg); + var obj = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); Assert.IsInstanceOf(obj, "Should be of type BarcodeImageConfiguration"); Assert.IsNotNull(obj, "BarcodeImageConfiguration should not be null after calling constructor."); } @@ -50,7 +42,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "int, int, String, BarcodeImageFormat")] public static void BarcodeImageConfiguration_Width_Height_INIT_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws( () => new BarcodeImageConfiguration(500, 400, null, BarcodeImageFormat.Jpeg)); + Assert.Throws( + () => new BarcodeImageConfiguration(500, 400, null, BarcodeImageFormat.Jpeg)); } [Test] @@ -63,7 +56,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "int, int, String, BarcodeImageFormat")] public static void BarcodeImageConfiguration_Width_Height_INIT_CHECK_OutOfRange_EXCEPTION() { - Assert.Throws(() => new BarcodeImageConfiguration(0, 0, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg)); + Assert.Throws( + () => new BarcodeImageConfiguration(0, 0, _mediaPath, BarcodeImageFormat.Jpeg)); } [Test] @@ -76,8 +70,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "Size, String, BarcodeImageFormat")] public static void BarcodeImageConfiguration_Size_INIT() { - Size size = new Size(500, 400); - var obj = new BarcodeImageConfiguration(size, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg); + var obj = new BarcodeImageConfiguration(new Size(500, 400), _mediaPath, BarcodeImageFormat.Jpeg); Assert.IsInstanceOf(obj, "Should be of type BarcodeImageConfiguration"); Assert.IsNotNull(obj, "BarcodeImageConfiguration should not be null after calling constructor."); } @@ -92,8 +85,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "Size, String, BarcodeImageFormat")] public static void BarcodeImageConfiguration_Size_INIT_CHECK_NULL_ARGUMENT_EXCEPTION() { - Size size = new Size(500, 400); - Assert.Throws(() => new BarcodeImageConfiguration(size, null, BarcodeImageFormat.Jpeg)); + Assert.Throws( + () => new BarcodeImageConfiguration(new Size(500, 400), null, BarcodeImageFormat.Jpeg)); } [Test] @@ -106,8 +99,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "Size, String, BarcodeImageFormat")] public static void BarcodeImageConfiguration_Size_INIT_CHECK_OutOfRange_EXCEPTION() { - Size size = new Size(-1, -1); - Assert.Throws( () => new BarcodeImageConfiguration(size, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg)); + Assert.Throws( + () => new BarcodeImageConfiguration(new Size(-1, -1), _mediaPath, BarcodeImageFormat.Jpeg)); } [Test] @@ -119,8 +112,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Width_READ_ONLY() { - /* TEST CODE */ - var obj = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg); + var obj = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); Assert.AreEqual(obj.Width, 500, "Width is incorrect"); } @@ -133,8 +125,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Height_READ_ONLY() { - /* TEST CODE */ - var obj = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg); + var obj = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); Assert.AreEqual(obj.Height, 400, "Height is incorrect"); } @@ -147,13 +138,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Size_READ_ONLY() { - /* TEST CODE */ - Size size = new Size(500, 400); - var obj = new BarcodeImageConfiguration(size, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg); + var size = new Size(500, 400); + var obj = new BarcodeImageConfiguration(size, _mediaPath, BarcodeImageFormat.Jpeg); Assert.AreEqual(obj.Size, size, "Width is incorrect"); } - [Test] [Category("P1")] [Description("Tests getting the path set in the image configuration")] @@ -163,9 +152,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Path_READ_ONLY() { - /* TEST CODE */ - var obj = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg); - Assert.AreEqual(obj.Path, "/opt/usr/test-barcode-generate-new", "Path is incorrect"); + var obj = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); + Assert.AreEqual(obj.Path, _mediaPath, "Path is incorrect"); } [Test] @@ -177,8 +165,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Format_GET_ENUM_BARCODEIMAGEFORMAT_BMP() { - /* TEST CODE */ - var obj = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Bmp); + var obj = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Bmp); Assert.AreEqual(obj.Format, BarcodeImageFormat.Bmp, "Format should be Bmp"); } @@ -191,8 +178,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Format_GET_ENUM_BARCODEIMAGEFORMAT_JPG() { - /* TEST CODE */ - var obj = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg); + var obj = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Jpeg); Assert.AreEqual(obj.Format, BarcodeImageFormat.Jpeg, "Format should be JPG"); } @@ -205,8 +191,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Format_GET_ENUM_BARCODEIMAGEFORMAT_PNG() { - /* TEST CODE */ - var obj = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Png); + var obj = new BarcodeImageConfiguration(500, 400, _mediaPath, BarcodeImageFormat.Png); Assert.AreEqual(obj.Format, BarcodeImageFormat.Png, "Format should be PNG"); } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetectionConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetectionConfiguration.cs old mode 100755 new mode 100644 index b5f8ac306..255576741 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetectionConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetectionConfiguration.cs @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,33 +15,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceDetectionConfiguration test class")] public class FaceDetectionConfigurationTests { - private static FaceDetectionConfiguration config = null; + private static FaceDetectionConfiguration _config = null; [SetUp] public static void Init() { - bool isFaceRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - config = new FaceDetectionConfiguration(); + _config = new FaceDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (isFaceRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support FaceDetection"); - else - Assert.Pass("FaceDetection is not supported"); + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -54,8 +45,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void FaceDetectionConfiguration_INIT() { - Assert.IsInstanceOf(config, "Should be of type FaceDetectionConfiguration"); - Assert.IsNotNull(config, "FaceDetectionConfiguration should not be null after calling constructor."); + Assert.IsInstanceOf(_config, "Should be of type FaceDetectionConfiguration"); + Assert.IsNotNull(_config, "FaceDetectionConfiguration should not be null after calling constructor."); } [Test] @@ -68,8 +59,8 @@ namespace Tizen.Multimedia.Vision.Tests public static void ModelFilePath_READ_WRITE() { string path = TestHelper.ResourcePath + "haarcascade_frontalface_alt.xml"; - config.ModelFilePath = path; - Assert.AreEqual(config.ModelFilePath, path, "ModelFilePath value is not correct"); + _config.ModelFilePath = path; + Assert.AreEqual(_config.ModelFilePath, path, "ModelFilePath value is not correct"); } [Test] @@ -81,7 +72,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void ModelFilePath_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.ModelFilePath = null); + Assert.Throws(() => _config.ModelFilePath = null); } [Test] @@ -93,7 +84,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void MinHeight_CHECK_DEFAULT_VALUE() { - Assert.IsNull(config.MinHeight, "Default value of minimum height should be null"); + Assert.IsNull(_config.MinHeight, "Default value of minimum height should be null"); } [Test] @@ -105,8 +96,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void MinHeight_READ_WRITE() { - config.MinHeight = 10; - Assert.AreEqual(config.MinHeight, 10, "MinHeight should be 10"); + _config.MinHeight = 10; + Assert.AreEqual(_config.MinHeight, 10, "MinHeight should be 10"); } [Test] @@ -118,7 +109,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void MinHeight_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.MinHeight = -1); + Assert.Throws(() => _config.MinHeight = -1); } [Test] @@ -130,7 +121,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void MinWidth_CHECK_DEFAULT_VALUE() { - Assert.IsNull(config.MinHeight, "Default value of minimum width should be null"); + Assert.IsNull(_config.MinHeight, "Default value of minimum width should be null"); } [Test] @@ -142,8 +133,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void MinWidth_READ_WRITE() { - config.MinWidth = 10; - Assert.AreEqual(config.MinWidth, 10, "MinWidth should be 10"); + _config.MinWidth = 10; + Assert.AreEqual(_config.MinWidth, 10, "MinWidth should be 10"); } [Test] @@ -155,7 +146,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void MinWidth_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.MinWidth = -1); + Assert.Throws(() => _config.MinWidth = -1); } [Test] @@ -167,7 +158,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Roi_CHECK_DEFAULT_VALUE() { - Assert.IsNull(config.Roi, "Default value of Roi should be null"); + Assert.IsNull(_config.Roi, "Default value of Roi should be null"); } [Test] @@ -180,8 +171,8 @@ namespace Tizen.Multimedia.Vision.Tests public static void Roi_READ_WRITE() { Rectangle roi = new Rectangle(10, 10, 20, 30); - config.Roi = roi; - Assert.AreEqual(config.Roi, roi, "Roi should be (10, 10, 20, 30)"); + _config.Roi = roi; + Assert.AreEqual(_config.Roi, roi, "Roi should be (10, 10, 20, 30)"); } [Test] @@ -193,8 +184,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Roi_CHECK_OutOfRange_EXCEPTION() { - Rectangle roi = new Rectangle(-1, -1, -1, -1); - Assert.Throws(() => config.Roi = roi); + Assert.Throws(() => _config.Roi = new Rectangle(-1, -1, -1, -1)); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetector.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetector.cs old mode 100755 new mode 100644 index d3cd09790..261af6c6f --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetector.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceDetector.cs @@ -17,32 +17,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceDetector test class")] public class FaceDetectorTests { - private static FaceDetectionConfiguration config = null; - private static bool isNotSupportedTC = false; + private static FaceDetectionConfiguration _config = null; [SetUp] public static void Init() { - bool isFaceRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - config = new FaceDetectionConfiguration(); + _config = new FaceDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (!isFaceRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -55,13 +48,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource")] public static async Task DetectAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg"); if (frame.Buffer == null || frame.Buffer.Length == 0) { - Assert.IsTrue(false, "Failed to get buffer data from face image"); + Assert.Fail("Failed to get buffer data from face image"); } using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888)) @@ -82,22 +73,19 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceDetectionConfiguration")] public static async Task DetectAsync_with_Roi_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - var frame = await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg"); if (frame.Buffer == null || frame.Buffer.Length == 0) { - Assert.IsTrue(false, "Failed to get buffer data from face image"); + Assert.Fail("Failed to get buffer data from face image"); } - config.MinHeight = 10; - config.MinWidth = 10; - config.Roi = new Rectangle(60, 150, 520, 100); + _config.MinHeight = 10; + _config.MinWidth = 10; + _config.Roi = new Rectangle(60, 150, 520, 100); using (var source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888)) { - var faceLists = await FaceDetector.DetectAsync(source, config); + var faceLists = await FaceDetector.DetectAsync(source, _config); Assert.IsInstanceOf(faceLists, "Should be Rectangle[]"); Assert.AreEqual(faceLists.Length, 5, "The number of detected faces should be 5"); } @@ -113,9 +101,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource")] public static async Task DetectAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - await AssertHelper.ThrowsAsync(() => FaceDetector.DetectAsync(null)); } @@ -129,14 +114,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceDetectionConfiguration")] public static async Task DetectAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - config.MinHeight = 10; - config.MinWidth = 10; - config.Roi = new Rectangle(60, 150, 520, 100); + _config.MinHeight = 10; + _config.MinWidth = 10; + _config.Roi = new Rectangle(60, 150, 520, 100); - await AssertHelper.ThrowsAsync(() => FaceDetector.DetectAsync(null, config)); + await AssertHelper.ThrowsAsync(() => FaceDetector.DetectAsync(null, _config)); } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionConfiguration.cs old mode 100755 new mode 100644 index b107737bf..769138325 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright 2016 by Samsung Electronics, Inc., +// Copyright 2016 by Samsung Electronics, Inc., // // This software is the confidential and proprietary information // of Samsung Electronics, Inc. ("Confidential Information"). You @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,33 +15,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceRecognitionConfiguration test class")] public class FaceRecognitionConfigurationTests { - private static FaceRecognitionConfiguration config = null; + private static FaceRecognitionConfiguration _config = null; [SetUp] public static void Init() { - bool isFaceRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - config = new FaceRecognitionConfiguration(); + _config = new FaceRecognitionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (isFaceRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support FaceRecognition"); - else - Assert.Pass("FaceRecognition is not supported"); + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -54,8 +45,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void FaceRecognitionConfiguration_INIT() { - Assert.IsInstanceOf(config, "Should be of type FaceRecognitionConfiguration"); - Assert.IsNotNull(config, "FaceRecognitionConfiguration should not be null after calling constructor."); + Assert.IsInstanceOf(_config, "Should be of type FaceRecognitionConfiguration"); + Assert.IsNotNull(_config, "FaceRecognitionConfiguration should not be null after calling constructor."); } [Test] @@ -67,7 +58,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void ModelType_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.ModelType, FaceRecognitionModelType.Lbph, "Default ModelType value should be LBPH"); + Assert.AreEqual(_config.ModelType, FaceRecognitionModelType.Lbph, "Default ModelType value should be LBPH"); } [Test] @@ -79,8 +70,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void ModelType_SET_GET_ENUM_EIGENFACES() { - config.ModelType = FaceRecognitionModelType.EigenFaces; - Assert.AreEqual(config.ModelType, FaceRecognitionModelType.EigenFaces, "ModelType should be EigenFaces"); + _config.ModelType = FaceRecognitionModelType.EigenFaces; + Assert.AreEqual(_config.ModelType, FaceRecognitionModelType.EigenFaces, "ModelType should be EigenFaces"); } [Test] @@ -92,8 +83,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void ModelType_SET_GET_ENUM_FISHERFACES() { - config.ModelType = FaceRecognitionModelType.FisherFaces; - Assert.AreEqual(config.ModelType, FaceRecognitionModelType.FisherFaces, "ModelType should be FisherFaces"); + _config.ModelType = FaceRecognitionModelType.FisherFaces; + Assert.AreEqual(_config.ModelType, FaceRecognitionModelType.FisherFaces, "ModelType should be FisherFaces"); } [Test] @@ -105,8 +96,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void ModelType_SET_GET_ENUM_FACERECOGNITIONMODELTYPE_LBPH() { - config.ModelType = FaceRecognitionModelType.Lbph; - Assert.AreEqual(config.ModelType, FaceRecognitionModelType.Lbph, "ModelType should be LBPH"); + _config.ModelType = FaceRecognitionModelType.Lbph; + Assert.AreEqual(_config.ModelType, FaceRecognitionModelType.Lbph, "ModelType should be LBPH"); } [Test] @@ -118,7 +109,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void ModelType_CHECK_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.ModelType = FaceRecognitionModelType.Lbph + 1); + Assert.Throws(() => _config.ModelType = FaceRecognitionModelType.Lbph + 1); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionModel.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionModel.cs index 9e13d622a..95d877c4b 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionModel.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionModel.cs @@ -8,9 +8,8 @@ using System; using System.IO; -using NUnit.Framework; using System.Threading.Tasks; -using Tizen.System; +using NUnit.Framework; namespace Tizen.Multimedia.Vision.Tests { @@ -18,33 +17,38 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceRecognitionModel test class")] public class FaceRecognitionModelTests { - private static FaceRecognitionModel model = null; + private static FaceRecognitionModel _model = null; + private static MediaVisionSource _source1 = null; + private static MediaVisionSource _source2 = null; + + private static async Task PrepareSourcesAsync() + { + _source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"); + _source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg"); + } [SetUp] public static void Init() { - bool isFaceRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - model = new FaceRecognitionModel(); + _model = new FaceRecognitionModel(); + + Task t = Task.Run(async () => await PrepareSourcesAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (isFaceRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support FaceRecognition"); - else - Assert.Pass("FaceRecognition is not supported"); + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] public static void Destroy() { - if (model != null) - model.Dispose(); + _model?.Dispose(); + _source1?.Dispose(); + _source2?.Dispose(); } [Test] @@ -56,8 +60,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void FaceRecognitionModel_INIT() { - Assert.IsInstanceOf(model, "Should be of type FaceRecognitionModel"); - Assert.IsNotNull(model, "FaceRecognitionModel should not be null after calling constructor."); + Assert.IsInstanceOf(_model, "Should be of type FaceRecognitionModel"); + Assert.IsNotNull(_model, "FaceRecognitionModel should not be null after calling constructor."); } [Test] @@ -70,7 +74,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "string")] public static void FaceRecognitionModel_with_ModelPath_INIT() { - using (FaceRecognitionModel testModel = new FaceRecognitionModel(TestHelper.ResourcePath + "face_recog/face_recog_model_p1")) + using (var testModel = new FaceRecognitionModel(TestHelper.ResourcePath + "face_recog/face_recog_model_p1")) { Assert.IsInstanceOf(testModel, "Should be of type FaceRecognitionModel"); Assert.IsNotNull(testModel, "FaceRecognitionModel should not be null after calling constructor."); @@ -108,21 +112,16 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Save_CHECK_RETURN_VALUE() + public static void Save_CHECK_RETURN_VALUE() { string path = TestHelper.TrustedPath + "face_recognition_model_test"; - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - model.Add(source1, 1); - - model.Add(source2, 2); + _model.Add(_source1, 1); + _model.Add(_source2, 2); - model.Learn(); - model.Save(path); - Assert.IsTrue(File.Exists(path), path + "doesn't exist"); - } + _model.Learn(); + _model.Save(path); + Assert.IsTrue(File.Exists(path), path + "doesn't exist"); } [Test] @@ -134,7 +133,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => model.Save(null)); + Assert.Throws(() => _model.Save(null)); } [Test] @@ -148,15 +147,13 @@ namespace Tizen.Multimedia.Vision.Tests { string restrictedPath = TestHelper.ResourcePath + "face_recog/unauthorizedPath"; - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P2/00.jpg")) + using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P2/00.jpg")) { - model.Add(source1, 1); - - model.Add(source2, 2); + _model.Add(_source1, 1); + _model.Add(source, 2); - model.Learn(); - Assert.Throws(() => model.Save(restrictedPath)); + _model.Learn(); + Assert.Throws(() => _model.Save(restrictedPath)); } } @@ -167,20 +164,15 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTIOn() + public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTIOn() { string fakePath = "/tmp/fake/fake_model"; - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - model.Add(source1, 1); + _model.Add(_source1, 1); + _model.Add(_source2, 2); - model.Add(source2, 2); - - model.Learn(); - Assert.Throws(() => model.Save(fakePath)); - } + _model.Learn(); + Assert.Throws(() => _model.Save(fakePath)); } [Test] @@ -191,18 +183,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] [Property("COVPARAM", "MediaVisionSource, int")] - public static async Task Add_CHECK_RETURN_VALUE() + public static void Add_CHECK_RETURN_VALUE() { - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - model.Add(source1, 1); - - model.Add(source2, 2); + _model.Add(_source1, 1); + _model.Add(_source2, 2); - model.Learn(); - Assert.AreEqual(model.Labels.Length, 2, "Face label count should be 2"); - } + _model.Learn(); + Assert.AreEqual(_model.Labels.Length, 2, "Face label count should be 2"); } [Test] @@ -215,7 +202,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, int")] public static void Add_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => model.Add(null, 1)); + Assert.Throws(() => _model.Add(null, 1)); } [Test] @@ -226,23 +213,18 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] [Property("COVPARAM", "MediaVisionSource, int, Rectangle")] - public static async Task Add_with_Roi_CHECK_RETURN_VALUE() + public static void Add_with_Roi_CHECK_RETURN_VALUE() { - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - /* Suppose that ROI is a whole image */ - Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source1.Width, (int)source1.Height)); - model.Add(source1, 1, roi); + /* Suppose that ROI is a whole image */ + Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)_source1.Width, (int)_source1.Height)); + _model.Add(_source1, 1, roi); - /* Suppose that ROI is a whole image */ - roi = new Rectangle(new Point(0, 0), new Size((int)source2.Width, (int)source2.Height)); + /* Suppose that ROI is a whole image */ + roi = new Rectangle(new Point(0, 0), new Size((int)_source2.Width, (int)_source2.Height)); + _model.Add(_source2, 2, roi); - model.Add(source2, 2, roi); - - model.Learn(); - Assert.AreEqual(model.Labels.Length, 2, "Face label count should be 2"); - } + _model.Learn(); + Assert.AreEqual(_model.Labels.Length, 2, "Face label count should be 2"); } [Test] @@ -255,9 +237,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, int, Rectangle")] public static void Add_with_Roi_CHECK_NULL_ARGUMENT_EXCEPTION() { - Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100)); + var roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - Assert.Throws(() => model.Add(null, 1, roi)); + Assert.Throws(() => _model.Add(null, 1, roi)); } [Test] @@ -267,20 +249,15 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MCST")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Reset_CHECK_RETURN_VALUE() + public static void Reset_CHECK_RETURN_VALUE() { - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - model.Add(source1, 1); + _model.Add(_source1, 1); + _model.Add(_source2, 2); - model.Add(source2, 2); + _model.Learn(); - model.Learn(); - - model.Reset(); - Assert.Throws(() => model.Learn()); - } + _model.Reset(); + Assert.Throws(() => _model.Learn()); } [Test] @@ -290,21 +267,16 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Remove_CHECK_RETURN_VALUE() + public static void Remove_CHECK_RETURN_VALUE() { - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - model.Add(source1, 1); - - model.Add(source2, 2); + _model.Add(_source1, 1); + _model.Add(_source2, 2); - model.Remove(1); + _model.Remove(1); - model.Learn(); - Assert.AreEqual(model.Labels.Length, 1, "Face label count should be 1 after remove"); - Assert.AreEqual(model.Labels[0], 2, "Face label value should be 2"); - } + _model.Learn(); + Assert.AreEqual(_model.Labels.Length, 1, "Face label count should be 1 after remove"); + Assert.AreEqual(_model.Labels[0], 2, "Face label value should be 2"); } [Test] @@ -315,16 +287,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] [Property("COVPARAM", "")] - public static async Task Learn_CHECK_RETURN_VALUE() + public static void Learn_CHECK_NO_EXCEPTION() { - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - model.Add(source1, 1); + _model.Add(_source1, 1); + _model.Add(_source2, 2); - model.Add(source2, 2); - model.Learn(); - } + Assert.DoesNotThrow(() => _model.Learn()); } [Test] @@ -337,7 +305,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "")] public static void Learn_CHECK_INVALID_OPERATION_EXCEPTION() { - Assert.Throws(() => model.Learn()); + Assert.Throws(() => _model.Learn()); } [Test] @@ -348,20 +316,17 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] [Property("COVPARAM", "FaceRecognitionConfiguration")] - public static async Task Learn_with_Configuration_CHECK_RETURN_VALUE() + public static void Learn_with_Configuration_CHECK_NO_EXCEPTION() { - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { - model.Add(source1, 1); - - model.Add(source2, 2); + _model.Add(_source1, 1); + _model.Add(_source2, 2); - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - engineConfig.ModelType = FaceRecognitionModelType.FisherFaces; + FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration() + { + ModelType = FaceRecognitionModelType.FisherFaces + }; - model.Learn(engineConfig); - } + Assert.DoesNotThrow(() => _model.Learn(engineConfig)); } [Test] @@ -374,10 +339,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "FaceRecognitionConfiguration")] public static void Learn_with_Configuration_CHECK_INVALID_OPERATION_EXCEPTION() { - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); + var engineConfig = new FaceRecognitionConfiguration + { + ModelType = FaceRecognitionModelType.FisherFaces + }; - engineConfig.ModelType = FaceRecognitionModelType.FisherFaces; - Assert.Throws(() => model.Learn(engineConfig)); + Assert.Throws(() => _model.Learn(engineConfig)); } [Test] @@ -387,26 +354,21 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Labels_READ_ONLY() + public static void Labels_READ_ONLY() { - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - using (MediaVisionSource source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/P1/00.jpg")) - { + /* Suppose that ROI is a whole image */ + Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)_source1.Width, (int)_source1.Height)); + _model.Add(_source1, 1, roi); - /* Suppose that ROI is a whole image */ - Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source1.Width, (int)source1.Height)); - model.Add(source1, 1, roi); + /* Suppose that ROI is a whole image */ + roi = new Rectangle(new Point(0, 0), new Size((int)_source2.Width, (int)_source2.Height)); + _model.Add(_source2, 2, roi); - /* Suppose that ROI is a whole image */ - roi = new Rectangle(new Point(0, 0), new Size((int)source2.Width, (int)source2.Height)); - model.Add(source2, 2, roi); + _model.Learn(); - model.Learn(); - - Assert.AreEqual(model.Labels.Length, 2, "Face label count should be 2"); - Assert.AreEqual(model.Labels[0], 1, "Face label[0] should be 0"); - Assert.AreEqual(model.Labels[1], 2, "Face label[1] should be 1"); - } + Assert.AreEqual(_model.Labels.Length, 2, "Face label count should be 2"); + Assert.AreEqual(_model.Labels[0], 1, "Face label[0] should be 0"); + Assert.AreEqual(_model.Labels[1], 2, "Face label[1] should be 1"); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionResult.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionResult.cs index 32177f6f5..08df33c12 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionResult.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognitionResult.cs @@ -9,7 +9,6 @@ using System; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,40 +16,40 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceRecognitionResult test class")] public class FaceRecognitionResultTests { - private static FaceRecognitionModel model = null; - private static bool isNotSupportedTC = false; + private static FaceRecognitionModel _model = null; + private static MediaVisionSource _source = null; - private static async Task PrepareModel() + private static async Task PrepareModelAsync() { - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); + await TestHelper.AddImagesToModel(_model, TestHelper.ResourcePath + "face_recog/P1/", 1); + await TestHelper.AddImagesToModel(_model, TestHelper.ResourcePath + "face_recog/P2/", 2); - model.Learn(); + _model.Learn(); + + _source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"); } [SetUp] public static void Init() { - bool isFaceRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - model = new FaceRecognitionModel(); + _model = new FaceRecognitionModel(); + + Task t = Task.Run(async () => await PrepareModelAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (!isFaceRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] public static void Destroy() { - if (model != null) - model.Dispose(); + _model?.Dispose(); + _source?.Dispose(); } [Test] @@ -62,16 +61,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Success_READ_ONLY() { - if (isNotSupportedTC) - return; - - await PrepareModel(); + var result = await FaceRecognizer.RecognizeAsync(_source, _model); - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - var result = await FaceRecognizer.RecognizeAsync(source, model); - Assert.IsTrue(result.Success, "Success should be true"); - } + Assert.IsTrue(result.Success, "Success should be true"); } [Test] @@ -83,17 +75,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Label_READ_ONLY() { - if (isNotSupportedTC) - return; + var result = await FaceRecognizer.RecognizeAsync(_source, _model); - await PrepareModel(); - - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - var result = await FaceRecognizer.RecognizeAsync(source, model); - Assert.IsTrue(result.Success, "Success should be true"); - Assert.AreEqual(result.Label, 1, "Label value should be 1"); - } + Assert.IsTrue(result.Success, "Success should be true"); + Assert.AreEqual(result.Label, 1, "Label value should be 1"); } [Test] @@ -105,20 +90,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Area_READ_ONLY() { - if (isNotSupportedTC) - return; - - await PrepareModel(); - - Rectangle faceArea = new Rectangle(0, 0, 325, 325); - - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - var result = await FaceRecognizer.RecognizeAsync(source, model); + var result = await FaceRecognizer.RecognizeAsync(_source, _model); - Assert.IsTrue(result.Success, "Success should be true"); - Assert.AreEqual(result.Area, faceArea, "Should be equal to facArea"); - } + Assert.IsTrue(result.Success, "Success should be true"); + Assert.AreEqual(result.Area, new Rectangle(0, 0, 325, 325), "Should be equal to facArea"); } [Test] @@ -130,17 +105,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Confidence_READ_ONLY() { - if (isNotSupportedTC) - return; - - await PrepareModel(); + var result = await FaceRecognizer.RecognizeAsync(_source, _model); - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - var result = await FaceRecognizer.RecognizeAsync(source, model); - Assert.IsTrue(result.Success, "Success should be true"); - Assert.IsTrue(result.Confidence > 0.99, "Confidence value should be greater than 0.99"); - } + Assert.IsTrue(result.Success, "Success should be true"); + Assert.IsTrue(result.Confidence > 0.99, "Confidence value should be greater than 0.99"); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognizer.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognizer.cs index 803568011..43a8c7cfe 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognizer.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceRecognizer.cs @@ -7,10 +7,8 @@ // you entered into with Samsung. using System; -using System.IO; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -18,32 +16,44 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceRecognizer test class")] public class FaceRecognizerTests { - private static FaceRecognitionModel model = null; - private static bool isNotSupportedTC = false; + private static FaceRecognitionModel _model = null; + private static FaceRecognitionConfiguration _engineConfig = null; + private static MediaVisionSource _source = null; - [SetUp] - public static void Init() + private static async Task PrepareModelAndSourceAsync() { - bool isFaceRecognitionSupported = false; + await TestHelper.AddImagesToModel(_model, TestHelper.ResourcePath + "face_recog/P1/", 1); + await TestHelper.AddImagesToModel(_model, TestHelper.ResourcePath + "face_recog/P2/", 2); - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); + _model.Learn(); + _source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg"); + } + + [SetUp] + public static void Init() + { try { - model = new FaceRecognitionModel(); + _model = new FaceRecognitionModel(); + _engineConfig = new FaceRecognitionConfiguration(); + + Task t = Task.Run(async () => await PrepareModelAndSourceAsync()); + t.Wait(); + } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (!isFaceRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] public static void Destroy() { - if (model != null) - model.Dispose(); + _model?.Dispose(); + _engineConfig?.Dispose(); + _source?.Dispose(); } [Test] @@ -56,19 +66,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel")] public static async Task RecognizeAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); + var result = await FaceRecognizer.RecognizeAsync(_source, _model); - model.Learn(); - - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - var result = await FaceRecognizer.RecognizeAsync(source, model); - Assert.IsTrue(result.Success, "Should be success"); - } + Assert.IsTrue(result.Success, "Should be success"); } [Test] @@ -81,9 +81,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel")] public static async Task RecognizeAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(null, null)); } @@ -97,18 +94,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel")] public static async Task RecognizeAsync_CHECK_INVALID_OPERATION_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - using (var localModel = new FaceRecognitionModel()) - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) { - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(source, localModel)); + await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(_source, localModel)); } } @@ -122,20 +110,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, Rectangle")] public static async Task RecognizeAsync_with_Roi_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); + var roi = new Rectangle(new Point(0, 0), new Size((int)_source.Width, (int)_source.Height)); + var result = await FaceRecognizer.RecognizeAsync(_source, _model, roi); - model.Learn(); - - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height)); - var result = await FaceRecognizer.RecognizeAsync(source, model, roi); - Assert.IsTrue(result.Success, "Should be success"); - } + Assert.IsTrue(result.Success, "Should be success"); } [Test] @@ -148,15 +126,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, Rectangle")] public static async Task RecognizeAsync_with_Roi_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); + var roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100)); await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(null, null, roi)); } @@ -170,19 +141,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, Rectangle")] public static async Task RecognizeAsync_with_Roi_CHECK_INVALID_OPERATION_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - using (var localModel = new FaceRecognitionModel()) - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) { - Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(source, localModel, roi)); + var roi = new Rectangle(new Point(0, 0), new Size(100, 100)); + await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(_source, localModel, roi)); } } @@ -196,21 +158,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, FaceRecognitionConfiguration")] public static async Task RecognizeAsync_with_Configuration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - - var result = await FaceRecognizer.RecognizeAsync(source, model, engineConfig); - Assert.IsTrue(result.Success, "Should be success"); - } + var result = await FaceRecognizer.RecognizeAsync(_source, _model, _engineConfig); + Assert.IsTrue(result.Success, "Should be success"); } [Test] @@ -223,17 +172,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, FaceRecognitionConfiguration")] public static async Task RecognizeAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - await AssertHelper.ThrowsAsync( () => FaceRecognizer.RecognizeAsync(null, null, engineConfig)); + await AssertHelper.ThrowsAsync( () => FaceRecognizer.RecognizeAsync(null, null, _engineConfig)); } [Test] @@ -246,20 +186,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, FaceRecognitionConfiguration")] public static async Task RecognizeAsync_with_Configuration_CHECK_INVALID_OPERATION_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - using (var localModel = new FaceRecognitionModel()) - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) { - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(source, localModel, engineConfig)); + await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(_source, localModel, _engineConfig)); } } @@ -273,24 +202,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, Rectangle, FaceRecognitionConfiguration")] public static async Task RecognizeAsync_with_Roi_Configuration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; + var roi = new Rectangle(new Point(0, 0), new Size((int)_source.Width, (int)_source.Height)); + Assert.AreEqual(_engineConfig.ModelType, FaceRecognitionModelType.Lbph, "ModelType Should be LBPH"); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) - { - Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height)); - - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - Assert.AreEqual(engineConfig.ModelType, FaceRecognitionModelType.Lbph, "ModelType Should be LBPH"); - - var result = await FaceRecognizer.RecognizeAsync(source, model, roi, engineConfig); - Assert.IsTrue(result.Success, "Should be success"); - } + var result = await FaceRecognizer.RecognizeAsync(_source, _model, roi, _engineConfig); + Assert.IsTrue(result.Success, "Should be success"); } [Test] @@ -303,18 +219,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, Rectangle, FaceRecognitionConfiguration")] public static async Task RecognizeAsync_with_Roi_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); + var roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(null, null, roi, engineConfig)); + await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(null, null, roi, _engineConfig)); } [Test] @@ -327,22 +234,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel, Rectangle, FaceRecognitionConfiguration")] public static async Task RecognizeAsync_with_Roi_Configuration_CHECK_INVALID_OPERATION_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - using (var localModel = new FaceRecognitionModel()) - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_recog/p1_09.jpg")) { - Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); + var roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(source, localModel, roi, engineConfig)); + await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeAsync(_source, localModel, roi, _engineConfig)); } } @@ -356,14 +252,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle")] public static async Task RecognizeEyeConditionAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg")); if (frame.Buffer == null || frame.Buffer.Length == 0) { @@ -380,7 +268,6 @@ namespace Tizen.Multimedia.Vision.Tests } } - [Test] [Category("P2")] [Description("Tests throwing null argument exception when null parameter of source is given")] @@ -391,13 +278,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle")] public static async Task RecognizeEyeConditionAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeEyeConditionAsync(null, new Rectangle(0, 0, 100, 100))); } @@ -412,13 +292,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle, FaceRecognitionConfiguration")] public static async Task RecognizeEyeConditionAsync_with_Configuration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg")); if (frame.Buffer == null || frame.Buffer.Length == 0) @@ -431,9 +304,7 @@ namespace Tizen.Multimedia.Vision.Tests var faceDetectionResult = await FaceDetector.DetectAsync(source); Assert.IsTrue(faceDetectionResult.Length > 0, "No face detected"); - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - - var result = await FaceRecognizer.RecognizeEyeConditionAsync(source, faceDetectionResult[5], engineConfig); + var result = await FaceRecognizer.RecognizeEyeConditionAsync(source, faceDetectionResult[5], _engineConfig); Assert.AreEqual(result, EyeCondition.Open, "Eye condition value should be open"); } } @@ -448,18 +319,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle, FaceRecognitionConfiguration")] public static async Task RecognizeEyeConditionAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); + var roi = new Rectangle(new Point(10, 10), new Size(50, 50)); - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - - Rectangle roi = new Rectangle(new Point(10, 10), new Size(50, 50)); - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeEyeConditionAsync(null, roi, engineConfig)); + await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeEyeConditionAsync(null, roi, _engineConfig)); } [Test] @@ -472,14 +334,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle")] public static async Task RecognizeFacialExpressionAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg")); if (frame.Buffer == null || frame.Buffer.Length == 0) { @@ -506,14 +360,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle")] public static async Task RecognizeFacialExpressionAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeFacialExpressionAsync(null, new Rectangle(0, 0, 100, 100))); } @@ -527,14 +373,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle, FaceRecognitionConfiguration")] public static async Task RecognizeFacialExpressionAsync_with_Configuration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - var frame = (await TestHelper.GetBitampFrameFromImage(TestHelper.ResourcePath + "face_detect/sample_face_det.jpg")); if (frame.Buffer == null || frame.Buffer.Length == 0) { @@ -547,9 +385,7 @@ namespace Tizen.Multimedia.Vision.Tests Assert.IsTrue(faceDetectionResult.Length > 0, "No face detected"); - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); - - var result = await FaceRecognizer.RecognizeFacialExpressionAsync(source, faceDetectionResult[2], engineConfig); + var result = await FaceRecognizer.RecognizeFacialExpressionAsync(source, faceDetectionResult[2], _engineConfig); Assert.IsInstanceOf(result, "It should be of type FacialExpression"); } } @@ -564,18 +400,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle, FaceRecognitionConfiguration")] public static async Task RecognizeFacialExpressionAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P1/", 1); - await TestHelper.AddImagesToModel(model, TestHelper.ResourcePath + "face_recog/P2/", 2); - - model.Learn(); - - Rectangle roi = new Rectangle(new Point(10, 10), new Size(50, 50)); - FaceRecognitionConfiguration engineConfig = new FaceRecognitionConfiguration(); + var roi = new Rectangle(new Point(10, 10), new Size(50, 50)); - await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeFacialExpressionAsync(null, roi, engineConfig)); + await AssertHelper.ThrowsAsync(() => FaceRecognizer.RecognizeFacialExpressionAsync(null, roi, _engineConfig)); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTracker.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTracker.cs index 9a02515de..4ca0ace0c 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTracker.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTracker.cs @@ -10,7 +10,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -18,44 +17,42 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceTracker test class")] public class FaceTrackerTests { - private static FaceTrackingModel model = null; - private static List sources = null; + private static FaceTrackingModel _model = null; + private static List _sources = null; - private static bool isNotSupportedTC = false; - - private static async Task PrepareMediaVisionSources() + private static async Task PrepareSourcesAsync() { - await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "face_track/"); + await TestHelper.FillMediaSourceFromImages(_sources, TestHelper.ResourcePath + "face_track/"); } [SetUp] public static void Init() { - bool isFaceRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - model = new FaceTrackingModel(); - sources = new List(); + _model = new FaceTrackingModel(); + _sources = new List(); + Task t = Task.Run(async () => await PrepareSourcesAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (!isFaceRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] public static void Destroy() { - if (model != null) - model.Dispose(); + _model?.Dispose(); + + foreach (var source in _sources) + { + source?.Dispose(); + } - if (sources != null) - if (sources.Count > 0) - sources.Clear(); + if (_sources?.Count > 0) + _sources?.Clear(); } [Test] @@ -67,26 +64,22 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task TrackAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - await PrepareMediaVisionSources(); - - Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image"); + Assert.IsTrue(_sources.Count > 1, "Failed to get buffer data from face image"); Point[] faceInitailpoints = { new Point(440, 130), new Point(530, 130), new Point(530, 240), - new Point(440, 240) }; + new Point(440, 240) + }; Quadrangle faceLocation = new Quadrangle(faceInitailpoints); - model.Prepare(sources[0], faceLocation); + _model.Prepare(_sources[0], faceLocation); - foreach (var frame in sources) + foreach (var frame in _sources) { - var result = await FaceTracker.TrackAsync(frame, model, false); + var result = await FaceTracker.TrackAsync(frame, _model, false); if (result.Success == false) continue; @@ -102,9 +95,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task TrackAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - await AssertHelper.ThrowsAsync(() => FaceTracker.TrackAsync(null, null, false)); } @@ -117,18 +107,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task TrackAsync_CHECK_INVALID_OPERATION_EXCEPTION() { - if (isNotSupportedTC) - return; + Assert.IsTrue(_sources.Count > 1, "Failed to get buffer data from face image"); - await PrepareMediaVisionSources(); - - Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image"); - - foreach (var frame in sources) + foreach (var frame in _sources) { - await AssertHelper.ThrowsAsync(() => FaceTracker.TrackAsync(frame, model, false)); + await AssertHelper.ThrowsAsync(() => FaceTracker.TrackAsync(frame, _model, false)); } - } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingModel.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingModel.cs index a80e78d9b..bc12e02cb 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingModel.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingModel.cs @@ -10,7 +10,6 @@ using System; using System.IO; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -18,33 +17,42 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceTrackingModel test class")] public class FaceTrackingModelTests { - private static FaceTrackingModel model = null; + private static FaceTrackingModel _model = null; + private static MediaVisionSource _source = null; + private static Quadrangle _faceLocation = new Quadrangle( + new Point[] + { + new Point(440, 130), + new Point(530, 130), + new Point(530, 240), + new Point(440, 240) + } + ); + private static async Task PrepareSourceAsync() + { + _source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg"); + } [SetUp] - public static void Init() + public static void SetUp() { - bool isFaceRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - model = new FaceTrackingModel(); + _model = new FaceTrackingModel(); + Task t = Task.Run(async () => await PrepareSourceAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (isFaceRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support FaceRecognition"); - else - Assert.Pass("FaceRecognition is not supported"); + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] - public static void Destroy() + public static void TearDown() { - if (model != null) - model.Dispose(); + _model?.Dispose(); + _source?.Dispose(); } [Test] @@ -56,8 +64,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void FaceTrackingModel_INIT() { - Assert.IsInstanceOf(model, "Should be of type FaceTrackingModel"); - Assert.IsNotNull(model, "FaceTrackingModel should not be null after calling constructor."); + Assert.IsInstanceOf(_model, "Should be of type FaceTrackingModel"); + Assert.IsNotNull(_model, "FaceTrackingModel should not be null after calling constructor."); } [Test] @@ -71,6 +79,7 @@ namespace Tizen.Multimedia.Vision.Tests public static void FaceTrackingModel_with_ModelPath_INIT() { var testModel = new FaceTrackingModel(TestHelper.ResourcePath + "face_track/face_tracking_model_01"); + Assert.IsInstanceOf(testModel, "Should be of type FaceTrackingModel"); Assert.IsNotNull(testModel, "FaceTrackingModel should not be null after calling constructor."); } @@ -108,20 +117,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Prepare_CHECK_RETURN_VALUE() + public static void Prepare_CHECK_NO_EXCEPTION() { - Point[] faceInitailpoints = { - new Point(440, 130), - new Point(530, 130), - new Point(530, 240), - new Point(440, 240) }; - - Quadrangle faceLocation = new Quadrangle(faceInitailpoints); - - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg")) - { - model.Prepare(source, faceLocation); - } + Assert.DoesNotThrow(() => _model.Prepare(_source, _faceLocation)); } [Test] @@ -133,15 +131,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Prepare_CHECK_NULL_ARUGMENT_EXCEPTION() { - Point[] faceInitailpoints = { - new Point(440, 130), - new Point(530, 130), - new Point(530, 240), - new Point(440, 240) }; - - Quadrangle faceLocation = new Quadrangle(faceInitailpoints); - - Assert.Throws(() => model.Prepare(null, faceLocation)); + Assert.Throws(() => _model.Prepare(null, _faceLocation)); } [Test] @@ -151,25 +141,14 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Save_CHECK_RETURN_VALUE() + public static void Save_CHECK_RETURN_VALUE() { - Point[] faceInitailpoints = { - new Point(440, 130), - new Point(530, 130), - new Point(530, 240), - new Point(440, 240) }; - - Quadrangle faceLocation = new Quadrangle(faceInitailpoints); - string path = TestHelper.TrustedPath + "face_tracking_model_test"; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg")) - { - model.Prepare(source, faceLocation); + _model.Prepare(_source, _faceLocation); + _model.Save(path); - model.Save(path); - Assert.IsTrue(File.Exists(path), "Saved file does not exist"); - } + Assert.IsTrue(File.Exists(path), "Saved file does not exist"); } [Test] @@ -181,7 +160,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => model.Save(null)); + Assert.Throws(() => _model.Save(null)); } [Test] @@ -191,24 +170,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION() + public static void Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION() { - Point[] faceInitailpoints = { - new Point(440, 130), - new Point(530, 130), - new Point(530, 240), - new Point(440, 240) }; - - Quadrangle faceLocation = new Quadrangle(faceInitailpoints); - string restrictedPath = TestHelper.ResourcePath + "face_track/face_track_model"; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg")) - { - model.Prepare(source, faceLocation); + _model.Prepare(_source, _faceLocation); - Assert.Throws(() => model.Save(restrictedPath)); - } + Assert.Throws(() => _model.Save(restrictedPath)); } [Test] @@ -218,24 +186,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION() + public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION() { - Point[] faceInitailpoints = { - new Point(440, 130), - new Point(530, 130), - new Point(530, 240), - new Point(440, 240) }; - - Quadrangle faceLocation = new Quadrangle(faceInitailpoints); - string fakePath = "/tmp/fake/face_fake_model"; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "face_track/01.jpg")) - { - model.Prepare(source, faceLocation); + _model.Prepare(_source, _faceLocation); - Assert.Throws(() => model.Save(fakePath)); - } + Assert.Throws(() => _model.Save(fakePath)); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingResult.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingResult.cs index dd7039084..c03a4514e 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingResult.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSFaceTrackingResult.cs @@ -10,7 +10,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -18,13 +17,12 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.FaceTrackingResult test class")] public class FaceTrackingResultTests { - private static FaceTrackingModel model = null; - private static List sources = null; - private static bool isNotSupportedTC = false; + private static FaceTrackingModel _model = null; + private static List _sources = null; - private static async Task PrepareModel() + private static async Task PrepareModelAsync() { - int ret = await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "face_track/"); + int ret = await TestHelper.FillMediaSourceFromImages(_sources, TestHelper.ResourcePath + "face_track/"); Assert.IsFalse(ret != 0, "Failed to get buffer data from face image"); Point[] faceInitailpoints = { @@ -35,36 +33,38 @@ namespace Tizen.Multimedia.Vision.Tests Quadrangle faceLocation = new Quadrangle(faceInitailpoints); - model.Prepare(sources[0], faceLocation); + _model.Prepare(_sources[0], faceLocation); } [SetUp] - public static void Init() + public static void SetUp() { - bool isFaceRecognitionSupported = false; - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - try { - model = new FaceTrackingModel(); - sources = new List(); + _model = new FaceTrackingModel(); + _sources = new List(); + + Task t = Task.Run(async () => await PrepareModelAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.FaceRecognition) == false) { - if (!isFaceRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("FaceRecognition is not supported"); } } [TearDown] - public static void Destroy() + public static void TearDown() { - if (model != null) - model.Dispose(); + _model?.Dispose(); + + foreach (var source in _sources) + { + source?.Dispose(); + } - if (sources != null) - if (sources.Count > 0) - sources.Clear(); + if (_sources?.Count > 0) + _sources?.Clear(); } [Test] @@ -76,16 +76,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Success_READ_ONLY() { - if (isNotSupportedTC) - return; - - await PrepareModel(); + Assert.IsTrue(_sources.Count > 1, "Failed to get buffer data from face image"); - Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image"); - - foreach (var frame in sources) + foreach (var frame in _sources) { - var result = await FaceTracker.TrackAsync(frame, model, false); + var result = await FaceTracker.TrackAsync(frame, _model, false); if (result.Region == null) Assert.IsFalse(result.Success, "Should be false"); else @@ -102,20 +97,16 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Region_READ_ONLY() { - if (isNotSupportedTC) - return; - - await PrepareModel(); - - Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image"); + Assert.IsTrue(_sources.Count > 1, "Failed to get buffer data from face image"); - foreach (var frame in sources) + foreach (var frame in _sources) { - var result = await FaceTracker.TrackAsync(frame, model, false); + var result = await FaceTracker.TrackAsync(frame, _model, false); if (result.Success == false) { continue; } + Assert.IsInstanceOf(result.Region, "Should be of type Quadrangle"); } } @@ -129,16 +120,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Confidence_READ_ONLY() { - if (isNotSupportedTC) - return; - - await PrepareModel(); - - Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from face image"); + Assert.IsTrue(_sources.Count > 1, "Failed to get buffer data from face image"); - foreach (var frame in sources) + foreach (var frame in _sources) { - var result = await FaceTracker.TrackAsync(frame, model, false); + var result = await FaceTracker.TrackAsync(frame, _model, false); if (result.Success) { continue; diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageFillConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageFillConfiguration.cs old mode 100755 new mode 100644 index cf81fa182..e9b5217fe --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageFillConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageFillConfiguration.cs @@ -16,33 +16,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageFillConfiguration test class")] public class ImageFillConfigurationTests { - private static ImageFillConfiguration config = null; + private static ImageFillConfiguration _config = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - config = new ImageFillConfiguration(); + _config = new ImageFillConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (isImageRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support ImageRecogntion"); - else - Assert.Pass("ImageRecogntion is not supported"); + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -54,7 +46,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ImageFillConfiguration_INIT() { - Assert.IsNotNull(config, "ImageFillConfiguration should not be null after calling constructor."); + Assert.IsNotNull(_config, "ImageFillConfiguration should not be null after calling constructor."); } [Test] @@ -90,7 +82,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ObjectScaleFactor_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.ObjectScaleFactor, 1.2, "Default value of ObjectScaleFactor should be 1.2"); + Assert.AreEqual(_config.ObjectScaleFactor, 1.2, "Default value of ObjectScaleFactor should be 1.2"); } [Test] @@ -102,8 +94,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ObjectScaleFactor_READ_WRITE() { - config.ObjectScaleFactor = 1.4; - Assert.AreEqual(config.ObjectScaleFactor, 1.4, "ObjectScaleFactor should be 1.4"); + _config.ObjectScaleFactor = 1.4; + Assert.AreEqual(_config.ObjectScaleFactor, 1.4, "ObjectScaleFactor should be 1.4"); } [Test] @@ -115,7 +107,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ObjectMaxKeyPoints_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.ObjectMaxKeyPoints, 1000, "Default value of ObjectMaxKeyPoints should be 1000"); + Assert.AreEqual(_config.ObjectMaxKeyPoints, 1000, "Default value of ObjectMaxKeyPoints should be 1000"); } [Test] @@ -127,8 +119,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ObjectMaxKeyPoints_READ_WRITE() { - config.ObjectMaxKeyPoints = 950; - Assert.AreEqual(config.ObjectMaxKeyPoints, 950, "ObjectMaxKeyPoints should be 950"); + _config.ObjectMaxKeyPoints = 950; + Assert.AreEqual(_config.ObjectMaxKeyPoints, 950, "ObjectMaxKeyPoints should be 950"); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageObject.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageObject.cs index 5fd0af8e1..1d3c2fba8 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageObject.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageObject.cs @@ -18,33 +18,42 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageObject test class")] public class ImageObjectTests { - private static ImageObject obj = null; + private static ImageObject _imageObject = null; + private static ImageFillConfiguration _engineCfg = null; + private static MediaVisionSource _source = null; + private static async Task PrepareSourceAsync() + { + _source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"); + } [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - obj = new ImageObject(); + _imageObject = new ImageObject(); + _engineCfg = new ImageFillConfiguration + { + ObjectScaleFactor = 1.5, + ObjectMaxKeyPoints = 1200 + }; + + Task t = Task.Run(async () => await PrepareSourceAsync()); + t.Wait(); + } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (isImageRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support ImageRecogntion"); - else - Assert.Pass("ImageRecogntion is not supported"); + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (obj != null) - obj.Dispose(); + _imageObject?.Dispose(); + _engineCfg?.Dispose(); + _source?.Dispose(); } [Test] @@ -56,7 +65,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ImageObject_INIT() { - Assert.IsNotNull(obj, "Image should not be null after calling constructor."); + Assert.IsNotNull(_imageObject, "Image should not be null after calling constructor."); } [Test] @@ -110,10 +119,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void GetLabel_CHECK_RETURN_VALUE() { - Assert.IsNull(obj.GetLabel(), "Label should be null"); + Assert.IsNull(_imageObject.GetLabel(), "Label should be null"); - obj.SetLabel(1); - Assert.AreEqual(obj.GetLabel(), 1, "Label should be 1"); + _imageObject.SetLabel(1); + + Assert.AreEqual(_imageObject.GetLabel(), 1, "Label should be 1"); } [Test] @@ -125,8 +135,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SetLabel_CHECK_RETURN_VALUE() { - obj.SetLabel(2); - Assert.AreEqual(obj.GetLabel(), 2, "Label should be 1"); + _imageObject.SetLabel(2); + + Assert.AreEqual(_imageObject.GetLabel(), 2, "Label should be 1"); } [Test] @@ -136,17 +147,14 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task RecognitionRate_READ_ONLY() + public static void RecognitionRate_READ_ONLY() { - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - Assert.IsNotNull(source, "source should be not null"); + Assert.IsNotNull(_source, "source should be not null"); - obj.SetLabel(1); + _imageObject.SetLabel(1); + _imageObject.Fill(_source); - obj.Fill(source); - Assert.IsTrue(obj.RecognitionRate >= 0 && obj.RecognitionRate <= 1, "RecognitionRate value should be between 0 and 1"); - } + Assert.IsTrue(_imageObject.RecognitionRate >= 0 && _imageObject.RecognitionRate <= 1, "RecognitionRate value should be between 0 and 1"); } [Test] @@ -157,12 +165,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] [Property("COVPARAM", "MediaVisionSource")] - public static async Task Fill_CHECK_RETURN_VALUE() + public static void Fill_CHECK_NO_EXCEPTION() { - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - obj.Fill(source); - } + Assert.DoesNotThrow(() => _imageObject.Fill(_source)); } [Test] @@ -175,7 +180,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource")] public static void Fill_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => obj.Fill(null)); + Assert.Throws(() => _imageObject.Fill(null)); } [Test] @@ -186,13 +191,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] [Property("COVPARAM", "MediaVisionSource, Rectangle")] - public static async Task Fill_with_Roi_CHECK_RETURN_VALUE() + public static void Fill_with_Roi_CHECK_NO_EXCEPTION() { - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height)); - obj.Fill(source, roi); - } + var roi = new Rectangle(new Point(0, 0), new Size((int)_source.Width, (int)_source.Height)); + + Assert.DoesNotThrow(() => _imageObject.Fill(_source, roi)); } [Test] @@ -205,9 +208,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, Rectangle")] public static void Fill_with_Roi_CHECK_NULL_ARGUMENT_EXCEPTION() { - Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100)); + var roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - Assert.Throws(() => obj.Fill(null, roi)); + Assert.Throws(() => _imageObject.Fill(null, roi)); } [Test] @@ -218,16 +221,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] [Property("COVPARAM", "MediaVisionSource, ImageFillConfiguration")] - public static async Task Fill_with_Configuration_CHECK_RETURN_VALUE() + public static void Fill_with_Configuration_CHECK_NO_EXCEPTION() { - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - ImageFillConfiguration engineCfg = new ImageFillConfiguration(); - engineCfg.ObjectScaleFactor = 1.5; - engineCfg.ObjectMaxKeyPoints = 1200; - - obj.Fill(source, engineCfg); - } + Assert.DoesNotThrow(() => _imageObject.Fill(_source, _engineCfg)); } [Test] @@ -240,11 +236,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageFillConfiguration")] public static void Fill_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - ImageFillConfiguration engineCfg = new ImageFillConfiguration(); - engineCfg.ObjectScaleFactor = 1.5; - engineCfg.ObjectMaxKeyPoints = 1200; - - Assert.Throws(() => obj.Fill(null, engineCfg)); + Assert.Throws(() => _imageObject.Fill(null, _engineCfg)); } [Test] @@ -255,17 +247,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] [Property("COVPARAM", "MediaVisionSource, ImageFillConfiguration, Rectangle")] - public static async Task Fill_with_Roi_Configuration_CHECK_RETURN_VALUE() + + public static void Fill_with_Roi_Configuration_CHECK_NO_EXCEPTION() { - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - Rectangle roi = new Rectangle(new Point(0, 0), new Size((int)source.Width, (int)source.Height)); - ImageFillConfiguration engineCfg = new ImageFillConfiguration(); - engineCfg.ObjectScaleFactor = 1.5; - engineCfg.ObjectMaxKeyPoints = 1200; + var roi = new Rectangle(new Point(0, 0), new Size((int)_source.Width, (int)_source.Height)); - obj.Fill(source, engineCfg, roi); - } + Assert.DoesNotThrow(() => _imageObject.Fill(_source, _engineCfg, roi)); } [Test] @@ -278,12 +265,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageFillConfiguration, Rectangle")] public static void Fill_with_Roi_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - Rectangle roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - ImageFillConfiguration engineCfg = new ImageFillConfiguration(); - engineCfg.ObjectScaleFactor = 1.5; - engineCfg.ObjectMaxKeyPoints = 1200; + var roi = new Rectangle(new Point(0, 0), new Size(100, 100)); - Assert.Throws(() => obj.Fill(null, engineCfg, roi)); + Assert.Throws(() => _imageObject.Fill(null, _engineCfg, roi)); } [Test] @@ -293,18 +277,15 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task Save_CHECK_RETURN_VALUE() + public static void Save_CHECK_RETURN_VALUE() { string path = TestHelper.TrustedPath + "image_ojbect_test"; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - obj.SetLabel(1); - obj.Fill(source); + _imageObject.SetLabel(1); + _imageObject.Fill(_source); + _imageObject.Save(path); - obj.Save(path); - Assert.IsTrue(File.Exists(path), path + "doesn't exist"); - } + Assert.IsTrue(File.Exists(path), path + "doesn't exist"); } [Test] @@ -316,7 +297,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => obj.Save(null)); + Assert.Throws(() => _imageObject.Save(null)); } [Test] @@ -326,16 +307,14 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION() + public static void Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION() { string restrictedPath = TestHelper.ResourcePath + "image/unautorized_model"; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - obj.SetLabel(1); - obj.Fill(source); - Assert.Throws(() => obj.Save(restrictedPath)); - } + _imageObject.SetLabel(1); + _imageObject.Fill(_source); + + Assert.Throws(() => _imageObject.Save(restrictedPath)); } [Test] @@ -345,16 +324,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] - public static async Task Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION() + public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION() { - string fakePath = "/tmp/fake/fake_model"; - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) - { - obj.SetLabel(1); + _imageObject.SetLabel(1); + _imageObject.Fill(_source); - obj.Fill(source); - Assert.Throws(() => obj.Save(fakePath)); - } + Assert.Throws(() => _imageObject.Save("/tmp/fake/fake_model")); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionConfiguration.cs old mode 100755 new mode 100644 index 7223cf594..cd3d374ce --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright 2016 by Samsung Electronics, Inc., +// Copyright 2016 by Samsung Electronics, Inc., // // This software is the confidential and proprietary information // of Samsung Electronics, Inc. ("Confidential Information"). You @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,33 +15,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageRecognitionConfiguration test class")] public class ImageRecognitionConfigurationTests { - private static ImageRecognitionConfiguration config = null; + private static ImageRecognitionConfiguration _config = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - config = new ImageRecognitionConfiguration(); + _config = new ImageRecognitionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (isImageRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support ImageRecogntion"); - else - Assert.Pass("ImageRecogntion is not supported"); + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -54,7 +45,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ImageRecognitionConfiguration_INIT() { - Assert.IsNotNull(config, "ImageRecognitionConfiguration should not be null after calling constructor."); + Assert.IsNotNull(_config, "ImageRecognitionConfiguration should not be null after calling constructor."); } [Test] @@ -66,7 +57,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SceneScaleFactor_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.SceneScaleFactor, 1.2, "Default value of SceneScaleFactor should be 1.2"); + Assert.AreEqual(_config.SceneScaleFactor, 1.2, "Default value of SceneScaleFactor should be 1.2"); } [Test] @@ -78,8 +69,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SceneScaleFactor_READ_WRITE() { - config.SceneScaleFactor = 1.4; - Assert.AreEqual(config.SceneScaleFactor, 1.4, "SceneScaleFactor should be 1.4"); + _config.SceneScaleFactor = 1.4; + Assert.AreEqual(_config.SceneScaleFactor, 1.4, "SceneScaleFactor should be 1.4"); } [Test] @@ -151,7 +142,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SceneMaxKeyPoints_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.SceneMaxKeyPoints, 5000, "Default value of SceneMaxKeyPoints should be 5000"); + Assert.AreEqual(_config.SceneMaxKeyPoints, 5000, "Default value of SceneMaxKeyPoints should be 5000"); } [Test] @@ -163,8 +154,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SceneMaxKeyPoints_READ_WRITE() { - config.SceneMaxKeyPoints = 3000; - Assert.AreEqual(config.SceneMaxKeyPoints, 3000, "SceneMaxKeyPoints should be 3000"); + _config.SceneMaxKeyPoints = 3000; + Assert.AreEqual(_config.SceneMaxKeyPoints, 3000, "SceneMaxKeyPoints should be 3000"); } [Test] @@ -176,7 +167,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void SceneMaxKeyPoints_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.SceneMaxKeyPoints = -1); + Assert.Throws(() => _config.SceneMaxKeyPoints = -1); } [Test] @@ -188,7 +179,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void MinKeyPointMatches_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.MinKeyPointMatches, 30, "Default value of MinKeyPointMatches should be 30"); + Assert.AreEqual(_config.MinKeyPointMatches, 30, "Default value of MinKeyPointMatches should be 30"); } [Test] @@ -200,8 +191,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void MinKeyPointMatches_READ_WRITE() { - config.MinKeyPointMatches = 40; - Assert.AreEqual(config.MinKeyPointMatches, 40, "MinKeyPointsMatches should be 40"); + _config.MinKeyPointMatches = 40; + Assert.AreEqual(_config.MinKeyPointMatches, 40, "MinKeyPointsMatches should be 40"); } @@ -214,7 +205,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void MinKeyPointMatches_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.MinKeyPointMatches = -1); + Assert.Throws(() => _config.MinKeyPointMatches = -1); } [Test] @@ -226,7 +217,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void RequiredMatchingPart_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.RequiredMatchingPart, 0.05, "Default value of RequiredMatchingPart should be 0.05"); + Assert.AreEqual(_config.RequiredMatchingPart, 0.05, "Default value of RequiredMatchingPart should be 0.05"); } [Test] @@ -238,8 +229,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void RequiredMatchingPart_READ_WRITE() { - config.RequiredMatchingPart = 0.03; - Assert.AreEqual(config.RequiredMatchingPart, 0.03, "RequiredMatchingPart should be 0.03"); + _config.RequiredMatchingPart = 0.03; + Assert.AreEqual(_config.RequiredMatchingPart, 0.03, "RequiredMatchingPart should be 0.03"); } [Test] @@ -251,7 +242,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void RequiredMatchingPart_CHECK_ABOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.RequiredMatchingPart = 2.3); + Assert.Throws(() => _config.RequiredMatchingPart = 2.3); } [Test] @@ -263,7 +254,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void RequiredMatchingPart_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.RequiredMatchingPart = -1.2); + Assert.Throws(() => _config.RequiredMatchingPart = -1.2); } [Test] @@ -275,7 +266,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void TolerantPartMatchError_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.TolerantPartMatchError, 0.1, "Default value of TolerantPartMatchError should be 0.1"); + Assert.AreEqual(_config.TolerantPartMatchError, 0.1, "Default value of TolerantPartMatchError should be 0.1"); } [Test] @@ -287,8 +278,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void TolerantPartMatchError_READ_WRITE() { - config.TolerantPartMatchError = 0.3; - Assert.AreEqual(config.TolerantPartMatchError, 0.3, "TolerantPartMatchError should be 0.3"); + _config.TolerantPartMatchError = 0.3; + Assert.AreEqual(_config.TolerantPartMatchError, 0.3, "TolerantPartMatchError should be 0.3"); } [Test] @@ -300,7 +291,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void TolerantPartMatchError_CHECK_ABOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.TolerantPartMatchError = 2.3); + Assert.Throws(() => _config.TolerantPartMatchError = 2.3); } [Test] @@ -312,7 +303,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void TolerantPartMatchError_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.TolerantPartMatchError = -1.2); + Assert.Throws(() => _config.TolerantPartMatchError = -1.2); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionResult.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionResult.cs old mode 100755 new mode 100644 index 0f1fcfcbf..0adf501e0 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionResult.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognitionResult.cs @@ -9,7 +9,6 @@ using System; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; using NUnit.Framework.TUnit; namespace Tizen.Multimedia.Vision.Tests @@ -18,32 +17,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageRecognitionResult test class")] public class ImageRecognitionResultTests { - private static ImageObject obj = null; - private static bool isNotSupportedTC = false; + private static ImageObject _imageObject = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - obj = new ImageObject(); + _imageObject = new ImageObject(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (!isImageRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (obj != null) - obj.Dispose(); + _imageObject?.Dispose(); } [Test] @@ -55,15 +47,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static async Task Success_READ_ONLY() { - if (isNotSupportedTC) - return; - using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg")) { - obj.Fill(sourceTarget); + _imageObject.Fill(sourceTarget); - ImageObject[] objs = new ImageObject[1] { obj }; + ImageObject[] objs = new ImageObject[1] { _imageObject }; var objLists = await ImageRecognizer.RecognizeAsync(sourceScene, objs); foreach (ImageRecognitionResult imageResult in objLists) @@ -85,15 +74,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static async Task Region_READ_ONLY() { - if (isNotSupportedTC) - return; - using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg")) { - obj.Fill(sourceTarget); + _imageObject.Fill(sourceTarget); - ImageObject[] objs = new ImageObject[1] { obj }; + ImageObject[] objs = new ImageObject[1] { _imageObject }; var objLists = await ImageRecognizer.RecognizeAsync(sourceScene, objs); foreach (ImageRecognitionResult imageResult in objLists) diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognizer.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognizer.cs old mode 100755 new mode 100644 index 5d2dff694..0e4cce096 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognizer.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageRecognizer.cs @@ -9,7 +9,6 @@ using System; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,32 +16,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageRecognizer test class")] public class ImageRecognizerTests { - private static ImageObject obj = null; - private static bool isNotSupportedTC = false; + private static ImageObject _imageObject = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - obj = new ImageObject(); + _imageObject = new ImageObject(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (!isImageRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (obj != null) - obj.Dispose(); + _imageObject?.Dispose(); } [Test] @@ -55,15 +47,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageObject[]")] public static async Task RecognizeAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg")) { - obj.Fill(sourceTarget); + _imageObject.Fill(sourceTarget); - ImageObject[] images = new ImageObject[1] { obj }; + ImageObject[] images = new ImageObject[1] { _imageObject }; var objLists = await ImageRecognizer.RecognizeAsync(sourceScene, images); Assert.IsInstanceOf(objLists, "It should be of type ImageRecognitionResult"); @@ -80,9 +69,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageObject[]")] public static async Task RecognizeAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - await AssertHelper.ThrowsAsync(() => ImageRecognizer.RecognizeAsync(null, null)); } @@ -96,9 +82,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageObject[]")] public static async Task RecognizeAsync_CHECK_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg")) { ImageObject[] images = new ImageObject[0]; @@ -116,18 +99,17 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageObject[], ImageRecognitionConfiguration")] public static async Task RecognizeAsync_with_Configuration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - using (MediaVisionSource sourceTarget = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg")) { - obj.Fill(sourceTarget); + _imageObject.Fill(sourceTarget); - ImageObject[] images = new ImageObject[1] { obj }; + ImageObject[] images = new ImageObject[1] { _imageObject }; - ImageRecognitionConfiguration engineConfig = new ImageRecognitionConfiguration(); - engineConfig.MinKeyPointMatches = 50; + var engineConfig = new ImageRecognitionConfiguration + { + MinKeyPointMatches = 50 + }; var objLists = await ImageRecognizer.RecognizeAsync(sourceScene, images, engineConfig); Assert.IsInstanceOf(objLists, "It should be of type ImageRecognitionResult"); @@ -144,11 +126,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageObject[], ImageRecognitionConfiguration")] public static async Task RecognizeAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - ImageRecognitionConfiguration engineConfig = new ImageRecognitionConfiguration(); - engineConfig.MinKeyPointMatches = 50; + var engineConfig = new ImageRecognitionConfiguration + { + MinKeyPointMatches = 50 + }; await AssertHelper.ThrowsAsync(() => ImageRecognizer.RecognizeAsync(null, null, engineConfig)); } @@ -163,19 +144,17 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageObject[], ImageRecognitionConfiguration")] public static async Task RecognizeAsync_with_Configuration_CHECK_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - using (MediaVisionSource sourceScene = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/scene.jpg")) { ImageObject[] images = new ImageObject[0]; - ImageRecognitionConfiguration engineConfig = new ImageRecognitionConfiguration(); - engineConfig.MinKeyPointMatches = 50; + var engineConfig = new ImageRecognitionConfiguration + { + MinKeyPointMatches = 50 + }; await AssertHelper.ThrowsAsync(() => ImageRecognizer.RecognizeAsync(sourceScene, images, engineConfig)); } } } - } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTracker.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTracker.cs index b85406e62..7bed42119 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTracker.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTracker.cs @@ -10,7 +10,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -18,43 +17,42 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageTracker test class")] public class ImageTrackerTests { - private static ImageTrackingModel model = null; - private static List sources = null; - private static bool isNotSupportedTC = false; + private static ImageTrackingModel _model = null; + private static List _sources = null; - private static async Task PrepareMediaVisionSources() + private static async Task PrepareSourcesAsync() { - await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "image_track/"); + await TestHelper.FillMediaSourceFromImages(_sources, TestHelper.ResourcePath + "image_track/"); } [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - model = new ImageTrackingModel(); - sources = new List(); + _model = new ImageTrackingModel(); + _sources = new List(); + Task t = Task.Run(async () => await PrepareSourcesAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (!isImageRecognitionSupported) - isNotSupportedTC = true; + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (model != null) - model.Dispose(); + _model?.Dispose(); + + foreach (var source in _sources) + { + source?.Dispose(); + } - if (sources != null) - if (sources.Count > 0) - sources.Clear(); + if (_sources?.Count > 0) + _sources?.Clear(); } [Test] @@ -67,22 +65,17 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageTrackingModel")] public static async Task TrackAsync_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; + Assert.IsTrue(_sources.Count > 1, "Failed to get buffer data from images"); - await PrepareMediaVisionSources(); - - Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from images"); - - using (var Obj = new ImageObject()) + using (var obj = new ImageObject()) using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) { - Obj.Fill(source); + obj.Fill(source); - model.SetTarget(Obj); - foreach (var frame in sources) + _model.SetTarget(obj); + foreach (var frame in _sources) { - var result = await ImageTracker.TrackAsync(frame, model); + var result = await ImageTracker.TrackAsync(frame, _model); if (result == null) continue; } @@ -99,9 +92,6 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageTrackingModel")] public static async Task TrackAsync_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - await AssertHelper.ThrowsAsync(() => ImageTracker.TrackAsync(null, null)); } @@ -115,12 +105,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageTrackingModel")] public static async Task TrackAsync_CHECK_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image_track/frame01.jpg")) { - await AssertHelper.ThrowsAsync(() => ImageTracker.TrackAsync(source, model)); + await AssertHelper.ThrowsAsync(() => ImageTracker.TrackAsync(source, _model)); } } @@ -134,27 +121,23 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageTrackingModel, ImageTrackingConfiguration")] public static async Task TrackAsync_wiht_COnfiguration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; + Assert.IsTrue(_sources.Count > 1, "Failed to get buffer data from images"); - await TestHelper.FillMediaSourceFromImages(sources, TestHelper.ResourcePath + "image_track/"); - - Assert.IsTrue(sources.Count > 1, "Failed to get buffer data from images"); - - using (var Obj = new ImageObject()) + using (var obj = new ImageObject()) using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) { - Obj.Fill(source); + obj.Fill(source); - model.SetTarget(Obj); + _model.SetTarget(obj); - ImageTrackingConfiguration engineConfig = new ImageTrackingConfiguration(); - - engineConfig.HistoryAmount = 1; + ImageTrackingConfiguration engineConfig = new ImageTrackingConfiguration + { + HistoryAmount = 1 + }; - foreach (var frame in sources) + foreach (var frame in _sources) { - var result = await ImageTracker.TrackAsync(frame, model, engineConfig); + var result = await ImageTracker.TrackAsync(frame, _model, engineConfig); if (result == null) continue; } @@ -171,11 +154,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageTrackingModel, ImageTrackingConfiguration")] public static async Task TrackAsync_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - ImageTrackingConfiguration engineConfig = new ImageTrackingConfiguration(); - engineConfig.HistoryAmount = 1; + ImageTrackingConfiguration engineConfig = new ImageTrackingConfiguration + { + HistoryAmount = 1 + }; await AssertHelper.ThrowsAsync(() => ImageTracker.TrackAsync(null, null, engineConfig)); } @@ -190,15 +172,14 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaVisionSource, ImageTrackingModel, ImageTrackingConfiguration")] public static async Task TrackAsync_with_Configuration_CHECK_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image_track/frame01.jpg")) { - ImageTrackingConfiguration engineConfig = new ImageTrackingConfiguration(); - engineConfig.HistoryAmount = 1; + ImageTrackingConfiguration engineConfig = new ImageTrackingConfiguration + { + HistoryAmount = 1 + }; - await AssertHelper.ThrowsAsync(() => ImageTracker.TrackAsync(source, model, engineConfig)); + await AssertHelper.ThrowsAsync(() => ImageTracker.TrackAsync(source, _model, engineConfig)); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingConfiguration.cs old mode 100755 new mode 100644 index b953be611..43182c4a5 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright 2016 by Samsung Electronics, Inc., +// Copyright 2016 by Samsung Electronics, Inc., // // This software is the confidential and proprietary information // of Samsung Electronics, Inc. ("Confidential Information"). You @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,33 +15,25 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageTrackingConfiguration test class")] public class ImageTrackingConfigurationTests { - private static ImageTrackingConfiguration config = null; + private static ImageTrackingConfiguration _config = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - config = new ImageTrackingConfiguration(); + _config = new ImageTrackingConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (isImageRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support ImageRecogntion"); - else - Assert.Pass("ImageRecogntion is not supported"); + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -54,7 +45,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ImageTrackingConfiguration_INIT() { - Assert.IsNotNull(config, "ImageTrackingConfiguration should not be null after calling constructor."); + Assert.IsNotNull(_config, "ImageTrackingConfiguration should not be null after calling constructor."); } [Test] @@ -138,7 +129,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void HistoryAmount_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.HistoryAmount, 3, "Default value of HistoryAmount should be 3"); + Assert.AreEqual(_config.HistoryAmount, 3, "Default value of HistoryAmount should be 3"); } [Test] @@ -150,8 +141,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void HistoryAmount_READ_WRITE() { - config.HistoryAmount = 5; - Assert.AreEqual(config.HistoryAmount, 5, "HistoryAmount should be 5"); + _config.HistoryAmount = 5; + Assert.AreEqual(_config.HistoryAmount, 5, "HistoryAmount should be 5"); } [Test] @@ -163,7 +154,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void HistoryAmount_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.HistoryAmount = -1); + Assert.Throws(() => _config.HistoryAmount = -1); } [Test] @@ -175,7 +166,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ExpectedOffset_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.ExpectedOffset, 0, "Default value of ExpectedOffset should be 0"); + Assert.AreEqual(_config.ExpectedOffset, 0, "Default value of ExpectedOffset should be 0"); } [Test] @@ -187,8 +178,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ExpectedOffset_READ_WRITE() { - config.ExpectedOffset = 0.5; - Assert.AreEqual(config.ExpectedOffset, 0.5, "ExpectedOffset should be 0.5"); + _config.ExpectedOffset = 0.5; + Assert.AreEqual(_config.ExpectedOffset, 0.5, "ExpectedOffset should be 0.5"); } [Test] @@ -200,7 +191,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationAcceleration_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.StabilizationAcceleration, 0.1, "Default value of StabilizationAcceleration should be 0.1"); + Assert.AreEqual(_config.StabilizationAcceleration, 0.1, "Default value of StabilizationAcceleration should be 0.1"); } [Test] @@ -212,8 +203,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationAcceleration_READ_WRITE() { - config.StabilizationAcceleration = 0.3; - Assert.AreEqual(config.StabilizationAcceleration, 0.3, "StabilizationAcceleration should be 0.3"); + _config.StabilizationAcceleration = 0.3; + Assert.AreEqual(_config.StabilizationAcceleration, 0.3, "StabilizationAcceleration should be 0.3"); } [Test] @@ -225,7 +216,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationAcceleration_CHECK_ABOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.StabilizationAcceleration = 2.3); + Assert.Throws(() => _config.StabilizationAcceleration = 2.3); } [Test] @@ -237,7 +228,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationAcceleration_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTIOn() { - Assert.Throws(() => config.StabilizationAcceleration = -1.2); + Assert.Throws(() => _config.StabilizationAcceleration = -1.2); } [Test] @@ -249,7 +240,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationSpeed_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.StabilizationSpeed, 0.3, "Default value of StabilizationSpeed should be 0.3"); + Assert.AreEqual(_config.StabilizationSpeed, 0.3, "Default value of StabilizationSpeed should be 0.3"); } [Test] @@ -261,8 +252,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationSpeed_READ_WRITE() { - config.StabilizationSpeed = 0.6; - Assert.AreEqual(config.StabilizationSpeed, 0.6, "StabilizationSpeed should be 0.6"); + _config.StabilizationSpeed = 0.6; + Assert.AreEqual(_config.StabilizationSpeed, 0.6, "StabilizationSpeed should be 0.6"); } [Test] @@ -274,7 +265,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationTolerantShift_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.StabilizationTolerantShift, 0.00006, "Default value of StabilizationTolerantShift should be 0.00006"); + Assert.AreEqual(_config.StabilizationTolerantShift, 0.00006, "Default value of StabilizationTolerantShift should be 0.00006"); } [Test] @@ -286,8 +277,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void StabilizationTolerantShift_READ_WRITE() { - config.StabilizationTolerantShift = 1.7; - Assert.AreEqual(config.StabilizationTolerantShift, 1.7, "StabilizationTolerantShift should be 1.7"); + _config.StabilizationTolerantShift = 1.7; + Assert.AreEqual(_config.StabilizationTolerantShift, 1.7, "StabilizationTolerantShift should be 1.7"); } [Test] @@ -299,7 +290,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void IsStabilizationEnabled_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.IsStabilizationEnabled, true, "Default value of IsStabilizationEnabled should be true"); + Assert.AreEqual(_config.IsStabilizationEnabled, true, "Default value of IsStabilizationEnabled should be true"); } [Test] @@ -311,8 +302,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void IsStabilizationEnabled_READ_WRITE() { - config.IsStabilizationEnabled = false; - Assert.AreEqual(config.IsStabilizationEnabled, false, "IsStabilizationEnabled should be false"); + _config.IsStabilizationEnabled = false; + Assert.AreEqual(_config.IsStabilizationEnabled, false, "IsStabilizationEnabled should be false"); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingModel.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingModel.cs index 000de82a2..d7da95142 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingModel.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSImageTrackingModel.cs @@ -8,10 +8,8 @@ using System; using System.IO; -using NUnit.Framework; using System.Threading.Tasks; -using NUnit.Framework.TUnit; -using Tizen.System; +using NUnit.Framework; namespace Tizen.Multimedia.Vision.Tests { @@ -19,33 +17,34 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.ImageTrackingModel test class")] public class ImageTrackingModelTests { - private static ImageTrackingModel model = null; + private static ImageTrackingModel _model = null; + private static MediaVisionSource _target = null; + + private static async Task PrepareTargetAsync() + { + _target = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg"); + } [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - try { - model = new ImageTrackingModel(); + _model = new ImageTrackingModel(); + Task t = Task.Run(async () => await PrepareTargetAsync()); + t.Wait(); + } - catch (NotSupportedException) + catch (NotSupportedException) when (FeatureChecker.IsSupported(Features.ImageRecognition) == false) { - if (isImageRecognitionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support ImageRecogntion"); - else - Assert.Pass("ImageRecogntion is not supported"); + Assert.Pass("ImageRecogntion is not supported"); } } [TearDown] public static void Destroy() { - if (model != null) - model.Dispose(); + _model?.Dispose(); } [Test] @@ -57,7 +56,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void ImageTrackingModel_INIT() { - Assert.IsNotNull(model, "ImageTrackingModel should not be null after calling constructor."); + Assert.IsNotNull(_model, "ImageTrackingModel should not be null after calling constructor."); } [Test] @@ -109,14 +108,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task SetTarget_CHECK_RETURN_VALUE() + public static void SetTarget_CHECK_NO_EXCEPTION() { using (var obj = new ImageObject()) - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) { - obj.Fill(source); + obj.Fill(_target); - model.SetTarget(obj); + Assert.DoesNotThrow(() => _model.SetTarget(obj)); } } @@ -129,7 +127,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void SetTarget_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => model.SetTarget(null)); + Assert.Throws(() => _model.SetTarget(null)); } [Test] @@ -139,16 +137,15 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task Refresh_CHECK_RETURN() + public static void Refresh_CHECK_NO_EXCEPTION() { using (var obj = new ImageObject()) - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) { - obj.Fill(source); + obj.Fill(_target); - model.SetTarget(obj); + _model.SetTarget(obj); - model.Refresh(); + Assert.DoesNotThrow(() => _model.Refresh()); } } @@ -159,18 +156,17 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task Save_CHECK_RETURN_VALUE() + public static void Save_CHECK_RETURN_VALUE() { string path = TestHelper.TrustedPath + "image_track_test"; using (var obj = new ImageObject()) - using (MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "image/target.jpg")) { - obj.Fill(source); + obj.Fill(_target); - model.SetTarget(obj); + _model.SetTarget(obj); - model.Save(path); + _model.Save(path); Assert.IsTrue(File.Exists(path), path + "doesn't exist"); } } @@ -184,7 +180,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => model.Save(null)); + Assert.Throws(() => _model.Save(null)); } [Test] @@ -197,7 +193,7 @@ namespace Tizen.Multimedia.Vision.Tests public static void Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION() { string restrictedPath = TestHelper.ResourcePath + "image_track/fake_model"; - Assert.Throws(() => model.Save(restrictedPath)); + Assert.Throws(() => _model.Save(restrictedPath)); } [Test] @@ -210,7 +206,7 @@ namespace Tizen.Multimedia.Vision.Tests public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION() { string restrictedPath = TestHelper.ResourcePath + "/tmp/fake/mofedl/"; - Assert.Throws(() => model.Save(restrictedPath)); + Assert.Throws(() => _model.Save(restrictedPath)); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMediaVisionSource.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMediaVisionSource.cs old mode 100755 new mode 100644 index e88d8a412..7e79ec93d --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMediaVisionSource.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMediaVisionSource.cs @@ -6,9 +6,8 @@ // it only in accordance with the terms of the license agreement // you entered into with Samsung. -using System; using NUnit.Framework; -using Tizen.System; +using System; using System.Linq; using System.Collections.Generic; @@ -18,11 +17,11 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.MediaVisionSource test class")] public class MediaVisionSourceTests { - private static MediaVisionSource bufferSource = null; - private static MediaVisionSource packetSource = null; - private static MediaPacket packet = null; + private static MediaVisionSource _bufferSource = null; + private static MediaVisionSource _packetSource = null; + private static MediaPacket _packet = null; - public static byte[] createBufferTypeRGB888(int width, int height) + public static byte[] CreateBufferTypeRGB888(int width, int height) { if (width <= 0 || height <= 0) { @@ -41,33 +40,23 @@ namespace Tizen.Multimedia.Vision.Tests [SetUp] public static void Init() { - bool isBarcodeDetecteSupported = false; - bool isBarcodeGenerateSupported = false; - bool isFaceRecognitionSupported = false; - bool isImageRecognitionSupported = false; - bool isMediaVisionSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.barcode_detection", out isBarcodeDetecteSupported); - Information.TryGetValue("http://tizen.org/feature/vision.barcode_generation", out isBarcodeGenerateSupported); - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isMediaVisionSupported = isBarcodeDetecteSupported || isBarcodeGenerateSupported || isFaceRecognitionSupported || isImageRecognitionSupported; + bool isMediaVisionSupported = FeatureChecker.IsSupported(Features.BarcodeDetection) + || FeatureChecker.IsSupported(Features.BarcodeGeneration) + || FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - packet = MediaPacket.Create(new VideoMediaFormat(MediaFormatVideoMimeType.Rgb888, 1, 1)); - Assert.IsNotNull(packet, "It should be not null"); + _packet = MediaPacket.Create(new VideoMediaFormat(MediaFormatVideoMimeType.Rgb888, 1, 1)); + Assert.IsNotNull(_packet, "It should be not null"); - packetSource = new MediaVisionSource(packet); + _packetSource = new MediaVisionSource(_packet); - bufferSource = new MediaVisionSource(createBufferTypeRGB888(100, 100), 100, 100, ColorSpace.Rgb888); + _bufferSource = new MediaVisionSource(CreateBufferTypeRGB888(100, 100), 100, 100, ColorSpace.Rgb888); } - catch (NotSupportedException) + catch (NotSupportedException) when (isMediaVisionSupported == false) { - if (isMediaVisionSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support MediaVision"); - else - Assert.Pass("MediaVision is not supported"); + Assert.Pass("MediaVision is not supported"); } } @@ -75,14 +64,9 @@ namespace Tizen.Multimedia.Vision.Tests [TearDown] public static void Destroy() { - if (packetSource != null) - packetSource.Dispose(); - - if (bufferSource != null) - bufferSource.Dispose(); - - if (packet != null) - packet.Dispose(); + _packetSource?.Dispose(); + _bufferSource?.Dispose(); + _packet?.Dispose(); } [Test] @@ -95,7 +79,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "byte[], uint, uint, Colorspace")] public static void MediaVisionSource_with_Buffer_INIT() { - Assert.IsNotNull(bufferSource, "MediaVisionSource should not be null after calling constructor."); + Assert.IsNotNull(_bufferSource, "MediaVisionSource should not be null after calling constructor."); } [Test] @@ -134,7 +118,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "MediaPacket")] public static void MediaVisionSource_With_MediaPacket_INIT() { - Assert.IsNotNull(packetSource, "MediaVisionSource should not be null after calling constructor."); + Assert.IsNotNull(_packetSource, "MediaVisionSource should not be null after calling constructor."); } [Test] @@ -159,7 +143,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Buffer_READ_ONLY() { - Assert.AreEqual(bufferSource.Buffer.Length, 30000, "Buffer length is not correct after FillBuffer"); + Assert.AreEqual(_bufferSource.Buffer.Length, 30000, "Buffer length is not correct after FillBuffer"); } [Test] @@ -171,7 +155,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Height_READ_ONLY() { - Assert.AreEqual(bufferSource.Height, 100, "buffer height is incorrect"); + Assert.AreEqual(_bufferSource.Height, 100, "buffer height is incorrect"); } [Test] @@ -183,7 +167,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Width_READ_ONLY() { - Assert.AreEqual(bufferSource.Width, 100, "buffer width is incorrect"); + Assert.AreEqual(_bufferSource.Width, 100, "buffer width is incorrect"); } [Test] @@ -195,7 +179,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Colorspace_READ_ONLY() { - Assert.AreEqual(bufferSource.Colorspace, ColorSpace.Rgb888, "Colorspace is incorrect"); + Assert.AreEqual(_bufferSource.Colorspace, ColorSpace.Rgb888, "Colorspace is incorrect"); } [Test] diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectedEventArgs.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectedEventArgs.cs old mode 100755 new mode 100644 index e9dfa3442..f79795098 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectedEventArgs.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectedEventArgs.cs @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,37 +15,28 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.MovementDetectedEventArgs test class")] public class MovementDetectedEventArgsTests { - private static MovementDetectionConfiguration config = null; + private static MovementDetectionConfiguration _config = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - config = new MovementDetectionConfiguration(); + _config = new MovementDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (isSurveillanceSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support Surveillance"); - else - Assert.Pass("Surveillance is not supported"); + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -58,8 +48,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void MovementDetectedEventArgs_INIT() { - Rectangle region = new Rectangle(10, 10, 100, 200); - var regions = new[] { region }; + var regions = new[] { + new Rectangle(10, 10, 100, 200) + }; Assert.IsNotNull(new MovementDetectedEventArgs(regions), "It should not be null"); } @@ -73,8 +64,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Areas_READ_ONLY() { - Rectangle region = new Rectangle(10, 10, 100, 200); - var regions = new[] { region }; + var regions = new[] { + new Rectangle(10, 10, 100, 200) + }; Assert.AreEqual(regions, new MovementDetectedEventArgs(regions).Areas, "It should be equal"); } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectionConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectionConfiguration.cs old mode 100755 new mode 100644 index b7a7e517d..520e1986a --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectionConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetectionConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright 2016 by Samsung Electronics, Inc., +// Copyright 2016 by Samsung Electronics, Inc., // // This software is the confidential and proprietary information // of Samsung Electronics, Inc. ("Confidential Information"). You @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,37 +16,28 @@ namespace Tizen.Multimedia.Vision.Tests public class MovementDetectionConfigurationTests { - private static MovementDetectionConfiguration config = null; + private static MovementDetectionConfiguration _config = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - config = new MovementDetectionConfiguration(); + _config = new MovementDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (isSurveillanceSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support Surveillance"); - else - Assert.Pass("Surveillance is not supported"); + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -59,7 +49,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void MovementDetectionConfiguration_INIT() { - Assert.IsNotNull(config, "MovementDetectionConfiguration should not be null after calling constructor."); + Assert.IsNotNull(_config, "MovementDetectionConfiguration should not be null after calling constructor."); } [Test] @@ -83,7 +73,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Threshold_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.Threshold, 10, "Default value of Threshold should be 10"); + Assert.AreEqual(_config.Threshold, 10, "Default value of Threshold should be 10"); } [Test] @@ -95,8 +85,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Threshold_READ_WRITE() { - config.Threshold = 15; - Assert.AreEqual(config.Threshold, 15, "Threshold should be 10"); + _config.Threshold = 15; + Assert.AreEqual(_config.Threshold, 15, "Threshold should be 10"); } [Test] @@ -108,7 +98,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Threshold_CHECK_AMOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.Threshold = 256); + Assert.Throws(() => _config.Threshold = 256); } [Test] @@ -120,7 +110,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Threshold_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.Threshold = -1); + Assert.Throws(() => _config.Threshold = -1); } } -} \ No newline at end of file +} diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetector.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetector.cs index ef9738fd6..f9232e09b 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetector.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSMovementDetector.cs @@ -9,7 +9,6 @@ using System; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,55 +16,40 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.MovementDetector test class")] public class MovementDetectorTests { - private static bool _waitFlag = false; + private static MovementDetector _detector = null; + private static MediaVisionSource _source1 = null; + private static MediaVisionSource _source2 = null; - private static MovementDetector detector = null; - private static MediaVisionSource source_1 = null; - private static MediaVisionSource source_2 = null; - private static bool isNotSupportedTC = false; - - private static async Task PrepareMediaVisionSources() + private static async Task PrepareSourcesAsync() { - source_1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"); - Assert.IsNotNull(source_1, "fail to get mediavisionsource from an image"); - - source_2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_2.jpg"); - Assert.IsNotNull(source_2, "fail to get mediavisionsource from an image"); + _source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"); + _source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_2.jpg"); } [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - detector = new MovementDetector(); + _detector = new MovementDetector(); + Task t = Task.Run(async () => await PrepareSourcesAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (!isSurveillanceSupported) - isNotSupportedTC = true; + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (detector != null) - detector.Dispose(); - - if (source_1 != null) - source_1.Dispose(); - - if (source_2 != null) - source_2.Dispose(); + _detector?.Dispose(); + _source1?.Dispose(); + _source2?.Dispose(); } [Test] @@ -77,10 +61,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void MovementDetector_INIT() { - if (isNotSupportedTC) - return; - - Assert.IsNotNull(detector, "MovementDetector should not be null after calling constructor."); + Assert.IsNotNull(_detector, "MovementDetector should not be null after calling constructor."); } [Test] @@ -91,16 +72,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] [Property("COVPARAM", "SurveillanceSource")] - public static async Task AddSource_CHECK_RETURN_VALUE() + public static async Task AddSource_CHECK_NO_EXCEPTION() { - if (isNotSupportedTC) - return; - - SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource); + var detectorSource = new SurveillanceSource(); + Assert.DoesNotThrow(() => _detector.AddSource(detectorSource)); await Task.Delay(10); - detector.RemoveSource(detectorSource); + Assert.DoesNotThrow(() => _detector.RemoveSource(detectorSource)); } [Test] @@ -113,10 +91,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "SurveillanceSource")] public static void AddSource_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - Assert.Throws(() => detector.AddSource(null)); + Assert.Throws(() => _detector.AddSource(null)); } [Test] @@ -129,17 +104,16 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "SurveillanceSource, MovementDetectionConfiguration")] public static async Task AddSource_with_Configuration_CHECK_RETURN_VALUE() { - if (isNotSupportedTC) - return; - - MovementDetectionConfiguration engineConfig = new MovementDetectionConfiguration(); - engineConfig.Threshold = 15; + var engineConfig = new MovementDetectionConfiguration + { + Threshold = 15 + }; SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource, engineConfig); + Assert.DoesNotThrow(() => _detector.AddSource(detectorSource, engineConfig)); await Task.Delay(10); - detector.RemoveSource(detectorSource); + Assert.DoesNotThrow(() => _detector.RemoveSource(detectorSource)); } [Test] @@ -152,18 +126,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "SurveillanceSource, MovementDetectionConfiguration")] public static void AddSource_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - MovementDetectionConfiguration engineConfig = new MovementDetectionConfiguration(); - engineConfig.Threshold = 15; - - Assert.Throws(() => detector.AddSource(null, engineConfig)); - } + MovementDetectionConfiguration engineConfig = new MovementDetectionConfiguration + { + Threshold = 15 + }; - public static void EventHandlerMovementDetected(object sender, EventArgs e) - { - _waitFlag = true; + Assert.Throws(() => _detector.AddSource(null, engineConfig)); } [Test] @@ -175,29 +143,20 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static async Task Detected_CHECK_EVENT() { - if (isNotSupportedTC) - return; - - await PrepareMediaVisionSources(); - - _waitFlag = false; - - detector.Detected += EventHandlerMovementDetected; - - SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource); - - detectorSource.Push(source_1); + using (var eventWaiter = EventAwaiter< MovementDetectedEventArgs>.Create()) + { + _detector.Detected += eventWaiter; - detectorSource.Push(source_2); + SurveillanceSource detectorSource = new SurveillanceSource(); + _detector.AddSource(detectorSource); - await Task.Delay(10); - Assert.True(_waitFlag, "Failed to receive MovementDetected event."); + detectorSource.Push(_source1); + detectorSource.Push(_source2); - detector.Detected -= EventHandlerMovementDetected; + Assert.That(await eventWaiter.IsRaisedAsync(), "Failed to receive MovementDetected event."); - detector.RemoveSource(detectorSource); + _detector.RemoveSource(detectorSource); + } } } - } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectedEventArgs.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectedEventArgs.cs old mode 100755 new mode 100644 index 36e1cf9d2..41fbe0d77 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectedEventArgs.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectedEventArgs.cs @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,45 +15,32 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.PersonAppearanceDetectedEventArgs test class")] public class PersonAppearanceDetectedEventArgsTests { - private static PersonAppearanceDetectionConfiguration config = null; + private static PersonAppearanceDetectionConfiguration _config = null; - private static Rectangle[] appearRegions = new[] { new Rectangle(10, 10, 100, 200) }; - private static Rectangle[] disappearRegions = new[] { new Rectangle(200, 300, 100, 200) }; - private static Rectangle[] trackRegions = new[] { new Rectangle(400, 100, 100, 200) }; - - public static bool isImageRecognitionSupported = false; - public static bool isFaceRecognitionSupported = false; - public static bool isSurveillanceSupported = false; + private static Rectangle[] _appearRegions = new[] { new Rectangle(10, 10, 100, 200) }; + private static Rectangle[] _disappearRegions = new[] { new Rectangle(200, 300, 100, 200) }; + private static Rectangle[] _trackRegions = new[] { new Rectangle(400, 100, 100, 200) }; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - config = new PersonAppearanceDetectionConfiguration(); + _config = new PersonAppearanceDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (isSurveillanceSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support Surveillance"); - else - Assert.Pass("Surveillance is not supported"); + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -66,7 +52,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void PersonAppearanceDetectedEventArgs_INIT() { - Assert.IsNotNull(new PersonAppearanceDetectedEventArgs(appearRegions, disappearRegions, trackRegions), "It should not be null"); + Assert.IsNotNull(new PersonAppearanceDetectedEventArgs(_appearRegions, _disappearRegions, _trackRegions), "It should not be null"); } [Test] @@ -78,7 +64,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void AppearanceAreas_READ_ONLY() { - Assert.AreEqual(appearRegions, new PersonAppearanceDetectedEventArgs(appearRegions, disappearRegions, trackRegions).AppearanceAreas); + Assert.AreEqual(_appearRegions, new PersonAppearanceDetectedEventArgs(_appearRegions, _disappearRegions, _trackRegions).AppearanceAreas); } [Test] @@ -90,7 +76,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void DisappearanceAreas_READ_ONLY() { - Assert.AreEqual(disappearRegions, new PersonAppearanceDetectedEventArgs(appearRegions, disappearRegions, trackRegions).DisappearanceAreas); + Assert.AreEqual(_disappearRegions, new PersonAppearanceDetectedEventArgs(_appearRegions, _disappearRegions, _trackRegions).DisappearanceAreas); } [Test] @@ -102,7 +88,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void TrackedAreas_READ_ONLY() { - Assert.AreEqual(trackRegions, new PersonAppearanceDetectedEventArgs(appearRegions, disappearRegions, trackRegions).TrackedAreas); + Assert.AreEqual(_trackRegions, new PersonAppearanceDetectedEventArgs(_appearRegions, _disappearRegions, _trackRegions).TrackedAreas); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectionConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectionConfiguration.cs old mode 100755 new mode 100644 index f94911a1b..b9521f941 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectionConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetectionConfiguration.cs @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,37 +16,28 @@ namespace Tizen.Multimedia.Vision.Tests public class PersonAppearanceDetectionConfigurationTests { - private static PersonAppearanceDetectionConfiguration config = null; + private static PersonAppearanceDetectionConfiguration _config = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - config = new PersonAppearanceDetectionConfiguration(); + _config = new PersonAppearanceDetectionConfiguration(); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (isSurveillanceSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support Surveillance"); - else - Assert.Pass("Surveillance is not supported"); + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -59,7 +49,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void PersonAppearanceDetectionConfiguration_INIT() { - Assert.IsNotNull(config, "PersonAppearanceDetectionConfiguration should not be null after calling constructor."); + Assert.IsNotNull(_config, "PersonAppearanceDetectionConfiguration should not be null after calling constructor."); } [Test] @@ -83,7 +73,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SkipFramesCount_CHECK_DEFAULT_VALUE() { - Assert.AreEqual(config.SkipFramesCount, 0, "Default value of SkipFramesCount should be 0"); + Assert.AreEqual(_config.SkipFramesCount, 0, "Default value of SkipFramesCount should be 0"); } [Test] @@ -95,8 +85,8 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SkipFramesCount_READ_WRITE() { - config.SkipFramesCount = 2; - Assert.AreEqual(config.SkipFramesCount, 2, "SkipFramesCount should be 10"); + _config.SkipFramesCount = 2; + Assert.AreEqual(_config.SkipFramesCount, 2, "SkipFramesCount should be 10"); } [Test] @@ -108,7 +98,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SkipFramesCount_CHEKC_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION() { - Assert.Throws< ArgumentOutOfRangeException>(() => config.SkipFramesCount = -1); + Assert.Throws< ArgumentOutOfRangeException>(() => _config.SkipFramesCount = -1); } } } \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetector.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetector.cs index c4d110c15..fa2d76067 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetector.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonAppearanceDetector.cs @@ -9,7 +9,6 @@ using System; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,55 +16,40 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.PersonAppearanceDetector test class")] public class PersonAppearanceDetectorTests { - private static bool _waitFlag = false; + private static PersonAppearanceDetector _detector = null; + private static MediaVisionSource _source1 = null; + private static MediaVisionSource _source2 = null; - private static PersonAppearanceDetector detector = null; - private static MediaVisionSource source_1 = null; - private static MediaVisionSource source_2 = null; - private static bool isNotSupportedTC = false; - - private static async Task PrepareMediaVisionSources() + private static async Task PrepareSourcesAsync() { - source_1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"); - Assert.IsNotNull(source_1, "fail to get mediavisionsource from an image"); - - source_2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/pers_det.jpg"); - Assert.IsNotNull(source_2, "fail to get mediavisionsource from an image"); + _source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg"); + _source2 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/pers_det.jpg"); } [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - detector = new PersonAppearanceDetector(); + _detector = new PersonAppearanceDetector(); + Task t = Task.Run(async () => await PrepareSourcesAsync()); + t.Wait(); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (!isSurveillanceSupported) - isNotSupportedTC = true; + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (detector != null) - detector.Dispose(); - - if (source_1 != null) - source_1.Dispose(); - - if (source_2 != null) - source_2.Dispose(); + _detector?.Dispose(); + _source1?.Dispose(); + _source2?.Dispose(); } [Test] @@ -77,10 +61,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void PersonAppearanceDetector_INIT() { - if (isNotSupportedTC) - return; - - Assert.IsNotNull(detector, "PersonAppearanceDetector should not be null after calling constructor."); + Assert.IsNotNull(_detector, "PersonAppearanceDetector should not be null after calling constructor."); } [Test] @@ -91,16 +72,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] [Property("COVPARAM", "SurveillanceSource")] - public static async Task AddSource_CHECK_RETURN_VALUE() + public static async Task AddSource_CHECK_NO_EXCEPTION() { - if (isNotSupportedTC) - return; - - SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource); + var detectorSource = new SurveillanceSource(); + Assert.DoesNotThrow(() => _detector.AddSource(detectorSource)); await Task.Delay(10); - detector.RemoveSource(detectorSource); + Assert.DoesNotThrow(() => _detector.RemoveSource(detectorSource)); } [Test] @@ -113,10 +91,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "SurveillanceSource")] public static void AddSource_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - Assert.Throws(() => detector.AddSource(null)); + Assert.Throws(() => _detector.AddSource(null)); } [Test] @@ -127,19 +102,18 @@ namespace Tizen.Multimedia.Vision.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] [Property("COVPARAM", "SurveillanceSource, PersonAppearanceDetectionConfiguration")] - public static async Task AddSource_with_Configuration_CHECK_RETURN_VALUE() + public static async Task AddSource_with_Configuration_CHECK_NO_EXCEPTION() { - if (isNotSupportedTC) - return; - - PersonAppearanceDetectionConfiguration engineConfig = new PersonAppearanceDetectionConfiguration(); - engineConfig.SkipFramesCount = 1; + var engineConfig = new PersonAppearanceDetectionConfiguration + { + SkipFramesCount = 1 + }; - SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource, engineConfig); + var detectorSource = new SurveillanceSource(); + Assert.DoesNotThrow(() => _detector.AddSource(detectorSource, engineConfig)); await Task.Delay(10); - detector.RemoveSource(detectorSource); + Assert.DoesNotThrow(() => _detector.RemoveSource(detectorSource)); } [Test] @@ -152,18 +126,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("COVPARAM", "SurveillanceSource, PersonAppearanceDetectionConfiguration")] public static void AddSource_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - PersonAppearanceDetectionConfiguration engineConfig = new PersonAppearanceDetectionConfiguration(); - engineConfig.SkipFramesCount = 1; - - Assert.Throws(() => detector.AddSource(null, engineConfig)); - } + var engineConfig = new PersonAppearanceDetectionConfiguration + { + SkipFramesCount = 1 + }; - public static void EventHandlerPersonAppearancetDetected(object sender, EventArgs e) - { - _waitFlag = true; + Assert.Throws(() => _detector.AddSource(null, engineConfig)); } [Test] @@ -175,29 +143,20 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static async Task Detected_CHECK_EVENT() { - if (isNotSupportedTC) - return; - - await PrepareMediaVisionSources(); - - _waitFlag = false; - - detector.Detected += EventHandlerPersonAppearancetDetected; - - SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource); - - detectorSource.Push(source_1); + using (var eventWaiter = EventAwaiter.Create()) + { + _detector.Detected += eventWaiter; - detectorSource.Push(source_2); + SurveillanceSource detectorSource = new SurveillanceSource(); + _detector.AddSource(detectorSource); - await Task.Delay(10); - Assert.True(_waitFlag, "Failed to receive PersonAppearanceChanged event."); + detectorSource.Push(_source1); + detectorSource.Push(_source2); - detector.Detected -= EventHandlerPersonAppearancetDetected; + Assert.That(await eventWaiter.IsRaisedAsync(), "Failed to receive PersonAppearanceChanged event."); - detector.RemoveSource(detectorSource); + _detector.RemoveSource(detectorSource); + } } } - } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionConfiguration.cs old mode 100755 new mode 100644 index e9dea16e1..34c5753eb --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright 2016 by Samsung Electronics, Inc., +// Copyright 2016 by Samsung Electronics, Inc., // // This software is the confidential and proprietary information // of Samsung Electronics, Inc. ("Confidential Information"). You @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,38 +16,29 @@ namespace Tizen.Multimedia.Vision.Tests public class PersonRecognitionConfigurationTests { - private static PersonRecognitionConfiguration config = null; - private static readonly string modelPath = TestHelper.ResourcePath + "surv/face_recog_model_p1"; + private static PersonRecognitionConfiguration _config = null; + private static readonly string _modelPath = TestHelper.ResourcePath + "surv/face_recog_model_p1"; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - config = new PersonRecognitionConfiguration(modelPath); + _config = new PersonRecognitionConfiguration(_modelPath); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (isSurveillanceSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support Surveillance"); - else - Assert.Pass("Surveillance is not supported"); + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -60,7 +50,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void PersonRecognitionConfiguration_with_ModelPath_INIT() { - Assert.IsNotNull(config, "PersonRecognitionConfiguration should not be null after calling constructor."); + Assert.IsNotNull(_config, "PersonRecognitionConfiguration should not be null after calling constructor."); } [Test] @@ -85,8 +75,8 @@ namespace Tizen.Multimedia.Vision.Tests public static void FaceRecognitionModelPath_READ_WRITE() { string newPath = TestHelper.ResourcePath + "surv/face_recog_model_p2"; - config.FaceRecognitionModelPath = newPath; - Assert.AreEqual(config.FaceRecognitionModelPath, newPath, "FaceRecognitionModelPath should be {0}", newPath); + _config.FaceRecognitionModelPath = newPath; + Assert.AreEqual(_config.FaceRecognitionModelPath, newPath, "FaceRecognitionModelPath should be {0}", newPath); } [Test] @@ -98,7 +88,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void FaceRecognitionModelPath_CHECK_NULL_ARGUMENT_EXCEPTION() { - Assert.Throws(() => config.FaceRecognitionModelPath = null); + Assert.Throws(() => _config.FaceRecognitionModelPath = null); } } -} \ No newline at end of file +} diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionInfo.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionInfo.cs old mode 100755 new mode 100644 index 6a2729cf8..b4150ec90 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionInfo.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognitionInfo.cs @@ -14,19 +14,9 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.PersonRecognitionInfo test class")] public class PersonRecognitionInfoTests { - private static Rectangle region = new Rectangle(10, 10, 100, 200); - private static int label = 1; - private static double confidence = 0.9; - - [SetUp] - public static void Init() - { - } - - [TearDown] - public static void Destroy() - { - } + private static Rectangle _region = new Rectangle(10, 10, 100, 200); + private static int _label = 1; + private static double _confidence = 0.9; [Test] [Category("P1")] @@ -37,7 +27,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void PersonRecognitionInfo_INIT() { - Assert.IsNotNull(new PersonRecognitionInfo(region, 1, 0.9), "It shoud be not null"); + Assert.IsNotNull(new PersonRecognitionInfo(_region, 1, 0.9), "It shoud be not null"); } [Test] @@ -49,7 +39,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Area_READ_ONLY() { - Assert.AreEqual(region, new PersonRecognitionInfo(region, label, confidence).Area); + Assert.AreEqual(_region, new PersonRecognitionInfo(_region, _label, _confidence).Area); } [Test] @@ -61,7 +51,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Label_READ_ONLY() { - Assert.AreEqual(label, new PersonRecognitionInfo(region, label, confidence).Label); + Assert.AreEqual(_label, new PersonRecognitionInfo(_region, _label, _confidence).Label); } [Test] @@ -73,7 +63,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Confidence_READ_ONLY() { - Assert.AreEqual(confidence, new PersonRecognitionInfo(region, label, confidence).Confidence); + Assert.AreEqual(_confidence, new PersonRecognitionInfo(_region, _label, _confidence).Confidence); } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizedEventArgs.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizedEventArgs.cs old mode 100755 new mode 100644 index 1ee6d8d7c..e34ab2496 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizedEventArgs.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizedEventArgs.cs @@ -8,7 +8,6 @@ using System; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -16,44 +15,34 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.PersonRecognizedEventArgs test class")] public class PersonRecognizedEventArgsTests { - private static Rectangle region = new Rectangle(10, 10, 100, 200); - private static int label = 1; - private static double confidence = 0.9; + private static Rectangle _region = new Rectangle(10, 10, 100, 200); + private static int _label = 1; + private static double _confidence = 0.9; - private static PersonRecognitionConfiguration config = null; + private static PersonRecognitionConfiguration _config = null; - private static readonly string modelPath = TestHelper.ResourcePath + "surv/face_recog_model_p1"; + private static readonly string _modelPath = TestHelper.ResourcePath + "surv/face_recog_model_p1"; [SetUp] public static void Init() { - - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - config = new PersonRecognitionConfiguration(modelPath); + _config = new PersonRecognitionConfiguration(_modelPath); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (isSurveillanceSupported) - Assert.Fail("Method throws NotSupportedException, but Tizen support Surveillance"); - else - Assert.Pass("Surveillance is not supported"); + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (config != null) - config.Dispose(); + _config?.Dispose(); } [Test] @@ -65,7 +54,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void PersonRecognizedEventArgs_INIT() { - var infos = new[] { new PersonRecognitionInfo(region, label, confidence) }; + var infos = new[] { new PersonRecognitionInfo(_region, _label, _confidence) }; Assert.DoesNotThrow(() => new PersonRecognizedEventArgs(infos)); } @@ -79,7 +68,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Recognitions_READ_ONLY() { - var infos = new[] { new PersonRecognitionInfo(region, label, confidence) }; + var infos = new[] { new PersonRecognitionInfo(_region, _label, _confidence) }; Assert.AreEqual(infos, new PersonRecognizedEventArgs(infos).Recognitions); } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizer.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizer.cs index aecd8ebe5..7e9388957 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizer.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPersonRecognizer.cs @@ -9,7 +9,6 @@ using System; using System.Threading.Tasks; using NUnit.Framework; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -17,39 +16,32 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.PersonRecognizer test class")] public class PersonRecognizerTests { - private static PersonRecognizer recognizer = null; - private static readonly string modelPath = TestHelper.ResourcePath + "surv/face_recog_model_p1"; - private static bool isNotSupportedTC = false; - - private static bool _waitFlag = false; + private static PersonRecognizer _recognizer = null; + private static PersonRecognitionConfiguration _config = null; + private static readonly string _modelPath = TestHelper.ResourcePath + "surv/face_recog_model_p1"; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - recognizer = new PersonRecognizer(); + _recognizer = new PersonRecognizer(); + _config = new PersonRecognitionConfiguration(_modelPath); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (!isSurveillanceSupported) - isNotSupportedTC = true; + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (recognizer != null) - recognizer.Dispose(); + _recognizer?.Dispose(); + _config?.Dispose(); } [Test] @@ -61,10 +53,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void PersonRecognizer_INIT() { - if (isNotSupportedTC) - return; - - Assert.IsNotNull(recognizer, "PersonRecognizer should not be null after calling constructor."); + Assert.IsNotNull(_recognizer, "PersonRecognizer should not be null after calling constructor."); } [Test] @@ -74,18 +63,14 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task AddSource_with_Configuration_CHECK_RETURN_VALUE() + public static async Task AddSource_with_Configuration_CHECK_NO_EXCEPTION() { - if (isNotSupportedTC) - return; - - PersonRecognitionConfiguration engineConfig = new PersonRecognitionConfiguration(modelPath); + var recognizerSource = new SurveillanceSource(); - SurveillanceSource recognizerSource = new SurveillanceSource(); - recognizer.AddSource(recognizerSource, engineConfig); + Assert.DoesNotThrow(() => _recognizer.AddSource(recognizerSource, _config)); await Task.Delay(10); - recognizer.RemoveSource(recognizerSource); + Assert.DoesNotThrow(() => _recognizer.RemoveSource(recognizerSource)); } [Test] @@ -97,10 +82,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void AddSource_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - Assert.Throws(() => recognizer.AddSource(null, null)); + Assert.Throws(() => _recognizer.AddSource(null, null)); } [Test] @@ -112,19 +94,11 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void AddSource_with_Configuration_CHECK_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - string fakePath = "/tmp/fake/face_recog_model_p1"; PersonRecognitionConfiguration engineConfig = new PersonRecognitionConfiguration(fakePath); - SurveillanceSource recognizerSource = new SurveillanceSource(); - Assert.Throws(() => recognizer.AddSource(recognizerSource, engineConfig)); - } - public static void EventHandlerPersonRecognized(object sender, EventArgs e) - { - _waitFlag = true; + Assert.Throws(() => _recognizer.AddSource(recognizerSource, engineConfig)); } [Test] @@ -136,28 +110,24 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static async Task Recognized_CHECK_EVENT() { - if (isNotSupportedTC) - return; - - _waitFlag = false; - - PersonRecognitionConfiguration config = new PersonRecognitionConfiguration(modelPath); + using (var eventWaiter = EventAwaiter.Create()) + using (var source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/p1_09.jpg")) + { + _recognizer.Recognized += eventWaiter; - recognizer.Recognized += EventHandlerPersonRecognized; + SurveillanceSource recognizerSource = new SurveillanceSource(); + _recognizer.AddSource(recognizerSource, _config); - SurveillanceSource recognizerSource = new SurveillanceSource(); - recognizer.AddSource(recognizerSource, config); + await Task.Delay(10); - MediaVisionSource source = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/p1_09.jpg"); - Assert.IsNotNull(source, "fail to get mediavisionsource from source"); + Assert.IsNotNull(source, "fail to get mediavisionsource from source"); - recognizerSource.Push(source); + recognizerSource.Push(source); - await Task.Delay(10); - Assert.True(_waitFlag, "Failed to receive PersonRecognized event."); + Assert.That(await eventWaiter.IsRaisedAsync()); - recognizer.Recognized -= EventHandlerPersonRecognized; - recognizer.RemoveSource(recognizerSource); + _recognizer.RemoveSource(recognizerSource); + } } } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPoint.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPoint.cs old mode 100755 new mode 100644 index d137c1fb9..bd9d2e809 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPoint.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSPoint.cs @@ -14,16 +14,6 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.MultimediaVision..Point test class")] public class PointTests { - [SetUp] - public static void Init() - { - } - - [TearDown] - public static void Destroy() - { - } - [Test] [Category("P1")] [Description("Tests instantiating a point instance")] @@ -45,8 +35,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void X_READ_WRITE() { - Point obj = new Point(10, 10); - obj.X = 20; + var obj = new Point(20, 10); Assert.AreEqual(obj.X, 20, "X-coordinate is incorrect"); } @@ -59,8 +48,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Y_READ_WRITE() { - Point obj = new Point(10, 10); - obj.Y = 20; + var obj = new Point(10, 20); Assert.AreEqual(obj.Y, 20, "Y-coordinate is incorrect"); } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQrConfiguration.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQrConfiguration.cs old mode 100755 new mode 100644 index c5f94c0d3..d862bf596 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQrConfiguration.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQrConfiguration.cs @@ -15,16 +15,6 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.QrConfiguration test class")] public class QrConfigurationTests { - [SetUp] - public static void Init() - { - } - - [TearDown] - public static void Destroy() - { - } - [Test] [Category("P1")] [Description("Tests instantiating a QrConfiguration instance")] diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQuadrangle.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQuadrangle.cs old mode 100755 new mode 100644 index 1c345bf65..1bc17a604 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQuadrangle.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSQuadrangle.cs @@ -15,16 +15,6 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.Quadrangle test class")] public class QuadrangleTests { - [SetUp] - public static void Init() - { - } - - [TearDown] - public static void Destroy() - { - } - [Test] [Category("P1")] [Description("Tests instantiating a quadrangle instance")] diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSRectangle.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSRectangle.cs old mode 100755 new mode 100644 index 5cc06471d..7c295dc24 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSRectangle.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSRectangle.cs @@ -6,7 +6,6 @@ // it only in accordance with the terms of the license agreement // you entered into with Samsung. -using System; using NUnit.Framework; namespace Tizen.Multimedia.Vision.Tests @@ -15,16 +14,6 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.Rectangle test class")] public class RectangleTests { - [SetUp] - public static void Init() - { - } - - [TearDown] - public static void Destroy() - { - } - [Test] [Category("P1")] [Description("Tests instantiating a rectangle instance")] diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSize.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSize.cs old mode 100755 new mode 100644 index b1a9c26b3..089c4ab5b --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSize.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSize.cs @@ -15,16 +15,6 @@ namespace Tizen.Multimedia.Vision.Tests [Description("Tizen.Multimedia.Vision.Size test class")] public class SizeTests { - [SetUp] - public static void Init() - { - } - - [TearDown] - public static void Destroy() - { - } - [Test] [Category("P1")] [Description("Tests instantiating a size instance")] @@ -46,8 +36,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Width_READ_WRITE() { - var size = new Size(100, 100); - size.Width = 200; + var size = new Size(200, 100); Assert.AreEqual(size.Width, 200, "Width is incorrect"); } @@ -60,8 +49,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Height_READ_WRITE() { - var size = new Size(100, 100); - size.Height = 200; + var size = new Size(100, 200); Assert.AreEqual(size.Height, 200, "Height is incorrect"); } } diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceEngine.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceEngine.cs old mode 100755 new mode 100644 index fd52c2b2d..8a0afb9c4 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceEngine.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceEngine.cs @@ -10,7 +10,6 @@ using System; using System.Threading.Tasks; using NUnit.Framework; using NUnit.Framework.TUnit; -using Tizen.System; namespace Tizen.Multimedia.Vision.Tests { @@ -19,36 +18,28 @@ namespace Tizen.Multimedia.Vision.Tests public class SurveillanceEngineTests { - private static MovementDetector detector = null; - private static bool isNotSupportedTC = false; + private static MovementDetector _detector = null; [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - detector = new MovementDetector(); + _detector = new MovementDetector(); } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (!isSurveillanceSupported) - isNotSupportedTC = true; + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (detector != null) - detector.Dispose(); + _detector?.Dispose(); } [Test] @@ -60,16 +51,13 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void Roi_READ_WRITE() { - if (isNotSupportedTC) - return; - Point[] points = { new Point(440, 130), new Point(530, 130), new Point(530, 240), new Point(440, 240) }; - SurveillanceEngine SubClass = detector; + SurveillanceEngine SubClass = _detector; SubClass.Roi = points; Assert.IsTrue(SubClass.Roi[0] == points[0], "Should be " + points[0].ToString()); @@ -90,26 +78,23 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task RemoveSource_CHECK_RETURN_VALUE() + public static async Task RemoveSource_CHECK_NO_EXCEPTION() { - if (isNotSupportedTC) - return; - - detector.Detected += EventHandlerMovementDetect; - - SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource); - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg")) + using (var eventWaiter = EventAwaiter.Create()) { + _detector.Detected += eventWaiter; + + SurveillanceSource detectorSource = new SurveillanceSource(); + _detector.AddSource(detectorSource); + detectorSource.Push(source1); - await Task.Delay(10); - } - detector.Detected -= EventHandlerMovementDetect; + await eventWaiter.IsRaisedAsync(); - SurveillanceEngine SubClass = detector; - SubClass.RemoveSource(detectorSource); + SurveillanceEngine SubClass = _detector; + Assert.DoesNotThrow(() => SubClass.RemoveSource(detectorSource)); + } } [Test] @@ -121,10 +106,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void RemoveSource_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - SurveillanceEngine SubClass = detector; + SurveillanceEngine SubClass = _detector; Assert.Throws(() => SubClass.RemoveSource(null)); } @@ -137,13 +119,10 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void RemoveSource_CHECK_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - SurveillanceSource detectorSource = new SurveillanceSource(); + var detectorSource = new SurveillanceSource(); - SurveillanceEngine SubClass = detector; + SurveillanceEngine SubClass = _detector; Assert.Throws(() => SubClass.RemoveSource(detectorSource)); } } -} \ No newline at end of file +} diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceSource.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceSource.cs old mode 100755 new mode 100644 index 29844c8fc..59d57bb5a --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceSource.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/TSSurveillanceSource.cs @@ -1,4 +1,4 @@ -// Copyright 2016 by Samsung Electronics, Inc., +// Copyright 2016 by Samsung Electronics, Inc., // // This software is the confidential and proprietary information // of Samsung Electronics, Inc. ("Confidential Information"). You @@ -19,13 +19,7 @@ namespace Tizen.Multimedia.Vision.Tests public class SurveillanceSourceTests { - private static MovementDetector detector = null; - - public static bool isImageRecognitionSupported = false; - public static bool isFaceRecognitionSupported = false; - public static bool isSurveillanceSupported = false; - - private static bool isNotSupportedTC = false; + private static MovementDetector _detector = null; public static void EventHandlerMovementDetect(object sender, EventArgs e) { @@ -35,34 +29,28 @@ namespace Tizen.Multimedia.Vision.Tests [SetUp] public static void Init() { - bool isImageRecognitionSupported = false; - bool isFaceRecognitionSupported = false; - bool isSurveillanceSupported = false; - - Information.TryGetValue("http://tizen.org/feature/vision.face_recognition", out isFaceRecognitionSupported); - Information.TryGetValue("http://tizen.org/feature/vision.image_recognition", out isImageRecognitionSupported); - isSurveillanceSupported = isImageRecognitionSupported && isFaceRecognitionSupported; + bool isSurveillanceSupported = FeatureChecker.IsSupported(Features.FaceRecognition) + || FeatureChecker.IsSupported(Features.ImageRecognition); try { - detector = new MovementDetector(); + _detector = new MovementDetector(); - detector.Detected += EventHandlerMovementDetect; + _detector.Detected += EventHandlerMovementDetect; } - catch (NotSupportedException) + catch (NotSupportedException) when (isSurveillanceSupported == false) { - if (!isSurveillanceSupported) - isNotSupportedTC = true; + Assert.Pass("Surveillance is not supported"); } } [TearDown] public static void Destroy() { - if (detector != null) + if (_detector != null) { - detector.Detected -= EventHandlerMovementDetect; - detector.Dispose(); + _detector.Detected -= EventHandlerMovementDetect; + _detector.Dispose(); } } @@ -75,14 +63,9 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] public static void SurveillanceSource_INIT() { - if (isNotSupportedTC) - return; - Assert.IsNotNull(new SurveillanceSource(), "SurveillanceSource should not be null after calling constructor."); } - - [Test] [Category("P1")] [Description("Tests pushing source")] @@ -90,22 +73,19 @@ namespace Tizen.Multimedia.Vision.Tests [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")] - public static async Task Push_CHECK_RETURN_VALUE() + public static async Task Push_CHECK_NO_EXCEPTION() { - if (isNotSupportedTC) - return; - - SurveillanceSource detectorSource = new SurveillanceSource(); - detector.AddSource(detectorSource); + var detectorSource = new SurveillanceSource(); + _detector.AddSource(detectorSource); - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg")) + using (var source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg")) { - detectorSource.Push(source1); + Assert.DoesNotThrow(() => detectorSource.Push(source1)); await Task.Delay(10); } - detector.RemoveSource(detectorSource); + Assert.DoesNotThrow(() => _detector.RemoveSource(detectorSource)); } [Test] @@ -117,10 +97,7 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static void Push_CHECK_NULL_ARGUMENT_EXCEPTION() { - if (isNotSupportedTC) - return; - - SurveillanceSource detectorSource = new SurveillanceSource(); + var detectorSource = new SurveillanceSource(); Assert.Throws(() => detectorSource.Push(null)); } @@ -133,15 +110,12 @@ namespace Tizen.Multimedia.Vision.Tests [Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")] public static async Task Push_CHECK_INVALID_OPERATIONT_EXCEPTION() { - if (isNotSupportedTC) - return; - - SurveillanceSource detectorSource = new SurveillanceSource(); + var detectorSource = new SurveillanceSource(); - using (MediaVisionSource source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg")) + using (var source1 = await TestHelper.GetMediaSourceFromImage(TestHelper.ResourcePath + "surv/move_det_1.jpg")) { Assert.Throws(() => detectorSource.Push(source1)); } } } -} \ No newline at end of file +} diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/AssertHelper.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/AssertHelper.cs deleted file mode 100755 index f994484dc..000000000 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/AssertHelper.cs +++ /dev/null @@ -1,68 +0,0 @@ -using NUnit.Framework; -using System; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; - -internal static class AssertHelper -{ - static public void AreEqual(T[] expected, T[] actual, string message = null) - { - message = message == null ? "" : message + " "; - - message = $"Expected [{ string.Join(" ", expected) }], but got [{ string.Join(" ", actual) }]."; - - - Assert.True(Enumerable.SequenceEqual(expected, actual), message); - } - - static public void PropertyReadOnly(string propertyName) - { - PropertyInfo propertyInfo = typeof(T).GetProperty(propertyName); - - Assert.NotNull(propertyInfo, $"A property named {propertyName} does not exist"); - - Assert.True(propertyInfo.CanRead && propertyInfo.GetMethod.IsPublic, - $"The property named {propertyName} is not readable."); - - Assert.True(!propertyInfo.CanWrite || !propertyInfo.SetMethod.IsPublic, - $"The property named {propertyName} is writable."); - } - - static public void PropertyReadOnly(T obj, string propertyName) - { - PropertyReadOnly(propertyName); - } - - static public void PropertyReadWrite(string propertyName) - { - PropertyInfo propertyInfo = typeof(T).GetProperty(propertyName); - - Assert.NotNull(propertyInfo, $"A property named {propertyName} does not exist"); - - Assert.True(propertyInfo.CanRead && propertyInfo.GetMethod.IsPublic, - $"The property named {propertyName} is not readable."); - - Assert.True(propertyInfo.CanWrite && propertyInfo.SetMethod.IsPublic, - $"The property named {propertyName} is not writable."); - } - - static private async Task CaughtExceptionAsync(Func f) - { - try - { - await f(); - } - catch (Exception e) - { - return e.GetType(); - } - return null; - } - - static public async Task ThrowsAsync(Func f) where EX : Exception - { - Assert.AreEqual(await CaughtExceptionAsync(f), typeof(EX)); - } -} - diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/Features.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/Features.cs new file mode 100644 index 000000000..0b0efc9fb --- /dev/null +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/Features.cs @@ -0,0 +1,7 @@ +internal static class Features +{ + public const string BarcodeDetection = "http://tizen.org/feature/vision.barcode_detection"; + public const string BarcodeGeneration = "http://tizen.org/feature/vision.barcode_generation"; + public const string FaceRecognition = "http://tizen.org/feature/vision.face_recognition"; + public const string ImageRecognition = "http://tizen.org/feature/vision.image_recognition"; +} diff --git a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/TestHelper.cs b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/TestHelper.cs index 72a80606f..0a8e5c472 100755 --- a/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/TestHelper.cs +++ b/tct-suite-vs/Tizen.MediaVision.Tests/testcase/support/TestHelper.cs @@ -55,7 +55,7 @@ namespace Tizen.Multimedia.Vision.Tests internal static async Task GetMediaSourceFromImage(string path) { - var frame = (await GetBitampFrameFromImage(path)); + var frame = await GetBitampFrameFromImage(path); MediaVisionSource source = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888);