mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
fixes for location and local-settings tests
This commit is contained in:
@ -78,8 +78,9 @@ export var testDefaults = function () {
|
||||
// ```
|
||||
// </snippet>
|
||||
TKUnit.assert("undefined" === typeof defaultValue, "Default string value is not undefined");
|
||||
TKUnit.assert("undefined" === LocalSettings.getBoolean(noBoolKey), "Default boolean value is not undefined");
|
||||
TKUnit.assert("undefined" === LocalSettings.getNumber(noNumberKey), "Default number value is not undefined");
|
||||
|
||||
TKUnit.assert("undefined" === typeof LocalSettings.getBoolean(noBoolKey), "Default boolean value is not undefined");
|
||||
TKUnit.assert("undefined" === typeof LocalSettings.getNumber(noNumberKey), "Default number value is not undefined");
|
||||
};
|
||||
|
||||
// <snippet name="local-settings">
|
||||
|
@ -121,7 +121,7 @@ export var testLocationOnceTimeout0 = function () {
|
||||
|
||||
export var testLocationOnceMaximumAge = function () {
|
||||
TKUnit.waitUntilReady(function () { return false; }, 2);
|
||||
doOnce({ maximumAge: 3000, timeout: 0 }); // this should pass
|
||||
doOnce({ maximumAge: 20000, timeout: 0 }); // this should pass
|
||||
try {
|
||||
doOnce({ maximumAge: 1000, timeout: 0 });
|
||||
TKUnit.assert(false, "maximumAge check failed");
|
||||
@ -130,8 +130,8 @@ export var testLocationOnceMaximumAge = function () {
|
||||
}
|
||||
};
|
||||
|
||||
export var testLocationOnceTimeout1000 = function () {
|
||||
doOnce({ timeout: 1000 });
|
||||
export var testLocationOnceTimeout10000 = function () {
|
||||
doOnce({ timeout: 10000 });
|
||||
};
|
||||
|
||||
export var testSnippet = function () {
|
||||
|
@ -54,7 +54,7 @@ export class LocationManager {
|
||||
|
||||
public static isEnabled(): boolean {
|
||||
var criteria = new android.location.Criteria();
|
||||
criteria.setAccuracy(1); // low ? fine ? who knows what 1 means (bug in android docs?)
|
||||
criteria.setAccuracy(android.location.Criteria.ACCURACY_COARSE);
|
||||
var lm = appModule.android.context.getSystemService(android.content.Context.LOCATION_SERVICE);
|
||||
return (lm.getBestProvider(criteria, true) != null) ? true : false;
|
||||
}
|
||||
@ -71,7 +71,7 @@ export class LocationManager {
|
||||
|
||||
constructor() {
|
||||
// put some defaults
|
||||
this.desiredAccuracy = types.Accuracy.HIGH;
|
||||
this.desiredAccuracy = types.Accuracy.ANY;
|
||||
this.updateDistance = 0;
|
||||
this.minimumUpdateTime = 200;
|
||||
this.isStarted = false;
|
||||
@ -86,7 +86,7 @@ export class LocationManager {
|
||||
public startLocationMonitoring(onLocation: (location: types.Location) => any, onError?: (error: Error) => any, options?: types.Options) {
|
||||
if (!this.isStarted) {
|
||||
var criteria = new android.location.Criteria();
|
||||
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? 1 : 2);
|
||||
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? android.location.Criteria.ACCURACY_FINE : android.location.Criteria.ACCURACY_COARSE);
|
||||
this.locationListener = <any>new android.location.LocationListener({
|
||||
onLocationChanged: function (location1: android.location.Location) {
|
||||
if (this._onLocation) {
|
||||
@ -153,7 +153,7 @@ export class LocationManager {
|
||||
|
||||
get lastKnownLocation(): types.Location {
|
||||
var criteria = new android.location.Criteria();
|
||||
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? 1 : 2);
|
||||
criteria.setAccuracy((this.desiredAccuracy === types.Accuracy.HIGH) ? android.location.Criteria.ACCURACY_FINE : android.location.Criteria.ACCURACY_COARSE);
|
||||
try {
|
||||
var providers = this.androidLocationManager.getProviders(criteria, false);
|
||||
var it = providers.iterator();
|
||||
|
@ -61,7 +61,7 @@ export class LocationManager {
|
||||
|
||||
constructor() {
|
||||
this.isStarted = false;
|
||||
this.desiredAccuracy = types.Accuracy.HIGH;
|
||||
this.desiredAccuracy = types.Accuracy.ANY;
|
||||
this.updateDistance = -1; // kCLDistanceFilterNone
|
||||
this.iosLocationManager = new CoreLocation.CLLocationManager();
|
||||
}
|
||||
|
Reference in New Issue
Block a user