|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package com.nokia.mj.test.lapi; |
|
18 |
|
19 import j2meunit.framework.*; |
|
20 import javax.microedition.location.*; |
|
21 |
|
22 /** |
|
23 * <b>TEST CASE SPECIFICATION</b> |
|
24 * |
|
25 * This suite of testcases tests that: - OrientationTest object can be created - |
|
26 * Default values are correct - |
|
27 * |
|
28 * |
|
29 * @created 2008-07-20 |
|
30 * |
|
31 */ |
|
32 |
|
33 public class OrientationTest extends TestCase |
|
34 { |
|
35 |
|
36 public OrientationTest() |
|
37 { |
|
38 } |
|
39 |
|
40 public OrientationTest(String sTestName, TestMethod rTestMethod) |
|
41 { |
|
42 super(sTestName, rTestMethod); |
|
43 } |
|
44 |
|
45 /** |
|
46 * |
|
47 * /*************************************** Creates the test suite. You need |
|
48 * to add a new aSuite.addTest antry for any new test methods, otherwise |
|
49 * they won't be run. |
|
50 */ |
|
51 public Test suite() |
|
52 { |
|
53 TestSuite aSuite = new TestSuite(); |
|
54 |
|
55 aSuite.addTest(new OrientationTest("testAzimuthData", new TestMethod() |
|
56 { |
|
57 public void run(TestCase tc) |
|
58 { |
|
59 ((OrientationTest) tc).testAzimuthData(); |
|
60 } |
|
61 })); |
|
62 |
|
63 aSuite.addTest(new OrientationTest("testPitchData", new TestMethod() |
|
64 { |
|
65 public void run(TestCase tc) |
|
66 { |
|
67 ((OrientationTest) tc).testPitchData(); |
|
68 } |
|
69 })); |
|
70 |
|
71 aSuite.addTest(new OrientationTest("testRollData", new TestMethod() |
|
72 { |
|
73 public void run(TestCase tc) |
|
74 { |
|
75 ((OrientationTest) tc).testRollData(); |
|
76 } |
|
77 })); |
|
78 |
|
79 aSuite.addTest(new OrientationTest("testIsOrientationMagneticData", |
|
80 new TestMethod() |
|
81 { |
|
82 public void run(TestCase tc) |
|
83 { |
|
84 ((OrientationTest) tc).testIsOrientationMagneticData(); |
|
85 } |
|
86 })); |
|
87 |
|
88 return aSuite; |
|
89 } |
|
90 |
|
91 // Test Azimuth Data |
|
92 public void testAzimuthData() |
|
93 { |
|
94 |
|
95 try |
|
96 { |
|
97 Orientation orientation = Orientation.getOrientation(); |
|
98 |
|
99 if (orientation != null) |
|
100 { |
|
101 float Azimuth = orientation.getCompassAzimuth(); |
|
102 |
|
103 if (!((Azimuth <= 360.0f) && (Azimuth >= 0.0f))) |
|
104 { |
|
105 assertTrue("Azimuth is out of range(0,360)", false); |
|
106 } |
|
107 |
|
108 } |
|
109 else |
|
110 { |
|
111 assertTrue("orientation can’t be currently determined", true); |
|
112 } |
|
113 assertTrue("", true); |
|
114 } |
|
115 catch (LocationException e) |
|
116 { |
|
117 assertTrue("Implmentation doesn't support Orientation", true); |
|
118 } |
|
119 catch (SecurityException e) |
|
120 { |
|
121 assertTrue("Calling application doesn't have the permission to" |
|
122 + "query Orientation Data", true); |
|
123 } |
|
124 } |
|
125 |
|
126 // Test Pitch Data |
|
127 public void testPitchData() |
|
128 { |
|
129 |
|
130 try |
|
131 { |
|
132 Orientation orientation = Orientation.getOrientation(); |
|
133 |
|
134 if (orientation != null) |
|
135 { |
|
136 float Pitch = orientation.getPitch(); |
|
137 |
|
138 if (!(((Pitch <= 90.0f) && (Pitch >= -90.0f)) || Float |
|
139 .isNaN(Pitch))) |
|
140 { |
|
141 assertTrue("Pitch is out of range(90,-90)", false); |
|
142 } |
|
143 } |
|
144 else |
|
145 { |
|
146 assertTrue("orientation can’t be currently determined", true); |
|
147 } |
|
148 |
|
149 assertTrue("", true); |
|
150 } |
|
151 catch (LocationException e) |
|
152 { |
|
153 assertTrue("Implmentation doesn't support Orientation", true); |
|
154 } |
|
155 catch (SecurityException e) |
|
156 { |
|
157 assertTrue("Calling application doesn't have the permission to" |
|
158 + "query Orientation Data", true); |
|
159 } |
|
160 } |
|
161 |
|
162 // Test Roll Data |
|
163 public void testRollData() |
|
164 { |
|
165 |
|
166 try |
|
167 { |
|
168 Orientation orientation = Orientation.getOrientation(); |
|
169 |
|
170 if (orientation != null) |
|
171 { |
|
172 float Roll = orientation.getRoll(); |
|
173 |
|
174 if (!(((Roll <= 180.0f) && (Roll >= -180.0f)) || Float |
|
175 .isNaN(Roll))) |
|
176 { |
|
177 assertTrue("Roll is out of range(180,-180)", false); |
|
178 } |
|
179 } |
|
180 else |
|
181 { |
|
182 assertTrue("orientation can’t be currently determined", true); |
|
183 } |
|
184 |
|
185 assertTrue("", true); |
|
186 } |
|
187 catch (LocationException e) |
|
188 { |
|
189 assertTrue("Implmentation doesn't support Orientation", true); |
|
190 } |
|
191 catch (SecurityException e) |
|
192 { |
|
193 assertTrue("Calling application doesn't have the permission to" |
|
194 + "query Orientation Data", true); |
|
195 } |
|
196 } |
|
197 |
|
198 // Test Orientation data is w.r.t Magnetic Data or True North Data |
|
199 public void testIsOrientationMagneticData() |
|
200 { |
|
201 |
|
202 try |
|
203 { |
|
204 Orientation orientation = Orientation.getOrientation(); |
|
205 |
|
206 if (orientation != null) |
|
207 { |
|
208 boolean IsMagnetic = orientation.isOrientationMagnetic(); |
|
209 |
|
210 if (!IsMagnetic) |
|
211 { |
|
212 assertTrue("IsMagnertic Data is wrong", false); |
|
213 } |
|
214 } |
|
215 else |
|
216 { |
|
217 assertTrue("orientation can’t be currently determined", true); |
|
218 } |
|
219 |
|
220 assertTrue("", true); |
|
221 } |
|
222 catch (LocationException e) |
|
223 { |
|
224 assertTrue("Implmentation doesn't support Orientation", true); |
|
225 } |
|
226 catch (SecurityException e) |
|
227 { |
|
228 assertTrue("Calling application doesn't have the permission to" |
|
229 + "query Orientation Data", true); |
|
230 } |
|
231 } |
|
232 } |