mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge remote-tracking branch 'origin/master' into merge-release-in-master
This commit is contained in:
@@ -43,6 +43,35 @@ export function test_children_immediately_registered_in_parent_grid_layout() {
|
||||
helper.buildUIAndRunTest(outer, testAction);
|
||||
}
|
||||
|
||||
export function test_proxy_layout_properties() {
|
||||
const outer = new GridLayout();
|
||||
const proxy = new ProxyViewContainer();
|
||||
|
||||
function testAction(views: Array<View>) {
|
||||
outer.addChild(proxy);
|
||||
|
||||
const btn = createBtn("1");
|
||||
proxy.addChild(btn);
|
||||
|
||||
proxy.row = 1;
|
||||
TKUnit.assertEqual(proxy.row, btn.row, "Proxy row value to existing child");
|
||||
|
||||
const btn2 = createBtn("2");
|
||||
proxy.addChild(btn2);
|
||||
TKUnit.assertEqual(proxy.row, btn2.row, "Proxy row value to new child");
|
||||
|
||||
proxy.removeChild(btn2);
|
||||
|
||||
btn.row = 0;
|
||||
TKUnit.assertNotEqual(proxy.row, btn.row, "Child value changed");
|
||||
|
||||
proxy.row = 1;
|
||||
TKUnit.assertNotEqual(proxy.row, btn.row, "Changed child value not overridden");
|
||||
}
|
||||
|
||||
helper.buildUIAndRunTest(outer, testAction);
|
||||
}
|
||||
|
||||
export function test_children_registered_in_parent_grid_layout_on_attach() {
|
||||
const outer = new GridLayout();
|
||||
const proxy = new ProxyViewContainer();
|
||||
|
||||
@@ -35,254 +35,178 @@ const UNKNOWN_ORIENTATION_CSS_CLASS = "ns-unknown";
|
||||
const DARK_SYSTEM_APPEARANCE_CSS_CLASS = "ns-dark";
|
||||
const LIGHT_SYSTEM_APPEARANCE_CSS_CLASS = "ns-light";
|
||||
|
||||
function _test_root_view_root_css_class(shouldSetClassName: boolean) {
|
||||
const rootView = getRootView();
|
||||
function _test_root_css_class(view: View, isModal: boolean, shouldSetClassName: boolean) {
|
||||
if (shouldSetClassName) {
|
||||
view.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const cssClass = isModal ? MODAL_CSS_CLASS : ROOT_CSS_CLASS;
|
||||
const viewCssClasses = view.cssClasses;
|
||||
TKUnit.assertTrue(viewCssClasses.has(cssClass), `${cssClass} CSS class is missing`);
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(viewCssClasses.has(CLASS_NAME), `${CLASS_NAME} CSS class is missing`);
|
||||
}
|
||||
}
|
||||
|
||||
function _test_platform_css_class(rootView: View, shouldSetClassName: boolean) {
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const rootViewCssClasses = rootView.cssClasses;
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
ROOT_CSS_CLASS),
|
||||
`${ROOT_CSS_CLASS} CSS class is missing`
|
||||
);
|
||||
const cssClasses = rootView.cssClasses;
|
||||
if (isAndroid) {
|
||||
TKUnit.assertTrue(cssClasses.has(ANDROID_PLATFORM_CSS_CLASS), `${ANDROID_PLATFORM_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(IOS_PLATFORM_CSS_CLASS), `${IOS_PLATFORM_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
else {
|
||||
TKUnit.assertTrue(cssClasses.has(IOS_PLATFORM_CSS_CLASS), `${IOS_PLATFORM_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(ANDROID_PLATFORM_CSS_CLASS), `${ANDROID_PLATFORM_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
CLASS_NAME),
|
||||
`${CLASS_NAME} CSS class is missing`
|
||||
);
|
||||
TKUnit.assertTrue(cssClasses.has(CLASS_NAME), `${CLASS_NAME} CSS class is missing`);
|
||||
}
|
||||
}
|
||||
|
||||
function _test_device_type_css_class(rootView: View, shouldSetClassName: boolean) {
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const cssClasses = rootView.cssClasses;
|
||||
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`);
|
||||
}
|
||||
else {
|
||||
TKUnit.assertTrue(cssClasses.has(TABLET_DEVICE_TYPE_CSS_CLASS), `${TABLET_DEVICE_TYPE_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(PHONE_DEVICE_TYPE_CSS_CLASS), `${PHONE_DEVICE_TYPE_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(cssClasses.has(CLASS_NAME), `${CLASS_NAME} CSS class is missing`);
|
||||
}
|
||||
}
|
||||
|
||||
function _test_orientation_css_class(rootView: View, shouldSetClassName: boolean) {
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const cssClasses = rootView.cssClasses;
|
||||
let appOrientation;
|
||||
if (isAndroid) {
|
||||
appOrientation = android.orientation;
|
||||
}
|
||||
else {
|
||||
appOrientation = ios.orientation;
|
||||
}
|
||||
if (appOrientation === "portrait") {
|
||||
TKUnit.assertTrue(cssClasses.has(PORTRAIT_ORIENTATION_CSS_CLASS), `${PORTRAIT_ORIENTATION_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(LANDSCAPE_ORIENTATION_CSS_CLASS), `${LANDSCAPE_ORIENTATION_CSS_CLASS} CSS class is present`);
|
||||
TKUnit.assertFalse(cssClasses.has(UNKNOWN_ORIENTATION_CSS_CLASS), `${UNKNOWN_ORIENTATION_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
else if (appOrientation === "landscape") {
|
||||
TKUnit.assertTrue(cssClasses.has(LANDSCAPE_ORIENTATION_CSS_CLASS), `${LANDSCAPE_ORIENTATION_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(PORTRAIT_ORIENTATION_CSS_CLASS), `${PORTRAIT_ORIENTATION_CSS_CLASS} CSS class is present`);
|
||||
TKUnit.assertFalse(cssClasses.has(UNKNOWN_ORIENTATION_CSS_CLASS), `${UNKNOWN_ORIENTATION_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
else if (appOrientation === "landscape") {
|
||||
TKUnit.assertTrue(cssClasses.has(UNKNOWN_ORIENTATION_CSS_CLASS), `${UNKNOWN_ORIENTATION_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(LANDSCAPE_ORIENTATION_CSS_CLASS), `${LANDSCAPE_ORIENTATION_CSS_CLASS} CSS class is present`);
|
||||
TKUnit.assertFalse(cssClasses.has(PORTRAIT_ORIENTATION_CSS_CLASS), `${PORTRAIT_ORIENTATION_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(cssClasses.has(CLASS_NAME), `${CLASS_NAME} CSS class is missing`);
|
||||
}
|
||||
}
|
||||
|
||||
function _test_system_appearance_css_class(rootView: View, shouldSetClassName: boolean) {
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const cssClasses = rootView.cssClasses;
|
||||
let systemAppearance;
|
||||
if (isAndroid) {
|
||||
systemAppearance = android.systemAppearance;
|
||||
}
|
||||
else {
|
||||
systemAppearance = ios.systemAppearance;
|
||||
}
|
||||
if (isIOS && iosUtils.MajorVersion <= 12) {
|
||||
TKUnit.assertFalse(cssClasses.has(DARK_SYSTEM_APPEARANCE_CSS_CLASS), `${DARK_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`);
|
||||
TKUnit.assertFalse(cssClasses.has(LIGHT_SYSTEM_APPEARANCE_CSS_CLASS), `${LIGHT_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
else if (systemAppearance === "dark") {
|
||||
TKUnit.assertTrue(cssClasses.has(DARK_SYSTEM_APPEARANCE_CSS_CLASS), `${DARK_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(LIGHT_SYSTEM_APPEARANCE_CSS_CLASS), `${LIGHT_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
else if (systemAppearance === "light") {
|
||||
TKUnit.assertTrue(cssClasses.has(LIGHT_SYSTEM_APPEARANCE_CSS_CLASS), `${LIGHT_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is missing`);
|
||||
TKUnit.assertFalse(cssClasses.has(DARK_SYSTEM_APPEARANCE_CSS_CLASS), `${DARK_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(cssClasses.has(CLASS_NAME), `${CLASS_NAME} CSS class is missing`);
|
||||
}
|
||||
}
|
||||
|
||||
// Application root view
|
||||
export function test_root_view_root_css_class() {
|
||||
_test_root_view_root_css_class(false);
|
||||
const rootView = getRootView();
|
||||
_test_root_css_class(rootView, false, false);
|
||||
}
|
||||
|
||||
export function test_root_view_class_name_preserve_root_css_class() {
|
||||
_test_root_view_root_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_view_platform_css_class(shouldSetClassName: boolean) {
|
||||
const rootView = getRootView();
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const rootViewCssClasses = rootView.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`
|
||||
);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
CLASS_NAME),
|
||||
`${CLASS_NAME} CSS class is missing`
|
||||
);
|
||||
}
|
||||
_test_root_css_class(rootView, false, true);
|
||||
}
|
||||
|
||||
export function test_root_view_platform_css_class() {
|
||||
_test_root_view_platform_css_class(false);
|
||||
const rootView = getRootView();
|
||||
_test_platform_css_class(rootView, false);
|
||||
}
|
||||
|
||||
export function test_root_view_class_name_preserve_platform_css_class() {
|
||||
_test_root_view_platform_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_view_device_type_css_class(shouldSetClassName: boolean) {
|
||||
const rootView = getRootView();
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const rootViewCssClasses = rootView.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`
|
||||
);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
CLASS_NAME),
|
||||
`${CLASS_NAME} CSS class is missing`
|
||||
);
|
||||
}
|
||||
_test_platform_css_class(rootView, true);
|
||||
}
|
||||
|
||||
export function test_root_view_device_type_css_class() {
|
||||
_test_root_view_device_type_css_class(false);
|
||||
const rootView = getRootView();
|
||||
_test_device_type_css_class(rootView, false);
|
||||
}
|
||||
|
||||
export function test_root_view_class_name_preserve_device_type_css_class() {
|
||||
_test_root_view_device_type_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_view_orientation_css_class(shouldSetClassName: boolean) {
|
||||
const rootView = getRootView();
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const rootViewCssClasses = rootView.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`
|
||||
);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
CLASS_NAME),
|
||||
`${CLASS_NAME} CSS class is missing`
|
||||
);
|
||||
}
|
||||
_test_device_type_css_class(rootView, true);
|
||||
}
|
||||
|
||||
export function test_root_view_orientation_css_class() {
|
||||
_test_root_view_orientation_css_class(false);
|
||||
const rootView = getRootView();
|
||||
_test_orientation_css_class(rootView, false);
|
||||
}
|
||||
|
||||
export function test_root_view_class_name_preserve_orientation_css_class() {
|
||||
_test_root_view_orientation_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_view_system_appearance_css_class(shouldSetClassName: boolean) {
|
||||
const rootView = getRootView();
|
||||
if (shouldSetClassName) {
|
||||
rootView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const rootViewCssClasses = rootView.cssClasses;
|
||||
let systemAppearance;
|
||||
|
||||
if (isAndroid) {
|
||||
systemAppearance = android.systemAppearance;
|
||||
} else {
|
||||
systemAppearance = ios.systemAppearance;
|
||||
}
|
||||
|
||||
if (isIOS && iosUtils.MajorVersion <= 12) {
|
||||
TKUnit.assertFalse(rootViewCssClasses.has(
|
||||
DARK_SYSTEM_APPEARANCE_CSS_CLASS),
|
||||
`${DARK_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`
|
||||
);
|
||||
TKUnit.assertFalse(rootViewCssClasses.has(
|
||||
LIGHT_SYSTEM_APPEARANCE_CSS_CLASS),
|
||||
`${LIGHT_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`
|
||||
);
|
||||
} else if (systemAppearance === "dark") {
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
DARK_SYSTEM_APPEARANCE_CSS_CLASS),
|
||||
`${DARK_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is missing`
|
||||
);
|
||||
TKUnit.assertFalse(rootViewCssClasses.has(
|
||||
LIGHT_SYSTEM_APPEARANCE_CSS_CLASS),
|
||||
`${LIGHT_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`
|
||||
);
|
||||
} else if (systemAppearance === "light") {
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
LIGHT_SYSTEM_APPEARANCE_CSS_CLASS),
|
||||
`${LIGHT_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is missing`
|
||||
);
|
||||
TKUnit.assertFalse(rootViewCssClasses.has(
|
||||
DARK_SYSTEM_APPEARANCE_CSS_CLASS),
|
||||
`${DARK_SYSTEM_APPEARANCE_CSS_CLASS} CSS class is present`
|
||||
);
|
||||
}
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(rootViewCssClasses.has(
|
||||
CLASS_NAME),
|
||||
`${CLASS_NAME} CSS class is missing`
|
||||
);
|
||||
}
|
||||
_test_orientation_css_class(rootView, true);
|
||||
}
|
||||
|
||||
export function test_root_view_system_appearance_css_class() {
|
||||
_test_root_view_system_appearance_css_class(false);
|
||||
const rootView = getRootView();
|
||||
_test_system_appearance_css_class(rootView, false);
|
||||
}
|
||||
|
||||
export function test_root_view_class_name_preserve_system_appearance_css_class() {
|
||||
_test_root_view_system_appearance_css_class(true);
|
||||
const rootView = getRootView();
|
||||
_test_system_appearance_css_class(rootView, true);
|
||||
}
|
||||
|
||||
// Modal root view
|
||||
function _test_modal_root_view_modal_css_class(shouldSetClassName: boolean) {
|
||||
let modalClosed = false;
|
||||
|
||||
@@ -294,20 +218,8 @@ function _test_modal_root_view_modal_css_class(shouldSetClassName: boolean) {
|
||||
const page = <Page>args.object;
|
||||
page.off(View.shownModallyEvent, modalPageShownModallyEventHandler);
|
||||
|
||||
const rootModalView = _rootModalViews[0];
|
||||
if (shouldSetClassName) {
|
||||
rootModalView.className = CLASS_NAME;
|
||||
}
|
||||
|
||||
const rootModalViewCssClasses = rootModalView.cssClasses;
|
||||
TKUnit.assertTrue(rootModalViewCssClasses.has(MODAL_CSS_CLASS),
|
||||
`${MODAL_CSS_CLASS} CSS class is missing`);
|
||||
|
||||
if (shouldSetClassName) {
|
||||
TKUnit.assertTrue(rootModalViewCssClasses.has(CLASS_NAME),
|
||||
`${CLASS_NAME} CSS class is missing`);
|
||||
}
|
||||
|
||||
const rootModalView = <View>_rootModalViews[0];
|
||||
_test_root_css_class(rootModalView, true, shouldSetClassName);
|
||||
args.closeCallback();
|
||||
};
|
||||
|
||||
@@ -348,3 +260,219 @@ export function test_modal_root_view_modal_css_class() {
|
||||
export function test_modal_root_view_class_name_preserve_modal_css_class() {
|
||||
_test_modal_root_view_modal_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_modal_view_platform_css_class(shouldSetClassName: boolean) {
|
||||
let modalClosed = false;
|
||||
|
||||
const modalCloseCallback = function () {
|
||||
modalClosed = true;
|
||||
};
|
||||
|
||||
const modalPageShownModallyEventHandler = function (args: ShownModallyData) {
|
||||
const page = <Page>args.object;
|
||||
page.off(View.shownModallyEvent, modalPageShownModallyEventHandler);
|
||||
|
||||
const rootModalView = <View>_rootModalViews[0];
|
||||
_test_platform_css_class(rootModalView, shouldSetClassName);
|
||||
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);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_platform_css_class() {
|
||||
_test_root_modal_view_platform_css_class(false);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_class_name_preserve_platform_css_class() {
|
||||
_test_root_modal_view_platform_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_modal_view_device_type_css_class(shouldSetClassName: boolean) {
|
||||
let modalClosed = false;
|
||||
|
||||
const modalCloseCallback = function () {
|
||||
modalClosed = true;
|
||||
};
|
||||
|
||||
const modalPageShownModallyEventHandler = function (args: ShownModallyData) {
|
||||
const page = <Page>args.object;
|
||||
page.off(View.shownModallyEvent, modalPageShownModallyEventHandler);
|
||||
|
||||
const rootModalView = <View>_rootModalViews[0];
|
||||
_test_device_type_css_class(rootModalView, shouldSetClassName);
|
||||
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);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_device_type_css_class() {
|
||||
_test_root_modal_view_device_type_css_class(false);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_class_name_preserve_device_type_css_class() {
|
||||
_test_root_modal_view_device_type_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_modal_view_orientation_css_class(shouldSetClassName: boolean) {
|
||||
let modalClosed = false;
|
||||
|
||||
const modalCloseCallback = function () {
|
||||
modalClosed = true;
|
||||
};
|
||||
|
||||
const modalPageShownModallyEventHandler = function (args: ShownModallyData) {
|
||||
const page = <Page>args.object;
|
||||
page.off(View.shownModallyEvent, modalPageShownModallyEventHandler);
|
||||
|
||||
const rootModalView = <View>_rootModalViews[0];
|
||||
_test_orientation_css_class(rootModalView, shouldSetClassName);
|
||||
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);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_orientation_css_class() {
|
||||
_test_root_modal_view_orientation_css_class(false);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_class_name_preserve_orientation_css_class() {
|
||||
_test_root_modal_view_orientation_css_class(true);
|
||||
}
|
||||
|
||||
function _test_root_modal_view_system_appearance_css_class(shouldSetClassName: boolean) {
|
||||
let modalClosed = false;
|
||||
|
||||
const modalCloseCallback = function () {
|
||||
modalClosed = true;
|
||||
};
|
||||
|
||||
const modalPageShownModallyEventHandler = function (args: ShownModallyData) {
|
||||
const page = <Page>args.object;
|
||||
page.off(View.shownModallyEvent, modalPageShownModallyEventHandler);
|
||||
|
||||
const rootModalView = <View>_rootModalViews[0];
|
||||
_test_system_appearance_css_class(rootModalView, shouldSetClassName);
|
||||
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);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_system_appearance_css_class() {
|
||||
_test_root_modal_view_system_appearance_css_class(false);
|
||||
}
|
||||
|
||||
export function test_modal_root_view_class_name_preserve_system_appearance_css_class() {
|
||||
_test_root_modal_view_system_appearance_css_class(true);
|
||||
}
|
||||
|
||||
@@ -1789,6 +1789,7 @@ export function test_nested_css_calc_and_variables() {
|
||||
|
||||
const cssVarName = `--my-width-factor-base-${Date.now()}`;
|
||||
const cssVarName2 = `--my-width-factor-${Date.now()}`;
|
||||
const undefinedCssVarName = `--my-undefined-variable-${Date.now()}`;
|
||||
|
||||
const stack = new stackModule.StackLayout();
|
||||
stack.css = `
|
||||
@@ -1809,6 +1810,10 @@ export function test_nested_css_calc_and_variables() {
|
||||
StackLayout.nested {
|
||||
${cssVarName2}: calc(var(${cssVarName}) * 2);
|
||||
}
|
||||
|
||||
StackLayout.nested-fallback {
|
||||
width: calc(calc(var(${undefinedCssVarName}, 16) / 2) * 2));
|
||||
}
|
||||
`;
|
||||
|
||||
const label = new labelModule.Label();
|
||||
@@ -1841,6 +1846,9 @@ export function test_nested_css_calc_and_variables() {
|
||||
|
||||
stack.className = "nested";
|
||||
TKUnit.assertDeepEqual(stack.width, { unit: "%", value: 1 }, "Stack - width === 100%");
|
||||
|
||||
stack.className = "nested-fallback";
|
||||
TKUnit.assertDeepEqual(stack.width, 16, "Stack - width === 16");
|
||||
}
|
||||
|
||||
export function test_css_variable_is_applied_to_normal_properties() {
|
||||
|
||||
Reference in New Issue
Block a user