* 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 <mh.byun@samsung.com>
--- /dev/null
+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<AutoRotationSensorDataUpdatedEventArgs> 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<SensorAccuracyChangedEventArgs> 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 + ")");
+ }
+ }
+ }
+}
+
--- /dev/null
+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<AutoRotationSensorDataUpdatedEventArgs> handler = null;
+ handler = (sender, e) =>
+ {
+ /* TESTCODE */
+ Assert.IsInstanceOf<SensorDataAccuracy>(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<AutoRotationSensorDataUpdatedEventArgs> handler = null;
+ handler = (sender, e) =>
+ {
+ /* TESTCODE */
+ Assert.IsNotNull(e, "AutoRotationSensor Event should not be null");
+ Assert.IsInstanceOf<AutoRotationState>(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 + ")");
+ }
+ }
+ }
+}
--- /dev/null
+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<bool>(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<AutoRotationSensor>(obj, "Object's type should be AutoRotationSensor.");
+
+ /* POST CONDITION */
+ obj.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (!support)
+ Assert.IsInstanceOf<NotSupportedException>(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<NotSupportedException>(() => { 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<NotSupportedException>(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<NotSupportedException>(e, "NotSupportedException should be thrown for not supported sensor");
+ else
+ Assert.True(false, "should not throw exception(" + e.Message + ")");
+ }
+ }
+ }
+}
+
sensors.Add(new UltravioletSensor(0));
if (GravitySensor.IsSupported)
sensors.Add(new GravitySensor(0));
+ if (AutoRotationSensor.IsSupported)
+ sensors.Add(new AutoRotationSensor(0));
}
[OneTimeTearDown]