mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Padding fix for stack-layout and tests
This commit is contained in:
@@ -73,6 +73,7 @@ export function test_padding() {
|
||||
return absoluteLayout.isLayoutValid;
|
||||
}, 1);
|
||||
|
||||
layoutHelper.assertMeasure(btn, 100, 100);
|
||||
layoutHelper.assertLayout(btn, 25, 35, 100, 100);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ export function test_padding() {
|
||||
|
||||
TKUnit.waitUntilReady(() => { return rootLayout.isLayoutValid; });
|
||||
|
||||
helper.assertMeasure(testBtn, 260, 240);
|
||||
helper.assertLayout(testBtn, 10, 20, 260, 240);
|
||||
}
|
||||
|
||||
|
||||
@@ -492,6 +492,7 @@ export function test_GridLayout_padding() {
|
||||
|
||||
TKUnit.waitUntilReady(() => { return btn.isLayoutValid });
|
||||
|
||||
helper.assertMeasure(btn, 260, 240);
|
||||
helper.assertLayout(btn, 10, 20, 260, 240);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,15 @@ export class MyButton extends button.Button {
|
||||
}
|
||||
}
|
||||
|
||||
export function assertMeasure(btn: MyButton, width: number, height: number, name?: string) {
|
||||
var density = utils.layout.getDisplayDensity();
|
||||
|
||||
name = name ? "[" + name + "]" : "";
|
||||
|
||||
TKUnit.assertAreClose(btn.measureWidth / density, width, DELTA, name + "width");
|
||||
TKUnit.assertAreClose(btn.measureHeight / density, height, DELTA, name + "height");
|
||||
}
|
||||
|
||||
export function assertLayout(btn: MyButton, left: number, top: number, width: number, height: number, name?: string): void {
|
||||
var density = utils.layout.getDisplayDensity();
|
||||
|
||||
|
||||
@@ -175,6 +175,9 @@ export function test_StackLayout_Padding_Vertical() {
|
||||
return btn2.arranged;
|
||||
}, ASYNC);
|
||||
|
||||
helper.assertMeasure(btn1, 260, 50);
|
||||
helper.assertMeasure(btn1, 260, 50);
|
||||
|
||||
helper.assertLayout(btn1, 10, 20, 260, 50, "btn1");
|
||||
helper.assertLayout(btn2, 10, 70, 260, 50, "btn2");
|
||||
}
|
||||
@@ -196,6 +199,9 @@ export function test_StackLayout_Padding_Horizontal() {
|
||||
return btn2.arranged;
|
||||
}, ASYNC);
|
||||
|
||||
helper.assertMeasure(btn1, 50, 240);
|
||||
helper.assertMeasure(btn1, 50, 240);
|
||||
|
||||
helper.assertLayout(btn1, 10, 20, 50, 240, "btn1");
|
||||
helper.assertLayout(btn2, 60, 20, 50, 240, "btn2");
|
||||
}
|
||||
|
||||
@@ -230,6 +230,9 @@ export function testPaddingRight() {
|
||||
return wrapLayout.isLayoutValid;
|
||||
});
|
||||
|
||||
layoutHelper.assertMeasure(btn1, 100, 50);
|
||||
layoutHelper.assertMeasure(btn2, 80, 50);
|
||||
|
||||
// There should be no space left for the button on the first row,
|
||||
// because fo the padding (200 - 100 - 30) = 70 button wants 80
|
||||
layoutHelper.assertLayout(btn1, 0, 0, 100, 50, "button1");
|
||||
@@ -258,6 +261,9 @@ export function testPaddingBottom() {
|
||||
return wrapLayout.isLayoutValid;
|
||||
});
|
||||
|
||||
layoutHelper.assertMeasure(btn1, 50, 100);
|
||||
layoutHelper.assertMeasure(btn2, 50, 80);
|
||||
|
||||
// There should be no space left for the button on the first row,
|
||||
// because fo the padding (200 - 100 - 30) = 70 button wants 80
|
||||
layoutHelper.assertLayout(btn1, 0, 0, 50, 100, "button1");
|
||||
|
||||
Reference in New Issue
Block a user