fix test project

Signed-off-by: yangbo <1442420648@qq.com>
Change-Id: I8aec7f2d8d4822d517bfd6a617b791f2100f5680
This commit is contained in:
yangbo
2022-01-03 08:58:15 +08:00
parent 9d4ba8fda1
commit 18cca15b14
3 changed files with 104 additions and 42 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import DefaultComponent from "./test/pages/DefaultComponent.ets"
import DefaultComponent from "./DefaultComponent.ets"
@Component
struct ExportComponent1 {
+1 -1
View File
@@ -13,4 +13,4 @@
* limitations under the License.
*/
export * as AllStarComponent from './test/pages/ExportComponent';
export * as AllStarComponent from './ExportComponent';
+102 -40
View File
@@ -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
@Builder aa(label: string) {
Text(label)
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)
}
build() {
Column() {
bb()
SquareText("A", this.size)
this.aa("A")
@Builder popupBuilder() {
Flex({direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItem: ItemAlign.Center}){
Text('Content of CustomPopup')
.fontSize(20)
}
.width(100)
.height(50)
}
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, {}));
`