chore: workflow permissions

This commit is contained in:
Nathan Walker
2025-06-25 10:58:05 -07:00
parent 51c4b106f0
commit a11ccd8753
14 changed files with 182 additions and 144 deletions

View File

@@ -1,4 +1,7 @@
name: 'apps/automated/android'
permissions:
contents: read
pull-requests: write
on:
push:

View File

@@ -1,4 +1,7 @@
name: 'apps/automated/ios'
permissions:
contents: read
pull-requests: write
on:
push:
@@ -51,8 +54,8 @@ jobs:
- name: Start iOS Simulator
uses: futureware-tech/simulator-action@v4
with:
model: 'iPhone 15'
os_version: '17.5'
model: 'iPhone 16 Pro'
os_version: '18.4'
- name: Run tests on iOS Simulator
run: npx nx test apps-automated -c=ios

View File

@@ -1,4 +1,7 @@
name: '@nativescript/core -> npm'
permissions:
contents: read
pull-requests: write
on:
push:

View File

@@ -1,4 +1,7 @@
name: 'tns-core-modules -> npm'
permissions:
contents: read
pull-requests: write
on:
push:

View File

@@ -1,5 +1,8 @@
# TODO: modify to build android & ios types first and then merge into types
name: '@nativescript/types -> npm'
permissions:
contents: read
pull-requests: write
on:
push:

View File

@@ -1,4 +1,7 @@
name: '@nativescript/webpack -> npm'
permissions:
contents: read
pull-requests: write
on:
push:

View File

@@ -1,7 +1,7 @@
import { Image } from '@nativescript/core/ui/image';
import { StackLayout } from '@nativescript/core/ui/layouts/stack-layout';
import { GridLayout } from '@nativescript/core/ui/layouts/grid-layout';
import { PropertyChangeData } from '@nativescript/core';
import { PropertyChangeData, Utils } from '@nativescript/core';
import * as utils from '@nativescript/core/utils';
import * as TKUnit from '../../tk-unit';
import { getColor } from '../../ui-helper';
@@ -27,6 +27,8 @@ if (global.isAndroid) {
(<any>backgroundModule).initImageCache(Application.android.startActivity, (<any>backgroundModule).CacheMode.memory); // use memory cache only.
}
const expectLayoutRequest = __APPLE__ && Utils.SDK_VERSION >= 18;
export const test_Image_Members = function () {
const image = new ImageModule.Image();
TKUnit.assert(types.isUndefined(image.src), 'Image.src is defined');
@@ -273,7 +275,11 @@ export const test_SettingImageSourceWhenSizedToParentDoesNotRequestLayout = ios(
image.requestLayout = () => (called = true);
image.src = '~/assets/logo.png';
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
if (expectLayoutRequest) {
TKUnit.assertTrue(called, 'image.requestLayout should be called.');
} else {
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
}
});
export const test_SettingImageSourceWhenFixedWidthAndHeightDoesNotRequestLayout = ios(() => {
@@ -291,7 +297,11 @@ export const test_SettingImageSourceWhenFixedWidthAndHeightDoesNotRequestLayout
image.requestLayout = () => (called = true);
image.src = '~/assets/logo.png';
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
if (expectLayoutRequest) {
TKUnit.assertTrue(called, 'image.requestLayout should be called.');
} else {
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
}
});
export const test_SettingImageSourceWhenSizedToContentShouldInvalidate = ios(() => {

View File

@@ -10,7 +10,7 @@ import * as colorModule from '@nativescript/core/color';
import * as utils from '@nativescript/core/utils';
import * as observableModule from '@nativescript/core/data/observable';
import * as bindable from '@nativescript/core/ui/core/bindable';
import { CoreTypes, Span, FormattedString } from '@nativescript/core';
import { CoreTypes, Span, FormattedString, Utils } from '@nativescript/core';
import * as labelTestsNative from './label-tests-native';
import * as fs from '@nativescript/core/file-system';
@@ -23,6 +23,8 @@ import * as helper from '../../ui-helper';
const testDir = 'ui/label';
const expectLayoutRequest = __APPLE__ && Utils.SDK_VERSION >= 18;
export class LabelTest extends testModule.UITest<LabelModule.Label> {
public create(): LabelModule.Label {
const label = new LabelModule.Label();
@@ -633,7 +635,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
}
public test_SettingTextWhenInFixedSizeGridShouldNotRequestLayout() {
this.requestLayoutFixture(false, '', (label) => {
this.requestLayoutFixture(expectLayoutRequest, '', (label) => {
label.textWrap = false;
let host = new GridLayout();
host.width = 100;
@@ -644,7 +646,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
}
public test_ChangingTextWhenInFixedSizeGridShouldNotRequestLayout() {
this.requestLayoutFixture(false, 'Hello World', (label) => {
this.requestLayoutFixture(expectLayoutRequest, 'Hello World', (label) => {
label.textWrap = false;
let host = new GridLayout();
host.width = 100;
@@ -655,7 +657,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
}
public test_SettingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
this.requestLayoutFixture(false, '', (label) => {
this.requestLayoutFixture(expectLayoutRequest, '', (label) => {
label.textWrap = false;
let host = new StackLayout();
label.width = 100;
@@ -666,7 +668,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
}
public test_ChangingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
this.requestLayoutFixture(false, 'Hello World', (label) => {
this.requestLayoutFixture(expectLayoutRequest, 'Hello World', (label) => {
label.textWrap = false;
let host = new StackLayout();
label.width = 100;
@@ -707,7 +709,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
}
public test_ChangingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldNotRequestLayout() {
this.requestLayoutFixture(false, 'Hello World', (label) => {
this.requestLayoutFixture(expectLayoutRequest, 'Hello World', (label) => {
label.textWrap = false;
let host = new StackLayout();
host.width = 100;

View File

@@ -116,7 +116,7 @@ let activity_flex_wrap = () =>
<Label id="text1" text="1" width="120" height="120" backgroundColor="red" />
<Label id="text2" text="2" width="120" height="120" backgroundColor="green" />
<Label id="text3" text="3" width="120" height="120" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export function test_recycling() {
@@ -126,7 +126,7 @@ export function test_recycling() {
export function test_item_recycling() {
helper.nativeView_recycling_test(
() => new Button(),
() => new FlexboxLayout()
() => new FlexboxLayout(),
);
}
@@ -142,7 +142,7 @@ export const testFlexWrap_wrap = test(
isBelow(text3, text2);
isLeftAlignedWith(text3, flexbox);
// equal(flexbox.getFlexLines().size(), is(1));
}
},
);
export const testFlexWrap_nowrap = test(
@@ -156,7 +156,7 @@ export const testFlexWrap_nowrap = test(
isRightOf(text3, text2);
isTopAlignedWith(text3, flexbox);
// equal(flexbox.getFlexLines().size(), is(1));
}
},
);
export const testFlexWrap_wrap_reverse = test(
@@ -169,7 +169,7 @@ export const testFlexWrap_wrap_reverse = test(
isAbove(text3, text2);
isLeftAlignedWith(text3, flexbox);
// equal(flexbox.getFlexLines().size(), is(2));
}
},
);
export const testFlexWrap_wrap_flexDirection_column = test(
@@ -184,7 +184,7 @@ export const testFlexWrap_wrap_flexDirection_column = test(
isRightOf(text3, text2);
isTopAlignedWith(text3, flexbox);
// equal(flexbox.getFlexLines().size(), is(2));
}
},
);
export const testFlexWrap_nowrap_flexDirection_column = test(
@@ -201,7 +201,7 @@ export const testFlexWrap_nowrap_flexDirection_column = test(
isBelow(text3, text2);
isLeftAlignedWith(text3, flexbox);
// equal(flexbox.getFlexLines().size(), is(1));
}
},
);
export const testFlexWrap_wrap_reverse_flexDirection_column = test(
@@ -218,7 +218,7 @@ export const testFlexWrap_wrap_reverse_flexDirection_column = test(
isLeftOf(text3, text2);
isTopAlignedWith(text3, flexbox);
// equal(flexbox.getFlexLines().size(), is(2));
}
},
);
let activity_flex_item_match_parent = () =>
@@ -234,7 +234,7 @@ let activity_flex_item_match_parent = () =>
<Label id="text1" width="100%" height="80" text="1" backgroundColor="red" />
<Label id="text2" width="100%" height="80" text="2" backgroundColor="green" />
<Label id="text3" width="100%" height="80" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFlexItem_match_parent = test(activity_flex_item_match_parent, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -257,7 +257,7 @@ let activity_flex_item_match_parent_direction_column = () =>
<Label id="text1" width="40" height="100%" text="1" backgroundColor="red"/>
<Label id="text2" width="40" height="100%" text="2" backgroundColor="green" />
<Label id="text3" width="40" height="100%" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFlexItem_match_parent_flexDirection_column = test(activity_flex_item_match_parent_direction_column, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -278,7 +278,7 @@ let activity_flexbox_wrap_content = () =>
<Label id="text1" horizontalAlignment="left" verticalAlignment="top" text="1" backgroundColor="red" />
<Label id="text2" horizontalAlignment="left" verticalAlignment="top" text="2" backgroundColor="green" />
<Label id="text3" horizontalAlignment="left" verticalAlignment="top" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFlexboxLayout_wrapContent = test(activity_flexbox_wrap_content, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -309,7 +309,7 @@ let activity_flexbox_wrapped_with_scrollview = () =>
<Label id="text2" width="140" height="500" text="2" backgroundColor="green" />
<Label id="text3" width="140" height="500" text="3" backgroundColor="blue" />
</FlexboxLayout>
</ScrollView>`
</ScrollView>`,
);
export const testFlexboxLayout_wrapped_with_ScrollView = test(activity_flexbox_wrapped_with_scrollview, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -334,7 +334,7 @@ let activity_flexbox_wrapped_with_horizontalscrollview = () =>
<Label id="text2" width="300" height="100%" text="2" backgroundColor="green" />
<Label id="text3" width="300" height="100%" text="3" backgroundColor="blue" />
</FlexboxLayout>
</ScrollView>`
</ScrollView>`,
);
export const testFlexboxLayout_wrapped_with_HorizontalScrollView = test(activity_flexbox_wrapped_with_horizontalscrollview, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -360,7 +360,7 @@ let activity_justify_content_test = () =>
<Label id="text1" width="60" height="60" text="1" backgroundColor="red" />
<Label id="text2" width="60" height="60" text="2" backgroundColor="green" />
<Label id="text3" width="60" height="60" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testJustifyContent_flexStart = test(activity_justify_content_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -378,7 +378,7 @@ let activity_justify_content_with_parent_padding = () =>
<Label id="text2" width="60" height="60" text="2" backgroundColor="green" />
<Label id="text3" width="60" height="60" text="3" backgroundColor="blue" />
</FlexboxLayout>
</GridLayout>`
</GridLayout>`,
);
export const testJustifyContent_flexStart_withParentPadding = test(activity_justify_content_with_parent_padding, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -396,7 +396,7 @@ export const testJustifyContent_flexEnd = test(
isRightAlignedWith(text3, flexbox);
isLeftOf(text2, text3);
isLeftOf(text1, text2);
}
},
);
export const testJustifyContent_flexEnd_withParentPadding = test(
@@ -411,7 +411,7 @@ export const testJustifyContent_flexEnd_withParentPadding = test(
equal(right(text3), paddingRight(flexbox));
isRightWith(text2, text3, width(text3));
isRightWith(text1, text2, width(text2));
}
},
);
export const testJustifyContent_center = test(
@@ -428,7 +428,7 @@ export const testJustifyContent_center = test(
space = space / 2;
closeEnough(left(text1), paddingLeft(flexbox) + space);
closeEnough(right(text3), paddingRight(flexbox) - space);
}
},
);
export const testJustifyContent_center_withParentPadding = test(
@@ -441,7 +441,7 @@ export const testJustifyContent_center_withParentPadding = test(
space = space / 2;
isLeftWith(flexbox, text1, space);
isRightWith(text3, flexbox, space);
}
},
);
export const testJustifyContent_spaceBetween = test(
@@ -457,7 +457,7 @@ export const testJustifyContent_spaceBetween = test(
space = space / 2;
check(space - 1 <= left(text2) - right(text1) && left(text2) - right(text1) <= space + 1);
check(space - 1 <= left(text3) - right(text2) && left(text3) - right(text2) <= space + 1);
}
},
);
export const testJustifyContent_spaceBetween_withPadding = test(
@@ -473,7 +473,7 @@ export const testJustifyContent_spaceBetween_withPadding = test(
closeEnough(right(text1) + space, left(text2));
closeEnough(right(text2) + space, left(text3));
equal(right(text3), paddingRight(flexbox));
}
},
);
export const testJustifyContent_spaceAround = test(
@@ -490,7 +490,7 @@ export const testJustifyContent_spaceAround = test(
closeEnough(right(text1) + space * 2, left(text2));
closeEnough(right(text2) + space * 2, left(text3));
closeEnough(right(text3), paddingRight(flexbox) - space);
}
},
);
const padding: any = 40;
@@ -504,13 +504,13 @@ export const testJustifyContent_spaceAround_withPadding = test(
({ root, flexbox, text1, text2, text3 }) => {
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - dipToDp(padding) * 2;
space = space / 6; // Divide by the number of children * 2
equal(top(text1), paddingTop(flexbox));
closeEnough(top(text1), paddingTop(flexbox));
closeEnough(left(text1), paddingLeft(flexbox) + space);
closeEnough(right(text1) + space * 2, left(text2));
closeEnough(right(text2) + space * 2, left(text3));
closeEnough(right(text3), paddingRight(flexbox) - space);
equal(bottom(text1), paddingBottom(flexbox));
}
closeEnough(bottom(text1), paddingBottom(flexbox));
},
);
export const testJustifyContent_flexStart_flexDirection_column = test(
@@ -523,7 +523,7 @@ export const testJustifyContent_flexStart_flexDirection_column = test(
isLeftAlignedWith(text2, flexbox);
isBelow(text3, text2);
isLeftAlignedWith(text3, flexbox);
}
},
);
export const testJustifyContent_flexEnd_flexDirection_column = test(
@@ -537,7 +537,7 @@ export const testJustifyContent_flexEnd_flexDirection_column = test(
isRightAlignedWith(text3, flexbox);
isAbove(text2, text3);
isAbove(text1, text2);
}
},
);
export const testJustifyContent_center_flexDirection_column = test(
@@ -557,7 +557,7 @@ export const testJustifyContent_center_flexDirection_column = test(
space = space / 2;
isBelowWith(flexbox, text1, space);
isAboveWith(text3, flexbox, space);
}
},
);
export const testJustifyContent_spaceBetween_flexDirection_column = test(
@@ -577,7 +577,7 @@ export const testJustifyContent_spaceBetween_flexDirection_column = test(
space = space / 2;
check(space - 1 <= top(text2) - bottom(text1) && top(text2) - bottom(text1) <= space + 1);
check(space - 1 <= top(text3) - bottom(text2) && top(text3) - bottom(text2) <= space + 1);
}
},
);
export const testJustifyContent_spaceBetween_flexDirection_column_withPadding = test(
@@ -594,7 +594,7 @@ export const testJustifyContent_spaceBetween_flexDirection_column_withPadding =
closeEnough(bottom(text3), paddingBottom(flexbox));
closeEnough(bottom(text1) + space, top(text2));
closeEnough(bottom(text2) + space, top(text3));
}
},
);
export const testJustifyContent_spaceAround_flexDirection_column = test(
@@ -614,7 +614,7 @@ export const testJustifyContent_spaceAround_flexDirection_column = test(
closeEnough(bottom(text1) + 2 * space, top(text2));
closeEnough(bottom(text2) + 2 * space, top(text3));
isAboveWith(text3, flexbox, space);
}
},
);
export const testJustifyContent_spaceAround_flexDirection_column_withPadding = test(
@@ -640,7 +640,7 @@ export const testJustifyContent_spaceAround_flexDirection_column_withPadding = t
equal(right(text1), paddingRight(flexbox));
equal(right(text2), paddingRight(flexbox));
equal(right(text3), paddingRight(flexbox));
}
},
);
let activity_flex_grow_test = () =>
@@ -649,7 +649,7 @@ let activity_flex_grow_test = () =>
<Label id="text1" width="60" height="60" text="1" backgroundColor="red" />
<Label id="text2" width="60" height="60" text="2" backgroundColor="green" />
<Label id="text3" width="60" height="60" text="3" backgroundColor="blue" flexGrow="1" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFlexGrow_withExactParentLength = test(activity_flex_grow_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -678,7 +678,7 @@ export const testFlexGrow_withExactParentLength_flexDirection_column = test(
isBelow(text3, text2);
equal(height(text3), height(flexbox) - height(text1) - height(text2));
}
},
);
export const testFlexGrow_including_view_gone = test(
@@ -693,7 +693,7 @@ export const testFlexGrow_including_view_gone = test(
isRightOf(text3, text1);
equal(width(text3), width(flexbox) - width(text1));
}
},
);
let activity_align_content_test = () =>
@@ -702,7 +702,7 @@ let activity_align_content_test = () =>
<Label id="text1" width="120" height="120" text="1" backgroundColor="red" />
<Label id="text2" width="120" height="120" text="2" backgroundColor="green" />
<Label id="text3" width="120" height="120" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testAlignContent_stretch = test(activity_align_content_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -730,7 +730,7 @@ export const testAlignContent_flexStart = test(
isBelow(text3, text1);
isBelow(text3, text2);
equal(top(text3), top(text1) + height(text1));
}
},
);
export const testAlignContent_flexEnd = test(
@@ -743,7 +743,7 @@ export const testAlignContent_flexEnd = test(
isLeftAlignedWith(text1, flexbox);
isAbove(text2, text3);
equal(bottom(text1), top(flexbox) + height(flexbox) - height(text3));
}
},
);
export const testAlignContent_flexEnd_parentPadding = test(
@@ -757,7 +757,7 @@ export const testAlignContent_flexEnd_parentPadding = test(
isAbove(text1, text3);
isAbove(text2, text3);
equal(bottom(text3), paddingBottom(flexbox));
}
},
);
export const testAlignContent_flexEnd_parentPadding_column = test(
@@ -771,7 +771,7 @@ export const testAlignContent_flexEnd_parentPadding_column = test(
isLeftOf(text1, text3);
isLeftOf(text2, text3);
equal(right(text3), paddingRight(flexbox));
}
},
);
export const testAlignContent_center = test(
@@ -788,7 +788,7 @@ export const testAlignContent_center = test(
isAboveWith(text3, flexbox, spaceAboveAndBottom);
// TODO: equal(flexbox.getFlexLines().size(), is(2));
}
},
);
export const testAlignContent_spaceBetween = test(
@@ -802,7 +802,7 @@ export const testAlignContent_spaceBetween = test(
isBottomAlignedWith(text3, flexbox);
isLeftAlignedWith(text3, flexbox);
// TODO: equal(flexbox.getFlexLines().size(), is(2));
}
},
);
export const testAlignContent_spaceBetween_withPadding = test(
@@ -815,7 +815,7 @@ export const testAlignContent_spaceBetween_withPadding = test(
isTopAlignedWith(text2, flexbox);
isBottomAlignedWith(text3, flexbox);
isLeftAlignedWith(text3, flexbox);
}
},
);
export const testAlignContent_spaceAround = test(
@@ -835,7 +835,7 @@ export const testAlignContent_spaceAround = test(
isAboveWith(text1, text3, height(text3) + 2 * spaceAround);
// TODO: equal(flexbox.getFlexLines().size(), is(2));
}
},
);
export const testAlignContent_stretch_parentWrapContent = test(
@@ -856,7 +856,7 @@ export const testAlignContent_stretch_parentWrapContent = test(
equal(top(text3), bottom(text1));
// TODO: equal(flexbox.getFlexLines().size(), is(2));
}
},
);
export const testAlignContent_stretch_flexDirection_column = test(
@@ -874,7 +874,7 @@ export const testAlignContent_stretch_flexDirection_column = test(
let flexLineCrossSize = width(flexbox) / 2;
equal(left(text3), flexLineCrossSize + left(flexbox));
}
},
);
export const testAlignContent_flexStart_flexDirection_column = test(
@@ -893,7 +893,7 @@ export const testAlignContent_flexStart_flexDirection_column = test(
isRightOf(text3, text1);
isRightOf(text3, text2);
equal(left(text3), width(text1) + left(flexbox));
}
},
);
export const testAlignContent_flexEnd_flexDirection_column = test(
@@ -909,7 +909,7 @@ export const testAlignContent_flexEnd_flexDirection_column = test(
isTopAlignedWith(text1, flexbox);
isBelow(text2, text3);
equal(right(text1), left(flexbox) + width(flexbox) - width(text3));
}
},
);
export const testAlignContent_center_flexDirection_column = test(
@@ -927,7 +927,7 @@ export const testAlignContent_center_flexDirection_column = test(
spaceLeftAndRight /= 2;
isLeftWith(flexbox, text1, spaceLeftAndRight);
isRightWith(text3, flexbox, spaceLeftAndRight);
}
},
);
export const testAlignContent_spaceBetween_flexDirection_column = test(
@@ -943,7 +943,7 @@ export const testAlignContent_spaceBetween_flexDirection_column = test(
isLeftAlignedWith(text2, flexbox);
isRightAlignedWith(text3, flexbox);
isTopAlignedWith(text3, flexbox);
}
},
);
export const testAlignContent_spaceAround_flexDirection_column = test(
@@ -963,7 +963,7 @@ export const testAlignContent_spaceAround_flexDirection_column = test(
isLeftWith(text1, text3, width(text1) + 2 * spaceAround);
isRightWith(text3, flexbox, Math.ceil(spaceAround));
isRightWith(text1, text3, width(text3) + 2 * spaceAround);
}
},
);
export const testAlignContent_stretch_parentWrapContent_flexDirection_column = test(
@@ -983,7 +983,7 @@ export const testAlignContent_stretch_parentWrapContent_flexDirection_column = t
isRightOf(text3, text1);
isRightOf(text3, text2);
equal(left(text3), left(flexbox) + width(text1));
}
},
);
let activity_stretch_test = () =>
@@ -992,7 +992,7 @@ let activity_stretch_test = () =>
<Label id="text1" width="140" height="80" text="1" backgroundColor="red" />
<Label id="text2" width="140" height="80" text="2" backgroundColor="green" />
<Label id="text3" width="140" height="80" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testAlignItems_stretch = test(activity_stretch_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -1016,7 +1016,7 @@ let activity_align_self_stretch_test = () =>
<Label id="text1" width="120" height="120" text="1" backgroundColor="red" alignSelf="${AlignSelf.STRETCH}" />
<Label id="text2" width="120" height="120" text="2" backgroundColor="green" />
<Label id="text3" width="120" height="120" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testAlignSelf_stretch = test(activity_align_self_stretch_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -1053,7 +1053,7 @@ export const testAlignSelf_stretch_flexDirection_column = test(
// use eps.
notEqual(width(text2), flexLineSize);
notEqual(width(text3), flexLineSize);
}
},
);
let activity_align_items_test = () =>
@@ -1062,7 +1062,7 @@ let activity_align_items_test = () =>
<Label id="text1" width="120" height="120" text="1" backgroundColor="red" />
<Label id="text2" width="120" height="120" text="2" backgroundColor="green" />
<Label id="text3" width="120" height="120" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testAlignItems_flexStart = test(
@@ -1082,7 +1082,7 @@ export const testAlignItems_flexStart = test(
notEqual(height(text2), flexLineSize);
notEqual(height(text3), flexLineSize);
equal(top(flexbox) + flexLineSize, top(text3));
}
},
);
export const testAlignItems_flexEnd = test(
@@ -1103,7 +1103,7 @@ export const testAlignItems_flexEnd = test(
equal(top(flexbox) + flexLineSize, bottom(text1));
equal(top(flexbox) + flexLineSize, bottom(text2));
equal(bottom(text3), top(flexbox) + height(flexbox));
}
},
);
let activity_align_items_parent_padding_test = () =>
@@ -1111,7 +1111,7 @@ let activity_align_items_parent_padding_test = () =>
`<FlexboxLayout iosOverflowSafeArea="false" id="flexbox" width="320" height="320" padding="16" flexDirection="${FlexDirection.ROW}" flexWrap="${FlexWrap.WRAP}" alignItems="${AlignItems.FLEX_END}" backgroundColor="gray">
<Label id="text1" width="120" height="120" text="1" backgroundColor="red" />
<Label id="text2" width="120" height="120" text="2" backgroundColor="green" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testAlignItems_flexEnd_parentPadding = test(
@@ -1121,7 +1121,7 @@ export const testAlignItems_flexEnd_parentPadding = test(
isRightOf(text2, text1);
isAboveWith(text1, flexbox, Length.toDevicePixels(flexbox.style.paddingBottom, 0));
isAboveWith(text2, flexbox, Length.toDevicePixels(flexbox.style.paddingBottom, 0));
}
},
);
export const testAlignItems_flexEnd_parentPadding_column = test(
@@ -1134,7 +1134,7 @@ export const testAlignItems_flexEnd_parentPadding_column = test(
isBelow(text2, text1);
isRightWith(text1, flexbox, Length.toDevicePixels(flexbox.style.paddingRight, 0));
isRightWith(text2, flexbox, Length.toDevicePixels(flexbox.style.paddingRight, 0));
}
},
);
export const testAlignItems_center = test(
@@ -1160,7 +1160,7 @@ export const testAlignItems_center = test(
isAboveWith(text3, flexbox, spaceAboveAndBelow);
isAboveWith(text1, text3, flexLineSize);
}
},
);
export const testAlignItems_flexEnd_wrapReverse = test(
@@ -1184,7 +1184,7 @@ export const testAlignItems_flexEnd_wrapReverse = test(
isBelowWith(flexbox, text2, flexLineSize);
isBelowWith(text3, text1, flexLineSize);
isBelowWith(text3, text2, flexLineSize);
}
},
);
export const testAlignItems_center_wrapReverse = test(
@@ -1211,7 +1211,7 @@ export const testAlignItems_center_wrapReverse = test(
isAboveWith(text3, text1, flexLineSize);
isAboveWith(text1, flexbox, spaceAboveAndBelow);
isAboveWith(text2, flexbox, spaceAboveAndBelow);
}
},
);
export const testAlignItems_flexStart_flexDirection_column = test(
@@ -1231,7 +1231,7 @@ export const testAlignItems_flexStart_flexDirection_column = test(
notEqual(width(text2), flexLineSize);
notEqual(width(text3), flexLineSize);
isLeftWith(flexbox, text3, flexLineSize);
}
},
);
export const testAlignItems_flexEnd_flexDirection_column = test(
@@ -1254,7 +1254,7 @@ export const testAlignItems_flexEnd_flexDirection_column = test(
notEqual(width(text3), flexLineSize);
isRightWith(text1, flexbox, flexLineSize);
isRightWith(text2, flexbox, flexLineSize);
}
},
);
export const testAlignItems_center_flexDirection_column = test(
@@ -1278,7 +1278,7 @@ export const testAlignItems_center_flexDirection_column = test(
isLeftWith(flexbox, text1, spaceLeftAndRight);
isLeftWith(flexbox, text2, spaceLeftAndRight);
isLeftWith(flexbox, text3, flexLineSize + spaceLeftAndRight);
}
},
);
export const testAlignItems_flexEnd_wrapReverse_flexDirection_column = test(
@@ -1300,7 +1300,7 @@ export const testAlignItems_flexEnd_wrapReverse_flexDirection_column = test(
notEqual(width(text3), flexLineSize);
isLeftWith(flexbox, text1, flexLineSize);
isLeftWith(flexbox, text2, flexLineSize);
}
},
);
export const testAlignItems_center_wrapReverse_flexDirection_column = test(
@@ -1326,7 +1326,7 @@ export const testAlignItems_center_wrapReverse_flexDirection_column = test(
isRightWith(text1, flexbox, spaceLeftAndRight);
isRightWith(text2, flexbox, spaceLeftAndRight);
isRightWith(text3, flexbox, flexLineSize + spaceLeftAndRight);
}
},
);
let activity_align_items_baseline_test = () =>
@@ -1335,7 +1335,7 @@ let activity_align_items_baseline_test = () =>
<Label id="text1" width="30" height="80" text="1" verticalAlignment="bottom" backgroundColor="red" />
<Label id="text2" width="30" height="80" text="2" verticalAlignment="top" backgroundColor="green" />
<Label id="text3" width="30" height="80" text="2" verticalAlignment="center" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testAlignItems_baseline = test(activity_align_items_baseline_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -1357,7 +1357,7 @@ export const testAlignItems_baseline_wrapReverse = test(
equal(bottomPluBaseline1, bottomPluBaseline2);
equal(bottomPluBaseline2, bottomPluBaseline3);
}
},
);
let activity_flex_wrap_test = () =>
@@ -1366,7 +1366,7 @@ let activity_flex_wrap_test = () =>
<Label id="text1" width="160" height="120" text="1" backgroundColor="red" />
<Label id="text2" width="160" height="120" text="2" backgroundColor="green" />
<Label id="text3" width="160" height="120" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFlexDirection_row_reverse = test(
@@ -1380,7 +1380,7 @@ export const testFlexDirection_row_reverse = test(
isBelow(text3, text1);
isBelow(text3, text2);
isRightAlignedWith(text3, flexbox);
}
},
);
export const testFlexDirection_column_reverse = test(
@@ -1394,7 +1394,7 @@ export const testFlexDirection_column_reverse = test(
isRightOf(text3, text1);
isRightOf(text3, text2);
isBottomAlignedWith(text3, flexbox);
}
},
);
let activity_flex_basis_percent_test = () =>
@@ -1403,7 +1403,7 @@ let activity_flex_basis_percent_test = () =>
<Label id="text1" width="50%" height="50%" text="1" backgroundColor="red" />
<Label id="text2" width="60%" height="60%" text="2" backgroundColor="green" />
<Label id="text3" width="60" height="60" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFlexBasisPercent_wrap = test(activity_flex_basis_percent_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -1431,7 +1431,7 @@ export const testFlexBasisPercent_nowrap = test(
let totalWidth = width(text1) + width(text2) + width(text3);
check(totalWidth >= width(flexbox) - 3 || totalWidth <= width(flexbox) + 3);
}
},
);
export const testFlexBasisPercent_wrap_flexDirection_column = test(
@@ -1446,7 +1446,7 @@ export const testFlexBasisPercent_wrap_flexDirection_column = test(
closeEnough(height(text1), Math.round(height(flexbox) * 0.5));
closeEnough(height(text2), Math.round(height(flexbox) * 0.6));
}
},
);
export const testFlexBasisPercent_nowrap_flexDirection_column = test(
@@ -1466,7 +1466,7 @@ export const testFlexBasisPercent_nowrap_flexDirection_column = test(
let totalHeight = height(text1) + height(text2) + height(text3);
check(totalHeight >= height(flexbox) - 3 || totalHeight <= height(flexbox) + 3);
}
},
);
let activity_minwidth_test = () =>
@@ -1474,7 +1474,7 @@ let activity_minwidth_test = () =>
`<FlexboxLayout iosOverflowSafeArea="false" id="flexbox" width="400" height="400" backgroundColor="gray">
<Label id="text1" horizontalAlignment="left" verticalAlignment="top" text="1" minWidth="100" backgroundColor="red" />
<Label id="text2" horizontalAlignment="left" verticalAlignment="top" text="2" minWidth="100" backgroundColor="green" flexGrow="1" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testMinWidth_initial_width_less_than_minWidth = test(activity_minwidth_test, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -1490,7 +1490,7 @@ let activity_minwidth_lower_bound_test = () =>
<Label id="text2" width="200" verticalAlignment="top" text="1" backgroundColor="green" />
<Label id="text3" width="200" verticalAlignment="top" text="1" backgroundColor="blue" />
<Label id="text4" width="200" verticalAlignment="top" text="1" backgroundColor="purple" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testMinWidth_works_as_lower_bound_shrink_to = test(activity_minwidth_lower_bound_test, noop, ({ root, flexbox, text1, text2, text3, text4 }) => {
@@ -1503,7 +1503,7 @@ let activity_minheight_test = () =>
`<FlexboxLayout iosOverflowSafeArea="false" id="flexbox" width="400" height="400" flexDirection="${FlexDirection.COLUMN}" backgroundColor="gray">
<Label id="text1" horizontalAlignment="left" verticalAlignment="top" text="1" minHeight="100" backgroundColor="red" />
<Label id="text2" horizontalAlignment="left" verticalAlignment="top" text="2" backgroundColor="green" flexGrow="1" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testMinHeight_initial_height_less_than_minHeight = test(activity_minheight_test, noop, ({ root, flexbox, text1, text2 }) => {
@@ -1518,7 +1518,7 @@ let activity_minheight_lower_bound_test = () =>
<Label id="text2" horizontalAlignment="left" height="200" text="2" backgroundColor="green" />
<Label id="text3" horizontalAlignment="left" height="200" text="3" backgroundColor="blue" />
<Label id="text4" horizontalAlignment="left" height="200" text="4" backgroundColor="purple" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testMinHeight_works_as_lower_bound_shrink_to = test(activity_minheight_lower_bound_test, noop, ({ root, flexbox, text1, text2, text3, text4 }) => {
@@ -1540,7 +1540,7 @@ let activity_views_visibility_gone = () =>
<Label id="text3" width="160" height="120" text="3" backgroundColor="blue" />
<Label id="text4" width="160" height="120" text="4" backgroundColor="purple" />
<Label id="text5" width="160" height="120" text="5" backgroundColor="cyan" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testView_visibility_gone = test(activity_views_visibility_gone, noop, ({ root, flexbox, text1, text2, text3, text4, text5 }) => {
@@ -1561,7 +1561,7 @@ let activity_visibility_gone_first_item_in_flex_line_row = () =>
<Label id="text1" width="160" verticalAlignment="top" text="1" backgroundColor="red" />
<Label id="text2" width="120" verticalAlignment="top" text="2" backgroundColor="green" />
<Label id="text3" width="160" verticalAlignment="top" text="3" visibility="collapse" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testView_visibility_gone_first_item_in_flex_line_horizontal = test(activity_visibility_gone_first_item_in_flex_line_row, noop, ({ root, flexbox, text1, text2, text3 }) => {
@@ -1575,7 +1575,7 @@ let activity_visibility_gone_first_item_in_flex_line_column = () =>
<Label id="text1" horizontalAlignment="left" height="160" text="1" backgroundColor="red" />
<Label id="text2" horizontalAlignment="left" height="160" text="1" backgroundColor="green" />
<Label id="text3" horizontalAlignment="left" height="160" text="1" visibility="collapse" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testView_visibility_gone_first_item_in_flex_line_vertical = test(activity_visibility_gone_first_item_in_flex_line_column, noop, ({ flexbox, text1, text3 }) => {
@@ -1589,7 +1589,7 @@ let activity_wrap_before_test = () =>
<Label id="text1" width="100" height="80" text="1" backgroundColor="red" />
<Label id="text2" width="100" height="80" text="2" backgroundColor="green" flexWrapBefore="true" />
<Label id="text3" width="100" height="80" text="3" backgroundColor="blue" flexWrapBefore="true" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testWrapBefore = test(activity_wrap_before_test, noop, ({ flexbox, text1, text2, text3 }) => {
@@ -1612,8 +1612,8 @@ export const testWrapBefore2 = test(
isLeftAlignedWith(text3, flexbox);
isBelow(text3, text1);
isBelow(text3, text2);
equal(height(flexbox), height(text1) + height(text3));
}
closeEnough(height(flexbox), height(text1) + height(text3));
},
);
export const testWrapBefore_nowrap = test(
@@ -1622,14 +1622,14 @@ export const testWrapBefore_nowrap = test(
({ flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isBottomAlignedWith(text1, flexbox);
isBottomAlignedWith(text1, flexbox, null, true);
isTopAlignedWith(text2, flexbox);
isRightOf(text2, text1);
isBottomAlignedWith(text2, flexbox);
isBottomAlignedWith(text2, flexbox, null, true);
isTopAlignedWith(text3, flexbox);
isRightOf(text3, text2);
isBottomAlignedWith(text3, flexbox);
}
isBottomAlignedWith(text3, flexbox, null, true);
},
);
let activity_wrap_parent_padding_horizontal_test = () =>
@@ -1638,7 +1638,7 @@ let activity_wrap_parent_padding_horizontal_test = () =>
<Label id="text1" width="280" height="80" text="1" backgroundColor="red" />
<Label id="text2" width="30" height="80" text="2" backgroundColor="green" />
<Label id="text3" width="100" height="80" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testWrap_parentPadding_horizontal = test(activity_wrap_parent_padding_horizontal_test, noop, ({ flexbox, text1, text2, text3 }) => {
@@ -1653,7 +1653,7 @@ let activity_wrap_parent_padding_vertical_test = () =>
<Label id="text1" width="80" height="280" text="1" backgroundColor="red" />
<Label id="text2" width="80" height="30" text="2" backgroundColor="green" />
<Label id="text3" width="80" height="80" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testWrap_parentPadding_vertical = test(activity_wrap_parent_padding_vertical_test, noop, ({ flexbox, text1, text2, text3 }) => {
@@ -1668,7 +1668,7 @@ let activity_wrap_child_margin_horizontal_test = () =>
<Label id="text1" width="280" height="80" text="1" backgroundColor="red" />
<Label id="text2" width="30" height="80" text="2" margin="32" backgroundColor="green" />
<Label id="text3" width="100" height="80" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testWrap_childMargin_horizontal = test(activity_wrap_child_margin_horizontal_test, noop, ({ flexbox, text1, text2, text3 }) => {
@@ -1683,7 +1683,7 @@ let activity_first_item_large_horizontal_test = () =>
<Label id="text1" width="500" height="60" text="1" />
<Label id="text2" width="120" height="60" text="2" />
<Label id="text3" width="300" height="60" text="3" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFirstItemLarge_horizontal = test(activity_first_item_large_horizontal_test, noop, ({ flexbox, text1, text2, text3 }) => {
@@ -1702,7 +1702,7 @@ let activity_first_item_large_vertical_test = () =>
<Label id="text1" width="60" height="500" text="1" backgroundColor="red" />
<Label id="text2" width="60" height="120" text="2" backgroundColor="green" />
<Label id="text3" width="6" height="300" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFirstItemLarge_vertical = test(activity_first_item_large_vertical_test, noop, ({ flexbox, text1, text2, text3 }) => {
@@ -1721,7 +1721,7 @@ let activity_wrap_child_margin_vertical_test = () =>
<Label id="text1" width="80" height="280" text="1" backgroundColor="red" />
<Label id="text2" width="80" height="30" margin="32" text="2" backgroundColor="green" />
<Label id="text3" width="80" height="80" text="3" backgroundColor="blue" />
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testWrap_childMargin_vertical = test(activity_wrap_child_margin_vertical_test, noop, ({ flexbox, text1, text2, text3 }) => {
@@ -1735,7 +1735,7 @@ let activity_flexbox_with_proxy_view_container = () =>
getViews(
`<FlexboxLayout iosOverflowSafeArea="false" id="flexbox">
<ProxyViewContainer></ProxyViewContainer>
</FlexboxLayout>`
</FlexboxLayout>`,
);
export const testFlexboxLayout_does_not_crash_with_proxy_view_container = test(activity_flexbox_with_proxy_view_container, noop, ({ root, flexbox }) => {

View File

@@ -88,8 +88,12 @@ export function isTopAlignedWith(view1: View, view2: View, message?: string) {
TKUnit.assertEqual(top(view1), top(view2), message || `${view1}:${top(view1)} is not top-aligned with ${view2}:${top(view2)}`);
}
export function isBottomAlignedWith(view1: View, view2: View, message?: string) {
TKUnit.assertEqual(bottom(view1), bottom(view2), message || `${view1}:${bottom(view1)} is not bottom-aligned with ${view2}:${bottom(view2)}`);
export function isBottomAlignedWith(view1: View, view2: View, message?: string, checkCloseEnough?: boolean) {
if (checkCloseEnough) {
closeEnough(bottom(view1), bottom(view2));
} else {
TKUnit.assertEqual(bottom(view1), bottom(view2), message || `${view1}:${bottom(view1)} is not bottom-aligned with ${view2}:${bottom(view2)}`);
}
}
export function isLeftOf(view1: View, view2: View, message?: string) {

View File

@@ -431,16 +431,16 @@ export class SafeAreaTests extends testModule.UITest<any> {
({ root, childLeft, childTop, childRight, childBottom, childFill }) => {
const insets = root.getSafeAreaInsets();
equal(left(childLeft), insets.left, `${childLeft}.left - actual: ${left(childLeft)} expected: ${insets.left}`);
equal(top(childLeft), insets.top, `${childLeft}.top - actual: ${top(childLeft)} expected: ${insets.top}`);
closeEnough(left(childLeft), insets.left, `${childLeft}.left - actual: ${left(childLeft)} expected: ${insets.left}`);
closeEnough(top(childLeft), insets.top, `${childLeft}.top - actual: ${top(childLeft)} expected: ${insets.top}`);
equal(top(childTop), insets.top, `${childTop}.top - actual: ${top(childTop)} expected: ${insets.top}`);
equal(right(childTop), width(root) - insets.right, `${childTop}.right - actual: ${right(childTop)} expected: ${width(root) - insets.right}`);
closeEnough(top(childTop), insets.top, `${childTop}.top - actual: ${top(childTop)} expected: ${insets.top}`);
closeEnough(right(childTop), width(root) - insets.right, `${childTop}.right - actual: ${right(childTop)} expected: ${width(root) - insets.right}`);
equal(right(childRight), width(root) - insets.right, `${childRight}.right - actual: ${right(childRight)} expected: ${width(root) - insets.right}`);
equal(bottom(childRight), height(root) - insets.bottom, `${childRight}.bottom - actual: ${bottom(childRight)} expected: ${height(root) - insets.bottom}`);
closeEnough(right(childRight), width(root) - insets.right, `${childRight}.right - actual: ${right(childRight)} expected: ${width(root) - insets.right}`);
closeEnough(bottom(childRight), height(root) - insets.bottom, `${childRight}.bottom - actual: ${bottom(childRight)} expected: ${height(root) - insets.bottom}`);
equal(bottom(childBottom), height(root) - insets.bottom, `${childBottom}.bottom - actual: ${bottom(childBottom)} expected: ${height(root) - insets.bottom}`);
closeEnough(bottom(childBottom), height(root) - insets.bottom, `${childBottom}.bottom - actual: ${bottom(childBottom)} expected: ${height(root) - insets.bottom}`);
isLeftWith(childLeft, childFill, width(childLeft));
isBelowWith(childTop, childFill, height(childTop));
@@ -686,13 +686,13 @@ export class SafeAreaTests extends testModule.UITest<any> {
({ root, child0, child2 }) => {
const insets = root.getSafeAreaInsets();
equal(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
equal(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
equal(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
closeEnough(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
closeEnough(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
closeEnough(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
equal(top(child2), insets.top, `${child2}.top - actual: ${top(child2)} expected: ${insets.top}`);
equal(right(child2), width(root) - insets.right, `${child2}.right - actual: ${right(child2)} expected: ${width(root) - insets.right}`);
equal(bottom(child2), height(root) - insets.bottom, `${child2}.bottom - actual: ${bottom(child2)} expected: ${height(root) - insets.bottom}`);
closeEnough(top(child2), insets.top, `${child2}.top - actual: ${top(child2)} expected: ${insets.top}`);
closeEnough(right(child2), width(root) - insets.right, `${child2}.right - actual: ${right(child2)} expected: ${width(root) - insets.right}`);
closeEnough(bottom(child2), height(root) - insets.bottom, `${child2}.bottom - actual: ${bottom(child2)} expected: ${height(root) - insets.bottom}`);
},
pageOptions,
);
@@ -1177,9 +1177,9 @@ export class SafeAreaTests extends testModule.UITest<any> {
this.noop,
({ root, child0, child1 }) => {
const insets = root.getSafeAreaInsets();
equal(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
equal(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
equal(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
closeEnough(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
closeEnough(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
closeEnough(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
isLeftWith(child0, child1, width(child0));
},
pageOptions,
@@ -1391,12 +1391,12 @@ export class SafeAreaTests extends testModule.UITest<any> {
this.noop,
({ root, child0, child1 }) => {
const insets = root.getSafeAreaInsets();
equal(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
equal(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
equal(right(child0), width(root) - insets.right, `${child0}.right - actual: ${right(child0)} expected: ${width(root) - insets.right}`);
equal(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
equal(height(child1), 0, `${child1} has been laid out, but should not`);
equal(width(child1), 0, `${child1} has been laid out, but should not`);
closeEnough(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
closeEnough(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
closeEnough(right(child0), width(root) - insets.right, `${child0}.right - actual: ${right(child0)} expected: ${width(root) - insets.right}`);
closeEnough(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
closeEnough(height(child1), 0, `${child1} has been laid out, but should not`);
closeEnough(width(child1), 0, `${child1} has been laid out, but should not`);
},
pageOptions,
);
@@ -1427,12 +1427,12 @@ export class SafeAreaTests extends testModule.UITest<any> {
this.noop,
({ root, child0, child1 }) => {
const insets = root.getSafeAreaInsets();
equal(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
equal(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
equal(right(child0), width(root) - insets.right, `${child0}.right - actual: ${right(child0)} expected: ${width(root) - insets.right}`);
equal(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
equal(height(child1), 0, `${child1} has been laid out, but should not`);
equal(width(child1), 0, `${child1} has been laid out, but should not`);
closeEnough(left(child0), insets.left, `${child0}.left - actual: ${left(child0)} expected: ${insets.left}`);
closeEnough(top(child0), insets.top, `${child0}.top - actual: ${top(child0)} expected: ${insets.top}`);
closeEnough(right(child0), width(root) - insets.right, `${child0}.right - actual: ${right(child0)} expected: ${width(root) - insets.right}`);
closeEnough(bottom(child0), height(root) - insets.bottom, `${child0}.bottom - actual: ${bottom(child0)} expected: ${height(root) - insets.bottom}`);
closeEnough(height(child1), 0, `${child1} has been laid out, but should not`);
closeEnough(width(child1), 0, `${child1} has been laid out, but should not`);
},
pageOptions,
);

View File

@@ -140,7 +140,11 @@ export function test_offset_zero_should_raise_same_events() {
resetActualEventsRaised();
waitUntilNavigatedToMaxTimeout([items[2].page], () => (tabView.selectedIndex = 2));
const expectedEventsRaisedAfterSelectThirdTab = [['Tab0 Frame0 Page0 unloaded', 'Tab0 Frame0 unloaded'], [], ['Tab2 Frame2 loaded', 'Tab2 Frame2 Page2 navigatingTo', 'Tab2 Frame2 Page2 loaded', 'Tab2 Frame2 Page2 navigatedTo']];
const startEvents = ['Tab0 Frame0 Page0 unloaded', 'Tab0 Frame0 unloaded'];
if (__APPLE__) {
startEvents.push('Tab0 Frame0 Page0 navigatingFrom');
}
const expectedEventsRaisedAfterSelectThirdTab = [startEvents, [], ['Tab2 Frame2 loaded', 'Tab2 Frame2 Page2 navigatingTo', 'Tab2 Frame2 Page2 loaded', 'Tab2 Frame2 Page2 navigatedTo']];
TKUnit.assertDeepEqual(actualEventsRaised, expectedEventsRaisedAfterSelectThirdTab);

View File

@@ -155,7 +155,7 @@ export class TabViewTest extends UITest<tabViewModule.TabView> {
TKUnit.assertEqual(actualValue, expectedValue, 'selectedIndex should be undefined.');
};
public testSelectedIndexBecomesUndefinedWhenItemsSetToNull = function () {
public testSelectedIndexBecomesNegativeOneWhenItemsSetToNull = function () {
var tabView = this.testView;
tabView.items = this._createItems(10);
tabView.selectedIndex = 9;
@@ -164,7 +164,7 @@ export class TabViewTest extends UITest<tabViewModule.TabView> {
tabView.items = null;
var expectedValue = -1;
var actualValue = tabView.selectedIndex;
TKUnit.assertEqual(actualValue, expectedValue, 'selectedIndex should be undefined.');
TKUnit.assertEqual(actualValue, expectedValue, 'selectedIndex should be -1.');
};
public testItemsIsResolvedCorrectlyIfSetBeforeViewIsLoaded = function () {

View File

@@ -390,7 +390,7 @@ export class TabView extends TabViewBase {
}
// The "< Back" and "< More" navigation bars should not be visible simultaneously.
const page = this.page || this._selectedView.page || (<any>this)._selectedView.currentPage;
const page = this.page || this._selectedView?.page || (<any>this)._selectedView?.currentPage;
if (!page || !page.frame) {
return;
}