• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16exports.source = `
17import { tExtend, tStyles, DivideTest, Base } from './test/pages/ImportNestAll';
18
19@Entry
20@Component
21struct ImportTest {
22  @State testText1: string = 'Hello'
23  @State testText2: string = 'World'
24  @State testText3: string = 'Test'
25  @State testText4: string = 'Component'
26
27  @State testState1: string = 'Base'
28  @State testState2: number = 0
29  @State testState3: object = { name: 'Base' }
30  @State testState4: number = 3
31  @State testState5: number = 10
32
33  build() {
34    Column() {
35      Text(this.testText1)
36        .fontSize(50)
37      tExtend(20)
38      Text(this.testText2)
39      tStyles()
40      Button(this.testText3)
41      Text(this.testText4)
42        .fontSize(50)
43
44      Base({
45        testStr: $testState1,
46        testNum: $testState2,
47        testObj: $testState3
48      })
49      DivideTest({
50        testNum1: $testState4,
51        testNum2: $testState5
52      })
53    }
54  }
55}
56`
57
58exports.expectResult =
59`"use strict";
60Object.defineProperty(exports, "__esModule", { value: true });
61const ImportNestAll_1 = require("./test/pages/ImportNestAll");
62class ImportTest extends ViewPU {
63    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined) {
64        super(parent, __localStorage, elmtId);
65        if (typeof paramsLambda === "function") {
66            this.paramsGenerator_ = paramsLambda;
67        }
68        this.__testText1 = new ObservedPropertySimplePU('Hello', this, "testText1");
69        this.__testText2 = new ObservedPropertySimplePU('World', this, "testText2");
70        this.__testText3 = new ObservedPropertySimplePU('Test', this, "testText3");
71        this.__testText4 = new ObservedPropertySimplePU('Component', this, "testText4");
72        this.__testState1 = new ObservedPropertySimplePU('Base', this, "testState1");
73        this.__testState2 = new ObservedPropertySimplePU(0, this, "testState2");
74        this.__testState3 = new ObservedPropertyObjectPU({ name: 'Base' }, this, "testState3");
75        this.__testState4 = new ObservedPropertySimplePU(3, this, "testState4");
76        this.__testState5 = new ObservedPropertySimplePU(10, this, "testState5");
77        this.setInitiallyProvidedValue(params);
78    }
79    setInitiallyProvidedValue(params) {
80        if (params.testText1 !== undefined) {
81            this.testText1 = params.testText1;
82        }
83        if (params.testText2 !== undefined) {
84            this.testText2 = params.testText2;
85        }
86        if (params.testText3 !== undefined) {
87            this.testText3 = params.testText3;
88        }
89        if (params.testText4 !== undefined) {
90            this.testText4 = params.testText4;
91        }
92        if (params.testState1 !== undefined) {
93            this.testState1 = params.testState1;
94        }
95        if (params.testState2 !== undefined) {
96            this.testState2 = params.testState2;
97        }
98        if (params.testState3 !== undefined) {
99            this.testState3 = params.testState3;
100        }
101        if (params.testState4 !== undefined) {
102            this.testState4 = params.testState4;
103        }
104        if (params.testState5 !== undefined) {
105            this.testState5 = params.testState5;
106        }
107    }
108    updateStateVars(params) {
109    }
110    purgeVariableDependenciesOnElmtId(rmElmtId) {
111        this.__testText1.purgeDependencyOnElmtId(rmElmtId);
112        this.__testText2.purgeDependencyOnElmtId(rmElmtId);
113        this.__testText3.purgeDependencyOnElmtId(rmElmtId);
114        this.__testText4.purgeDependencyOnElmtId(rmElmtId);
115        this.__testState1.purgeDependencyOnElmtId(rmElmtId);
116        this.__testState2.purgeDependencyOnElmtId(rmElmtId);
117        this.__testState3.purgeDependencyOnElmtId(rmElmtId);
118        this.__testState4.purgeDependencyOnElmtId(rmElmtId);
119        this.__testState5.purgeDependencyOnElmtId(rmElmtId);
120    }
121    aboutToBeDeleted() {
122        this.__testText1.aboutToBeDeleted();
123        this.__testText2.aboutToBeDeleted();
124        this.__testText3.aboutToBeDeleted();
125        this.__testText4.aboutToBeDeleted();
126        this.__testState1.aboutToBeDeleted();
127        this.__testState2.aboutToBeDeleted();
128        this.__testState3.aboutToBeDeleted();
129        this.__testState4.aboutToBeDeleted();
130        this.__testState5.aboutToBeDeleted();
131        SubscriberManager.Get().delete(this.id__());
132        this.aboutToBeDeletedInternal();
133    }
134    get testText1() {
135        return this.__testText1.get();
136    }
137    set testText1(newValue) {
138        this.__testText1.set(newValue);
139    }
140    get testText2() {
141        return this.__testText2.get();
142    }
143    set testText2(newValue) {
144        this.__testText2.set(newValue);
145    }
146    get testText3() {
147        return this.__testText3.get();
148    }
149    set testText3(newValue) {
150        this.__testText3.set(newValue);
151    }
152    get testText4() {
153        return this.__testText4.get();
154    }
155    set testText4(newValue) {
156        this.__testText4.set(newValue);
157    }
158    get testState1() {
159        return this.__testState1.get();
160    }
161    set testState1(newValue) {
162        this.__testState1.set(newValue);
163    }
164    get testState2() {
165        return this.__testState2.get();
166    }
167    set testState2(newValue) {
168        this.__testState2.set(newValue);
169    }
170    get testState3() {
171        return this.__testState3.get();
172    }
173    set testState3(newValue) {
174        this.__testState3.set(newValue);
175    }
176    get testState4() {
177        return this.__testState4.get();
178    }
179    set testState4(newValue) {
180        this.__testState4.set(newValue);
181    }
182    get testState5() {
183        return this.__testState5.get();
184    }
185    set testState5(newValue) {
186        this.__testState5.set(newValue);
187    }
188    initialRender() {
189        this.observeComponentCreation2((elmtId, isInitialRender) => {
190            Column.create();
191        }, Column);
192        this.observeComponentCreation2((elmtId, isInitialRender) => {
193            Text.create(this.testText1);
194            Text.fontSize(50);
195        }, Text);
196        Text.pop();
197        ImportNestAll_1.tExtend.bind(this)(20);
198        this.observeComponentCreation2((elmtId, isInitialRender) => {
199            Text.create(this.testText2);
200        }, Text);
201        Text.pop();
202        ImportNestAll_1.tStyles.bind(this)();
203        this.observeComponentCreation2((elmtId, isInitialRender) => {
204            Button.createWithLabel(this.testText3);
205        }, Button);
206        Button.pop();
207        this.observeComponentCreation2((elmtId, isInitialRender) => {
208            Text.create(this.testText4);
209            Text.fontSize(50);
210        }, Text);
211        Text.pop();
212        {
213            this.observeComponentCreation2((elmtId, isInitialRender) => {
214                if (isInitialRender) {
215                    let paramsLambda = () => {
216                        return {
217                            testStr: this.testState1,
218                            testNum: this.testState2,
219                            testObj: this.testState3
220                        };
221                    };
222                    ViewPU.create(new ImportNestAll_1.Base(this, {
223                        testStr: this.__testState1,
224                        testNum: this.__testState2,
225                        testObj: this.__testState3
226                    }, undefined, elmtId, paramsLambda));
227                }
228                else {
229                    this.updateStateVarsOfChildByElmtId(elmtId, {});
230                }
231            }, null);
232        }
233        {
234            this.observeComponentCreation2((elmtId, isInitialRender) => {
235                if (isInitialRender) {
236                    let paramsLambda = () => {
237                        return {
238                            testNum1: this.testState4,
239                            testNum2: this.testState5
240                        };
241                    };
242                    ViewPU.create(new ImportNestAll_1.DivideTest(this, {
243                        testNum1: this.__testState4,
244                        testNum2: this.__testState5
245                    }, undefined, elmtId, paramsLambda));
246                }
247                else {
248                    this.updateStateVarsOfChildByElmtId(elmtId, {});
249                }
250            }, null);
251        }
252        Column.pop();
253    }
254    rerender() {
255        this.updateDirtyElements();
256    }
257}
258ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent());
259loadDocument(new ImportTest(undefined, {}));
260ViewStackProcessor.StopGetAccessRecording();
261`
262