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 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 74}) : (function(o, m, k, k2) { 75 if (k2 === undefined) k2 = k; 76 o[k2] = m[k]; 77})); 78var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 79 Object.defineProperty(o, "default", { enumerable: true, value: v }); 80}) : function(o, v) { 81 o["default"] = v; 82}); 83var __importStar = (this && this.__importStar) || function (mod) { 84 if (mod && mod.__esModule) return mod; 85 var result = {}; 86 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 87 __setModuleDefault(result, mod); 88 return result; 89}; 90var __importDefault = (this && this.__importDefault) || function (mod) { 91 return (mod && mod.__esModule) ? mod : { "default": mod }; 92}; 93Object.defineProperty(exports, "__esModule", { value: true }); 94let __generate__Id = 0; 95function generateId() { 96 return "importAllEts_" + ++__generate__Id; 97} 98const AllComponent = __importStar(require("./test/pages/NamespaceComponent")); 99const TsModule_1 = __importDefault(require("./test/pages/TsModule")); 100class ImportTest extends View { 101 constructor(compilerAssignedUniqueChildId, parent, params, localStorage) { 102 super(compilerAssignedUniqueChildId, parent, localStorage); 103 this.__myState1 = new ObservedPropertyObject(new TsModule_1.default(1).method(), this, "myState1"); 104 this.__myState2 = new ObservedPropertySimple(0, this, "myState2"); 105 this.__myState3 = new ObservedPropertySimple(false, this, "myState3"); 106 this.__myState4 = new ObservedPropertySimple('ImportTest', this, "myState4"); 107 this.updateWithValueParams(params); 108 } 109 updateWithValueParams(params) { 110 if (params.myState1 !== undefined) { 111 this.myState1 = params.myState1; 112 } 113 if (params.myState2 !== undefined) { 114 this.myState2 = params.myState2; 115 } 116 if (params.myState3 !== undefined) { 117 this.myState3 = params.myState3; 118 } 119 if (params.myState4 !== undefined) { 120 this.myState4 = params.myState4; 121 } 122 } 123 aboutToBeDeleted() { 124 this.__myState1.aboutToBeDeleted(); 125 this.__myState2.aboutToBeDeleted(); 126 this.__myState3.aboutToBeDeleted(); 127 this.__myState4.aboutToBeDeleted(); 128 SubscriberManager.Get().delete(this.id()); 129 } 130 get myState1() { 131 return this.__myState1.get(); 132 } 133 set myState1(newValue) { 134 this.__myState1.set(newValue); 135 } 136 get myState2() { 137 return this.__myState2.get(); 138 } 139 set myState2(newValue) { 140 this.__myState2.set(newValue); 141 } 142 get myState3() { 143 return this.__myState3.get(); 144 } 145 set myState3(newValue) { 146 this.__myState3.set(newValue); 147 } 148 get myState4() { 149 return this.__myState4.get(); 150 } 151 set myState4(newValue) { 152 this.__myState4.set(newValue); 153 } 154 render() { 155 Column.create(); 156 let earlierCreatedChild_2 = (this && this.findChildById) ? this.findChildById("2") : undefined; 157 if (earlierCreatedChild_2 == undefined) { 158 View.create(new AllComponent.NamespaceComponent1("2", this, { 159 NamespaceComponent1Link1: this.__myState1, 160 NamespaceComponent1Link2: this.__myState2, 161 NamespaceComponent1Link3: this.__myState3, 162 NamespaceComponent1Link4: this.__myState4, 163 myVar: 100, 164 myVar2: 80 165 })); 166 } 167 else { 168 earlierCreatedChild_2.updateWithValueParams({ 169 myVar: 100, 170 myVar2: 80 171 }); 172 View.create(earlierCreatedChild_2); 173 } 174 __Common__.create(); 175 __Common__.width(100); 176 let earlierCreatedChild_3 = (this && this.findChildById) ? this.findChildById("3") : undefined; 177 if (earlierCreatedChild_3 == undefined) { 178 View.create(new AllComponent.NamespaceComponent1("3", this, { 179 NamespaceComponent1Link1: this.__myState1, 180 NamespaceComponent1Link2: this.__myState2, 181 NamespaceComponent1Link3: this.__myState3, 182 NamespaceComponent1Link4: this.__myState4, 183 myVar: 100, 184 myVar2: 80 185 })); 186 } 187 else { 188 earlierCreatedChild_3.updateWithValueParams({ 189 myVar: 100, 190 myVar2: 80 191 }); 192 View.create(earlierCreatedChild_3); 193 } 194 __Common__.pop(); 195 let earlierCreatedChild_4 = (this && this.findChildById) ? this.findChildById("4") : undefined; 196 if (earlierCreatedChild_4 == undefined) { 197 View.create(new AllComponent.default("4", this, { 198 NamespaceComponent3Link1: this.__myState1, 199 NamespaceComponent3Link2: this.__myState2, 200 NamespaceComponent3Link3: this.__myState3, 201 NamespaceComponent3Link4: this.__myState4, 202 myVar: 100, 203 myVar2: 80 204 })); 205 } 206 else { 207 earlierCreatedChild_4.updateWithValueParams({ 208 myVar: 100, 209 myVar2: 80 210 }); 211 View.create(earlierCreatedChild_4); 212 } 213 __Common__.create(); 214 __Common__.height(200); 215 let earlierCreatedChild_5 = (this && this.findChildById) ? this.findChildById("5") : undefined; 216 if (earlierCreatedChild_5 == undefined) { 217 View.create(new AllComponent.default("5", this, { 218 NamespaceComponent3Link1: this.__myState1, 219 NamespaceComponent3Link2: this.__myState2, 220 NamespaceComponent3Link3: this.__myState3, 221 NamespaceComponent3Link4: this.__myState4, 222 myVar: 100, 223 myVar2: 80 224 })); 225 } 226 else { 227 earlierCreatedChild_5.updateWithValueParams({ 228 myVar: 100, 229 myVar2: 80 230 }); 231 View.create(earlierCreatedChild_5); 232 } 233 __Common__.pop(); 234 Column.pop(); 235 } 236} 237loadDocument(new ImportTest("1", undefined, {})); 238` 239