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 * as AllComponent from './test/pages/NamespaceComponent'
18import TsModule from './test/pages/TsModule'
19
20@Entry
21@Component
22struct ImportTest {
23  @State myState1: any = new TsModule(1).method()
24  @State myState2: number = 0
25  @State myState3: boolean = false
26  @State myState4: string = 'ImportTest'
27
28  build() {
29    Column() {
30        AllComponent.NamespaceComponent1({
31            NamespaceComponent1Link1: $myState1,
32            NamespaceComponent1Link2: $myState2,
33            NamespaceComponent1Link3: $myState3,
34            NamespaceComponent1Link4: $myState4,
35            myVar: 100,
36            myVar2: 80
37          })
38        AllComponent.NamespaceComponent1({
39            NamespaceComponent1Link1: $myState1,
40            NamespaceComponent1Link2: $myState2,
41            NamespaceComponent1Link3: $myState3,
42            NamespaceComponent1Link4: $myState4,
43            myVar: 100,
44            myVar2: 80
45          })
46          .width(100)
47          AllComponent.default({
48            NamespaceComponent3Link1: $myState1,
49            NamespaceComponent3Link2: $myState2,
50            NamespaceComponent3Link3: $myState3,
51            NamespaceComponent3Link4: $myState4,
52            myVar: 100,
53            myVar2: 80
54          })
55          AllComponent.default({
56            NamespaceComponent3Link1: $myState1,
57            NamespaceComponent3Link2: $myState2,
58            NamespaceComponent3Link3: $myState3,
59            NamespaceComponent3Link4: $myState4,
60            myVar: 100,
61            myVar2: 80
62          })
63          .height(200)
64    }
65  }
66}
67`
68
69exports.expectResult =
70`"use strict";
71var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
72    if (k2 === undefined) k2 = k;
73    var desc = Object.getOwnPropertyDescriptor(m, k);
74    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
75      desc = { enumerable: true, get: function() { return m[k]; } };
76    }
77    Object.defineProperty(o, k2, desc);
78}) : (function(o, m, k, k2) {
79    if (k2 === undefined) k2 = k;
80    o[k2] = m[k];
81}));
82var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
83    Object.defineProperty(o, "default", { enumerable: true, value: v });
84}) : function(o, v) {
85    o["default"] = v;
86});
87var __importStar = (this && this.__importStar) || function (mod) {
88    if (mod && mod.__esModule) return mod;
89    var result = {};
90    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
91    __setModuleDefault(result, mod);
92    return result;
93};
94var __importDefault = (this && this.__importDefault) || function (mod) {
95    return (mod && mod.__esModule) ? mod : { "default": mod };
96};
97Object.defineProperty(exports, "__esModule", { value: true });
98let __generate__Id = 0;
99function generateId() {
100    return "importAllEts_" + ++__generate__Id;
101}
102const AllComponent = __importStar(require("./test/pages/NamespaceComponent"));
103const TsModule_1 = __importDefault(require("./test/pages/TsModule"));
104class ImportTest extends View {
105    constructor(compilerAssignedUniqueChildId, parent, params, localStorage) {
106        super(compilerAssignedUniqueChildId, parent, localStorage);
107        this.__myState1 = new ObservedPropertyObject(new TsModule_1.default(1).method(), this, "myState1");
108        this.__myState2 = new ObservedPropertySimple(0, this, "myState2");
109        this.__myState3 = new ObservedPropertySimple(false, this, "myState3");
110        this.__myState4 = new ObservedPropertySimple('ImportTest', this, "myState4");
111        this.updateWithValueParams(params);
112    }
113    updateWithValueParams(params) {
114        if (params.myState1 !== undefined) {
115            this.myState1 = params.myState1;
116        }
117        if (params.myState2 !== undefined) {
118            this.myState2 = params.myState2;
119        }
120        if (params.myState3 !== undefined) {
121            this.myState3 = params.myState3;
122        }
123        if (params.myState4 !== undefined) {
124            this.myState4 = params.myState4;
125        }
126    }
127    aboutToBeDeleted() {
128        this.__myState1.aboutToBeDeleted();
129        this.__myState2.aboutToBeDeleted();
130        this.__myState3.aboutToBeDeleted();
131        this.__myState4.aboutToBeDeleted();
132        SubscriberManager.Get().delete(this.id());
133    }
134    get myState1() {
135        return this.__myState1.get();
136    }
137    set myState1(newValue) {
138        this.__myState1.set(newValue);
139    }
140    get myState2() {
141        return this.__myState2.get();
142    }
143    set myState2(newValue) {
144        this.__myState2.set(newValue);
145    }
146    get myState3() {
147        return this.__myState3.get();
148    }
149    set myState3(newValue) {
150        this.__myState3.set(newValue);
151    }
152    get myState4() {
153        return this.__myState4.get();
154    }
155    set myState4(newValue) {
156        this.__myState4.set(newValue);
157    }
158    render() {
159        Column.create();
160        let earlierCreatedChild_2 = (this && this.findChildById) ? this.findChildById("2") : undefined;
161        if (earlierCreatedChild_2 == undefined) {
162            View.create(new AllComponent.NamespaceComponent1("2", this, {
163                NamespaceComponent1Link1: this.__myState1,
164                NamespaceComponent1Link2: this.__myState2,
165                NamespaceComponent1Link3: this.__myState3,
166                NamespaceComponent1Link4: this.__myState4,
167                myVar: 100,
168                myVar2: 80
169            }));
170        }
171        else {
172            earlierCreatedChild_2.updateWithValueParams({
173                myVar: 100,
174                myVar2: 80
175            });
176            View.create(earlierCreatedChild_2);
177        }
178        __Common__.create();
179        __Common__.width(100);
180        let earlierCreatedChild_3 = (this && this.findChildById) ? this.findChildById("3") : undefined;
181        if (earlierCreatedChild_3 == undefined) {
182            View.create(new AllComponent.NamespaceComponent1("3", this, {
183                NamespaceComponent1Link1: this.__myState1,
184                NamespaceComponent1Link2: this.__myState2,
185                NamespaceComponent1Link3: this.__myState3,
186                NamespaceComponent1Link4: this.__myState4,
187                myVar: 100,
188                myVar2: 80
189            }));
190        }
191        else {
192            earlierCreatedChild_3.updateWithValueParams({
193                myVar: 100,
194                myVar2: 80
195            });
196            View.create(earlierCreatedChild_3);
197        }
198        __Common__.pop();
199        let earlierCreatedChild_4 = (this && this.findChildById) ? this.findChildById("4") : undefined;
200        if (earlierCreatedChild_4 == undefined) {
201            View.create(new AllComponent.default("4", this, {
202                NamespaceComponent3Link1: this.__myState1,
203                NamespaceComponent3Link2: this.__myState2,
204                NamespaceComponent3Link3: this.__myState3,
205                NamespaceComponent3Link4: this.__myState4,
206                myVar: 100,
207                myVar2: 80
208            }));
209        }
210        else {
211            earlierCreatedChild_4.updateWithValueParams({
212                myVar: 100,
213                myVar2: 80
214            });
215            View.create(earlierCreatedChild_4);
216        }
217        __Common__.create();
218        __Common__.height(200);
219        let earlierCreatedChild_5 = (this && this.findChildById) ? this.findChildById("5") : undefined;
220        if (earlierCreatedChild_5 == undefined) {
221            View.create(new AllComponent.default("5", this, {
222                NamespaceComponent3Link1: this.__myState1,
223                NamespaceComponent3Link2: this.__myState2,
224                NamespaceComponent3Link3: this.__myState3,
225                NamespaceComponent3Link4: this.__myState4,
226                myVar: 100,
227                myVar2: 80
228            }));
229        }
230        else {
231            earlierCreatedChild_5.updateWithValueParams({
232                myVar: 100,
233                myVar2: 80
234            });
235            View.create(earlierCreatedChild_5);
236        }
237        __Common__.pop();
238        Column.pop();
239    }
240}
241loadDocument(new ImportTest("1", undefined, {}));
242`
243