From 82dd6bf1079a961132a5416007932e1977b7c900 Mon Sep 17 00:00:00 2001 From: MuHong Byun Date: Thu, 23 Apr 2020 11:42:04 +0900 Subject: [PATCH] [Tizen.Sensor][TCSACR-297] Add TCs for new auto rotation sensor * Add testcases for new type sensor(AutoRotationSensor). This sensor is a fusion type of sensor which is used to sense the orientation of the device. Change-Id: I25a9c129b200b0d3bde628a90426e40d883b5173 Signed-off-by: MuHong Byun --- .../testcase/TSAutoRotationSensor.cs | 108 +++++++++++++ .../TSAutoRotationSensorDataUpdatedEventArgs.cs | 114 ++++++++++++++ .../testcase/TSAutoRotationSensor.cs | 168 +++++++++++++++++++++ .../Tizen.Sensor.Tests/testcase/TSSensor.cs | 2 + 4 files changed, 392 insertions(+) create mode 100644 tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensor.cs create mode 100644 tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensorDataUpdatedEventArgs.cs create mode 100644 tct-suite-vs/Tizen.Sensor.Tests/testcase/TSAutoRotationSensor.cs diff --git a/tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensor.cs b/tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensor.cs new file mode 100644 index 0000000..d46249c --- /dev/null +++ b/tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensor.cs @@ -0,0 +1,108 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Tizen.Sensor.Tests +{ + [TestFixture] + [Description("Testing Tizen.Sensor.AutoRotationSensor class")] + public class AutoRotationSensorTests + { + private static bool _support = false; + + [OneTimeSetUp] + public void Init() + { + _support = TSSensorHelper.CheckCapability("http://tizen.org/feature/sensor.accelerometer"); + } + + [Test] + [Category("P1")] + [Description("Check AutoRotationSensor DataUpdated event")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensor.DataUpdated E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + [Precondition(1, "AutoRotationSensor sensor should be available")] + [Step(1, "Tap the Run button")] + [Step(2, "Rotate the test device")] + public async Task DataUpdated_CHECK_EVENT() + { + try + { + /* TEST CODE */ + EventHandler handler = null; + handler = (sender, e) => + { + + Assert.True(true); + ManualTest.Confirm(); + }; + + var sensor = new AutoRotationSensor(0); + sensor.DataUpdated += handler; + sensor.Start(); + sensor.Interval = 100; + await ManualTest.WaitForConfirm(); + sensor.Stop(); + sensor.DataUpdated -= handler; + sensor.Dispose(); + } + catch (NotSupportedException) + { + Assert.IsTrue(_support == false, "Invalid NotSupportedException"); + TSSensorHelper.DisplayLabel("AutoRotationSensor"); + await ManualTest.WaitForConfirm(); + } + catch (Exception e) + { + Assert.True(false, "should not throw exception(" + e.Message + ")"); + } + } + + [Test] + [Category("P1")] + [Description("Check AutoRotationSensor AccuracyChanged event")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensor.AccuracyChanged E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + [Precondition(1, "AutoRotationSensor sensor should be available")] + [Step(1, "Tap the Run button")] + [Step(2, "Rotate the test device")] + public async Task AccuracyChanged_CHECK_EVENT() + { + try + { + /* TEST CODE */ + EventHandler handler = null; + handler = (sender, e) => + { + + Assert.True(true); + ManualTest.Confirm(); + }; + + var sensor = new AutoRotationSensor(); + sensor.AccuracyChanged += handler; + sensor.Start(); + sensor.Interval = 100; + await ManualTest.WaitForConfirm(); + sensor.Stop(); + sensor.AccuracyChanged -= handler; + sensor.Dispose(); + } + catch (NotSupportedException) + { + Assert.IsTrue(_support == false, "Invalid NotSupportedException"); + TSSensorHelper.DisplayLabel("AutoRotationSensor"); + await ManualTest.WaitForConfirm(); + } + catch (Exception e) + { + Assert.True(false, "should not throw exception(" + e.Message + ")"); + } + } + } +} + diff --git a/tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensorDataUpdatedEventArgs.cs b/tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensorDataUpdatedEventArgs.cs new file mode 100644 index 0000000..9b62ce7 --- /dev/null +++ b/tct-suite-vs/Tizen.Sensor.Manual.Tests/testcase/TSAutoRotationSensorDataUpdatedEventArgs.cs @@ -0,0 +1,114 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Tizen.Sensor.Tests +{ + [TestFixture] + [Description("Testing Tizen.Sensor.AutoRotationSensorDataUpdatedEventArgs class")] + public class AutoRotationSensorDataUpdatedEventArgsTests + { + private static bool _support = false; + + [OneTimeSetUp] + public void Init() + { + _support = TSSensorHelper.CheckCapability("http://tizen.org/feature/sensor.accelerometer"); + } + + [Test] + [Category("P1")] + [Description("Check accuracy when AutoRotationSensor DataUpdated event is triggered")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensorDataUpdatedEventArgs.Accuracy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + [Precondition(1, "AutoRotationSensor should be available")] + [Step(1, "Tap the Run button")] + [Step(2, "AutoRotationSensor data update event: Rotate the test device")] + public async Task Accuracy_PROPERTY_READ_ONLY() + { + try + { + var sensor = new AutoRotationSensor(0); + sensor.Interval = 100; + SensorDataAccuracy getValue = sensor.Accuracy; + + EventHandler handler = null; + handler = (sender, e) => + { + /* TESTCODE */ + Assert.IsInstanceOf(e.Accuracy, "Accuracy value should be of type SensorDataAccuracy"); + Assert.IsTrue(e.Accuracy != getValue, "Accuracy value should be changed."); + ManualTest.Confirm(); + }; + + sensor.DataUpdated += handler; + sensor.Start(); + + await ManualTest.WaitForConfirm(); + + sensor.Stop(); + sensor.DataUpdated -= handler; + sensor.Dispose(); + } + catch (NotSupportedException) + { + Assert.IsTrue(_support == false, "Invalid NotSupportedException"); + TSSensorHelper.DisplayLabel("AutoRotationSensor"); + await ManualTest.WaitForConfirm(); + } + catch (Exception e) + { + Assert.True(false, "should not throw exception(" + e.Message + ")"); + } + } + + [Test] + [Category("P1")] + [Description("Check Rotation state when AutoRotationSensor DataUpdated event is triggered")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensorDataUpdatedEventArgs.Rotation A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + [Precondition(1, "AutoRotationSensor should be available")] + [Step(1, "Tap the Run button")] + [Step(2, "Rotate the test device")] + public async Task Rotation_PROPERTY_READ_ONLY() + { + try + { + var sensor = new AutoRotationSensor(0); + sensor.Interval = 100; + + EventHandler handler = null; + handler = (sender, e) => + { + /* TESTCODE */ + Assert.IsNotNull(e, "AutoRotationSensor Event should not be null"); + Assert.IsInstanceOf(e.Rotation, "Rotation value should be of type AutoRotationState"); + ManualTest.Confirm(); + }; + + sensor.DataUpdated += handler; + sensor.Start(); + + await ManualTest.WaitForConfirm(); + + sensor.Stop(); + sensor.DataUpdated -= handler; + sensor.Dispose(); + } + catch (NotSupportedException) + { + Assert.IsTrue(_support == false, "Invalid NotSupportedException"); + TSSensorHelper.DisplayLabel("AutoRotationSensor"); + await ManualTest.WaitForConfirm(); + } + catch (Exception e) + { + Assert.True(false, "should not throw exception(" + e.Message + ")"); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Sensor.Tests/testcase/TSAutoRotationSensor.cs b/tct-suite-vs/Tizen.Sensor.Tests/testcase/TSAutoRotationSensor.cs new file mode 100644 index 0000000..00fd864 --- /dev/null +++ b/tct-suite-vs/Tizen.Sensor.Tests/testcase/TSAutoRotationSensor.cs @@ -0,0 +1,168 @@ +using System; +using Tizen.System; +using NUnit.Framework; + +namespace Tizen.Sensor.Tests +{ + [TestFixture] + [Description("Testing Tizen.Sensor.AutoRotationSensor class")] + public class AutoRotationSensorTests + { + private static string AutoRotationSensorKey = "http://tizen.org/feature/sensor.accelerometer"; + private static bool support = false; + + private static bool CheckCapability() + { + bool ret = false; + if (Information.TryGetValue(AutoRotationSensorKey, out ret)) + return ret; + + return false; + } + + [OneTimeSetUp] + public void Init() + { + support = CheckCapability(); + } + + [Test] + [Category("P1")] + [Description("Test AutoRotationSensor object construction")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensor.AutoRotationSensor C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + [Property("COVPARAM", "")] + public void AutoRotationSensor_INIT() + { + /* + * PRECONDITION + * 1. AutoRotationSensor should be available + */ + try + { + /* TESTCODE */ + var obj = new AutoRotationSensor(); + Assert.IsNotNull(obj, "Object should not be null after construction"); + Assert.IsInstanceOf(obj, "Object's type should be AutoRotationSensor."); + + /* POST CONDITION */ + obj.Dispose(); + } + catch (Exception e) + { + if (!support) + Assert.IsInstanceOf(e, "NotSupportedException should be thrown for not supported sensor"); + else + Assert.True(false, "should not throw exception(" + e.Message + ")"); + } + } + + [Test] + [Category("P2")] + [Description("Check AutoRotationSensor constructor for exception")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensor.AutoRotationSensor C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "")] + public void AutoRotationSensor_INIT_N() + { + if (!support) + Assert.Throws(() => { var obj = new AutoRotationSensor(); }); + else + Assert.Pass("Test skipped! Can't test not supported exception"); + } + + [Test] + [Category("P1")] + [Description("Check the return type and value of AutoRotationSensor.Accuracy")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensor.Accuracy A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + public void Accuracy_PROPERTY_READ_ONLY() + { + /* + * PRECONDITION + * 1. AutoRotationSensor Sensor should be available + * 2. Sensor PausePolicy set All. + */ + try + { + var sensor = new AutoRotationSensor(); + sensor.PausePolicy = SensorPausePolicy.All; + + /* TESTCODE */ + object ret = sensor.Accuracy; + Assert.IsNotNull(ret, "AutoRotationSensor.Accuracy is null"); + Assert.IsTrue(sensor.Accuracy >= SensorDataAccuracy.Undefined && sensor.Accuracy <= SensorDataAccuracy.VeryGood, "Not in range"); + Assert.True((ret is SensorDataAccuracy), "Accuracy value returned is not of type SensorDataAccuracy"); + + /* POST CONDITION */ + sensor.PausePolicy = SensorPausePolicy.None; + sensor.Dispose(); + } + catch (Exception e) + { + if (!support) + Assert.IsInstanceOf(e, "NotSupportedException should be thrown for not supported sensor"); + else + Assert.True(false, "should not throw exception(" + e.Message + ")"); + } + } + + [Test] + [Category("P1")] + [Description("Check the return type and value of AutoRotationSensor.IsSupported")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensor.IsSupported A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + public void IsSupported_PROPERTY_READ_ONLY() + { + /* TESTCODE */ + bool ret = AutoRotationSensor.IsSupported; + Assert.IsNotNull(ret, "IsSupported value returned is null"); + Assert.True((ret == support), "IsSupported value returned is different from capability"); + } + + [Test] + [Category("P1")] + [Description("Check the return type and value of AutoRotationSensor.Rotation")] + [Property("SPEC", "Tizen.Sensor.AutoRotationSensor.Rotation A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Muhong Byun, mh.byun@samsung.com")] + public void Rotation_PROPERTY_READ_ONLY() + { + /* + * PRECONDITION + * 1. AutoRotationSensor should be available + * 2. Sensor PausePolicy set All. + */ + try + { + var sensor = new AutoRotationSensor(); + sensor.PausePolicy = SensorPausePolicy.All; + + /* TESTCODE */ + object ret = sensor.Rotation; + Assert.IsNotNull(ret, "AutoRotationSensor.Rotation is null"); + Assert.True((ret is AutoRotationState), "Rotation value returned is not of type AutoRotationState"); + + /* POST CONDITION */ + sensor.PausePolicy = SensorPausePolicy.None; + sensor.Dispose(); + } + catch (Exception e) + { + if (!support) + Assert.IsInstanceOf(e, "NotSupportedException should be thrown for not supported sensor"); + else + Assert.True(false, "should not throw exception(" + e.Message + ")"); + } + } + } +} + diff --git a/tct-suite-vs/Tizen.Sensor.Tests/testcase/TSSensor.cs b/tct-suite-vs/Tizen.Sensor.Tests/testcase/TSSensor.cs index e775e8c..80410db 100755 --- a/tct-suite-vs/Tizen.Sensor.Tests/testcase/TSSensor.cs +++ b/tct-suite-vs/Tizen.Sensor.Tests/testcase/TSSensor.cs @@ -60,6 +60,8 @@ namespace Tizen.Sensor.Tests sensors.Add(new UltravioletSensor(0)); if (GravitySensor.IsSupported) sensors.Add(new GravitySensor(0)); + if (AutoRotationSensor.IsSupported) + sensors.Add(new AutoRotationSensor(0)); } [OneTimeTearDown] -- 2.7.4