From 3d9631bd00ef649586dd95d4596d85040bdd3709 Mon Sep 17 00:00:00 2001 From: Nedyalko Nikolov Date: Thu, 10 Nov 2016 15:32:36 +0200 Subject: [PATCH] Removed location tests and deprecated camera module. --- tests/app/location-tests.ts | 176 ---------------------- tests/app/location.md | 29 ---- tests/app/testRunner.ts | 3 - tns-core-modules/camera/Readme.md | 2 +- tns-core-modules/camera/camera.android.ts | 6 + tns-core-modules/camera/camera.d.ts | 8 +- tns-core-modules/camera/camera.ios.ts | 7 + tns-core-modules/location/Readme.md | 2 +- tns-core-modules/location/location.d.ts | 6 + 9 files changed, 26 insertions(+), 213 deletions(-) delete mode 100644 tests/app/location-tests.ts delete mode 100644 tests/app/location.md diff --git a/tests/app/location-tests.ts b/tests/app/location-tests.ts deleted file mode 100644 index b30f73e7a..000000000 --- a/tests/app/location-tests.ts +++ /dev/null @@ -1,176 +0,0 @@ -// >> location-require -import locationModule = require("location"); -// << location-require - -import TKUnit = require("./TKUnit"); - -var LocationManager = locationModule.LocationManager; -var Location = locationModule.Location; - -var locationIsEnabled: boolean; - -export function setUp() { - locationIsEnabled = LocationManager.isEnabled(); -} - -export function tearDown() { - locationIsEnabled = undefined; -} - -export var testIsEnabled = function () { - if (!locationIsEnabled) { - console.log("Location service is not enabled!!!"); - return; - } - // >> location-funcs - //var LocationManager = require("location").LocationManager; - var isEnabled = LocationManager.isEnabled(); - // << location-funcs - TKUnit.assert(isEnabled); -}; - -export var testDistance = function () { - // >> location-distance - //var Location = require("location").Location; - var locSofia = new Location(); - locSofia.longitude = 42.696552; - locSofia.latitude = 23.32601; - var locNewYork = new Location(); - locNewYork.longitude = 40.71448; - locNewYork.latitude = -74.00598; - var distance = LocationManager.distance(locSofia, locNewYork); - // << location-distance - TKUnit.assert((distance > 10780000) && (distance < 10860000), "invalid distance " + distance); -}; - -export var testLocation = function (done) { - if (!locationIsEnabled) { - done(null); - } - - var locationReceived; - - // >> location-updates - //var LocationManager = require("location").LocationManager; - var locationManager = new LocationManager(); - - locationManager.startLocationMonitoring(function (location) { - //console.log('Location received: ' + JSON.stringify(location)); - // >> (hide) - locationReceived = true; - locationManager.stopLocationMonitoring(); - try { - TKUnit.assert(true === locationReceived, locationReceived); - done(null); - } - catch (e) { - done(e); - } - // << (hide) - }, function (error) { - //console.log('Location error received: ' + error); - // >> (hide) - locationReceived = error; - locationManager.stopLocationMonitoring(); - done(error); - // << (hide) - } - ); - - // << location-updates - //var isReady = function () { - // return locationReceived; - //} - - //TKUnit.waitUntilReady(isReady, 10); - - //TKUnit.assert(true === locationReceived, locationReceived); -}; - -export var testLastKnownLocation = function () { - if (!locationIsEnabled) { - return; - } - - TKUnit.waitUntilReady(function () { return false; }, 1); // give it some time after the last test - // >> location-last-known - // var LocationManager = require("location").LocationManager; - var locationManager = new LocationManager(); - var lastKnownLocation = locationManager.lastKnownLocation; - // << location-last-known - TKUnit.assert((lastKnownLocation != null), "There is no last known location"); -}; - -function doOnce(options: locationModule.Options, done) { - if (!locationIsEnabled) { - return done(null); - } - var locationReceived; - locationModule.getLocation(options).then(function (location) { - locationReceived = true; - try { - TKUnit.assert(true === locationReceived, locationReceived); - done(null); - } - catch (e) { - done(e); - } - }, function (error) { - locationReceived = error; - done(error); - }); -} - -export var testLocationOnce = function (done) { - doOnce(undefined, done); -}; - -export var testLocationOnceTimeout0 = function (done) { - doOnce({ timeout: 0 }, done); -}; - -export var testLocationOnceMaximumAge = function (done) { - if (!locationIsEnabled) { - return done(null); - } - TKUnit.waitUntilReady(function () { return false; }, 2); - doOnce({ maximumAge: 86400000, timeout: 0 }, done); // this should pass max age denotes that Real location is taken today. - doOnce({ maximumAge: 1000, timeout: 0 }, (err) => { - if (err && err.message === "timeout is 0 and last known location is older than maximumAge") { - // since last known location is taken before 1 sec (what is the meaning of the maximumAge: 1000 value) - // we consider this as a successful test since we test that maxAge check is working - done(null); - } - else { - done(new Error("maximumAge check failed")); - } - }); -}; - -export var testLocationOnceTimeout10000 = function (done) { - doOnce({ timeout: 10000 }, done); -}; - -export var testSnippet = function (done) { - if (!locationIsEnabled) { - return done(null); - } - var locationReceived; - // >> location-timeour - // var locationModule = require("location"); - //// options can also look like { maximumAge: 2000, timeout: 20 * 1000 } - locationModule.getLocation({ maximumAge: 30000, timeout: 5000 }).then(function (location) { - //console.log('Location received: ' + location); - // >> (hide) - locationReceived = true; - done(null); - // << (hide) - }, function (error) { - //console.log('Location error received: ' + error); - // >> (hide) - locationReceived = error; - done(error); - // << (hide) - }); - // << location-timeour -}; diff --git a/tests/app/location.md b/tests/app/location.md deleted file mode 100644 index 42af0294b..000000000 --- a/tests/app/location.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -nav-title: "location How-To" -title: "location" -environment: nativescript -description: "Examples for using location" -previous_url: /ApiReference/location/HOW-TO ---- -# Location -Using the location requires the Location module. -{%snippet location-require%} - -## Other functions -### Test are location services available for this device -{%snippet location-funcs%} - -### Get distance between two locations -{%snippet location-distance%} - -## Getting location -### Receive continuous location updates -{%snippet location-updates%} - -### Get last known location -{%snippet location-last-known%} - -### Get location once -if there is `options.timeout` you will receive error on timeout. If `options.timeout` is 0 then the result is the same as the result from `LocationManager.lastKnownLocation` -and there will be no wait. You can use `options.maximumAge` to specify you don't want to receive locations older than specified time in ms. -{%snippet location-timeour%} diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index 771ce5fa7..80127e8e1 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -28,9 +28,6 @@ export function isRunningOnEmulator(): boolean { } export var allTests = {}; -if (!isRunningOnEmulator()) { - allTests["LOCATION"] = require("./location-tests"); -} allTests["PLATFORM"] = require("./platform-tests"); allTests["FILE SYSTEM"] = require("./file-system-tests"); diff --git a/tns-core-modules/camera/Readme.md b/tns-core-modules/camera/Readme.md index da4bfc8ed..670d2e842 100644 --- a/tns-core-modules/camera/Readme.md +++ b/tns-core-modules/camera/Readme.md @@ -1 +1 @@ -Allows you to take pictures with the device's camera. +Deprecated. Please use same functionality from `nativescript-camera` npm module. diff --git a/tns-core-modules/camera/camera.android.ts b/tns-core-modules/camera/camera.android.ts index 96e1306d1..05acb1f7b 100644 --- a/tns-core-modules/camera/camera.android.ts +++ b/tns-core-modules/camera/camera.android.ts @@ -7,6 +7,9 @@ import * as platform from "platform"; var REQUEST_IMAGE_CAPTURE = 3453; +/** + * [Deprecated. Please use same functionality from `nativescript-camera` npm module] + */ export var takePicture = function (options?): Promise { return new Promise((resolve, reject) => { try { @@ -96,6 +99,9 @@ export var takePicture = function (options?): Promise { }); } +/** + * [Deprecated. Please use same functionality from `nativescript-camera` npm module] + */ export var isAvailable = function () { var utils: typeof utilsModule = require("utils/utils"); diff --git a/tns-core-modules/camera/camera.d.ts b/tns-core-modules/camera/camera.d.ts index 2e032eba0..adc4ca917 100644 --- a/tns-core-modules/camera/camera.d.ts +++ b/tns-core-modules/camera/camera.d.ts @@ -6,16 +6,18 @@ declare module "camera" { import imageSource = require("image-source"); /** - * Take a photo using the camera. - * @param options - Optional parameter for setting different camera options. + * [Deprecated. Please use same functionality from `nativescript-camera` npm module] */ export function takePicture(options?: CameraOptions): Promise; /** - * Is the camera available to use + * [Deprecated. Please use same functionality from `nativescript-camera` npm module] */ export function isAvailable(): Boolean; + /** + * [Deprecated. Please use same functionality from `nativescript-camera` npm module] + */ export interface CameraOptions { /** * Defines the desired width (in device independent pixels) of the taken image. It should be used with height property. diff --git a/tns-core-modules/camera/camera.ios.ts b/tns-core-modules/camera/camera.ios.ts index 4976ae6a8..c76e927bd 100644 --- a/tns-core-modules/camera/camera.ios.ts +++ b/tns-core-modules/camera/camera.ios.ts @@ -3,6 +3,7 @@ import * as cameraCommonModule from "./camera-common"; import * as imageSourceModule from "image-source"; import * as frameModule from "ui/frame"; +@Deprecated class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePickerControllerDelegate { public static ObjCProtocols = [UIImagePickerControllerDelegate]; @@ -79,6 +80,9 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic var listener; +/** + * [Deprecated. Please use same functionality from `nativescript-camera` npm module] + */ export var takePicture = function (options): Promise { return new Promise((resolve, reject) => { listener = null; @@ -125,6 +129,9 @@ export var takePicture = function (options): Promise { }); } +/** + * [Deprecated. Please use same functionality from `nativescript-camera` npm module] + */ export var isAvailable = function () { return UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera); } diff --git a/tns-core-modules/location/Readme.md b/tns-core-modules/location/Readme.md index 860171f68..580755e65 100644 --- a/tns-core-modules/location/Readme.md +++ b/tns-core-modules/location/Readme.md @@ -1 +1 @@ -Allows you to use the geolocation of the device. +Deprecated. Please use same functionality from `nativescript-geolocation` npm module. \ No newline at end of file diff --git a/tns-core-modules/location/location.d.ts b/tns-core-modules/location/location.d.ts index 596711a20..c61197f31 100644 --- a/tns-core-modules/location/location.d.ts +++ b/tns-core-modules/location/location.d.ts @@ -12,6 +12,7 @@ declare module "location" { /** * A data class that encapsulates common properties for a geolocation. + * [Deprecated. Please use same functionality from `nativescript-geolocation` npm module] */ export class Location { /** @@ -67,6 +68,7 @@ declare module "location" { /** * Provides options for location monitoring. + * [Deprecated. Please use same functionality from `nativescript-geolocation` npm module] */ export interface Options { /** @@ -97,6 +99,7 @@ declare module "location" { /** * Provides methods for querying geolocation (in case available) on the target platform. + * [Deprecated. Please use same functionality from `nativescript-geolocation` npm module] */ export class LocationManager { /** @@ -157,6 +160,7 @@ declare module "location" { /** * Provides Android specific data related to location. + * [Deprecated. Please use same functionality from `nativescript-geolocation` npm module] */ export interface AndroidLocationManager { /** @@ -175,12 +179,14 @@ declare module "location" { * If you specify timeout = 0 it just requests the last known location. * However if you specify maximumAge and the location received is older it won't be received. * @param options - An optional object specifying location update settings. + * [Deprecated. Please use same functionality from `nativescript-geolocation` npm module] */ export function getLocation(options?: Options): Promise; /* tslint:disable */ /** * Provides iOS specific data related to location. + * [Deprecated. Please use same functionality from `nativescript-geolocation` npm module] */ export interface iOSLocationManager { /**