• 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 });
61let __generate__Id = 0;
62function generateId() {
63    return "importExportNest_" + ++__generate__Id;
64}
65const ImportNestAll_1 = require("./test/pages/ImportNestAll");
66class ImportTest extends View {
67    constructor(compilerAssignedUniqueChildId, parent, params, localStorage) {
68        super(compilerAssignedUniqueChildId, parent, localStorage);
69        this.__testText1 = new ObservedPropertySimple('Hello', this, "testText1");
70        this.__testText2 = new ObservedPropertySimple('World', this, "testText2");
71        this.__testText3 = new ObservedPropertySimple('Test', this, "testText3");
72        this.__testText4 = new ObservedPropertySimple('Component', this, "testText4");
73        this.__testState1 = new ObservedPropertySimple('Base', this, "testState1");
74        this.__testState2 = new ObservedPropertySimple(0, this, "testState2");
75        this.__testState3 = new ObservedPropertyObject({ name: 'Base' }, this, "testState3");
76        this.__testState4 = new ObservedPropertySimple(3, this, "testState4");
77        this.__testState5 = new ObservedPropertySimple(10, this, "testState5");
78        this.updateWithValueParams(params);
79    }
80    updateWithValueParams(params) {
81        if (params.testText1 !== undefined) {
82            this.testText1 = params.testText1;
83        }
84        if (params.testText2 !== undefined) {
85            this.testText2 = params.testText2;
86        }
87        if (params.testText3 !== undefined) {
88            this.testText3 = params.testText3;
89        }
90        if (params.testText4 !== undefined) {
91            this.testText4 = params.testText4;
92        }
93        if (params.testState1 !== undefined) {
94            this.testState1 = params.testState1;
95        }
96        if (params.testState2 !== undefined) {
97            this.testState2 = params.testState2;
98        }
99        if (params.testState3 !== undefined) {
100            this.testState3 = params.testState3;
101        }
102        if (params.testState4 !== undefined) {
103            this.testState4 = params.testState4;
104        }
105        if (params.testState5 !== undefined) {
106            this.testState5 = params.testState5;
107        }
108    }
109    aboutToBeDeleted() {
110        this.__testText1.aboutToBeDeleted();
111        this.__testText2.aboutToBeDeleted();
112        this.__testText3.aboutToBeDeleted();
113        this.__testText4.aboutToBeDeleted();
114        this.__testState1.aboutToBeDeleted();
115        this.__testState2.aboutToBeDeleted();
116        this.__testState3.aboutToBeDeleted();
117        this.__testState4.aboutToBeDeleted();
118        this.__testState5.aboutToBeDeleted();
119        SubscriberManager.Get().delete(this.id());
120    }
121    get testText1() {
122        return this.__testText1.get();
123    }
124    set testText1(newValue) {
125        this.__testText1.set(newValue);
126    }
127    get testText2() {
128        return this.__testText2.get();
129    }
130    set testText2(newValue) {
131        this.__testText2.set(newValue);
132    }
133    get testText3() {
134        return this.__testText3.get();
135    }
136    set testText3(newValue) {
137        this.__testText3.set(newValue);
138    }
139    get testText4() {
140        return this.__testText4.get();
141    }
142    set testText4(newValue) {
143        this.__testText4.set(newValue);
144    }
145    get testState1() {
146        return this.__testState1.get();
147    }
148    set testState1(newValue) {
149        this.__testState1.set(newValue);
150    }
151    get testState2() {
152        return this.__testState2.get();
153    }
154    set testState2(newValue) {
155        this.__testState2.set(newValue);
156    }
157    get testState3() {
158        return this.__testState3.get();
159    }
160    set testState3(newValue) {
161        this.__testState3.set(newValue);
162    }
163    get testState4() {
164        return this.__testState4.get();
165    }
166    set testState4(newValue) {
167        this.__testState4.set(newValue);
168    }
169    get testState5() {
170        return this.__testState5.get();
171    }
172    set testState5(newValue) {
173        this.__testState5.set(newValue);
174    }
175    render() {
176        Column.create();
177        Text.create(this.testText1);
178        Text.fontSize(50);
179        Text.pop();
180        ImportNestAll_1.tExtend(20, this);
181        Text.create(this.testText2);
182        Text.pop();
183        ImportNestAll_1.tStyles(this);
184        Button.createWithLabel(this.testText3);
185        Button.pop();
186        Text.create(this.testText4);
187        Text.fontSize(50);
188        Text.pop();
189        let earlierCreatedChild_2 = (this && this.findChildById) ? this.findChildById("2") : undefined;
190        if (earlierCreatedChild_2 == undefined) {
191            View.create(new ImportNestAll_1.Base("2", this, {
192                testStr: this.__testState1,
193                testNum: this.__testState2,
194                testObj: this.__testState3
195            }));
196        }
197        else {
198            earlierCreatedChild_2.updateWithValueParams({});
199            View.create(earlierCreatedChild_2);
200        }
201        let earlierCreatedChild_3 = (this && this.findChildById) ? this.findChildById("3") : undefined;
202        if (earlierCreatedChild_3 == undefined) {
203            View.create(new ImportNestAll_1.DivideTest("3", this, {
204                testNum1: this.__testState4,
205                testNum2: this.__testState5
206            }));
207        }
208        else {
209            earlierCreatedChild_3.updateWithValueParams({});
210            View.create(earlierCreatedChild_3);
211        }
212        Column.pop();
213    }
214}
215loadDocument(new ImportTest("1", undefined, {}));
216`
217