| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -524,12 +524,13 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> { | |||
| 524 | 524 | TKUnit.assertNotEqual(this.errorMessage, undefined); | |
| 525 | 525 | } | |
| 526 | 526 | ||
| 527 | - private requestLayoutFixture(expectRequestLayout: boolean, setup: (label: Label) => LayoutBase): void { | ||
| 527 | + private requestLayoutFixture(expectRequestLayout: boolean, initialValue: string, setup: (label: Label) => LayoutBase): void { | ||
| 528 | 528 | if (!isIOS) { | |
| 529 | 529 | return; | |
| 530 | 530 | } | |
| 531 | 531 | ||
| 532 | 532 | let label = new Label(); | |
| 533 | + label.text = initialValue; | ||
| 533 | 534 | let host = setup(label); | |
| 534 | 535 | ||
| 535 | 536 | host.addChild(label); | |
@@ -540,7 +541,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> { | |||
| 540 | 541 | ||
| 541 | 542 | let called = false; | |
| 542 | 543 | label.requestLayout = () => called = true; | |
| 543 | - label.text = "Hello World"; | ||
| 544 | + // changing text actually could request layout | ||
| 545 | + label.text = initialValue + " Again"; | ||
| 544 | 546 | ||
| 545 | 547 | if (expectRequestLayout) { | |
| 546 | 548 | TKUnit.assertTrue(called, "label.requestLayout should be called."); | |
@@ -550,7 +552,16 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> { | |||
| 550 | 552 | } | |
| 551 | 553 | ||
| 552 | 554 | public test_SettingTextWhenInFixedSizeGridShouldNotRequestLayout() { | |
| 553 | - this.requestLayoutFixture(false, () => { | ||
| 555 | + this.requestLayoutFixture(false, "", () => { | ||
| 556 | + let host = new GridLayout(); | ||
| 557 | + host.width = 100; | ||
| 558 | + host.height = 100; | ||
| 559 | + return host; | ||
| 560 | + }); | ||
| 561 | + } | ||
| 562 | + | ||
| 563 | + public test_ChangingTextWhenInFixedSizeGridShouldNotRequestLayout() { | ||
| 564 | + this.requestLayoutFixture(false, "Hello World", () => { | ||
| 554 | 565 | let host = new GridLayout(); | |
| 555 | 566 | host.width = 100; | |
| 556 | 567 | host.height = 100; | |
@@ -559,7 +570,16 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> { | |||
| 559 | 570 | } | |
| 560 | 571 | ||
| 561 | 572 | public test_SettingTextWhenFixedWidthAndHeightDoesNotRequestLayout() { | |
| 562 | - this.requestLayoutFixture(false, label => { | ||
| 573 | + this.requestLayoutFixture(false, "", label => { | ||
| 574 | + let host = new StackLayout(); | ||
| 575 | + label.width = 100; | ||
| 576 | + label.height = 100; | ||
| 577 | + return host; | ||
| 578 | + }); | ||
| 579 | + }; | ||
| 580 | + | ||
| 581 | + public test_ChangingTextWhenFixedWidthAndHeightDoesNotRequestLayout() { | ||
| 582 | + this.requestLayoutFixture(false, "Hello World", label => { | ||
| 563 | 583 | let host = new StackLayout(); | |
| 564 | 584 | label.width = 100; | |
| 565 | 585 | label.height = 100; | |
@@ -568,23 +588,48 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> { | |||
| 568 | 588 | }; | |
| 569 | 589 | ||
| 570 | 590 | public test_SettingTextWhenSizedToContentShouldInvalidate() { | |
| 571 | - this.requestLayoutFixture(true, () => { | ||
| 591 | + this.requestLayoutFixture(true, "", () => { | ||
| 572 | 592 | let host = new StackLayout(); | |
| 573 | 593 | host.orientation = "horizontal"; | |
| 574 | 594 | return host; | |
| 575 | 595 | }); | |
| 576 | 596 | }; | |
| 577 | 597 | ||
| 578 | - public test_SettingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldNotRequestLayout() { | ||
| 579 | - this.requestLayoutFixture(false, () => { | ||
| 598 | + public test_ChangingTextWhenSizedToContentShouldInvalidate() { | ||
| 599 | + this.requestLayoutFixture(true, "Hello World", () => { | ||
| 600 | + let host = new StackLayout(); | ||
| 601 | + host.orientation = "horizontal"; | ||
| 602 | + return host; | ||
| 603 | + }); | ||
| 604 | + }; | ||
| 605 | + | ||
| 606 | + public test_SettingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldRequestLayout() { | ||
| 607 | + this.requestLayoutFixture(true, "", () => { | ||
| 608 | + let host = new StackLayout(); | ||
| 609 | + host.width = 100; | ||
| 610 | + return host; | ||
| 611 | + }); | ||
| 612 | + } | ||
| 613 | + | ||
| 614 | + public test_ChangingTextOnSingleLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldNotRequestLayout() { | ||
| 615 | + this.requestLayoutFixture(false, "Hello World", () => { | ||
| 580 | 616 | let host = new StackLayout(); | |
| 581 | 617 | host.width = 100; | |
| 582 | 618 | return host; | |
| 583 | 619 | }); | |
| 584 | 620 | } | |
| 585 | 621 | ||
| 586 | 622 | public test_SettingTextOnMultilineLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldRequestLayout() { | |
| 587 | - this.requestLayoutFixture(true, label => { | ||
| 623 | + this.requestLayoutFixture(true, "", label => { | ||
| 624 | + label.textWrap = true; | ||
| 625 | + let host = new StackLayout(); | ||
| 626 | + host.width = 100; | ||
| 627 | + return host; | ||
| 628 | + }); | ||
| 629 | + } | ||
| 630 | + | ||
| 631 | + public test_ChangingTextOnMultilineLineTextWhenWidthIsSizedToParentAndHeightIsSizedToContentShouldRequestLayout() { | ||
| 632 | + this.requestLayoutFixture(true, "Hello World", label => { | ||
| 588 | 633 | label.textWrap = true; | |
| 589 | 634 | let host = new StackLayout(); | |
| 590 | 635 | host.width = 100; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ export class Label extends common.Label { | |||
| 48 | 48 | if (this._fixedSize === FixedSize.BOTH) { | |
| 49 | 49 | return; | |
| 50 | 50 | } | |
| 51 | - if (this._fixedSize === FixedSize.WIDTH && !this.textWrap) { | ||
| 51 | + if (this._fixedSize === FixedSize.WIDTH && !this.textWrap && this.getMeasuredHeight() > 0) { | ||
| 52 | 52 | // Single line label with fixed width will skip request layout on text change. | |
| 53 | 53 | return; | |
| 54 | 54 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments