From cb9a1778c42d4210376c49bdb70d1ed741e385af Mon Sep 17 00:00:00 2001 From: yangbo <1442420648@qq.com> Date: Mon, 3 Jan 2022 08:58:15 +0800 Subject: [PATCH] fix test project Signed-off-by: yangbo <1442420648@qq.com> Change-Id: I8aec7f2d8d4822d517bfd6a617b791f2100f5680 --- compiler/test/pages/ExportComponent.ets | 2 +- compiler/test/pages/ExportStarComponent.ets | 2 +- compiler/test/ut/decorator/builder.ts | 140 ++++++++++++++------ 3 files changed, 103 insertions(+), 41 deletions(-) diff --git a/compiler/test/pages/ExportComponent.ets b/compiler/test/pages/ExportComponent.ets index d3d65b425..8a3f99cfc 100644 --- a/compiler/test/pages/ExportComponent.ets +++ b/compiler/test/pages/ExportComponent.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import DefaultComponent from "./test/pages/DefaultComponent.ets" +import DefaultComponent from "./DefaultComponent.ets" @Component struct ExportComponent1 { diff --git a/compiler/test/pages/ExportStarComponent.ets b/compiler/test/pages/ExportStarComponent.ets index 164a1cc91..aabfcd9ae 100644 --- a/compiler/test/pages/ExportStarComponent.ets +++ b/compiler/test/pages/ExportStarComponent.ets @@ -13,4 +13,4 @@ * limitations under the License. */ -export * as AllStarComponent from './test/pages/ExportComponent'; +export * as AllStarComponent from './ExportComponent'; diff --git a/compiler/test/ut/decorator/builder.ts b/compiler/test/ut/decorator/builder.ts index 9b8c506fb..bbdef6daf 100644 --- a/compiler/test/ut/decorator/builder.ts +++ b/compiler/test/ut/decorator/builder.ts @@ -14,73 +14,135 @@ */ exports.source = ` -@Builder -function SquareText(label: string, size: number) { - Text(label) - .width(1 * size).height(1 * size) -} - -@Builder -function bb() { - Text("label") -} - @Entry @Component -struct HomeComponent { - size = 1 +struct CompA { + size: number = 100; + @State customPopupArrow: boolean = false + @Builder SquareText(label: string){ + Text(label) + .width(1 * this.size) + .height(1 * this.size) + } +@Builder RowOfSquareTexts (label1: string, label2: string){ + Row(){ + this.SquareText(label1) + this.SquareText(label2) + } + .width(1 * this.size) + .height(1 * this.size) +} - @Builder aa(label: string) { - Text(label) +@Builder popupBuilder() { + Flex({direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItem: ItemAlign.Center}){ + Text('Content of CustomPopup') + .fontSize(20) } + .width(100) + .height(50) +} - build() { - Column() { - bb() - SquareText("A", this.size) - this.aa("A") + build(){ + Column(){ + Row(){ + this.SquareText("A") + this.SquareText("B") + } + .width(2 * this.size) + .height(1 * this.size) + .bindPopup(this.customPopupArrow, { + builder: this.popupBuilder, + placement: Placement.Bottom, + maskColor: 0x01000000, + popupColor: Color.Red, + enableArrow: true, + onStateChange: (e) => { + if(!e.isVisible){ + this.customPopupArrow = false + } + } + }) + this.RowOfSquareTexts("C", "D") } - .height(500) + .width(2 * this.size) + .height(2 * this.size) } }` exports.expectResult = -`function SquareText(label, size) { - Text.create(label); - Text.width(1 * size); - Text.height(1 * size); - Text.pop(); -} -function bb() { - Text.create("label"); - Text.pop(); -} -class HomeComponent extends View { +`class CompA extends View { constructor(compilerAssignedUniqueChildId, parent, params) { super(compilerAssignedUniqueChildId, parent); - this.size = 1; + this.size = 100; + this.__customPopupArrow = new ObservedPropertySimple(false, this, "customPopupArrow"); this.updateWithValueParams(params); } updateWithValueParams(params) { if (params.size !== undefined) { this.size = params.size; } + if (params.customPopupArrow !== undefined) { + this.customPopupArrow = params.customPopupArrow; + } } aboutToBeDeleted() { + this.__customPopupArrow.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id()); } - aa(label) { + get customPopupArrow() { + return this.__customPopupArrow.get(); + } + set customPopupArrow(newValue) { + this.__customPopupArrow.set(newValue); + } + SquareText(label) { Text.create(label); + Text.width(1 * this.size); + Text.height(1 * this.size); + Text.pop(); + } + RowOfSquareTexts(label1, label2) { + Row.create(); + Row.width(1 * this.size); + Row.height(1 * this.size); + this.SquareText(label1); + this.SquareText(label2); + Row.pop(); + } + popupBuilder() { + Flex.create({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItem: ItemAlign.Center }); + Flex.width(100); + Flex.height(50); + Text.create('Content of CustomPopup'); + Text.fontSize(20); Text.pop(); + Flex.pop(); } render() { Column.create(); - Column.height(500); - bb(); - SquareText("A", this.size); - this.aa("A"); + Column.width(2 * this.size); + Column.height(2 * this.size); + Row.create(); + Row.width(2 * this.size); + Row.height(1 * this.size); + Row.bindPopup(this.customPopupArrow, { + builder: { builder: this.popupBuilder.bind(this) }, + placement: Placement.Bottom, + maskColor: 0x01000000, + popupColor: Color.Red, + enableArrow: true, + onStateChange: (e) => { + if (!e.isVisible) { + this.customPopupArrow = false; + } + } + }); + this.SquareText("A"); + this.SquareText("B"); + Row.pop(); + this.RowOfSquareTexts("C", "D"); Column.pop(); } } -loadDocument(new HomeComponent("1", undefined, {})); +loadDocument(new CompA("1", undefined, {})); ` -- Gitee