Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions apps/automated/src/ui/image/image-tests.ts
Original file line number Diff line number Diff line change
@@ -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, Utils } from '@nativescript/core';
import { PropertyChangeData } from '@nativescript/core';
import * as utils from '@nativescript/core/utils';
import * as TKUnit from '../../tk-unit';
import { getColor } from '../../ui-helper';
Expand All @@ -27,8 +27,6 @@ if (__ANDROID__) {
appHelpers.initImageCache(Application.android.startActivity, appHelpers.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');
Expand Down Expand Up @@ -269,17 +267,17 @@ export const test_SettingImageSourceWhenSizedToParentDoesNotRequestLayout = ios(

let mainPage = helper.getCurrentPage();
mainPage.content = host;
TKUnit.waitUntilReady(() => host.isLoaded);

const nativeHostView = host.nativeViewProtected as UIView;

// Check if native view layer is still marked as dirty before proceeding
TKUnit.waitUntilReady(() => host.isLoaded && nativeHostView?.layer && !nativeHostView.layer.needsLayout());

let called = false;
image.requestLayout = () => (called = true);
image.src = '~/assets/logo.png';

if (expectLayoutRequest) {
TKUnit.assertTrue(called, 'image.requestLayout should be called.');
} else {
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
}
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
});

export const test_SettingImageSourceWhenFixedWidthAndHeightDoesNotRequestLayout = ios(() => {
Expand All @@ -291,17 +289,17 @@ export const test_SettingImageSourceWhenFixedWidthAndHeightDoesNotRequestLayout

let mainPage = helper.getCurrentPage();
mainPage.content = host;
TKUnit.waitUntilReady(() => host.isLoaded);

const nativeHostView = host.nativeViewProtected as UIView;

// Check if native view layer is still marked as dirty before proceeding
TKUnit.waitUntilReady(() => host.isLoaded && nativeHostView?.layer && !nativeHostView.layer.needsLayout());

let called = false;
image.requestLayout = () => (called = true);
image.src = '~/assets/logo.png';

if (expectLayoutRequest) {
TKUnit.assertTrue(called, 'image.requestLayout should be called.');
} else {
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
}
TKUnit.assertFalse(called, 'image.requestLayout should not be called.');
});

export const test_SettingImageSourceWhenSizedToContentShouldInvalidate = ios(() => {
Expand Down
18 changes: 10 additions & 8 deletions apps/automated/src/ui/label/label-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import * as helper from '../../ui-helper';

const testDir = 'ui/label';

const expectLayoutRequest = __APPLE__ && Utils.SDK_VERSION >= 18;

export class LabelTest extends testModule.UITest<Label> {
public create(): Label {
const label = new Label();
Expand Down Expand Up @@ -603,7 +601,11 @@ export class LabelTest extends testModule.UITest<Label> {

let mainPage = helper.getCurrentPage();
mainPage.content = host;
TKUnit.waitUntilReady(() => host.isLoaded);

const nativeHostView = host.nativeViewProtected as UIView;

// Check if native view layer is still marked as dirty before proceeding
TKUnit.waitUntilReady(() => host.isLoaded && nativeHostView?.layer && !nativeHostView.layer.needsLayout());

let called = false;
label.requestLayout = () => (called = true);
Expand All @@ -618,7 +620,7 @@ export class LabelTest extends testModule.UITest<Label> {
}

public test_SettingTextWhenInFixedSizeGridShouldNotRequestLayout() {
this.requestLayoutFixture(expectLayoutRequest, '', (label) => {
this.requestLayoutFixture(false, '', (label) => {
label.textWrap = false;
let host = new GridLayout();
host.width = 100;
Expand All @@ -629,7 +631,7 @@ export class LabelTest extends testModule.UITest<Label> {
}

public test_ChangingTextWhenInFixedSizeGridShouldNotRequestLayout() {
this.requestLayoutFixture(expectLayoutRequest, 'Hello World', (label) => {
this.requestLayoutFixture(false, 'Hello World', (label) => {
label.textWrap = false;
let host = new GridLayout();
host.width = 100;
Expand All @@ -640,7 +642,7 @@ export class LabelTest extends testModule.UITest<Label> {
}

public test_SettingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
this.requestLayoutFixture(expectLayoutRequest, '', (label) => {
this.requestLayoutFixture(false, '', (label) => {
label.textWrap = false;
let host = new StackLayout();
label.width = 100;
Expand All @@ -651,7 +653,7 @@ export class LabelTest extends testModule.UITest<Label> {
}

public test_ChangingTextWhenFixedWidthAndHeightDoesNotRequestLayout() {
this.requestLayoutFixture(expectLayoutRequest, 'Hello World', (label) => {
this.requestLayoutFixture(false, 'Hello World', (label) => {
label.textWrap = false;
let host = new StackLayout();
label.width = 100;
Expand Down Expand Up @@ -692,7 +694,7 @@ export class LabelTest extends testModule.UITest<Label> {
}

public test_ChangingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldNotRequestLayout() {
this.requestLayoutFixture(expectLayoutRequest, 'Hello World', (label) => {
this.requestLayoutFixture(false, 'Hello World', (label) => {
label.textWrap = false;
let host = new StackLayout();
host.width = 100;
Expand Down
Loading