<!-- Include Nuget Package for Tizen Project building -->
<ItemGroup>
<ProjectReference Include="..\Template\AutoTemplate\AutoTemplate.csproj" />
+ <ProjectReference Include="..\Tizen.Multimedia.Support.Library\Tizen.Multimedia.Support.Library.csproj" />
</ItemGroup>
</Project>
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
{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
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void Barcode_INIT()
{
- Barcode barcode = new Barcode(region, message, type);
- Assert.IsInstanceOf<Barcode>(barcode, "Should be of type Barcode");
- Assert.IsNotNull(barcode, "barcode should not be null after calling constructor.");
+ Assert.IsInstanceOf<Barcode>(_barcode, "Should be of type Barcode");
}
[Test]
[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]
[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]
[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);
}
}
-
}
// 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
{
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void BarcodeDetectionConfiguration_INIT()
{
- Assert.IsInstanceOf<BarcodeDetectionConfiguration>(config, "Should be of type BarcodeDetectionConfiguration");
- Assert.IsNotNull(config, "BarcodeDetectionConfiguration should not be null after calling constructor.");
+ Assert.IsInstanceOf<BarcodeDetectionConfiguration>(_config, "Should be of type BarcodeDetectionConfiguration");
+ Assert.IsNotNull(_config, "BarcodeDetectionConfiguration should not be null after calling constructor.");
}
[Test]
[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]
[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]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void Target_CHECK_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentException>(() => config.Target = BarcodeDetectionTarget.Barcode2D + 1);
+ Assert.Throws<ArgumentException>(() => _config.Target = BarcodeDetectionTarget.Barcode2D + 1);
}
}
}
using NUnit.Framework;
using System;
using System.Threading.Tasks;
-using Tizen.System;
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]
[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");
[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");
[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<ArgumentNullException>(() => BarcodeDetector.DetectAsync(null, roi));
}
[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<ArgumentNullException>(() => BarcodeDetector.DetectAsync(null, roi, config));
+ _config.Target = BarcodeDetectionTarget.All;
+ var roi = new Rectangle(new Point(0, 0), new Size(300, 300));
+ await AssertHelper.ThrowsAsync<ArgumentNullException>(() => BarcodeDetector.DetectAsync(null, roi, _config));
}
}
using System;
using NUnit.Framework;
using Tizen.Common;
-using Tizen.System;
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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void BarcodeGenerationConfiguration_INIT()
{
- Assert.IsInstanceOf<BarcodeGenerationConfiguration>(config, "Should be of type BarcodeGenerationConfiguration");
- Assert.IsNotNull(config, "BarcodeGenerationConfiguration should not be null after calling constructor.");
+ Assert.IsInstanceOf<BarcodeGenerationConfiguration>(_config, "Should be of type BarcodeGenerationConfiguration");
+ Assert.IsNotNull(_config, "BarcodeGenerationConfiguration should not be null after calling constructor.");
}
[Test]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void TextVisibility_CHECK_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentException>(() => config.TextVisibility = Visibility.Visible + 1);
+ Assert.Throws<ArgumentException>(() => _config.TextVisibility = Visibility.Visible + 1);
}
[Test]
[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]
[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]
[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");
}
}
using System;
using NUnit.Framework;
using Tizen.Common;
-using Tizen.System;
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]
[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");
[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<ArgumentException>(() => BarcodeGenerator.GenerateSource("abcdef", qrConfig));
}
[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");
[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<ArgumentNullException>(() => BarcodeGenerator.GenerateSource("0123455", null, config));
+ Assert.Throws<ArgumentNullException>(() => BarcodeGenerator.GenerateSource("0123455", null, _config));
}
[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<ArgumentException>(() => BarcodeGenerator.GenerateSource("abcdef", qrConfig, config));
+ Assert.Throws<ArgumentException>(() => BarcodeGenerator.GenerateSource("abcdef", qrConfig, _config));
}
[Test]
[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");
[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<ArgumentNullException>(() => BarcodeGenerator.GenerateSource(null, BarcodeType.Code128, config));
+ Assert.Throws<ArgumentNullException>(() => BarcodeGenerator.GenerateSource(null, BarcodeType.Code128, _config));
}
[Test]
[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<ArgumentException>(() => BarcodeGenerator.GenerateSource("0123455", BarcodeType.QR, config));
+ Assert.Throws<ArgumentException>(() => BarcodeGenerator.GenerateSource("0123455", BarcodeType.QR, _config));
}
[Test]
[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<ArgumentNullException>( () => BarcodeGenerator.GenerateImage(message, null, imageConfig));
+ Assert.Throws<ArgumentNullException>(() => BarcodeGenerator.GenerateImage("0123455", null, imageConfig));
}
[Test]
[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<ArgumentException>(() => BarcodeGenerator.GenerateImage(message, qrConfig, imageConfig));
+ Assert.Throws<ArgumentException>(() => BarcodeGenerator.GenerateImage("abcdef", qrConfig, imageConfig));
}
[Test]
[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<ArgumentNullException>(() => BarcodeGenerator.GenerateImage(message, null, imageConfig, config));
+ Assert.Throws<ArgumentNullException>(() => BarcodeGenerator.GenerateImage("0123455", null, imageConfig, _config));
}
[Test]
[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<ArgumentException>(() => BarcodeGenerator.GenerateImage(message, qrConfig, imageConfig, config));
+ Assert.Throws<ArgumentException>(() => BarcodeGenerator.GenerateImage("abcdef", qrConfig, imageConfig, _config));
}
[Test]
[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<ArgumentNullException>(() => BarcodeGenerator.GenerateImage(null, type, imageConfig));
+ Assert.Throws<ArgumentNullException>(() => BarcodeGenerator.GenerateImage(null, BarcodeType.Code128, imageConfig));
}
[Test]
[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<ArgumentException>(() => BarcodeGenerator.GenerateImage(message, type, imageConfig));
+ Assert.Throws<ArgumentException>(() => BarcodeGenerator.GenerateImage("0123455", BarcodeType.QR, imageConfig));
}
[Test]
[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<ArgumentNullException>(() => BarcodeGenerator.GenerateImage(null, type, imageConfig, config));
+ Assert.Throws<ArgumentNullException>(() => BarcodeGenerator.GenerateImage(null, BarcodeType.Code128, imageConfig, _config));
}
[Test]
[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<ArgumentException>(() => BarcodeGenerator.GenerateImage(message, type, imageConfig, config));
+ Assert.Throws<ArgumentException>(() => BarcodeGenerator.GenerateImage("0123455", BarcodeType.QR, imageConfig, _config));
}
}
}
[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")]
[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<BarcodeImageConfiguration>(obj, "Should be of type BarcodeImageConfiguration");
Assert.IsNotNull(obj, "BarcodeImageConfiguration should not be null after calling constructor.");
}
[Property("COVPARAM", "int, int, String, BarcodeImageFormat")]
public static void BarcodeImageConfiguration_Width_Height_INIT_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>( () => new BarcodeImageConfiguration(500, 400, null, BarcodeImageFormat.Jpeg));
+ Assert.Throws<ArgumentNullException>(
+ () => new BarcodeImageConfiguration(500, 400, null, BarcodeImageFormat.Jpeg));
}
[Test]
[Property("COVPARAM", "int, int, String, BarcodeImageFormat")]
public static void BarcodeImageConfiguration_Width_Height_INIT_CHECK_OutOfRange_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => new BarcodeImageConfiguration(0, 0, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg));
+ Assert.Throws<ArgumentOutOfRangeException>(
+ () => new BarcodeImageConfiguration(0, 0, _mediaPath, BarcodeImageFormat.Jpeg));
}
[Test]
[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<BarcodeImageConfiguration>(obj, "Should be of type BarcodeImageConfiguration");
Assert.IsNotNull(obj, "BarcodeImageConfiguration should not be null after calling constructor.");
}
[Property("COVPARAM", "Size, String, BarcodeImageFormat")]
public static void BarcodeImageConfiguration_Size_INIT_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Size size = new Size(500, 400);
- Assert.Throws<ArgumentNullException>(() => new BarcodeImageConfiguration(size, null, BarcodeImageFormat.Jpeg));
+ Assert.Throws<ArgumentNullException>(
+ () => new BarcodeImageConfiguration(new Size(500, 400), null, BarcodeImageFormat.Jpeg));
}
[Test]
[Property("COVPARAM", "Size, String, BarcodeImageFormat")]
public static void BarcodeImageConfiguration_Size_INIT_CHECK_OutOfRange_EXCEPTION()
{
- Size size = new Size(-1, -1);
- Assert.Throws<ArgumentOutOfRangeException>( () => new BarcodeImageConfiguration(size, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.Jpeg));
+ Assert.Throws<ArgumentOutOfRangeException>(
+ () => new BarcodeImageConfiguration(new Size(-1, -1), _mediaPath, BarcodeImageFormat.Jpeg));
}
[Test]
[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");
}
[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");
}
[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")]
[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]
[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");
}
[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");
}
[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");
}
}
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void FaceDetectionConfiguration_INIT()
{
- Assert.IsInstanceOf<FaceDetectionConfiguration>(config, "Should be of type FaceDetectionConfiguration");
- Assert.IsNotNull(config, "FaceDetectionConfiguration should not be null after calling constructor.");
+ Assert.IsInstanceOf<FaceDetectionConfiguration>(_config, "Should be of type FaceDetectionConfiguration");
+ Assert.IsNotNull(_config, "FaceDetectionConfiguration should not be null after calling constructor.");
}
[Test]
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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void ModelFilePath_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => config.ModelFilePath = null);
+ Assert.Throws<ArgumentNullException>(() => _config.ModelFilePath = null);
}
[Test]
[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]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void MinHeight_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.MinHeight = -1);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.MinHeight = -1);
}
[Test]
[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]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void MinWidth_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.MinWidth = -1);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.MinWidth = -1);
}
[Test]
[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]
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]
[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<ArgumentOutOfRangeException>(() => config.Roi = roi);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.Roi = new Rectangle(-1, -1, -1, -1));
}
}
}
[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]
[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))
[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<Rectangle[]>(faceLists, "Should be Rectangle[]");
Assert.AreEqual(faceLists.Length, 5, "The number of detected faces should be 5");
}
[Property("COVPARAM", "MediaVisionSource")]
public static async Task DetectAsync_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceDetector.DetectAsync(null));
}
[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<ArgumentNullException>(() => FaceDetector.DetectAsync(null, config));
+ await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceDetector.DetectAsync(null, _config));
}
}
-// 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
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void FaceRecognitionConfiguration_INIT()
{
- Assert.IsInstanceOf<FaceRecognitionConfiguration>(config, "Should be of type FaceRecognitionConfiguration");
- Assert.IsNotNull(config, "FaceRecognitionConfiguration should not be null after calling constructor.");
+ Assert.IsInstanceOf<FaceRecognitionConfiguration>(_config, "Should be of type FaceRecognitionConfiguration");
+ Assert.IsNotNull(_config, "FaceRecognitionConfiguration should not be null after calling constructor.");
}
[Test]
[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]
[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]
[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]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void ModelType_CHECK_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentException>(() => config.ModelType = FaceRecognitionModelType.Lbph + 1);
+ Assert.Throws<ArgumentException>(() => _config.ModelType = FaceRecognitionModelType.Lbph + 1);
}
}
}
using System;
using System.IO;
-using NUnit.Framework;
using System.Threading.Tasks;
-using Tizen.System;
+using NUnit.Framework;
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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void FaceRecognitionModel_INIT()
{
- Assert.IsInstanceOf<FaceRecognitionModel>(model, "Should be of type FaceRecognitionModel");
- Assert.IsNotNull(model, "FaceRecognitionModel should not be null after calling constructor.");
+ Assert.IsInstanceOf<FaceRecognitionModel>(_model, "Should be of type FaceRecognitionModel");
+ Assert.IsNotNull(_model, "FaceRecognitionModel should not be null after calling constructor.");
}
[Test]
[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<FaceRecognitionModel>(testModel, "Should be of type FaceRecognitionModel");
Assert.IsNotNull(testModel, "FaceRecognitionModel should not be null after calling constructor.");
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => model.Save(null));
+ Assert.Throws<ArgumentNullException>(() => _model.Save(null));
}
[Test]
{
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<UnauthorizedAccessException>(() => model.Save(restrictedPath));
+ _model.Learn();
+ Assert.Throws<UnauthorizedAccessException>(() => _model.Save(restrictedPath));
}
}
[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<DirectoryNotFoundException>(() => model.Save(fakePath));
- }
+ _model.Learn();
+ Assert.Throws<DirectoryNotFoundException>(() => _model.Save(fakePath));
}
[Test]
[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]
[Property("COVPARAM", "MediaVisionSource, int")]
public static void Add_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => model.Add(null, 1));
+ Assert.Throws<ArgumentNullException>(() => _model.Add(null, 1));
}
[Test]
[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]
[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<ArgumentNullException>(() => model.Add(null, 1, roi));
+ Assert.Throws<ArgumentNullException>(() => _model.Add(null, 1, roi));
}
[Test]
[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<InvalidOperationException>(() => model.Learn());
- }
+ _model.Reset();
+ Assert.Throws<InvalidOperationException>(() => _model.Learn());
}
[Test]
[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]
[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]
[Property("COVPARAM", "")]
public static void Learn_CHECK_INVALID_OPERATION_EXCEPTION()
{
- Assert.Throws<InvalidOperationException>(() => model.Learn());
+ Assert.Throws<InvalidOperationException>(() => _model.Learn());
}
[Test]
[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]
[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<InvalidOperationException>(() => model.Learn(engineConfig));
+ Assert.Throws<InvalidOperationException>(() => _model.Learn(engineConfig));
}
[Test]
[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");
}
}
}
using System;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[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]
[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");
}
}
}
// 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
{
[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]
[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]
[Property("COVPARAM", "MediaVisionSource, FaceRecognitionModel")]
public static async Task RecognizeAsync_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceRecognizer.RecognizeAsync(null, null));
}
[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<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(source, localModel));
+ await AssertHelper.ThrowsAsync<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(_source, localModel));
}
}
[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]
[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<ArgumentNullException>(() => FaceRecognizer.RecognizeAsync(null, null, roi));
}
[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<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(source, localModel, roi));
+ var roi = new Rectangle(new Point(0, 0), new Size(100, 100));
+ await AssertHelper.ThrowsAsync<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(_source, localModel, roi));
}
}
[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]
[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<ArgumentNullException>( () => FaceRecognizer.RecognizeAsync(null, null, engineConfig));
+ await AssertHelper.ThrowsAsync<ArgumentNullException>( () => FaceRecognizer.RecognizeAsync(null, null, _engineConfig));
}
[Test]
[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<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(source, localModel, engineConfig));
+ await AssertHelper.ThrowsAsync<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(_source, localModel, _engineConfig));
}
}
[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]
[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<ArgumentNullException>(() => FaceRecognizer.RecognizeAsync(null, null, roi, engineConfig));
+ await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceRecognizer.RecognizeAsync(null, null, roi, _engineConfig));
}
[Test]
[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<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(source, localModel, roi, engineConfig));
+ await AssertHelper.ThrowsAsync<InvalidOperationException>(() => FaceRecognizer.RecognizeAsync(_source, localModel, roi, _engineConfig));
}
}
[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)
{
}
}
-
[Test]
[Category("P2")]
[Description("Tests throwing null argument exception when null parameter of source is given")]
[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<ArgumentNullException>(() => FaceRecognizer.RecognizeEyeConditionAsync(null, new Rectangle(0, 0, 100, 100)));
}
[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)
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");
}
}
[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<ArgumentNullException>(() => FaceRecognizer.RecognizeEyeConditionAsync(null, roi, engineConfig));
+ await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceRecognizer.RecognizeEyeConditionAsync(null, roi, _engineConfig));
}
[Test]
[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)
{
[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<ArgumentNullException>(() => FaceRecognizer.RecognizeFacialExpressionAsync(null, new Rectangle(0, 0, 100, 100)));
}
[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)
{
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<FacialExpression>(result, "It should be of type FacialExpression");
}
}
[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<ArgumentNullException>(() => FaceRecognizer.RecognizeFacialExpressionAsync(null, roi, engineConfig));
+ await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceRecognizer.RecognizeFacialExpressionAsync(null, roi, _engineConfig));
}
}
}
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
namespace Tizen.Multimedia.Vision.Tests
{
[Description("Tizen.Multimedia.Vision.FaceTracker test class")]
public class FaceTrackerTests
{
- private static FaceTrackingModel model = null;
- private static List<MediaVisionSource> sources = null;
+ private static FaceTrackingModel _model = null;
+ private static List<MediaVisionSource> _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<MediaVisionSource>();
+ _model = new FaceTrackingModel();
+ _sources = new List<MediaVisionSource>();
+ 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]
[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;
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static async Task TrackAsync_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => FaceTracker.TrackAsync(null, null, false));
}
[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<InvalidOperationException>(() => FaceTracker.TrackAsync(frame, model, false));
+ await AssertHelper.ThrowsAsync<InvalidOperationException>(() => FaceTracker.TrackAsync(frame, _model, false));
}
-
}
}
}
using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void FaceTrackingModel_INIT()
{
- Assert.IsInstanceOf<FaceTrackingModel>(model, "Should be of type FaceTrackingModel");
- Assert.IsNotNull(model, "FaceTrackingModel should not be null after calling constructor.");
+ Assert.IsInstanceOf<FaceTrackingModel>(_model, "Should be of type FaceTrackingModel");
+ Assert.IsNotNull(_model, "FaceTrackingModel should not be null after calling constructor.");
}
[Test]
public static void FaceTrackingModel_with_ModelPath_INIT()
{
var testModel = new FaceTrackingModel(TestHelper.ResourcePath + "face_track/face_tracking_model_01");
+
Assert.IsInstanceOf<FaceTrackingModel>(testModel, "Should be of type FaceTrackingModel");
Assert.IsNotNull(testModel, "FaceTrackingModel should not be null after calling constructor.");
}
[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]
[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<ArgumentNullException>(() => model.Prepare(null, faceLocation));
+ Assert.Throws<ArgumentNullException>(() => _model.Prepare(null, _faceLocation));
}
[Test]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => model.Save(null));
+ Assert.Throws<ArgumentNullException>(() => _model.Save(null));
}
[Test]
[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<UnauthorizedAccessException>(() => model.Save(restrictedPath));
- }
+ Assert.Throws<UnauthorizedAccessException>(() => _model.Save(restrictedPath));
}
[Test]
[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<DirectoryNotFoundException>(() => model.Save(fakePath));
- }
+ Assert.Throws<DirectoryNotFoundException>(() => _model.Save(fakePath));
}
}
}
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
namespace Tizen.Multimedia.Vision.Tests
{
[Description("Tizen.Multimedia.Vision.FaceTrackingResult test class")]
public class FaceTrackingResultTests
{
- private static FaceTrackingModel model = null;
- private static List<MediaVisionSource> sources = null;
- private static bool isNotSupportedTC = false;
+ private static FaceTrackingModel _model = null;
+ private static List<MediaVisionSource> _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 = {
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<MediaVisionSource>();
+ _model = new FaceTrackingModel();
+ _sources = new List<MediaVisionSource>();
+
+ 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]
[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
[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<Quadrangle>(result.Region, "Should be of type Quadrangle");
}
}
[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;
[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]
[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]
[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]
[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]
[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]
[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");
}
}
}
[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]
[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]
[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]
[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]
[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]
[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]
[Property("COVPARAM", "MediaVisionSource")]
public static void Fill_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => obj.Fill(null));
+ Assert.Throws<ArgumentNullException>(() => _imageObject.Fill(null));
}
[Test]
[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]
[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<ArgumentNullException>(() => obj.Fill(null, roi));
+ Assert.Throws<ArgumentNullException>(() => _imageObject.Fill(null, roi));
}
[Test]
[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]
[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<ArgumentNullException>(() => obj.Fill(null, engineCfg));
+ Assert.Throws<ArgumentNullException>(() => _imageObject.Fill(null, _engineCfg));
}
[Test]
[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]
[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<ArgumentNullException>(() => obj.Fill(null, engineCfg, roi));
+ Assert.Throws<ArgumentNullException>(() => _imageObject.Fill(null, _engineCfg, roi));
}
[Test]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => obj.Save(null));
+ Assert.Throws<ArgumentNullException>(() => _imageObject.Save(null));
}
[Test]
[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<UnauthorizedAccessException>(() => obj.Save(restrictedPath));
- }
+ _imageObject.SetLabel(1);
+ _imageObject.Fill(_source);
+
+ Assert.Throws<UnauthorizedAccessException>(() => _imageObject.Save(restrictedPath));
}
[Test]
[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<DirectoryNotFoundException>(() => obj.Save(fakePath));
- }
+ Assert.Throws<DirectoryNotFoundException>(() => _imageObject.Save("/tmp/fake/fake_model"));
}
}
}
-// 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
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[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]
[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]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void SceneMaxKeyPoints_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.SceneMaxKeyPoints = -1);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.SceneMaxKeyPoints = -1);
}
[Test]
[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]
[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");
}
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void MinKeyPointMatches_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.MinKeyPointMatches = -1);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.MinKeyPointMatches = -1);
}
[Test]
[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]
[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]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void RequiredMatchingPart_CHECK_ABOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.RequiredMatchingPart = 2.3);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.RequiredMatchingPart = 2.3);
}
[Test]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void RequiredMatchingPart_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.RequiredMatchingPart = -1.2);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.RequiredMatchingPart = -1.2);
}
[Test]
[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]
[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]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void TolerantPartMatchError_CHECK_ABOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.TolerantPartMatchError = 2.3);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TolerantPartMatchError = 2.3);
}
[Test]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void TolerantPartMatchError_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.TolerantPartMatchError = -1.2);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.TolerantPartMatchError = -1.2);
}
}
}
using System;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
using NUnit.Framework.TUnit;
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]
[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)
[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)
using System;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
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]
[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<ImageRecognitionResult[]>(objLists, "It should be of type ImageRecognitionResult");
[Property("COVPARAM", "MediaVisionSource, ImageObject[]")]
public static async Task RecognizeAsync_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => ImageRecognizer.RecognizeAsync(null, null));
}
[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];
[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<ImageRecognitionResult[]>(objLists, "It should be of type ImageRecognitionResult");
[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<ArgumentNullException>(() => ImageRecognizer.RecognizeAsync(null, null, engineConfig));
}
[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<ArgumentException>(() => ImageRecognizer.RecognizeAsync(sourceScene, images, engineConfig));
}
}
}
-
}
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
namespace Tizen.Multimedia.Vision.Tests
{
[Description("Tizen.Multimedia.Vision.ImageTracker test class")]
public class ImageTrackerTests
{
- private static ImageTrackingModel model = null;
- private static List<MediaVisionSource> sources = null;
- private static bool isNotSupportedTC = false;
+ private static ImageTrackingModel _model = null;
+ private static List<MediaVisionSource> _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<MediaVisionSource>();
+ _model = new ImageTrackingModel();
+ _sources = new List<MediaVisionSource>();
+ 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]
[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;
}
[Property("COVPARAM", "MediaVisionSource, ImageTrackingModel")]
public static async Task TrackAsync_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
await AssertHelper.ThrowsAsync<ArgumentNullException>(() => ImageTracker.TrackAsync(null, null));
}
[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<ArgumentException>(() => ImageTracker.TrackAsync(source, model));
+ await AssertHelper.ThrowsAsync<ArgumentException>(() => ImageTracker.TrackAsync(source, _model));
}
}
[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;
}
[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<ArgumentNullException>(() => ImageTracker.TrackAsync(null, null, engineConfig));
}
[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<ArgumentException>(() => ImageTracker.TrackAsync(source, model, engineConfig));
+ await AssertHelper.ThrowsAsync<ArgumentException>(() => ImageTracker.TrackAsync(source, _model, engineConfig));
}
}
}
-// 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
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void HistoryAmount_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.HistoryAmount = -1);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.HistoryAmount = -1);
}
[Test]
[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]
[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]
[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]
[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]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void StabilizationAcceleration_CHECK_ABOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.StabilizationAcceleration = 2.3);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.StabilizationAcceleration = 2.3);
}
[Test]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void StabilizationAcceleration_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTIOn()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.StabilizationAcceleration = -1.2);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.StabilizationAcceleration = -1.2);
}
[Test]
[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]
[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]
[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]
[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]
[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]
[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");
}
}
}
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
{
[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]
[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]
[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));
}
}
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void SetTarget_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => model.SetTarget(null));
+ Assert.Throws<ArgumentNullException>(() => _model.SetTarget(null));
}
[Test]
[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());
}
}
[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");
}
}
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void Save_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => model.Save(null));
+ Assert.Throws<ArgumentNullException>(() => _model.Save(null));
}
[Test]
public static void Save_CHECK_UNAUTHORIZED_ACCESS_EXCEPTION()
{
string restrictedPath = TestHelper.ResourcePath + "image_track/fake_model";
- Assert.Throws<UnauthorizedAccessException>(() => model.Save(restrictedPath));
+ Assert.Throws<UnauthorizedAccessException>(() => _model.Save(restrictedPath));
}
[Test]
public static void Save_CHECK_DIRECTORY_NOT_FOUND_EXCEPTION()
{
string restrictedPath = TestHelper.ResourcePath + "/tmp/fake/mofedl/";
- Assert.Throws<DirectoryNotFoundException>(() => model.Save(restrictedPath));
+ Assert.Throws<DirectoryNotFoundException>(() => _model.Save(restrictedPath));
}
}
}
// 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;
[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)
{
[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");
}
}
[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]
[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]
[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]
[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]
[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]
[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]
[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]
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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");
}
[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");
}
-// 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
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[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]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void Threshold_CHECK_AMOVE_MAX_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.Threshold = 256);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.Threshold = 256);
}
[Test]
[Property("AUTHOR", "Rajeev Ranjan, rajeev.ran@samsung.com")]
public static void Threshold_CHECK_BELOW_MIN_OUT_OF_RANGE_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentOutOfRangeException>(() => config.Threshold = -1);
+ Assert.Throws<ArgumentOutOfRangeException>(() => _config.Threshold = -1);
}
}
-}
\ No newline at end of file
+}
using System;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[Property("COVPARAM", "SurveillanceSource")]
public static void AddSource_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
- Assert.Throws<ArgumentNullException>(() => detector.AddSource(null));
+ Assert.Throws<ArgumentNullException>(() => _detector.AddSource(null));
}
[Test]
[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]
[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<ArgumentNullException>(() => detector.AddSource(null, engineConfig));
- }
+ MovementDetectionConfiguration engineConfig = new MovementDetectionConfiguration
+ {
+ Threshold = 15
+ };
- public static void EventHandlerMovementDetected(object sender, EventArgs e)
- {
- _waitFlag = true;
+ Assert.Throws<ArgumentNullException>(() => _detector.AddSource(null, engineConfig));
}
[Test]
[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);
+ }
}
}
-
}
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[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]
[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);
}
}
}
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[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]
[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
using System;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[Property("COVPARAM", "SurveillanceSource")]
public static void AddSource_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
- Assert.Throws<ArgumentNullException>(() => detector.AddSource(null));
+ Assert.Throws<ArgumentNullException>(() => _detector.AddSource(null));
}
[Test]
[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]
[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<ArgumentNullException>(() => detector.AddSource(null, engineConfig));
- }
+ var engineConfig = new PersonAppearanceDetectionConfiguration
+ {
+ SkipFramesCount = 1
+ };
- public static void EventHandlerPersonAppearancetDetected(object sender, EventArgs e)
- {
- _waitFlag = true;
+ Assert.Throws<ArgumentNullException>(() => _detector.AddSource(null, engineConfig));
}
[Test]
[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<PersonAppearanceDetectedEventArgs>.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);
+ }
}
}
-
}
-// 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
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void FaceRecognitionModelPath_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- Assert.Throws<ArgumentNullException>(() => config.FaceRecognitionModelPath = null);
+ Assert.Throws<ArgumentNullException>(() => _config.FaceRecognitionModelPath = null);
}
}
-}
\ No newline at end of file
+}
[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")]
[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]
[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]
[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]
[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);
}
}
}
using System;
using NUnit.Framework;
-using Tizen.System;
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]
[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));
}
[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);
}
using System;
using System.Threading.Tasks;
using NUnit.Framework;
-using Tizen.System;
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]
[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]
[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]
[Property("AUTHOR", "Tae-Young Chung, ty83.chung@samsung.com")]
public static void AddSource_with_Configuration_CHECK_NULL_ARGUMENT_EXCEPTION()
{
- if (isNotSupportedTC)
- return;
-
- Assert.Throws<ArgumentNullException>(() => recognizer.AddSource(null, null));
+ Assert.Throws<ArgumentNullException>(() => _recognizer.AddSource(null, null));
}
[Test]
[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<ArgumentException>(() => recognizer.AddSource(recognizerSource, engineConfig));
- }
- public static void EventHandlerPersonRecognized(object sender, EventArgs e)
- {
- _waitFlag = true;
+ Assert.Throws<ArgumentException>(() => _recognizer.AddSource(recognizerSource, engineConfig));
}
[Test]
[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<PersonRecognizedEventArgs>.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);
+ }
}
}
}
[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")]
[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");
}
[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");
}
}
[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")]
[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")]
// 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
[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")]
[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")]
[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");
}
[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");
}
}
using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Framework.TUnit;
-using Tizen.System;
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]
[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());
[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<MovementDetectedEventArgs>.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]
[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<ArgumentNullException>(() => SubClass.RemoveSource(null));
}
[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<ArgumentException>(() => SubClass.RemoveSource(detectorSource));
}
}
-}
\ No newline at end of file
+}
-// 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
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)
{
[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();
}
}
[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")]
[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]
[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<ArgumentNullException>(() => detectorSource.Push(null));
}
[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<InvalidOperationException>(() => detectorSource.Push(source1));
}
}
}
-}
\ No newline at end of file
+}
+++ /dev/null
-using NUnit.Framework;
-using System;
-using System.Linq;
-using System.Reflection;
-using System.Threading.Tasks;
-
-internal static class AssertHelper
-{
- static public void AreEqual<T>(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<T>(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>(T obj, string propertyName)
- {
- PropertyReadOnly<T>(propertyName);
- }
-
- static public void PropertyReadWrite<T>(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<Type> CaughtExceptionAsync(Func<Task> f)
- {
- try
- {
- await f();
- }
- catch (Exception e)
- {
- return e.GetType();
- }
- return null;
- }
-
- static public async Task ThrowsAsync<EX>(Func<Task> f) where EX : Exception
- {
- Assert.AreEqual(await CaughtExceptionAsync(f), typeof(EX));
- }
-}
-
--- /dev/null
+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";
+}
internal static async Task<MediaVisionSource> 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);