mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Tests moved into separate folders (#3794)
Fix android crash on application exit
This commit is contained in:
40
tests/app/platform/platform-tests.ts
Normal file
40
tests/app/platform/platform-tests.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import * as TKUnit from "../TKUnit";
|
||||
import * as app from "tns-core-modules/application";
|
||||
import { isIOS, isAndroid } from "tns-core-modules/platform";
|
||||
|
||||
// >> platform-require
|
||||
import * as platformModule from "tns-core-modules/platform";
|
||||
// << platform-require
|
||||
|
||||
export function test_setTimeout_isDefined() {
|
||||
var expected;
|
||||
if (app.android) {
|
||||
expected = "Android";
|
||||
}
|
||||
else {
|
||||
expected = "iOS";
|
||||
}
|
||||
TKUnit.assertEqual(platformModule.device.os, expected, "device.os");
|
||||
};
|
||||
|
||||
export function snippet_print_all() {
|
||||
// >> platform-current
|
||||
console.log("Device model: " + platformModule.device.model);
|
||||
console.log("Device type: " + platformModule.device.deviceType);
|
||||
console.log("OS: " + platformModule.device.os);
|
||||
console.log("OS version: " + platformModule.device.osVersion);
|
||||
console.log("SDK Version: " + platformModule.device.sdkVersion);
|
||||
|
||||
console.log("Screen width: " + platformModule.screen.mainScreen.widthPixels);
|
||||
console.log("Screen height: " + platformModule.screen.mainScreen.heightPixels);
|
||||
console.log("Screen scale: " + platformModule.screen.mainScreen.scale);
|
||||
// << platform-current
|
||||
};
|
||||
|
||||
export function testIsIOSandIsAndroid() {
|
||||
if (isIOS) {
|
||||
TKUnit.assertTrue(!!NSObject, "isIOS is true-ish but common iOS APIs are not available.");
|
||||
} else if (isAndroid) {
|
||||
TKUnit.assertTrue(!!android, "isAndroid is true but common 'android' package is not available.");
|
||||
}
|
||||
}
|
||||
14
tests/app/platform/platform.md
Normal file
14
tests/app/platform/platform.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
nav-title: "platform How-To"
|
||||
title: "platform"
|
||||
environment: nativescript
|
||||
description: "Examples for using platform"
|
||||
previous_url: /ApiReference/platform/HOW-TO
|
||||
---
|
||||
# Platform
|
||||
Information about the current device and screen are defined in the platform module
|
||||
### Declaring platform module to be available for further usage.
|
||||
{%snippet platform-require%}
|
||||
|
||||
### Getting information about the current device:
|
||||
{%snippet platform-current%}
|
||||
Reference in New Issue
Block a user