mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(core): nativescript.config and webpack updates (#8801)
This commit is contained in:
45
apps/automated/src/platform/platform-tests.ts
Normal file
45
apps/automated/src/platform/platform-tests.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import * as TKUnit from '../tk-unit';
|
||||
import { isAndroid, isIOS, Device, Screen, Utils } from '@nativescript/core';
|
||||
|
||||
export function test_platform() {
|
||||
let expectedPlatform;
|
||||
if (isAndroid) {
|
||||
expectedPlatform = 'Android';
|
||||
} else {
|
||||
expectedPlatform = 'iOS';
|
||||
}
|
||||
TKUnit.assertEqual(Device.os, expectedPlatform);
|
||||
}
|
||||
|
||||
export function test_device_screen() {
|
||||
TKUnit.assert(Device.model, 'Device model not initialized.');
|
||||
TKUnit.assert(Device.manufacturer, 'Device manufacturer not initialized.');
|
||||
TKUnit.assert(Device.deviceType, 'Device type not initialized.');
|
||||
TKUnit.assert(Device.uuid, 'Device UUID not initialized.');
|
||||
|
||||
TKUnit.assert(Device.language, 'Preferred language not initialized.');
|
||||
|
||||
// NSLocale.currentLocale.objectForKey(NSLocaleCountryCode) not initialized by default on iOS13 simulator;
|
||||
// can be set through Settings -> General -> Language & Region -> Region
|
||||
if (isAndroid || Utils.ios.MajorVersion < 13) {
|
||||
TKUnit.assert(Device.region, 'Preferred region not initialized.');
|
||||
}
|
||||
|
||||
TKUnit.assert(Device.os, 'OS not initialized.');
|
||||
TKUnit.assert(Device.osVersion, 'OS version not initialized.');
|
||||
TKUnit.assert(Device.sdkVersion, 'SDK version not initialized.');
|
||||
|
||||
TKUnit.assert(Screen.mainScreen.widthPixels, 'Screen width (px) not initialized.');
|
||||
TKUnit.assert(Screen.mainScreen.heightPixels, 'Screen height (px) not initialized.');
|
||||
TKUnit.assert(Screen.mainScreen.widthDIPs, 'Screen width (DIPs) not initialized.');
|
||||
TKUnit.assert(Screen.mainScreen.heightDIPs, 'Screen height (DIPs) not initialized.');
|
||||
TKUnit.assert(Screen.mainScreen.scale, 'Screen scale not initialized.');
|
||||
}
|
||||
|
||||
export function test_IsAndroid_IsIOS() {
|
||||
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-ish but common 'android' package is not available.");
|
||||
}
|
||||
}
|
||||
14
apps/automated/src/platform/platform.md
Normal file
14
apps/automated/src/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