Merge remote-tracking branch 'origin/master' into vsetoslavtsenov/merge-release-in-master

This commit is contained in:
SvetoslavTsenov
2019-08-20 01:00:52 +03:00
193 changed files with 3029 additions and 2257 deletions

View File

@@ -1,21 +1,16 @@
// >> application-require
import * as app from "tns-core-modules/application";
import * as app from "tns-core-modules/application";
import * as platform from "tns-core-modules/platform";
// << application-require
// >> application-app-check
if (app.android) {
console.log("We are running on Android device!");
} else if (app.ios) {
console.log("We are running on iOS device");
}
// << application-app-check
import * as TKUnit from "../tk-unit";
if (app.android) {
console.log("We are running on an Android device!");
} else if (app.ios) {
console.log("We are running on an iOS device!");
}
export function testInitialized() {
if (platform.device.os === platform.platformNames.android) {
// we have the android defined
TKUnit.assert(app.android, "Application module not properly intialized");
} else if (platform.device.os === platform.platformNames.ios) {
TKUnit.assert(app.ios, "Application module not properly intialized");

View File

@@ -37,12 +37,13 @@ if (app.android) {
}
// << application-app-android-broadcast
export var testAndroidApplicationInitialized = function () {
export function testAndroidApplicationInitialized() {
TKUnit.assert(app.android, "Android application not initialized.");
TKUnit.assert(app.android.context, "Android context not initialized.");
TKUnit.assert(app.android.foregroundActivity, "Android foregroundActivity not initialized.");
TKUnit.assert(app.android.foregroundActivity.isNativeScriptActivity, "Andorid foregroundActivity.isNativeScriptActivity is true");
TKUnit.assert(app.android.foregroundActivity.isNativeScriptActivity, "Andorid foregroundActivity.isNativeScriptActivity is false.");
TKUnit.assert(app.android.startActivity, "Android startActivity not initialized.");
TKUnit.assert(app.android.nativeApp, "Android nativeApp not initialized.");
TKUnit.assert(app.android.orientation, "Android orientation not initialized.");
TKUnit.assert(app.android.packageName, "Android packageName not initialized.");
};
}

View File

@@ -1,4 +1,2 @@
/* tslint:disable */
//@private
import * as android from "./application-tests.android";
import * as iOS from "./application-tests.ios";
import * as iOS from "./application-tests.ios";

View File

@@ -1,5 +1,6 @@
/* tslint:disable:no-unused-variable */
import * as app from "tns-core-modules/application";
import * as TKUnit from "../tk-unit";
export * from "./application-tests-common";
@@ -39,3 +40,12 @@ if (app.ios) {
}
// << application-ios-delegate
export function testIOSApplicationInitialized() {
TKUnit.assert(app.ios, "iOS application not initialized.");
TKUnit.assert(app.ios.delegate, "iOS delegate not initialized.");
TKUnit.assert(app.ios.nativeApp, "iOS nativeApp not initialized.");
TKUnit.assert(app.ios.orientation, "iOS orientation not initialized.");
TKUnit.assert(app.ios.window, "iOS window not initialized.");
TKUnit.assert(app.ios.rootController, "iOS root controller not initialized.");
}

View File

@@ -1,34 +0,0 @@
---
nav-title: "application How-To"
title: "application"
environment: nativescript
description: "Examples for using application"
previous_url: /ApiReference/application/HOW-TO
---
# Application
The Application module provides abstraction over the platform-specific Application implementations.
It is the main BCL module and is required for other BCL modules to work properly.
The default bootstrap.js implementation for each platform loads and initializes this module.
{%snippet application-require%}
The pre-required `app` module is used throughout the following code snippets.
### Checking the target platform
Use the following code in case you need to check somewhere in your code the platform you are running against:
{%snippet application-app-check%}
### Using the Android-specific implementation
Accessing the Android-specific object instance (will be undefined if running on iOS)
{%snippet application-app-android%}
### Using the Android Application context
{%snippet application-app-android-context%}
### Tracking the current Activity
{%snippet application-app-android-current%}
### Registering a Broadcast Receiver (Android)
{%snippet application-app-android-broadcast%}
### Adding a Notification Observer (iOS)
{%snippet application-ios-observer%}

View File

@@ -1,46 +1,41 @@
import * as TKUnit from "../tk-unit";
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;
export function test_platform() {
let expectedPlatform;
if (app.android) {
expected = "Android";
expectedPlatform = "Android";
} else {
expectedPlatform = "iOS";
}
else {
expected = "iOS";
}
TKUnit.assertEqual(platformModule.device.os, expected, "device.os");
TKUnit.assertEqual(platformModule.device.os, expectedPlatform);
}
export function snippet_print_all() {
// >> platform-current
console.log("Device model: " + platformModule.device.model);
console.log("Device type: " + platformModule.device.deviceType);
console.log("Device manufacturer: " + platformModule.device.manufacturer);
console.log("Preferred language: " + platformModule.device.language);
console.log("Preferred region: " + platformModule.device.region);
console.log("OS: " + platformModule.device.os);
console.log("OS version: " + platformModule.device.osVersion);
console.log("SDK version: " + platformModule.device.sdkVersion);
console.log("Device UUID: " + platformModule.device.uuid);
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.");
console.log("Screen width (px): " + platformModule.screen.mainScreen.widthPixels);
console.log("Screen height (px): " + platformModule.screen.mainScreen.heightPixels);
console.log("Screen width (DIPs): " + platformModule.screen.mainScreen.widthDIPs);
console.log("Screen height (DIPs): " + platformModule.screen.mainScreen.heightDIPs);
console.log("Screen scale: " + platformModule.screen.mainScreen.scale);
// << platform-current
TKUnit.assert(platformModule.device.language, "Preferred language 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.screen.mainScreen.widthPixels, "Screen width (px) not initialized.");
TKUnit.assert(platformModule.screen.mainScreen.heightPixels, "Screen height (px) not initialized.");
TKUnit.assert(platformModule.screen.mainScreen.widthDIPs, "Screen width (DIPs) not initialized.");
TKUnit.assert(platformModule.screen.mainScreen.heightDIPs, "Screen height (DIPs) not initialized.");
TKUnit.assert(platformModule.screen.mainScreen.scale, "Screen scale not initialized.");
}
export function testIsIOSandIsAndroid() {
if (isIOS) {
export function test_IsAndroid_IsIOS() {
if (platformModule.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.");
} else if (platformModule.isAndroid) {
TKUnit.assertTrue(!!android, "isAndroid is true-ish but common 'android' package is not available.");
}
}

View File

@@ -154,6 +154,9 @@ if (platform.isIOS && ios.MajorVersion > 10) {
allTests["SAFEAREA-WEBVIEW"] = webViewSafeAreaTests;
}
import * as rootViewsCssClassesTests from "./ui/styling/root-views-css-classes-tests";
allTests["ROOT-VIEWS-CSS-CLASSES"] = rootViewsCssClassesTests;
import * as stylePropertiesTests from "./ui/styling/style-properties-tests";
allTests["STYLE-PROPERTIES"] = stylePropertiesTests;

View File

@@ -72,6 +72,23 @@ export function test_setTimeout_callbackCalledAfterSpecifiedTime() {
TKUnit.assert(completed, "Callback should be called after the specified time!");
}
export function test_setTimeout_callbackCalledWithBooleanPeriod() {
let completed = false;
// >> timer-set-false
const id = timer.setTimeout(() => {
// >> (hide)
completed = true;
// << (hide)
// @ts-ignore
}, false);
// << timer-set-false
TKUnit.waitUntilReady(() => completed, 1);
timer.clearTimeout(id);
TKUnit.assert(completed, "Callback should be called in 0 seconds!");
}
export function test_setTimeout_callbackNotCalled() {
let completed = false;

View File

@@ -23,7 +23,7 @@ function _createContentItems(count: number): Array<TabContentItem> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}
@@ -101,12 +101,12 @@ export function testBackNavigationToTabViewWithNestedFramesShouldWork() {
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "Item1";
tabViewitem.view = _createFrameView();
tabViewitem.content = _createFrameView();
items.push(tabViewitem);
let tabViewitem2 = new TabContentItem();
// tabViewitem2.title = "Item2";
tabViewitem2.view = _createFrameView();
tabViewitem2.content = _createFrameView();
items.push(tabViewitem2);
tabView.items = items;
@@ -145,7 +145,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "List";
tabViewitem.view = _createListView();
tabViewitem.content = _createListView();
items.push(tabViewitem);
let label = new Label();
@@ -155,7 +155,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
aboutLayout.addChild(label);
tabViewitem = new TabContentItem();
// tabViewitem.title = "About";
tabViewitem.view = aboutLayout;
tabViewitem.content = aboutLayout;
items.push(tabViewitem);
tabView.items = items;
@@ -184,7 +184,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
TKUnit.waitUntilReady(() => topFrame.currentPage === rootPage);
TKUnit.assert(tabView.items[0].view instanceof ListView, "ListView should be created when navigating back to the main page.");
TKUnit.assert(tabView.items[0].content instanceof ListView, "ListView should be created when navigating back to the main page.");
}
function tabViewIsFullyLoaded(tabView: BottomNavigation): boolean {
@@ -232,8 +232,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
}
tabView.items.forEach((item, i) => {
item.view.on("loaded", createLoadedFor(i));
item.view.on("unloaded", createUnloadedFor(i));
item.content.on("loaded", createLoadedFor(i));
item.content.on("unloaded", createUnloadedFor(i));
});
const tabViewPage = new Page();
@@ -252,8 +252,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
TKUnit.assertEqual(topFrame.currentPage, tabViewPage);
for (let i = 0; i < itemCount; i++) {
tabView.items[i].view.off("loaded");
tabView.items[i].view.off("unloaded");
tabView.items[i].content.off("loaded");
tabView.items[i].content.off("unloaded");
}
helper.goBack();
@@ -267,7 +267,7 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
function _clickTheFirstButtonInTheListViewNatively(tabView: BottomNavigation) {
if (tabView.android) {
const androidListView = <android.widget.ListView>tabView.items[0].view.nativeView;
const androidListView = <android.widget.ListView>tabView.items[0].content.nativeView;
// var viewPager: android.support.v4.view.ViewPager = (<any>tabView)._viewPager;
// var androidListView = <android.widget.ListView>viewPager.getChildAt(0);
var stackLayout = <org.nativescript.widgets.StackLayout>androidListView.getChildAt(0);

View File

@@ -47,7 +47,7 @@ function createFrame(i: number, page: Page) {
function createTabItem(i: number, frame: Frame) {
const tabEntry = new TabContentItem();
// tabEntry.title = "Tab " + i;
tabEntry.view = frame;
tabEntry.content = frame;
tabEntry["index"] = i;
return tabEntry;

View File

@@ -27,7 +27,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}
@@ -208,7 +208,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = undefined;
item.content = undefined;
tabView.items = [item];
}, "Binding TabNavigation to a TabItem with undefined view should throw.");
@@ -221,7 +221,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = null;
item.content = null;
tabView.items = [item];
}, "Binding TabNavigation to a TabItem with null view should throw.");
@@ -230,6 +230,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
public test_when_selecting_tab_natively_selectedIndex_is_updated_properly = function () {
var tabView = this.testView;
tabView.items = this._createContentItems(2);
tabView.tabStrip = this._createTabStrip(2);
this.waitUntilTestElementIsLoaded();
var expectedValue = 1;
@@ -245,6 +246,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
public test_when_selecting_tab_natively_selectedIndexChangedEvent_is_raised = function () {
var tabView = this.testView;
tabView.items = this._createContentItems(5);
tabView.tabStrip = this._createTabStrip(5);
this.waitUntilTestElementIsLoaded();
var expectedOldIndex = 3;

View File

@@ -556,16 +556,15 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
TKUnit.assertEqual(actualResult, this.expectedTextAlignment);
}
// TODO: fix this, broken with https://github.com/NativeScript/NativeScript/pull/7499
// public testErrorMessageWhenWrongCssIsAddedWithFile() {
// const view = this.testView;
// const page = this.testPage;
// this.waitUntilTestElementIsLoaded();
public testErrorMessageWhenWrongCssIsAddedWithFile() {
const view = this.testView;
const page = this.testPage;
this.waitUntilTestElementIsLoaded();
// view.id = "testLabel";
// page.addCssFile(fs.path.join(testDir, "label-tests-wrong-page.css"));
// TKUnit.assertNotEqual(this.errorMessage, undefined);
// }
view.id = "testLabel";
page.addCssFile(fs.path.join(testDir, "label-tests-wrong-page.css"));
TKUnit.assertNotEqual(this.errorMessage, undefined);
}
public testErrorMessageWhenWrongCssIsAdded() {
const view = this.testView;

View File

@@ -119,6 +119,60 @@ export class GridLayoutTest extends testModule.UITest<RemovalTrackingGridLayout>
TKUnit.assertEqual(this.colSpan(test), 1, "'columnSpan' property default value should be 1.");
}
public test_synonym_property_setting_column_changes_col() {
const test = new Button();
test.column = 3;
TKUnit.assertEqual(test.column, 3, "Setting column should work.");
TKUnit.assertEqual(test.col, 3, "Setting column property should affect col property.");
}
public test_synonym_property_setting_col_changes_column() {
const test = new Button();
test.col = 3;
TKUnit.assertEqual(test.col, 3, "Setting col should work.");
TKUnit.assertEqual(test.column, 3, "Setting col property should affect column property.");
}
public test_synonym_property_setColumn_should_set_col_and_column() {
const test = new Button();
GridLayout.setColumn(test, 3);
TKUnit.assertEqual(test.col, 3, "setColumn should set col");
TKUnit.assertEqual(test.column, 3, "setColumn should set column");
}
public test_synonym_property_setting_columnSpan_changes_colSpan() {
const test = new Button();
test.columnSpan = 3;
TKUnit.assertEqual(test.columnSpan, 3, "Setting columnSpan should work.");
TKUnit.assertEqual(test.colSpan, 3, "Setting columnSpan property should affect colSpan property.");
}
public test_synonym_property_setting_colSpan_changes_columnSpan() {
const test = new Button();
test.colSpan = 3;
TKUnit.assertEqual(test.colSpan, 3, "Setting colSpan should work.");
TKUnit.assertEqual(test.columnSpan, 3, "Setting colSpan property should affect columnSpan property.");
}
public test_synonym_property_setColumnSpan_should_set_colSpan_and_columnSpan() {
const test = new Button();
GridLayout.setColumnSpan(test, 3);
TKUnit.assertEqual(test.colSpan, 3, "setColumnSpan should set colSpan");
TKUnit.assertEqual(test.columnSpan, 3, "setColumnSpan should set columnSpan");
}
public test_getRow_shouldThrow_onNullValues() {
TKUnit.assertThrows(() => {
GridLayout.getRow(null);
@@ -250,17 +304,17 @@ export class GridLayoutTest extends testModule.UITest<RemovalTrackingGridLayout>
TKUnit.assertEqual(
this.row(btn),
row,
"'row' property not applied For GridLayout addChildAtCell without rowspan."
"'row' property not applied For GridLayout addChildAtCell without rowSpan."
);
TKUnit.assertEqual(
this.col(btn),
column,
"'column' property not applied For GridLayout addChildAtCell without rowspan."
"'column' property not applied For GridLayout addChildAtCell without rowSpan."
);
TKUnit.assertEqual(
this.rowSpan(btn),
defaultSpanValue,
"'rowSpan' property not applied For GridLayout addChildAtCell without rowspan."
"'rowSpan' property not applied For GridLayout addChildAtCell without rowSpan."
);
TKUnit.assertEqual(
this.colSpan(btn),

View File

@@ -505,11 +505,6 @@ function _test_WhenInnerViewCallsCloseModal(closeModalGetter: (ShownModallyData)
helper.navigate(masterPageFactory);
TKUnit.waitUntilReady(() => modalClosedWithResult);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
}
export function test_WhenViewBaseCallsShowModal_WithArguments_ShouldOpenModal() {
@@ -572,11 +567,6 @@ export function test_WhenViewBaseCallsShowModal_WithArguments_ShouldOpenModal()
helper.navigate(masterPageFactory);
TKUnit.waitUntilReady(() => modalClosed);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
}
export function test_WhenViewBaseCallsShowModal_WithShowModalOptionsArguments_ShouldOpenModal() {
@@ -794,11 +784,6 @@ export function test_WhenRootTabViewShownModallyItCanCloseModal() {
helper.navigate(masterPageFactory);
TKUnit.waitUntilReady(() => modalClosed);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
}
export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() {
@@ -885,11 +870,6 @@ export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() {
TKUnit.assertEqual(modalUnloaded, 1, "modalUnloaded");
masterPage.off(Page.navigatedToEvent, navigatedToEventHandler);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
}
export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised() {
@@ -967,11 +947,6 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised
TKUnit.waitUntilReady(() => ready);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
// only raised by the initial navigation to the master page
TKUnit.assertTrue(hostNavigatingToCount === 1);
TKUnit.assertTrue(hostNavigatedToCount === 1);
@@ -1058,11 +1033,6 @@ export function test_WhenModalPageShownModalNavigationToEventsShouldBeRaised() {
TKUnit.waitUntilReady(() => ready && !modalFrame.isLoaded);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
// only raised by the initial show modal navigation
TKUnit.assertTrue(modalNavigatingToCount === 1);
TKUnit.assertTrue(modalNavigatedToCount === 1);
@@ -1138,12 +1108,6 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() {
helper.navigate(masterPageFactory);
TKUnit.waitUntilReady(() => ready && !modalFrame.isLoaded);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
TKUnit.assertTrue(showingModallyCount === 1);
TKUnit.assertTrue(shownModallyCount === 1);
}
@@ -1206,12 +1170,6 @@ export function test_WhenModalPageShownShowModalEventsRaisedOnRootModalPage() {
helper.navigate(masterPageFactory);
TKUnit.waitUntilReady(() => ready);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
TKUnit.assertTrue(showingModallyCount === 1);
TKUnit.assertTrue(shownModallyCount === 1);
}
@@ -1279,12 +1237,6 @@ export function test_WhenModalPageShownShowModalEventsRaisedOnRootModalTabView()
TKUnit.assertEqual(_stack().length, 2, "Host and modal tab frame should be instantiated at this point!");
TKUnit.waitUntilReady(() => ready);
if (isIOS) {
// Remove this line when we have a good way to detect actual modal close on ios
TKUnit.waitUntilReady(() => !(<UIViewController>topmost().currentPage.viewController).presentedViewController);
}
TKUnit.assertEqual(_stack().length, 1, "Single host frame should be instantiated at this point!");
TKUnit.assertTrue(showingModallyCount === 1);

View File

@@ -0,0 +1,188 @@
import * as helper from "../../ui-helper";
import * as TKUnit from "../../tk-unit";
import {
android,
getRootView,
ios
} from "tns-core-modules/application";
import {
isAndroid,
device
} from "tns-core-modules/platform";
import { Button } from "tns-core-modules/ui/button/button";
import { Page } from "tns-core-modules/ui/page";
import {
ShownModallyData,
ShowModalOptions,
View
} from "tns-core-modules/ui/frame";
import {
_rootModalViews
} from "tns-core-modules/ui/core/view/view-common";
import { DeviceType } from "tns-core-modules/ui/enums/enums";
const ROOT_CSS_CLASS = "ns-root";
const MODAL_CSS_CLASS = "ns-modal";
const ANDROID_PLATFORM_CSS_CLASS = "ns-android";
const IOS_PLATFORM_CSS_CLASS = "ns-ios";
const PHONE_DEVICE_TYPE_CSS_CLASS = "ns-phone";
const TABLET_DEVICE_TYPE_CSS_CLASS = "ns-tablet";
const PORTRAIT_ORIENTATION_CSS_CLASS = "ns-portrait";
const LANDSCAPE_ORIENTATION_CSS_CLASS = "ns-landscape";
const UNKNOWN_ORIENTATION_CSS_CLASS = "ns-unknown";
export function test_root_view_root_css_class() {
const rootViewCssClasses = getRootView().cssClasses;
TKUnit.assertTrue(rootViewCssClasses.has(
ROOT_CSS_CLASS),
`${ROOT_CSS_CLASS} CSS class is missing`
);
}
export function test_root_view_platform_css_class() {
const rootViewCssClasses = getRootView().cssClasses;
if (isAndroid) {
TKUnit.assertTrue(rootViewCssClasses.has(
ANDROID_PLATFORM_CSS_CLASS),
`${ANDROID_PLATFORM_CSS_CLASS} CSS class is missing`
);
TKUnit.assertFalse(rootViewCssClasses.has(
IOS_PLATFORM_CSS_CLASS),
`${IOS_PLATFORM_CSS_CLASS} CSS class is present`
);
} else {
TKUnit.assertTrue(rootViewCssClasses.has(
IOS_PLATFORM_CSS_CLASS),
`${IOS_PLATFORM_CSS_CLASS} CSS class is missing`
);
TKUnit.assertFalse(rootViewCssClasses.has(
ANDROID_PLATFORM_CSS_CLASS),
`${ANDROID_PLATFORM_CSS_CLASS} CSS class is present`
);
}
}
export function test_root_view_device_type_css_class() {
const rootViewCssClasses = getRootView().cssClasses;
const deviceType = device.deviceType;
if (deviceType === DeviceType.Phone) {
TKUnit.assertTrue(rootViewCssClasses.has(
PHONE_DEVICE_TYPE_CSS_CLASS),
`${PHONE_DEVICE_TYPE_CSS_CLASS} CSS class is missing`
);
TKUnit.assertFalse(rootViewCssClasses.has(
TABLET_DEVICE_TYPE_CSS_CLASS),
`${TABLET_DEVICE_TYPE_CSS_CLASS} CSS class is present`
);
} else {
TKUnit.assertTrue(rootViewCssClasses.has(
TABLET_DEVICE_TYPE_CSS_CLASS),
`${TABLET_DEVICE_TYPE_CSS_CLASS} CSS class is missing`
);
TKUnit.assertFalse(rootViewCssClasses.has(
PHONE_DEVICE_TYPE_CSS_CLASS),
`${PHONE_DEVICE_TYPE_CSS_CLASS} CSS class is present`
);
}
}
export function test_root_view_orientation_css_class() {
const rootViewCssClasses = getRootView().cssClasses;
let appOrientation;
if (isAndroid) {
appOrientation = android.orientation;
} else {
appOrientation = ios.orientation;
}
if (appOrientation === "portrait") {
TKUnit.assertTrue(rootViewCssClasses.has(
PORTRAIT_ORIENTATION_CSS_CLASS),
`${PORTRAIT_ORIENTATION_CSS_CLASS} CSS class is missing`
);
TKUnit.assertFalse(rootViewCssClasses.has(
LANDSCAPE_ORIENTATION_CSS_CLASS),
`${LANDSCAPE_ORIENTATION_CSS_CLASS} CSS class is present`
);
TKUnit.assertFalse(rootViewCssClasses.has(
UNKNOWN_ORIENTATION_CSS_CLASS),
`${UNKNOWN_ORIENTATION_CSS_CLASS} CSS class is present`
);
} else if (appOrientation === "landscape") {
TKUnit.assertTrue(rootViewCssClasses.has(
LANDSCAPE_ORIENTATION_CSS_CLASS),
`${LANDSCAPE_ORIENTATION_CSS_CLASS} CSS class is missing`
);
TKUnit.assertFalse(rootViewCssClasses.has(
PORTRAIT_ORIENTATION_CSS_CLASS),
`${PORTRAIT_ORIENTATION_CSS_CLASS} CSS class is present`
);
TKUnit.assertFalse(rootViewCssClasses.has(
UNKNOWN_ORIENTATION_CSS_CLASS),
`${UNKNOWN_ORIENTATION_CSS_CLASS} CSS class is present`
);
} else if (appOrientation === "landscape") {
TKUnit.assertTrue(rootViewCssClasses.has(
UNKNOWN_ORIENTATION_CSS_CLASS),
`${UNKNOWN_ORIENTATION_CSS_CLASS} CSS class is missing`
);
TKUnit.assertFalse(rootViewCssClasses.has(
LANDSCAPE_ORIENTATION_CSS_CLASS),
`${LANDSCAPE_ORIENTATION_CSS_CLASS} CSS class is present`
);
TKUnit.assertFalse(rootViewCssClasses.has(
PORTRAIT_ORIENTATION_CSS_CLASS),
`${PORTRAIT_ORIENTATION_CSS_CLASS} CSS class is present`
);
}
}
export function test_modal_root_view_modal_css_class() {
let modalClosed = false;
const modalCloseCallback = function () {
modalClosed = true;
};
const modalPageShownModallyEventHandler = function (args: ShownModallyData) {
const page = <Page>args.object;
page.off(View.shownModallyEvent, modalPageShownModallyEventHandler);
TKUnit.assertTrue(_rootModalViews[0].cssClasses.has(MODAL_CSS_CLASS));
args.closeCallback();
};
const hostNavigatedToEventHandler = function (args) {
const page = <Page>args.object;
page.off(Page.navigatedToEvent, hostNavigatedToEventHandler);
const modalPage = new Page();
modalPage.on(View.shownModallyEvent, modalPageShownModallyEventHandler);
const button = <Button>page.content;
const options: ShowModalOptions = {
context: {},
closeCallback: modalCloseCallback,
fullscreen: false,
animated: false
};
button.showModal(modalPage, options);
};
const hostPageFactory = function (): Page {
const hostPage = new Page();
hostPage.on(Page.navigatedToEvent, hostNavigatedToEventHandler);
const button = new Button();
hostPage.content = button;
return hostPage;
};
helper.navigate(hostPageFactory);
TKUnit.waitUntilReady(() => modalClosed);
}

View File

@@ -13,6 +13,7 @@ import { resolveFileNameFromUrl, removeTaggedAdditionalCSS, addTaggedAdditionalC
import { unsetValue } from "tns-core-modules/ui/core/view";
import * as color from "tns-core-modules/color";
import * as fs from "tns-core-modules/file-system";
import { _evaluateCssCalcExpression } from "tns-core-modules/ui/core/properties/properties";
export function test_css_dataURI_is_applied_to_backgroundImageSource() {
const stack = new stackModule.StackLayout();
@@ -1426,6 +1427,413 @@ export function test_CascadingClassNamesAppliesAfterPageLoad() {
});
}
export function test_evaluateCssCalcExpression() {
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(1px + 1px)"), "2px", "Simple calc (1)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(50px - (20px - 30px))"), "60px", "Simple calc (2)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(100px - (100px - 100%))"), "100%", "Simple calc (3)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(100px + (100px - 100%))"), "calc(200px - 100%)", "Simple calc (4)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(100% - 10px + 20px)"), "calc(100% + 10px)", "Simple calc (5)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(100% + 10px - 20px)"), "calc(100% - 10px)", "Simple calc (6)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(10.px + .0px)"), "10px", "Simple calc (8)");
TKUnit.assertEqual(_evaluateCssCalcExpression("a calc(1px + 1px)"), "a 2px", "Ignore value surrounding calc function (1)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(1px + 1px) a"), "2px a", "Ignore value surrounding calc function (2)");
TKUnit.assertEqual(_evaluateCssCalcExpression("a calc(1px + 1px) b"), "a 2px b", "Ignore value surrounding calc function (3)");
TKUnit.assertEqual(_evaluateCssCalcExpression("a calc(1px + 1px) b calc(1em + 2em) c"), "a 2px b 3em c", "Ignore value surrounding calc function (4)");
TKUnit.assertEqual(_evaluateCssCalcExpression(`calc(\n1px \n* 2 \n* 1.5)`), "3px", "Handle new lines");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(1/100)"), "0.01", "Handle precision correctly (1)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(5/1000000)"), "0.00001", "Handle precision correctly (2)");
TKUnit.assertEqual(_evaluateCssCalcExpression("calc(5/100000)"), "0.00005", "Handle precision correctly (3)");
}
export function test_css_calc() {
const page = helper.getClearCurrentPage();
const stack = new stackModule.StackLayout();
stack.css = `
StackLayout.slim {
width: calc(100 * .1);
}
StackLayout.wide {
width: calc(100 * 1.25);
}
StackLayout.invalid-css-calc {
width: calc(asd3 * 1.25);
}
`;
const label = new labelModule.Label();
page.content = stack;
stack.addChild(label);
stack.className = "slim";
TKUnit.assertEqual(stack.width as any, 10, "Stack - width === 10");
stack.className = "wide";
TKUnit.assertEqual(stack.width as any, 125, "Stack - width === 125");
(stack as any).style = `width: calc(100% / 2)`;
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 0.5 }, "Stack - width === 50%");
// This should log an error for the invalid css-calc expression, but not cause a crash
stack.className = "invalid-css-calc";
}
export function test_css_calc_units() {
const page = helper.getClearCurrentPage();
const stack = new stackModule.StackLayout();
stack.css = `
StackLayout.no_unit {
width: calc(100 * .1);
}
StackLayout.dip_unit {
width: calc(100dip * .1);
}
StackLayout.pct_unit {
width: calc(100% * .1);
}
StackLayout.px_unit {
width: calc(100px * .1);
}
`;
const label = new labelModule.Label();
page.content = stack;
stack.addChild(label);
stack.className = "no_unit";
TKUnit.assertEqual(stack.width as any, 10, "Stack - width === 10");
stack.className = "dip_unit";
TKUnit.assertEqual(stack.width as any, 10, "Stack - width === 10dip");
stack.className = "pct_unit";
TKUnit.assertDeepEqual(stack.width as any, { unit: "%", value: 0.1 }, "Stack - width === 10%");
stack.className = "px_unit";
TKUnit.assertDeepEqual(stack.width as any, { unit: "px", value: 10 }, "Stack - width === 10px");
}
export function test_nested_css_calc() {
const page = helper.getClearCurrentPage();
const stack = new stackModule.StackLayout();
stack.css = `
StackLayout.slim {
width: calc(calc(10 * 10) * .1);
}
StackLayout.wide {
width: calc(calc(10 * 10) * 1.25);
}
`;
const label = new labelModule.Label();
page.content = stack;
stack.addChild(label);
stack.className = "slim";
TKUnit.assertEqual(stack.width as any, 10, "Stack - width === 10");
stack.className = "wide";
TKUnit.assertEqual(stack.width as any, 125, "Stack - width === 125");
(stack as any).style = `width: calc(100% * calc(1 / 2)`;
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 0.5 }, "Stack - width === 50%");
}
export function test_css_variables() {
const blackColor = "#000000";
const redColor = "#FF0000";
const greenColor = "#00FF00";
const blueColor = "#0000FF";
const page = helper.getClearCurrentPage();
const cssVarName = `--my-background-color-${Date.now()}`;
const stack = new stackModule.StackLayout();
stack.css = `
StackLayout[use-css-vars] {
background-color: var(${cssVarName});
}
StackLayout.make-red {
${cssVarName}: red;
}
StackLayout.make-blue {
${cssVarName}: blue;
}
Label.lab1 {
background-color: var(${cssVarName});
color: black;
}`;
const label = new labelModule.Label();
page.content = stack;
stack.addChild(label);
// This should log an error about not finding the css-variable but not cause a crash
stack["use-css-vars"] = true;
label.className = "lab1";
stack.className = "make-red";
TKUnit.assertEqual(label.color.hex, blackColor, "text color is black");
TKUnit.assertEqual((<color.Color>stack.backgroundColor).hex, redColor, "Stack - background-color is red");
TKUnit.assertEqual((<color.Color>label.backgroundColor).hex, redColor, "Label - background-color is red");
stack.className = "make-blue";
TKUnit.assertEqual(label.color.hex, blackColor, "text color is black");
TKUnit.assertEqual((<color.Color>stack.backgroundColor).hex, blueColor, "Stack - background-color is blue");
TKUnit.assertEqual((<color.Color>label.backgroundColor).hex, blueColor, "Label - background-color is blue");
stack.className = "make-red";
TKUnit.assertEqual(label.color.hex, blackColor, "text color is black");
TKUnit.assertEqual((<color.Color>stack.backgroundColor).hex, redColor, "Stack - background-color is red");
TKUnit.assertEqual((<color.Color>label.backgroundColor).hex, redColor, "Label - background-color is red");
// view.style takes priority over css-classes.
(stack as any).style = `${cssVarName}: ${greenColor}`;
stack.className = "";
TKUnit.assertEqual(label.color.hex, blackColor, "text color is black");
TKUnit.assertEqual((<color.Color>stack.backgroundColor).hex, greenColor, "Stack - background-color is green");
TKUnit.assertEqual((<color.Color>label.backgroundColor).hex, greenColor, "Label - background-color is green");
stack.className = "make-red";
TKUnit.assertEqual(label.color.hex, blackColor, "text color is black");
TKUnit.assertEqual((<color.Color>stack.backgroundColor).hex, greenColor, "Stack - background-color is green");
TKUnit.assertEqual((<color.Color>label.backgroundColor).hex, greenColor, "Label - background-color is green");
(stack as any).style = "";
TKUnit.assertEqual(label.color.hex, blackColor, "text color is black");
TKUnit.assertEqual((<color.Color>stack.backgroundColor).hex, redColor, "Stack - background-color is red");
TKUnit.assertEqual((<color.Color>label.backgroundColor).hex, redColor, "Label - background-color is red");
}
export function test_css_calc_and_variables() {
const page = helper.getClearCurrentPage();
const cssVarName = `--my-width-factor-${Date.now()}`;
const stack = new stackModule.StackLayout();
stack.css = `
StackLayout[use-css-vars] {
${cssVarName}: 1;
width: calc(100% * var(${cssVarName}));
}
StackLayout.slim {
${cssVarName}: 0.1;
}
StackLayout.wide {
${cssVarName}: 1.25;
}
`;
const label = new labelModule.Label();
page.content = stack;
stack["use-css-vars"] = true;
stack.addChild(label);
stack.className = "";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 1 }, "Stack - width === 100%");
stack.className = "slim";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 0.1 }, "Stack - width === 10%");
stack.className = "wide";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 1.25 }, "Stack - width === 125%");
// Test setting the CSS variable via the style-attribute, this should override any value set via css-class
(stack as any).style = `${cssVarName}: 0.5`;
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 0.5 }, "Stack - width === 50%");
}
export function test_css_variable_fallback() {
const redColor = "#FF0000";
const blueColor = "#0000FF";
const limeColor = new color.Color("lime").hex;
const yellowColor = new color.Color("yellow").hex;
const classToValue = [
{
className: "defined-css-variable",
expectedColor: blueColor,
}, {
className: "defined-css-variable-with-fallback",
expectedColor: blueColor,
}, {
className: "undefined-css-variable-without-fallback",
expectedColor: undefined,
}, {
className: "undefined-css-variable-with-fallback",
expectedColor: redColor,
}, {
className: "undefined-css-variable-with-defined-fallback",
expectedColor: limeColor,
}, {
className: "undefined-css-variable-with-multiple-fallbacks",
expectedColor: limeColor,
}, {
className: "undefined-css-variable-with-missing-fallback-value",
expectedColor: undefined,
}, {
className: "undefined-css-variable-with-nested-fallback",
expectedColor: yellowColor,
},
];
const page = helper.getClearCurrentPage();
const stack = new stackModule.StackLayout();
stack.css = `
.defined-css-variable {
--my-var: blue;
color: var(--my-var); /* resolved as color: blue; */
}
.defined-css-variable-with-fallback {
--my-var: blue;
color: var(--my-var, red); /* resolved as color: blue; */
}
.undefined-css-variable-without-fallback {
color: var(--undefined-var); /* resolved as color: unset; */
}
.undefined-css-variable-with-fallback {
color: var(--undefined-var, red); /* resolved as color: red; */
}
.undefined-css-variable-with-defined-fallback {
--my-fallback-var: lime;
color: var(--undefined-var, var(--my-fallback-var)); /* resolved as color: lime; */
}
.undefined-css-variable-with-multiple-fallbacks {
--my-fallback-var: lime;
color: var(--undefined-var, var(--my-fallback-var), yellow); /* resolved as color: lime; */
}
.undefined-css-variable-with-missing-fallback-value {
color: var(--undefined-var, var(--undefined-fallback-var)); /* resolved as color: unset; */
}
.undefined-css-variable-with-nested-fallback {
color: var(--undefined-var, var(--undefined-fallback-var, yellow)); /* resolved as color: yellow; */
}
`;
const label = new labelModule.Label();
page.content = stack;
stack.addChild(label);
for (const { className, expectedColor } of classToValue) {
label.className = className;
TKUnit.assertEqual(label.color && label.color.hex, expectedColor, className);
}
}
export function test_nested_css_calc_and_variables() {
const page = helper.getClearCurrentPage();
const cssVarName = `--my-width-factor-base-${Date.now()}`;
const cssVarName2 = `--my-width-factor-${Date.now()}`;
const stack = new stackModule.StackLayout();
stack.css = `
StackLayout[use-css-vars] {
${cssVarName}: 0.5;
${cssVarName2}: var(${cssVarName});
width: calc(100% * calc(var(${cssVarName2}) * 2));
}
StackLayout.slim {
${cssVarName}: 0.05;
}
StackLayout.wide {
${cssVarName}: 0.625
}
StackLayout.nested {
${cssVarName2}: calc(var(${cssVarName}) * 2);
}
`;
const label = new labelModule.Label();
page.content = stack;
stack["use-css-vars"] = true;
stack.addChild(label);
stack.className = "";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 1 }, "Stack - width === 100%");
stack.className = "nested";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 2 }, "Stack - width === 200%");
stack.className = "slim";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 0.1 }, "Stack - width === 10%");
stack.className = "slim nested";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 0.2 }, "Stack - width === 20%");
stack.className = "wide";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 1.25 }, "Stack - width === 125%");
stack.className = "wide nested";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 2.5 }, "Stack - width === 250%");
// Test setting the CSS variable via the style-attribute, this should override any value set via css-class
stack.className = "wide";
(stack as any).style = `${cssVarName}: 0.25`;
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 0.5 }, "Stack - width === 50%");
stack.className = "nested";
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 1 }, "Stack - width === 100%");
}
export function test_css_variable_is_applied_to_normal_properties() {
const stack = new stackModule.StackLayout();
const cssVarName = `--my-custom-variable-${Date.now()}`;
helper.buildUIAndRunTest(stack, function (views: Array<viewModule.View>) {
const page = <pageModule.Page>views[1];
const expected = "horizontal";
page.css = `StackLayout {
${cssVarName}: ${expected};
orientation: var(${cssVarName});
}`;
TKUnit.assertEqual(stack.orientation, expected);
});
}
export function test_css_variable_is_applied_to_special_properties() {
const stack = new stackModule.StackLayout();
const cssVarName = `--my-custom-variable-${Date.now()}`;
helper.buildUIAndRunTest(stack, function (views: Array<viewModule.View>) {
const page = <pageModule.Page>views[1];
const expected = "test";
page.css = `StackLayout {
${cssVarName}: ${expected};
class: var(${cssVarName});
}`;
TKUnit.assertEqual(stack.className, expected);
});
}
export function test_resolveFileNameFromUrl_local_file_tilda() {
const localFileExistsMock = (fileName: string) => true;
const url = "~/theme/core.css";

View File

@@ -23,7 +23,7 @@ function _createContentItems(count: number): Array<TabContentItem> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}
@@ -101,12 +101,12 @@ export function testBackNavigationToTabViewWithNestedFramesShouldWork() {
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "Item1";
tabViewitem.view = _createFrameView();
tabViewitem.content = _createFrameView();
items.push(tabViewitem);
let tabViewitem2 = new TabContentItem();
// tabViewitem2.title = "Item2";
tabViewitem2.view = _createFrameView();
tabViewitem2.content = _createFrameView();
items.push(tabViewitem2);
tabView.items = items;
@@ -145,7 +145,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "List";
tabViewitem.view = _createListView();
tabViewitem.content = _createListView();
items.push(tabViewitem);
let label = new Label();
@@ -155,7 +155,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
aboutLayout.addChild(label);
tabViewitem = new TabContentItem();
// tabViewitem.title = "About";
tabViewitem.view = aboutLayout;
tabViewitem.content = aboutLayout;
items.push(tabViewitem);
tabView.items = items;
@@ -184,7 +184,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
TKUnit.waitUntilReady(() => topFrame.currentPage === rootPage);
TKUnit.assert(tabView.items[0].view instanceof ListView, "ListView should be created when navigating back to the main page.");
TKUnit.assert(tabView.items[0].content instanceof ListView, "ListView should be created when navigating back to the main page.");
}
function tabViewIsFullyLoaded(tabView: Tabs): boolean {
@@ -232,8 +232,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
}
tabView.items.forEach((item, i) => {
item.view.on("loaded", createLoadedFor(i));
item.view.on("unloaded", createUnloadedFor(i));
item.content.on("loaded", createLoadedFor(i));
item.content.on("unloaded", createUnloadedFor(i));
});
const tabViewPage = new Page();
@@ -252,8 +252,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
TKUnit.assertEqual(topFrame.currentPage, tabViewPage);
for (let i = 0; i < itemCount; i++) {
tabView.items[i].view.off("loaded");
tabView.items[i].view.off("unloaded");
tabView.items[i].content.off("loaded");
tabView.items[i].content.off("unloaded");
}
helper.goBack();
@@ -267,7 +267,7 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
function _clickTheFirstButtonInTheListViewNatively(tabView: Tabs) {
if (tabView.android) {
const androidListView = <android.widget.ListView>tabView.items[0].view.nativeView;
const androidListView = <android.widget.ListView>tabView.items[0].content.nativeView;
// var viewPager: android.support.v4.view.ViewPager = (<any>tabView)._viewPager;
// var androidListView = <android.widget.ListView>viewPager.getChildAt(0);
var stackLayout = <org.nativescript.widgets.StackLayout>androidListView.getChildAt(0);

View File

@@ -35,7 +35,7 @@ function createFrame(i: number, page: Page) {
function createTabItem(i: number, frame: Frame) {
const tabEntry = new TabContentItem();
// tabEntry.title = "Tab " + i;
tabEntry.view = frame;
tabEntry.content = frame;
tabEntry["index"] = i;
return tabEntry;

View File

@@ -27,7 +27,7 @@ export class TabsTest extends UITest<Tabs> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}
@@ -210,7 +210,7 @@ export class TabsTest extends UITest<Tabs> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = undefined;
item.content = undefined;
tabView.items = [item];
}, "Binding TabNavigation to a TabItem with undefined view should throw.");
@@ -223,7 +223,7 @@ export class TabsTest extends UITest<Tabs> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = null;
item.content = null;
tabView.items = [item];
}, "Binding TabNavigation to a TabItem with null view should throw.");

View File

@@ -54,6 +54,32 @@ export var test_XmlParser_EntityReferencesInAttributeValuesAreDecoded = function
TKUnit.assert(data === "<>\"&'", "Expected result: <>\"&'; Actual result: " + data + ";");
};
export var test_XmlParser_UnicodeEntitiesAreDecoded = function () {
var data;
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
switch (event.eventType) {
case xmlModule.ParserEventType.Text:
data = event.data;
break;
}
});
xmlParser.parse("<element>&#x1f923;&#x2713;</element>");
TKUnit.assert(data === "\uD83E\uDD23\u2713", "Expected result: \uD83E\uDD23\u2713; Actual result: " + data + ";");
};
export var test_XmlParser_UnicodeEntitiesInAttributeValuesAreDecoded = function () {
var data;
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
switch (event.eventType) {
case xmlModule.ParserEventType.StartElement:
data = event.attributes["text"];
break;
}
});
xmlParser.parse("<Label text=\"&#x1f923;&#x2713;\"/>");
TKUnit.assert(data === "\uD83E\uDD23\u2713", "Expected result: \uD83E\uDD23\u2713; Actual result: " + data + ";");
};
export var test_XmlParser_OnErrorIsCalledWhenAnErrorOccurs = function () {
var e;
var xmlParser = new xmlModule.XmlParser(