mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import * as app from "@nativescript/core/application";
|
||||
import * as platform from "@nativescript/core/platform";
|
||||
import { isAndroid, isIOS, Device, Application, platformNames } from "@nativescript/core";
|
||||
|
||||
import * as TKUnit from "../tk-unit";
|
||||
|
||||
if (app.android) {
|
||||
if (isAndroid) {
|
||||
console.log("We are running on an Android device!");
|
||||
} else if (app.ios) {
|
||||
} else if (isIOS) {
|
||||
console.log("We are running on an iOS device!");
|
||||
}
|
||||
|
||||
export function testInitialized() {
|
||||
if (platform.device.os === platform.platformNames.android) {
|
||||
if (Device.os === platformNames.android) {
|
||||
TKUnit.assert(app.android, "Application module not properly intialized");
|
||||
} else if (platform.device.os === platform.platformNames.ios) {
|
||||
} else if (Device.os === platformNames.ios) {
|
||||
TKUnit.assert(app.ios, "Application module not properly intialized");
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,5 @@ export function testDisplayedEvent() {
|
||||
}
|
||||
|
||||
export function testOrientation() {
|
||||
TKUnit.assert(app.orientation(), "Orientation not initialized.");
|
||||
TKUnit.assert(Application.orientation(), "Orientation not initialized.");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as fs from "@nativescript/core/file-system";
|
||||
|
||||
import * as TKUnit from "../tk-unit";
|
||||
import * as appModule from "@nativescript/core/application";
|
||||
import * as platform from "@nativescript/core/platform";
|
||||
import { isIOS, Device, platformNames } from "@nativescript/core";
|
||||
|
||||
export var testPathNormalize = function () {
|
||||
// >> file-system-normalize
|
||||
@@ -190,7 +190,7 @@ export var testFileReadWriteBinary = function () {
|
||||
// >> (hide)
|
||||
var destination = destinationFile.readSync(e => { error = e; });
|
||||
TKUnit.assertNull(error);
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (Device.os === platformNames.ios) {
|
||||
TKUnit.assertTrue(source.isEqualToData(destination));
|
||||
} else {
|
||||
TKUnit.assertEqual(new java.io.File(sourceFile.path).length(), new java.io.File(destinationFile.path).length());
|
||||
@@ -217,7 +217,7 @@ export var testFileReadWriteBinaryAsync = function () {
|
||||
// Succeded in writing the file
|
||||
destinationFile.read()
|
||||
.then(function (destination) {
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (Device.os === platformNames.ios) {
|
||||
TKUnit.assertTrue(source.isEqualToData(destination));
|
||||
} else {
|
||||
TKUnit.assertEqual(new java.io.File(sourceFile.path).length(), new java.io.File(destinationFile.path).length());
|
||||
@@ -268,7 +268,7 @@ function _testIOSSpecificKnownFolder(knownFolderName: string) {
|
||||
createdFile.writeTextSync("some text");
|
||||
}
|
||||
};
|
||||
if (platform.isIOS) {
|
||||
if (isIOS) {
|
||||
testFunc();
|
||||
if (knownFolder) {
|
||||
TKUnit.assertTrue(knownFolder.isKnown, `The ${knownFolderName} folder should have its "isKnown" property set to true.`);
|
||||
|
||||
@@ -37,10 +37,10 @@ export function test_Transitions() {
|
||||
});
|
||||
|
||||
var transitions;
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
transitions = ["curl"];
|
||||
} else {
|
||||
const _sdkVersion = parseInt(platform.device.sdkVersion);
|
||||
const _sdkVersion = parseInt(platform.Device.sdkVersion);
|
||||
transitions = _sdkVersion >= 21 ? ["explode"] : [];
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ function printDeviceInfoIOS() {
|
||||
}
|
||||
|
||||
function printTNSInfo() {
|
||||
console.log("platform.device.model = " + platform.device.model);
|
||||
console.log("platform.device.os = " + platform.device.os);
|
||||
console.log("platform.device.osVersion = " + platform.device.osVersion);
|
||||
console.log("platform.device.sdkVersion = " + platform.device.sdkVersion);
|
||||
console.log("platform.device.deviceType = " + platform.device.deviceType);
|
||||
console.log("platform.Device.model = " + platform.Device.model);
|
||||
console.log("platform.Device.os = " + platform.Device.os);
|
||||
console.log("platform.Device.osVersion = " + platform.Device.osVersion);
|
||||
console.log("platform.Device.sdkVersion = " + platform.Device.sdkVersion);
|
||||
console.log("platform.Device.deviceType = " + platform.Device.deviceType);
|
||||
|
||||
console.log("platform.screen.mainScreen.widthDIPs = " + platform.screen.mainScreen.widthDIPs);
|
||||
console.log("platform.screen.mainScreen.heightDIPs = " + platform.screen.mainScreen.heightDIPs);
|
||||
|
||||
@@ -10,26 +10,26 @@ export function test_platform() {
|
||||
} else {
|
||||
expectedPlatform = "iOS";
|
||||
}
|
||||
TKUnit.assertEqual(platformModule.device.os, expectedPlatform);
|
||||
TKUnit.assertEqual(platformModule.Device.os, expectedPlatform);
|
||||
}
|
||||
|
||||
export function test_device_screen() {
|
||||
TKUnit.assert(platformModule.device.model, "Device model not initialized.");
|
||||
TKUnit.assert(platformModule.device.manufacturer, "Device manufacturer not initialized.");
|
||||
TKUnit.assert(platformModule.device.deviceType, "Device type not initialized.");
|
||||
TKUnit.assert(platformModule.device.uuid, "Device UUID not initialized.");
|
||||
TKUnit.assert(platformModule.Device.model, "Device model not initialized.");
|
||||
TKUnit.assert(platformModule.Device.manufacturer, "Device manufacturer not initialized.");
|
||||
TKUnit.assert(platformModule.Device.deviceType, "Device type not initialized.");
|
||||
TKUnit.assert(platformModule.Device.uuid, "Device UUID not initialized.");
|
||||
|
||||
TKUnit.assert(platformModule.device.language, "Preferred language not initialized.");
|
||||
TKUnit.assert(platformModule.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 (platformModule.isAndroid || ios.MajorVersion < 13) {
|
||||
TKUnit.assert(platformModule.device.region, "Preferred region not initialized.");
|
||||
TKUnit.assert(platformModule.Device.region, "Preferred region not initialized.");
|
||||
}
|
||||
|
||||
TKUnit.assert(platformModule.device.os, "OS not initialized.");
|
||||
TKUnit.assert(platformModule.device.osVersion, "OS version not initialized.");
|
||||
TKUnit.assert(platformModule.device.sdkVersion, "SDK version not initialized.");
|
||||
TKUnit.assert(platformModule.Device.os, "OS not initialized.");
|
||||
TKUnit.assert(platformModule.Device.osVersion, "OS version not initialized.");
|
||||
TKUnit.assert(platformModule.Device.sdkVersion, "SDK version not initialized.");
|
||||
|
||||
TKUnit.assert(platformModule.screen.mainScreen.widthPixels, "Screen width (px) not initialized.");
|
||||
TKUnit.assert(platformModule.screen.mainScreen.heightPixels, "Screen height (px) not initialized.");
|
||||
|
||||
@@ -17,14 +17,14 @@ Frame.defaultAnimatedNavigation = false;
|
||||
export function isRunningOnEmulator(): boolean {
|
||||
// These checks are not good enough to be added to modules but they keep unit tests green.
|
||||
|
||||
if (platform.device.os === platform.platformNames.android) {
|
||||
if (platform.Device.os === platform.platformNames.android) {
|
||||
return android.os.Build.FINGERPRINT.indexOf("generic") > -1 ||
|
||||
android.os.Build.HARDWARE.toLowerCase() === "goldfish" ||
|
||||
android.os.Build.HARDWARE.toLowerCase() === "donatello" || // VS Emulator
|
||||
android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("sdk") > -1 ||
|
||||
android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("emulator") > -1; // VS Emulator
|
||||
}
|
||||
else if (platform.device.os === platform.platformNames.ios) {
|
||||
else if (platform.Device.os === platform.platformNames.ios) {
|
||||
return (__dirname.search("Simulator") > -1);
|
||||
}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ function generateTestFile(allTests: TestInfo[]) {
|
||||
let testName = testCase.testName;
|
||||
let duration = (testCase.duration / 1000).toFixed(2);
|
||||
|
||||
testCases.push(`<testcase classname="${platform.device.os}" name="${testName}" time="${duration}">`)
|
||||
testCases.push(`<testcase classname="${platform.Device.os}" name="${testName}" time="${duration}">`)
|
||||
if (!testCase.isPassed) {
|
||||
failedTestCount++;
|
||||
testCases.push(`<failure type="exceptions.AssertionError"><![CDATA[${testCase.errorMessage}]]></failure>`)
|
||||
|
||||
@@ -17,7 +17,7 @@ import * as timer from "@nativescript/core/timer";
|
||||
import { Trace } from "@nativescript/core";
|
||||
import * as types from "@nativescript/core/utils/types";
|
||||
|
||||
const sdkVersion = parseInt(platform.device.sdkVersion);
|
||||
const sdkVersion = parseInt(platform.Device.sdkVersion);
|
||||
|
||||
Trace.enable();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export function test_set_TNS_value_updates_native_value() {
|
||||
}
|
||||
|
||||
// Uncomment this when find way to check android Drawable color set by setColorFilter() method.
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
exports.test_set_color = function () {
|
||||
var ai = new activityIndicatorModule.ActivityIndicator();
|
||||
ai.color = new color.Color("red");
|
||||
|
||||
@@ -76,7 +76,7 @@ export class DatePickerTest extends testModule.UITest<datePickerModule.DatePicke
|
||||
}
|
||||
|
||||
public test_set_color() {
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
this.testView.color = new color.Color("red");
|
||||
TKUnit.assertEqual(this.testView.color.ios.CGColor, this.testView.ios.valueForKey("textColor").CGColor, "datePicker.color");
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as imageCacheModule from "@nativescript/core/ui/image-cache";
|
||||
import { ImageSource } from "@nativescript/core/image-source";
|
||||
import { isAndroid, device } from "@nativescript/core/platform";
|
||||
import { isAndroid, Device } from "@nativescript/core/platform";
|
||||
import lazy from "@nativescript/core/utils/lazy";
|
||||
|
||||
const sdkVersion = lazy(() => parseInt(device.sdkVersion));
|
||||
const sdkVersion = lazy(() => parseInt(Device.sdkVersion));
|
||||
|
||||
export const test_ImageCache_ValidUrl = function (done: (err: Error, res?: string) => void) {
|
||||
// see https://github.com/NativeScript/NativeScript/issues/6643
|
||||
|
||||
@@ -786,7 +786,7 @@ export function test_WhenRootTabViewShownModallyItCanCloseModal() {
|
||||
}
|
||||
|
||||
export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() {
|
||||
// if (platform.device.os === platform.platformNames.android
|
||||
// if (platform.Device.os === platform.platformNames.android
|
||||
// && android.os.Build.VERSION.SDK_INT === android.os.Build.VERSION_CODES.JELLY_BEAN_MR1
|
||||
// && android.os.Build.CPU_ABI.indexOf("x86") !== -1) {
|
||||
// // Skip this test on x68 Android with API Level 17
|
||||
|
||||
@@ -57,7 +57,7 @@ export function test_set_value_greater_than_max_should_set_value_to_max() {
|
||||
}
|
||||
|
||||
// Uncomment this when find way to check android Drawable color set by setColorFilter() method.
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
exports.test_set_color = function () {
|
||||
var progress = new progressModule.Progress();
|
||||
progress.color = new color.Color("red");
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import {
|
||||
isAndroid,
|
||||
isIOS,
|
||||
device
|
||||
Device
|
||||
} from "@nativescript/core/platform";
|
||||
import { Button } from "@nativescript/core";
|
||||
import { Page } from "@nativescript/core/ui/page";
|
||||
@@ -75,7 +75,7 @@ function _test_device_type_css_class(rootView: View, shouldSetClassName: boolean
|
||||
}
|
||||
|
||||
const cssClasses = rootView.cssClasses;
|
||||
const deviceType = device.deviceType;
|
||||
const deviceType = Device.deviceType;
|
||||
if (deviceType === DeviceType.Phone) {
|
||||
TKUnit.assertTrue(cssClasses.has(PHONE_DEVICE_TYPE_CSS_CLASS), `${PHONE_DEVICE_TYPE_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(TABLET_DEVICE_TYPE_CSS_CLASS), `${TABLET_DEVICE_TYPE_CSS_CLASS} CSS class is present`);
|
||||
|
||||
@@ -42,7 +42,7 @@ export function test_default_native_values() {
|
||||
}
|
||||
|
||||
// Uncomment this when find way to check android Drawable color set by setColorFilter() method.
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
exports.test_set_color = function () {
|
||||
var mySwitch = new switchModule.Switch();
|
||||
mySwitch.color = new Color("red");
|
||||
|
||||
@@ -87,7 +87,7 @@ export var testSetTextUndefined = function () {
|
||||
};
|
||||
|
||||
// Supported for ios only.
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
exports.test_set_color = function () {
|
||||
helper.buildUIAndRunTest(_createTextViewFunc(), function (views: Array<viewModule.View>) {
|
||||
var textView = <textViewModule.TextView>views[0];
|
||||
|
||||
@@ -49,7 +49,7 @@ export class TimePickerTest extends testModule.UITest<timePickerModule.TimePicke
|
||||
|
||||
// Supported in iOS only.
|
||||
public test_set_color() {
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
this.testView.color = new color.Color("red");
|
||||
TKUnit.assertEqual(this.testView.color.ios.CGColor, this.testView.ios.valueForKey("textColor").CGColor, "timePicker.color");
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ export function test_parse_ShouldParsePlatformSpecificProperties() {
|
||||
var p = <Page>Builder.parse("<Page><TextField ios:editable='False' android:editable='True' /></Page>");
|
||||
var tf = <textFieldModule.TextField>p.content;
|
||||
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
TKUnit.assertFalse(tf.editable, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable));
|
||||
} else {
|
||||
TKUnit.assertTrue(tf.editable, "Expected result: true; Actual result: " + tf.editable + "; type: " + typeof (tf.editable));
|
||||
@@ -350,7 +350,7 @@ export function test_parse_ShouldParsePlatformSpecificProperties() {
|
||||
|
||||
export function test_parse_ShouldParsePlatformSpecificComponents() {
|
||||
var p = <Page>Builder.parse("<Page><ios><TextField /></ios><android><Label /></android></Page>");
|
||||
if (platform.device.os === platform.platformNames.ios) {
|
||||
if (platform.Device.os === platform.platformNames.ios) {
|
||||
TKUnit.assert(p.content instanceof textFieldModule.TextField, "Expected result: TextField; Actual result: " + p.content);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -6,10 +6,10 @@ import * as TKUnit from "../tk-unit";
|
||||
import * as xmlModule from "@nativescript/core/xml";
|
||||
import * as fs from "@nativescript/core/file-system";
|
||||
import { Builder } from "@nativescript/core/ui/builder";
|
||||
import { isIOS, device } from "@nativescript/core/platform";
|
||||
import { isIOS, Device } from "@nativescript/core/platform";
|
||||
import lazy from "@nativescript/core/utils/lazy";
|
||||
|
||||
const sdkVersion = lazy(() => parseInt(device.sdkVersion));
|
||||
const sdkVersion = lazy(() => parseInt(Device.sdkVersion));
|
||||
|
||||
export var test_XmlParser_IsDefined = function () {
|
||||
TKUnit.assertNotEqual(xmlModule.XmlParser, undefined, "Class XmlParser should be defined!");
|
||||
|
||||
Reference in New Issue
Block a user