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