4527fa89dcbe4d34b285178fe2aaf914aa49fcc0
[test/tct/csharp/api.git] /
1 using System;
2 using System.Threading.Tasks;
3 using NUnit.Framework;
4
5 namespace Tizen.Sensor.Tests
6 {
7     [TestFixture]
8     [Description("Testing Tizen.Sensor.MagnetometerRotationVectorSensorDataUpdatedEventArgs class")]
9     public static class MagnetometerRotationVectorSensorDataUpdatedEventArgsTests
10     {
11         private static bool _support = false;
12
13         [OneTimeSetUp]
14         public static void Init()
15         {
16             _support = TSSensorHelper.CheckCapability("http://tizen.org/feature/sensor.geomagnetic_rotation_vector");
17         }
18
19         [Test]
20         [Category("P1")]
21         [Description("Check accuracy when MagnetometerRotationVectorSensorDataUpdated event is triggered")]
22         [Property("SPEC", "Tizen.Sensor.MagnetometerRotationVectorSensorDataUpdatedEventArgs.Accuracy A")]
23         [Property("SPEC_URL", "-")]
24         [Property("CRITERIA", "PRO")]
25         [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")]
26         [Precondition(1, "MagnetometerRotationVectorSensor sensor should be available")]
27         [Step(1, "Tap the Run button")]
28         [Step(2, "MagnetometerRotationVectorSensor sensor data update event: Rotate the test device")]
29         public static async Task Accuracy_PROPERTY_READ_ONLY()
30         {
31             try
32             {
33                 var sensor = new MagnetometerRotationVectorSensor(0);
34                 sensor.Interval = 100;
35                 SensorDataAccuracy getValue = sensor.Accuracy;
36
37                 EventHandler<MagnetometerRotationVectorSensorDataUpdatedEventArgs> handler = null;
38                 handler = (sender, e) =>
39                 {
40                     /* TESTCODE */
41                     Assert.IsInstanceOf<SensorDataAccuracy>(e.Accuracy, "Accuracy value should be of type SensorDataAccuracy");
42                     Assert.IsTrue(e.Accuracy != getValue, "Accuracy value should be changed.");
43                     ManualTest.Confirm();
44                 };
45
46                 sensor.DataUpdated += handler;
47                 sensor.Start();
48
49                 await ManualTest.WaitForConfirm();
50
51                 sensor.Stop();
52                 sensor.DataUpdated -= handler;
53                 sensor.Dispose();
54             }
55             catch (NotSupportedException)
56             {
57                 Assert.IsTrue(_support == false, "Invalid NotSupportedException");
58                 TSSensorHelper.DisplayLabel("MagnetometerRotationVectorSensor");
59                 await ManualTest.WaitForConfirm();
60             }
61             catch (Exception e)
62             {
63                 Assert.True(false, "should not throw exception(" + e.Message + ")");
64             }
65         }
66
67         [Test]
68         [Category("P1")]
69         [Description("Check w when MagnetometerRotationVectorSensorDataUpdated event is triggered")]
70         [Property("SPEC", "Tizen.Sensor.MagnetometerRotationVectorSensorDataUpdatedEventArgs.W A")]
71         [Property("SPEC_URL", "-")]
72         [Property("CRITERIA", "PRO")]
73         [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")]
74         [Precondition(1, "MagnetometerRotationVectorSensor sensor should be available")]
75         [Step(1, "Tap the Run button")]
76         [Step(2, "MagnetometerRotationVectorSensor sensor data update event: Rotate the test device")]
77         public static async Task W_PROPERTY_READ_ONLY()
78         {
79             try
80             {
81                 var sensor = new MagnetometerRotationVectorSensor(0);
82                 sensor.Interval = 100;
83                 float getValue = sensor.W;
84
85                 EventHandler<MagnetometerRotationVectorSensorDataUpdatedEventArgs> handler = null;
86                 handler = (sender, e) =>
87                 {
88                     /* TESTCODE */
89                     Assert.IsInstanceOf<float>(e.W, "W value should be of type float");
90                     Assert.IsTrue(e.W != getValue, "W value should be changed.");
91                     ManualTest.Confirm();
92                 };
93
94                 sensor.DataUpdated += handler;
95                 sensor.Start();
96
97                 await ManualTest.WaitForConfirm();
98
99                 sensor.Stop();
100                 sensor.DataUpdated -= handler;
101                 sensor.Dispose();
102             }
103             catch (NotSupportedException)
104             {
105                 Assert.IsTrue(_support == false, "Invalid NotSupportedException");
106                 TSSensorHelper.DisplayLabel("MagnetometerRotationVectorSensor");
107                 await ManualTest.WaitForConfirm();
108             }
109             catch (Exception e)
110             {
111                 Assert.True(false, "should not throw exception(" + e.Message + ")");
112             }
113         }
114
115         [Test]
116         [Category("P1")]
117         [Description("Check x when MagnetometerRotationVectorSensorDataUpdated event is triggered")]
118         [Property("SPEC", "Tizen.Sensor.MagnetometerRotationVectorSensorDataUpdatedEventArgs.X A")]
119         [Property("SPEC_URL", "-")]
120         [Property("CRITERIA", "PRO")]
121         [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")]
122         [Precondition(1, "MagnetometerRotationVectorSensor sensor should be available")]
123         [Step(1, "Tap the Run button")]
124         [Step(2, "MagnetometerRotationVectorSensor sensor data update event: Rotate the test device")]
125         public static async Task X_PROPERTY_READ_ONLY()
126         {
127             try
128             {
129                 var sensor = new MagnetometerRotationVectorSensor(0);
130                 sensor.Interval = 100;
131                 float getValue = sensor.X;
132
133                 EventHandler<MagnetometerRotationVectorSensorDataUpdatedEventArgs> handler = null;
134                 handler = (sender, e) =>
135                 {
136                     /* TESTCODE */
137                     Assert.IsInstanceOf<float>(e.X, "X value should be of type float");
138                     Assert.IsTrue(e.X != getValue, "X value should be changed.");
139                     ManualTest.Confirm();
140                 };
141
142                 sensor.DataUpdated += handler;
143                 sensor.Start();
144
145                 await ManualTest.WaitForConfirm();
146
147                 sensor.Stop();
148                 sensor.DataUpdated -= handler;
149                 sensor.Dispose();
150             }
151             catch (NotSupportedException)
152             {
153                 Assert.IsTrue(_support == false, "Invalid NotSupportedException");
154                 TSSensorHelper.DisplayLabel("MagnetometerRotationVectorSensor");
155                 await ManualTest.WaitForConfirm();
156             }
157             catch (Exception e)
158             {
159                 Assert.True(false, "should not throw exception(" + e.Message + ")");
160             }
161         }
162
163         [Test]
164         [Category("P1")]
165         [Description("Check y when MagnetometerRotationVectorSensorDataUpdated event is triggered")]
166         [Property("SPEC", "Tizen.Sensor.MagnetometerRotationVectorSensorDataUpdatedEventArgs.Y A")]
167         [Property("SPEC_URL", "-")]
168         [Property("CRITERIA", "PRO")]
169         [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")]
170         [Precondition(1, "MagnetometerRotationVectorSensor sensor should be available")]
171         [Step(1, "Tap the Run button")]
172         [Step(2, "MagnetometerRotationVectorSensor sensor data update event: Rotate the test device")]
173         public static async Task Y_PROPERTY_READ_ONLY()
174         {
175             try
176             {
177                 var sensor = new MagnetometerRotationVectorSensor(0);
178                 sensor.Interval = 100;
179                 float getValue = sensor.Y;
180
181                 EventHandler<MagnetometerRotationVectorSensorDataUpdatedEventArgs> handler = null;
182                 handler = (sender, e) =>
183                 {
184                     /* TESTCODE */
185                     Assert.IsInstanceOf<float>(e.Y, "Y value should be of type float");
186                     Assert.IsTrue(e.Y != getValue, "Y value should be changed.");
187                     ManualTest.Confirm();
188                 };
189
190                 sensor.DataUpdated += handler;
191                 sensor.Start();
192
193                 await ManualTest.WaitForConfirm();
194
195                 sensor.Stop();
196                 sensor.DataUpdated -= handler;
197                 sensor.Dispose();
198             }
199             catch (NotSupportedException)
200             {
201                 Assert.IsTrue(_support == false, "Invalid NotSupportedException");
202                 TSSensorHelper.DisplayLabel("MagnetometerRotationVectorSensor");
203                 await ManualTest.WaitForConfirm();
204             }
205             catch (Exception e)
206             {
207                 Assert.True(false, "should not throw exception(" + e.Message + ")");
208             }
209         }
210
211         [Test]
212         [Category("P1")]
213         [Description("Check z when MagnetometerRotationVectorSensorDataUpdated event is triggered")]
214         [Property("SPEC", "Tizen.Sensor.MagnetometerRotationVectorSensorDataUpdatedEventArgs.Z A")]
215         [Property("SPEC_URL", "-")]
216         [Property("CRITERIA", "PRO")]
217         [Property("AUTHOR", "Ankur Garg, ankur29.garg@samsung.com")]
218         [Precondition(1, "MagnetometerRotationVectorSensor sensor should be available")]
219         [Step(1, "Tap the Run button")]
220         [Step(2, "MagnetometerRotationVectorSensor sensor data update event: Rotate the test device")]
221         public static async Task Z_PROPERTY_READ_ONLY()
222         {
223             try
224             {
225                 var sensor = new MagnetometerRotationVectorSensor(0);
226                 sensor.Interval = 100;
227                 float getValue = sensor.Z;
228
229                 EventHandler<MagnetometerRotationVectorSensorDataUpdatedEventArgs> handler = null;
230                 handler = (sender, e) =>
231                 {
232                     /* TESTCODE */
233                     Assert.IsInstanceOf<float>(e.Z, "Z value should be of type float");
234                     Assert.IsTrue(e.Z != getValue, "Z value should be changed.");
235                     ManualTest.Confirm();
236                 };
237
238                 sensor.DataUpdated += handler;
239                 sensor.Start();
240
241                 await ManualTest.WaitForConfirm();
242
243                 sensor.Stop();
244                 sensor.DataUpdated -= handler;
245                 sensor.Dispose();
246             }
247             catch (NotSupportedException)
248             {
249                 Assert.IsTrue(_support == false, "Invalid NotSupportedException");
250                 TSSensorHelper.DisplayLabel("MagnetometerRotationVectorSensor");
251                 await ManualTest.WaitForConfirm();
252             }
253             catch (Exception e)
254             {
255                 Assert.True(false, "should not throw exception(" + e.Message + ")");
256             }
257         }
258     }
259 }
260
261