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 }); 61if (!("finalizeConstruction" in ViewPU.prototype)) { 62 Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); 63} 64const ImportNestAll_1 = require("./test/pages/ImportNestAll"); 65class ImportTest extends ViewPU { 66 constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { 67 super(parent, __localStorage, elmtId, extraInfo); 68 if (typeof paramsLambda === "function") { 69 this.paramsGenerator_ = paramsLambda; 70 } 71 this.__testText1 = new ObservedPropertySimplePU('Hello', this, "testText1"); 72 this.__testText2 = new ObservedPropertySimplePU('World', this, "testText2"); 73 this.__testText3 = new ObservedPropertySimplePU('Test', this, "testText3"); 74 this.__testText4 = new ObservedPropertySimplePU('Component', this, "testText4"); 75 this.__testState1 = new ObservedPropertySimplePU('Base', this, "testState1"); 76 this.__testState2 = new ObservedPropertySimplePU(0, this, "testState2"); 77 this.__testState3 = new ObservedPropertyObjectPU({ name: 'Base' }, this, "testState3"); 78 this.__testState4 = new ObservedPropertySimplePU(3, this, "testState4"); 79 this.__testState5 = new ObservedPropertySimplePU(10, this, "testState5"); 80 this.setInitiallyProvidedValue(params); 81 this.finalizeConstruction(); 82 } 83 setInitiallyProvidedValue(params) { 84 if (params.testText1 !== undefined) { 85 this.testText1 = params.testText1; 86 } 87 if (params.testText2 !== undefined) { 88 this.testText2 = params.testText2; 89 } 90 if (params.testText3 !== undefined) { 91 this.testText3 = params.testText3; 92 } 93 if (params.testText4 !== undefined) { 94 this.testText4 = params.testText4; 95 } 96 if (params.testState1 !== undefined) { 97 this.testState1 = params.testState1; 98 } 99 if (params.testState2 !== undefined) { 100 this.testState2 = params.testState2; 101 } 102 if (params.testState3 !== undefined) { 103 this.testState3 = params.testState3; 104 } 105 if (params.testState4 !== undefined) { 106 this.testState4 = params.testState4; 107 } 108 if (params.testState5 !== undefined) { 109 this.testState5 = params.testState5; 110 } 111 } 112 updateStateVars(params) { 113 } 114 purgeVariableDependenciesOnElmtId(rmElmtId) { 115 this.__testText1.purgeDependencyOnElmtId(rmElmtId); 116 this.__testText2.purgeDependencyOnElmtId(rmElmtId); 117 this.__testText3.purgeDependencyOnElmtId(rmElmtId); 118 this.__testText4.purgeDependencyOnElmtId(rmElmtId); 119 this.__testState1.purgeDependencyOnElmtId(rmElmtId); 120 this.__testState2.purgeDependencyOnElmtId(rmElmtId); 121 this.__testState3.purgeDependencyOnElmtId(rmElmtId); 122 this.__testState4.purgeDependencyOnElmtId(rmElmtId); 123 this.__testState5.purgeDependencyOnElmtId(rmElmtId); 124 } 125 aboutToBeDeleted() { 126 this.__testText1.aboutToBeDeleted(); 127 this.__testText2.aboutToBeDeleted(); 128 this.__testText3.aboutToBeDeleted(); 129 this.__testText4.aboutToBeDeleted(); 130 this.__testState1.aboutToBeDeleted(); 131 this.__testState2.aboutToBeDeleted(); 132 this.__testState3.aboutToBeDeleted(); 133 this.__testState4.aboutToBeDeleted(); 134 this.__testState5.aboutToBeDeleted(); 135 SubscriberManager.Get().delete(this.id__()); 136 this.aboutToBeDeletedInternal(); 137 } 138 get testText1() { 139 return this.__testText1.get(); 140 } 141 set testText1(newValue) { 142 this.__testText1.set(newValue); 143 } 144 get testText2() { 145 return this.__testText2.get(); 146 } 147 set testText2(newValue) { 148 this.__testText2.set(newValue); 149 } 150 get testText3() { 151 return this.__testText3.get(); 152 } 153 set testText3(newValue) { 154 this.__testText3.set(newValue); 155 } 156 get testText4() { 157 return this.__testText4.get(); 158 } 159 set testText4(newValue) { 160 this.__testText4.set(newValue); 161 } 162 get testState1() { 163 return this.__testState1.get(); 164 } 165 set testState1(newValue) { 166 this.__testState1.set(newValue); 167 } 168 get testState2() { 169 return this.__testState2.get(); 170 } 171 set testState2(newValue) { 172 this.__testState2.set(newValue); 173 } 174 get testState3() { 175 return this.__testState3.get(); 176 } 177 set testState3(newValue) { 178 this.__testState3.set(newValue); 179 } 180 get testState4() { 181 return this.__testState4.get(); 182 } 183 set testState4(newValue) { 184 this.__testState4.set(newValue); 185 } 186 get testState5() { 187 return this.__testState5.get(); 188 } 189 set testState5(newValue) { 190 this.__testState5.set(newValue); 191 } 192 initialRender() { 193 this.observeComponentCreation2((elmtId, isInitialRender) => { 194 Column.create(); 195 }, Column); 196 this.observeComponentCreation2((elmtId, isInitialRender) => { 197 Text.create(this.testText1); 198 Text.fontSize(50); 199 }, Text); 200 Text.pop(); 201 ImportNestAll_1.tExtend.bind(this)(20); 202 this.observeComponentCreation2((elmtId, isInitialRender) => { 203 Text.create(this.testText2); 204 }, Text); 205 Text.pop(); 206 ImportNestAll_1.tStyles.bind(this)(); 207 this.observeComponentCreation2((elmtId, isInitialRender) => { 208 Button.createWithLabel(this.testText3); 209 }, Button); 210 Button.pop(); 211 this.observeComponentCreation2((elmtId, isInitialRender) => { 212 Text.create(this.testText4); 213 Text.fontSize(50); 214 }, Text); 215 Text.pop(); 216 { 217 this.observeComponentCreation2((elmtId, isInitialRender) => { 218 if (isInitialRender) { 219 let componentCall = new ImportNestAll_1.Base(this, { 220 testStr: this.__testState1, 221 testNum: this.__testState2, 222 testObj: this.__testState3 223 }, undefined, elmtId, () => { }, { page: "importExportNest.ets", line: 29, col: 7 }); 224 ViewPU.create(componentCall); 225 let paramsLambda = () => { 226 return { 227 testStr: this.testState1, 228 testNum: this.testState2, 229 testObj: this.testState3 230 }; 231 }; 232 componentCall.paramsGenerator_ = paramsLambda; 233 } 234 else { 235 this.updateStateVarsOfChildByElmtId(elmtId, {}); 236 } 237 }, { name: "Base" }); 238 } 239 { 240 this.observeComponentCreation2((elmtId, isInitialRender) => { 241 if (isInitialRender) { 242 let componentCall = new ImportNestAll_1.DivideTest(this, { 243 testNum1: this.__testState4, 244 testNum2: this.__testState5 245 }, undefined, elmtId, () => { }, { page: "importExportNest.ets", line: 34, col: 7 }); 246 ViewPU.create(componentCall); 247 let paramsLambda = () => { 248 return { 249 testNum1: this.testState4, 250 testNum2: this.testState5 251 }; 252 }; 253 componentCall.paramsGenerator_ = paramsLambda; 254 } 255 else { 256 this.updateStateVarsOfChildByElmtId(elmtId, {}); 257 } 258 }, { name: "DivideTest" }); 259 } 260 Column.pop(); 261 } 262 rerender() { 263 this.updateDirtyElements(); 264 } 265} 266ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent()); 267loadDocument(new ImportTest(undefined, {})); 268ViewStackProcessor.StopGetAccessRecording(); 269` 270