Skip to content

Commit f3446e4

Browse files
author
Stanimir Karoserov
committed
fixes for location and local-settings tests
1 parent 641d4b4 commit f3446e4

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

Tests/local-settings-tests.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ export var testDefaults = function () {
7878
// ```
7979
// </snippet>
8080
TKUnit.assert("undefined" === typeof defaultValue, "Default string value is not undefined");
81-
TKUnit.assert("undefined" === LocalSettings.getBoolean(noBoolKey), "Default boolean value is not undefined");
82-
TKUnit.assert("undefined" === LocalSettings.getNumber(noNumberKey), "Default number value is not undefined");
81+
82+
TKUnit.assert("undefined" === typeof LocalSettings.getBoolean(noBoolKey), "Default boolean value is not undefined");
83+
TKUnit.assert("undefined" === typeof LocalSettings.getNumber(noNumberKey), "Default number value is not undefined");
8384
};
8485

8586
// <snippet name="local-settings">

Tests/location-tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export var testLocationOnceTimeout0 = function () {
121121

122122
export var testLocationOnceMaximumAge = function () {
123123
TKUnit.waitUntilReady(function () { return false; }, 2);
124-
doOnce({ maximumAge: 3000, timeout: 0 }); // this should pass
124+
doOnce({ maximumAge: 20000, timeout: 0 }); // this should pass
125125
try {
126126
doOnce({ maximumAge: 1000, timeout: 0 });
127127
TKUnit.assert(false, "maximumAge check failed");
@@ -130,8 +130,8 @@ export var testLocationOnceMaximumAge = function () {
130130
}
131131
};
132132

133-
export var testLocationOnceTimeout1000 = function () {
134-
doOnce({ timeout: 1000 });
133+
export var testLocationOnceTimeout10000 = function () {
134+
doOnce({ timeout: 10000 });
135135
};
136136

137137
export var testSnippet = function () {

location/location-manager.android.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class LocationManager {
5454

5555
public static isEnabled(): boolean {
5656
var criteria = new android.location.Criteria();
57-
criteria.setAccuracy(1); // low ? fine ? who knows what 1 means (bug in android docs?)
57+
criteria.setAccuracy(android.location.Criteria.ACCURACY_COARSE);
5858
var lm = appModule.android.context.getSystemService(android.content.Context.LOCATION_SERVICE);
5959
return (lm.getBestProvider(criteria, true) != null) ? true : false;
6060
}
@@ -71,7 +71,7 @@ export class LocationManager {
7171

7272
constructor() {
7373
// put some defaults
74-
this.desiredAccuracy = types.Accuracy.HIGH;
74+
this.desiredAccuracy = types.Accuracy.ANY;
7575
this.updateDistance = 0;
7676
this.minimumUpdateTime = 200;
7777
this.isStarted = false;
@@ -86,7 +86,7 @@ export class LocationManager {
8686
public startLocationMonitoring(onLocation: (location: types.Location) => any, onError?: (error: Error) => any, options?: types.Options) {
8787
if (!this.isStarted) {
8888
var criteria = new android.location.Criteria();
89-
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? 1 : 2);
89+
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? android.location.Criteria.ACCURACY_FINE : android.location.Criteria.ACCURACY_COARSE);
9090
this.locationListener = <any>new android.location.LocationListener({
9191
onLocationChanged: function (location1: android.location.Location) {
9292
if (this._onLocation) {
@@ -153,7 +153,7 @@ export class LocationManager {
153153

154154
get lastKnownLocation(): types.Location {
155155
var criteria = new android.location.Criteria();
156-
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? 1 : 2);
156+
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? android.location.Criteria.ACCURACY_FINE : android.location.Criteria.ACCURACY_COARSE);
157157
try {
158158
var providers = this.androidLocationManager.getProviders(criteria, false);
159159
var it = providers.iterator();

location/location-manager.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class LocationManager {
6161

6262
constructor() {
6363
this.isStarted = false;
64-
this.desiredAccuracy = types.Accuracy.HIGH;
64+
this.desiredAccuracy = types.Accuracy.ANY;
6565
this.updateDistance = -1; // kCLDistanceFilterNone
6666
this.iosLocationManager = new CoreLocation.CLLocationManager();
6767
}

0 commit comments

Comments
 (0)