19
19
*
20
20
*/
21
21
22
- /* global cordova, Windows */
23
-
24
22
exports . defineAutoTests = function ( ) {
25
- const isWindows = cordova . platformId === 'windows' ;
26
- // Checking existence of accelerometer for windows platform
27
- // Assumed that accelerometer always exists on other platforms. Extend
28
- // condition to support accelerometer check on other platforms
29
- let isAccelExist = isWindows ? Windows . Devices . Sensors . Accelerometer . getDefault ( ) !== null : true ;
30
-
31
23
describe ( 'Accelerometer (navigator.accelerometer)' , function ( ) {
32
24
const fail = function ( done ) {
33
25
expect ( true ) . toBe ( false ) ;
@@ -53,10 +45,6 @@ exports.defineAutoTests = function () {
53
45
} ) ;
54
46
55
47
it ( 'accelerometer.spec.3 success callback should be called with an Acceleration object' , function ( done ) {
56
- // skip the test if Accelerometer doesn't exist on this device
57
- if ( ! isAccelExist ) {
58
- pending ( ) ;
59
- }
60
48
const win = function ( a ) {
61
49
expect ( a ) . toBeDefined ( ) ;
62
50
expect ( a . x ) . toBeDefined ( ) ;
@@ -73,7 +61,6 @@ exports.defineAutoTests = function () {
73
61
const onError = function ( err ) {
74
62
console . log ( err ) ;
75
63
console . log ( 'Skipping gyroscope tests, marking all as pending.' ) ;
76
- isAccelExist = false ;
77
64
expect ( true ) . toBe ( true ) ;
78
65
done ( ) ;
79
66
} ;
@@ -82,10 +69,6 @@ exports.defineAutoTests = function () {
82
69
} ) ;
83
70
84
71
it ( 'accelerometer.spec.4 success callback Acceleration object should have (reasonable) values for x, y and z expressed in m/s^2' , function ( done ) {
85
- // skip the test if Accelerometer doesn't exist on this device
86
- if ( ! isAccelExist ) {
87
- pending ( ) ;
88
- }
89
72
const reasonableThreshold = 15 ;
90
73
const win = function ( a ) {
91
74
expect ( a . x ) . toBeLessThan ( reasonableThreshold ) ;
@@ -101,10 +84,6 @@ exports.defineAutoTests = function () {
101
84
} ) ;
102
85
103
86
it ( 'accelerometer.spec.5 success callback Acceleration object should return a recent timestamp' , function ( done ) {
104
- // skip the test if Accelerometer doesn't exist on this device
105
- if ( ! isAccelExist ) {
106
- pending ( ) ;
107
- }
108
87
const veryRecently = new Date ( ) . getTime ( ) ;
109
88
// Need to check that dates returned are not vastly greater than a recent time stamp.
110
89
// In case the timestamps returned are ridiculously high
@@ -137,10 +116,6 @@ exports.defineAutoTests = function () {
137
116
} ) ;
138
117
139
118
it ( 'accelerometer.spec.7 success callback should be called with an Acceleration object' , function ( done ) {
140
- // skip the test if Accelerometer doesn't exist on this device
141
- if ( ! isAccelExist ) {
142
- pending ( ) ;
143
- }
144
119
const win = function ( a ) {
145
120
expect ( a ) . toBeDefined ( ) ;
146
121
expect ( a . x ) . toBeDefined ( ) ;
@@ -158,10 +133,6 @@ exports.defineAutoTests = function () {
158
133
} ) ;
159
134
160
135
it ( 'accelerometer.spec.8 success callback Acceleration object should have (reasonable) values for x, y and z expressed in m/s^2' , function ( done ) {
161
- // skip the test if Accelerometer doesn't exist on this device
162
- if ( ! isAccelExist ) {
163
- pending ( ) ;
164
- }
165
136
const reasonableThreshold = 15 ;
166
137
const win = function ( a ) {
167
138
expect ( a . x ) . toBeLessThan ( reasonableThreshold ) ;
@@ -177,10 +148,6 @@ exports.defineAutoTests = function () {
177
148
} ) ;
178
149
179
150
it ( 'accelerometer.spec.9 success callback Acceleration object should return a recent timestamp' , function ( done ) {
180
- // skip the test if Accelerometer doesn't exist on this device
181
- if ( ! isAccelExist ) {
182
- pending ( ) ;
183
- }
184
151
const veryRecently = new Date ( ) . getTime ( ) ;
185
152
// Need to check that dates returned are not vastly greater than a recent time stamp.
186
153
// In case the timestamps returned are ridiculously high
@@ -195,10 +162,6 @@ exports.defineAutoTests = function () {
195
162
} ) ;
196
163
197
164
it ( 'accelerometer.spec.12 success callback should be preserved and called several times' , function ( done ) {
198
- // skip the test if Accelerometer doesn't exist on this device
199
- if ( ! isAccelExist ) {
200
- pending ( ) ;
201
- }
202
165
let callbacksCallCount = 0 ;
203
166
const callbacksCallTestCount = 3 ;
204
167
@@ -221,11 +184,6 @@ exports.defineAutoTests = function () {
221
184
} ) ;
222
185
223
186
it ( 'accelerometer.spec.11 should clear an existing watch' , function ( done ) {
224
- // skip the test if Accelerometer doesn't exist on this device
225
- if ( ! isAccelExist ) {
226
- pending ( ) ;
227
- }
228
-
229
187
// expect win to get called exactly once
230
188
let win = function ( a ) {
231
189
// clear watch on first call
0 commit comments