add ut for partial update

Signed-off-by: s00912778 <shijiakai2@huawei.com>
Change-Id: I55b3e966020d7b3532a21397a4c898f9c08e174a
This commit is contained in:
s00912778 2024-10-21 20:58:19 +08:00
parent 69cee50c4f
commit b55fc4d852
9 changed files with 1006 additions and 1 deletions

View File

@ -0,0 +1,187 @@
"use strict";
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
class CompA extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__reviewVotes = new ObservedPropertySimplePU(0, this, "reviewVotes");
this.addProvidedVar("reviewVote", this.__reviewVotes, false);
this.addProvidedVar("reviewVotes", this.__reviewVotes, false);
this.__message = new ObservedPropertySimplePU('1111', this, "message");
this.addProvidedVar('aliasName', this.__message, true);
this.addProvidedVar("message", this.__message, true);
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params) {
if (params.reviewVotes !== undefined) {
this.reviewVotes = params.reviewVotes;
}
if (params.message !== undefined) {
this.message = params.message;
}
}
updateStateVars(params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__reviewVotes.purgeDependencyOnElmtId(rmElmtId);
this.__message.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__reviewVotes.aboutToBeDeleted();
this.__message.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
get reviewVotes() {
return this.__reviewVotes.get();
}
set reviewVotes(newValue) {
this.__reviewVotes.set(newValue);
}
get message() {
return this.__message.get();
}
set message(newValue) {
this.__message.set(newValue);
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
}, Column);
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new CompB(this, {}, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ets", line: 9, col: 7 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};
};
componentCall.paramsGenerator_ = paramsLambda;
}
else {
this.updateStateVarsOfChildByElmtId(elmtId, {});
}
}, { name: "CompB" });
}
this.observeComponentCreation2((elmtId, isInitialRender) => {
Button.createWithChild();
Button.onClick(() => {
this.reviewVotes += 1;
});
}, Button);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('' + this.reviewVotes);
Text.fontSize(30);
}, Text);
Text.pop();
Button.pop();
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
static getEntryName() {
return "CompA";
}
}
class CompB extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params) {
}
updateStateVars(params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
}
aboutToBeDeleted() {
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
}, Column);
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new CompC(this, {}, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ets", line: 25, col: 7 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {};
};
componentCall.paramsGenerator_ = paramsLambda;
}
else {
this.updateStateVarsOfChildByElmtId(elmtId, {});
}
}, { name: "CompC" });
}
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
}
class CompC extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__reviewVotes = this.initializeConsume("reviewVote", "reviewVotes");
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params) {
}
updateStateVars(params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__reviewVotes.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__reviewVotes.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
get reviewVotes() {
return this.__reviewVotes.get();
}
set reviewVotes(newValue) {
this.__reviewVotes.set(newValue);
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Button.createWithChild();
Button.onClick(() => {
this.reviewVotes += 1;
});
}, Button);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('' + this.reviewVotes);
Text.fontSize(30);
}, Text);
Text.pop();
Button.pop();
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
}
registerNamedRoute(() => new CompA(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide", integratedHsp: "false" });
//# sourceMappingURL=@consume_@provide.js.map

View File

@ -0,0 +1,142 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
let NextID = 0;
let ClassA = class ClassA {
constructor(c) {
this.id = NextID++;
this.c = c;
}
};
ClassA = __decorate([
Observed
], ClassA);
let ClassB = class ClassB {
constructor(a) {
this.a = a;
}
};
ClassB = __decorate([
Observed
], ClassB);
class ViewA extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__varA = new SynchedPropertyNesedObjectPU(params.varA, this, "varA");
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params) {
this.__varA.set(params.varA);
}
updateStateVars(params) {
this.__varA.set(params.varA);
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__varA.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__varA.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
get varA() {
return this.__varA.get();
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Row.create();
}, Row);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('ViewA-' + this.varA.id);
}, Text);
Text.pop();
Row.pop();
}
rerender() {
this.updateDirtyElements();
}
}
class ViewB extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__varB = new ObservedPropertyObjectPU(new ClassB(new ClassA(0)), this, "varB");
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params) {
if (params.varB !== undefined) {
this.varB = params.varB;
}
}
updateStateVars(params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__varB.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__varB.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
get varB() {
return this.__varB.get();
}
set varB(newValue) {
this.__varB.set(newValue);
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Row.create();
}, Row);
{
this.observeComponentCreation2((elmtId, isInitialRender) => {
if (isInitialRender) {
let componentCall = new ViewA(this, { varA: this.varB.a }, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ets", line: 36, col: 9 });
ViewPU.create(componentCall);
let paramsLambda = () => {
return {
varA: this.varB.a
};
};
componentCall.paramsGenerator_ = paramsLambda;
}
else {
this.updateStateVarsOfChildByElmtId(elmtId, {
varA: this.varB.a
});
}
}, { name: "ViewA" });
}
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('ViewB');
}, Text);
Text.pop();
Row.pop();
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
static getEntryName() {
return "ViewB";
}
}
registerNamedRoute(() => new ViewB(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink", integratedHsp: "false" });
//# sourceMappingURL=@observed_@objectLink.js.map

View File

@ -0,0 +1,136 @@
"use strict";
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
class CompA extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__shopBasket = new ObservedPropertyObjectPU([7, 12, 47, 3], this, "shopBasket");
this.__totalPurchase = new ObservedPropertySimplePU(0, this, "totalPurchase");
this.__defArray = new ObservedPropertyObjectPU(['c', 'g', 't', 'z'], this, "defArray");
this.__resultTip = new ObservedPropertySimplePU('', this, "resultTip");
this.setInitiallyProvidedValue(params);
this.declareWatch("shopBasket", this.onBasketUpdated);
this.declareWatch("defArray", this.onPutItem);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params) {
if (params.shopBasket !== undefined) {
this.shopBasket = params.shopBasket;
}
if (params.totalPurchase !== undefined) {
this.totalPurchase = params.totalPurchase;
}
if (params.defArray !== undefined) {
this.defArray = params.defArray;
}
if (params.resultTip !== undefined) {
this.resultTip = params.resultTip;
}
}
updateStateVars(params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__shopBasket.purgeDependencyOnElmtId(rmElmtId);
this.__totalPurchase.purgeDependencyOnElmtId(rmElmtId);
this.__defArray.purgeDependencyOnElmtId(rmElmtId);
this.__resultTip.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__shopBasket.aboutToBeDeleted();
this.__totalPurchase.aboutToBeDeleted();
this.__defArray.aboutToBeDeleted();
this.__resultTip.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
get shopBasket() {
return this.__shopBasket.get();
}
set shopBasket(newValue) {
this.__shopBasket.set(newValue);
}
get totalPurchase() {
return this.__totalPurchase.get();
}
set totalPurchase(newValue) {
this.__totalPurchase.set(newValue);
}
get defArray() {
return this.__defArray.get();
}
set defArray(newValue) {
this.__defArray.set(newValue);
}
get resultTip() {
return this.__resultTip.get();
}
set resultTip(newValue) {
this.__resultTip.set(newValue);
}
updateTotal() {
let sum = 0;
this.shopBasket.forEach((i) => { sum += i; });
this.totalPurchase = (sum < 100) ? sum : 0.9 * sum;
return this.totalPurchase;
}
onBasketUpdated(propName) {
Context.animateTo({ duration: 1000 }, () => {
this.updateTotal();
});
}
updateTip() {
let tempArray = this.defArray.slice(0, -1);
let addItem = this.defArray[this.defArray.length - 1];
this.resultTip = tempArray.includes(addItem) ?
'add item invalid' :
'congratulations! add item success';
return this.resultTip;
}
onPutItem(propName) {
this.updateTip();
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Column.create();
}, Column);
this.observeComponentCreation2((elmtId, isInitialRender) => {
Button.createWithLabel("add to basket");
Button.onClick(() => {
this.shopBasket.push(Math.round(100 * Math.random()));
});
}, Button);
Button.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('totalPurchase: ' + this.totalPurchase);
Text.fontSize(20);
}, Text);
Text.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
Button.createWithLabel("put item");
Button.onClick(() => {
let alList = 'abcdefghijklmnopqrstuvwxyz';
let ranItem = alList[Math.floor(Math.random() * 26)];
this.defArray.push(ranItem);
});
}, Button);
Button.pop();
this.observeComponentCreation2((elmtId, isInitialRender) => {
Text.create('tips: ' + this.resultTip);
Text.fontSize(20);
}, Text);
Text.pop();
Column.pop();
}
rerender() {
this.updateDirtyElements();
}
static getEntryName() {
return "CompA";
}
}
registerNamedRoute(() => new CompA(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/@watch/@watch", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@watch/@watch", integratedHsp: "false" });
//# sourceMappingURL=@watch.js.map

View File

@ -0,0 +1,354 @@
if (!("finalizeConstruction" in ViewPU.prototype)) {
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
}
import { stringVariable, stringObj, stringFunction } from '../../../../../test/decoratorKeyCheck';
let para = { 'PropA': 47 };
let storage = new LocalStorage(para);
class Index extends ViewPU {
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
super(parent, __localStorage, elmtId, extraInfo);
this.__LocalStorageLink = this.createLocalStorageLink(stringVariable, 'LocalStorageLink', "LocalStorageLink");
this.__LocalStorageLink1 = this.createLocalStorageLink(stringObj.stringKey, 'LocalStorageLink1', "LocalStorageLink1");
this.__LocalStorageLink2 = this.createLocalStorageLink(stringFunction(), 'LocalStorageLink2', "LocalStorageLink2");
this.__LocalStorageLink3 = this.createLocalStorageLink('LocalStorageLink3', 'LocalStorageLink3', "LocalStorageLink3");
this.__LocalStorageProp = this.createLocalStorageProp(stringVariable, 'LocalStorageProp', "LocalStorageProp");
this.__LocalStorageProp1 = this.createLocalStorageProp(stringObj.stringKey, 'LocalStorageProp1', "LocalStorageProp1");
this.__LocalStorageProp2 = this.createLocalStorageProp(stringFunction(), 'LocalStorageProp2', "LocalStorageProp2");
this.__LocalStorageProp3 = this.createLocalStorageProp('LocalStorageProp3', 'LocalStorageProp3', "LocalStorageProp3");
if (typeof paramsLambda === "function") {
this.paramsGenerator_ = paramsLambda;
}
this.__StorageProp = this.createStorageProp(stringVariable, 'StorageProp', "StorageProp");
this.__StorageProp1 = this.createStorageProp(stringObj.stringKey, 'StorageProp1', "StorageProp1");
this.__StorageProp2 = this.createStorageProp(stringFunction(), 'StorageProp2', "StorageProp2");
this.__StorageProp3 = this.createStorageProp('StorageProp3', 'StorageProp3', "StorageProp3");
this.__StorageLink = this.createStorageLink(stringVariable, 'StorageLink', "StorageLink");
this.__StorageLink1 = this.createStorageLink(stringObj.stringKey, 'StorageLink1', "StorageLink1");
this.__StorageLink2 = this.createStorageLink(stringFunction(), 'StorageLink2', "StorageLink2");
this.__StorageLink3 = this.createStorageLink('StorageLink3', 'StorageLink3', "StorageLink3");
this.__Provide = new ObservedPropertySimplePU('Provide', this, "Provide");
this.addProvidedVar(stringVariable, this.__Provide, false);
this.addProvidedVar("Provide", this.__Provide, false);
this.__Provide1 = new ObservedPropertySimplePU('Provide1', this, "Provide1");
this.addProvidedVar(stringObj.stringKey, this.__Provide1, false);
this.addProvidedVar("Provide1", this.__Provide1, false);
this.__Provide2 = new ObservedPropertySimplePU('Provide2', this, "Provide2");
this.addProvidedVar(stringFunction(), this.__Provide2, false);
this.addProvidedVar("Provide2", this.__Provide2, false);
this.__Provide3 = new ObservedPropertySimplePU('Provide3', this, "Provide3");
this.addProvidedVar("Provide32", this.__Provide3, false);
this.addProvidedVar("Provide3", this.__Provide3, false);
this.__Provide4 = new ObservedPropertySimplePU('Provide4', this, "Provide4");
this.addProvidedVar("Provide4", this.__Provide4, false);
this.__Provide5 = new ObservedPropertySimplePU('Provide5', this, "Provide5");
this.addProvidedVar(stringVariable, this.__Provide5, true);
this.addProvidedVar("Provide5", this.__Provide5, true);
this.__Provide6 = new ObservedPropertySimplePU('Provide6', this, "Provide6");
this.addProvidedVar(stringObj, this.__Provide6, true);
this.addProvidedVar("Provide6", this.__Provide6, true);
this.__Provide7 = new ObservedPropertySimplePU('Provide7', this, "Provide7");
this.addProvidedVar(stringFunction, this.__Provide7, true);
this.addProvidedVar("Provide7", this.__Provide7, true);
this.__Consume = this.initializeConsume(stringVariable, "Consume");
this.__Consume1 = this.initializeConsume(stringObj.stringKey, "Consume1");
this.__Consume2 = this.initializeConsume(stringFunction(), "Consume2");
this.__Consume3 = this.initializeConsume('Consume3', "Consume3");
this.__Consume4 = this.initializeConsume("Consume4", "Consume4");
this.setInitiallyProvidedValue(params);
this.finalizeConstruction();
}
setInitiallyProvidedValue(params) {
if (params.Provide !== undefined) {
this.Provide = params.Provide;
}
if (params.Provide1 !== undefined) {
this.Provide1 = params.Provide1;
}
if (params.Provide2 !== undefined) {
this.Provide2 = params.Provide2;
}
if (params.Provide3 !== undefined) {
this.Provide3 = params.Provide3;
}
if (params.Provide4 !== undefined) {
this.Provide4 = params.Provide4;
}
if (params.Provide5 !== undefined) {
this.Provide5 = params.Provide5;
}
if (params.Provide6 !== undefined) {
this.Provide6 = params.Provide6;
}
if (params.Provide7 !== undefined) {
this.Provide7 = params.Provide7;
}
}
updateStateVars(params) {
}
purgeVariableDependenciesOnElmtId(rmElmtId) {
this.__LocalStorageLink.purgeDependencyOnElmtId(rmElmtId);
this.__LocalStorageLink1.purgeDependencyOnElmtId(rmElmtId);
this.__LocalStorageLink2.purgeDependencyOnElmtId(rmElmtId);
this.__LocalStorageLink3.purgeDependencyOnElmtId(rmElmtId);
this.__LocalStorageProp.purgeDependencyOnElmtId(rmElmtId);
this.__LocalStorageProp1.purgeDependencyOnElmtId(rmElmtId);
this.__LocalStorageProp2.purgeDependencyOnElmtId(rmElmtId);
this.__LocalStorageProp3.purgeDependencyOnElmtId(rmElmtId);
this.__StorageProp.purgeDependencyOnElmtId(rmElmtId);
this.__StorageProp1.purgeDependencyOnElmtId(rmElmtId);
this.__StorageProp2.purgeDependencyOnElmtId(rmElmtId);
this.__StorageProp3.purgeDependencyOnElmtId(rmElmtId);
this.__StorageLink.purgeDependencyOnElmtId(rmElmtId);
this.__StorageLink1.purgeDependencyOnElmtId(rmElmtId);
this.__StorageLink2.purgeDependencyOnElmtId(rmElmtId);
this.__StorageLink3.purgeDependencyOnElmtId(rmElmtId);
this.__Provide.purgeDependencyOnElmtId(rmElmtId);
this.__Provide1.purgeDependencyOnElmtId(rmElmtId);
this.__Provide2.purgeDependencyOnElmtId(rmElmtId);
this.__Provide3.purgeDependencyOnElmtId(rmElmtId);
this.__Provide4.purgeDependencyOnElmtId(rmElmtId);
this.__Provide5.purgeDependencyOnElmtId(rmElmtId);
this.__Provide6.purgeDependencyOnElmtId(rmElmtId);
this.__Provide7.purgeDependencyOnElmtId(rmElmtId);
this.__Consume.purgeDependencyOnElmtId(rmElmtId);
this.__Consume1.purgeDependencyOnElmtId(rmElmtId);
this.__Consume2.purgeDependencyOnElmtId(rmElmtId);
this.__Consume3.purgeDependencyOnElmtId(rmElmtId);
this.__Consume4.purgeDependencyOnElmtId(rmElmtId);
}
aboutToBeDeleted() {
this.__LocalStorageLink.aboutToBeDeleted();
this.__LocalStorageLink1.aboutToBeDeleted();
this.__LocalStorageLink2.aboutToBeDeleted();
this.__LocalStorageLink3.aboutToBeDeleted();
this.__LocalStorageProp.aboutToBeDeleted();
this.__LocalStorageProp1.aboutToBeDeleted();
this.__LocalStorageProp2.aboutToBeDeleted();
this.__LocalStorageProp3.aboutToBeDeleted();
this.__StorageProp.aboutToBeDeleted();
this.__StorageProp1.aboutToBeDeleted();
this.__StorageProp2.aboutToBeDeleted();
this.__StorageProp3.aboutToBeDeleted();
this.__StorageLink.aboutToBeDeleted();
this.__StorageLink1.aboutToBeDeleted();
this.__StorageLink2.aboutToBeDeleted();
this.__StorageLink3.aboutToBeDeleted();
this.__Provide.aboutToBeDeleted();
this.__Provide1.aboutToBeDeleted();
this.__Provide2.aboutToBeDeleted();
this.__Provide3.aboutToBeDeleted();
this.__Provide4.aboutToBeDeleted();
this.__Provide5.aboutToBeDeleted();
this.__Provide6.aboutToBeDeleted();
this.__Provide7.aboutToBeDeleted();
this.__Consume.aboutToBeDeleted();
this.__Consume1.aboutToBeDeleted();
this.__Consume2.aboutToBeDeleted();
this.__Consume3.aboutToBeDeleted();
this.__Consume4.aboutToBeDeleted();
SubscriberManager.Get().delete(this.id__());
this.aboutToBeDeletedInternal();
}
get LocalStorageLink() {
return this.__LocalStorageLink.get();
}
set LocalStorageLink(newValue) {
this.__LocalStorageLink.set(newValue);
}
get LocalStorageLink1() {
return this.__LocalStorageLink1.get();
}
set LocalStorageLink1(newValue) {
this.__LocalStorageLink1.set(newValue);
}
get LocalStorageLink2() {
return this.__LocalStorageLink2.get();
}
set LocalStorageLink2(newValue) {
this.__LocalStorageLink2.set(newValue);
}
get LocalStorageLink3() {
return this.__LocalStorageLink3.get();
}
set LocalStorageLink3(newValue) {
this.__LocalStorageLink3.set(newValue);
}
get LocalStorageProp() {
return this.__LocalStorageProp.get();
}
set LocalStorageProp(newValue) {
this.__LocalStorageProp.set(newValue);
}
get LocalStorageProp1() {
return this.__LocalStorageProp1.get();
}
set LocalStorageProp1(newValue) {
this.__LocalStorageProp1.set(newValue);
}
get LocalStorageProp2() {
return this.__LocalStorageProp2.get();
}
set LocalStorageProp2(newValue) {
this.__LocalStorageProp2.set(newValue);
}
get LocalStorageProp3() {
return this.__LocalStorageProp3.get();
}
set LocalStorageProp3(newValue) {
this.__LocalStorageProp3.set(newValue);
}
get StorageProp() {
return this.__StorageProp.get();
}
set StorageProp(newValue) {
this.__StorageProp.set(newValue);
}
get StorageProp1() {
return this.__StorageProp1.get();
}
set StorageProp1(newValue) {
this.__StorageProp1.set(newValue);
}
get StorageProp2() {
return this.__StorageProp2.get();
}
set StorageProp2(newValue) {
this.__StorageProp2.set(newValue);
}
get StorageProp3() {
return this.__StorageProp3.get();
}
set StorageProp3(newValue) {
this.__StorageProp3.set(newValue);
}
get StorageLink() {
return this.__StorageLink.get();
}
set StorageLink(newValue) {
this.__StorageLink.set(newValue);
}
get StorageLink1() {
return this.__StorageLink1.get();
}
set StorageLink1(newValue) {
this.__StorageLink1.set(newValue);
}
get StorageLink2() {
return this.__StorageLink2.get();
}
set StorageLink2(newValue) {
this.__StorageLink2.set(newValue);
}
get StorageLink3() {
return this.__StorageLink3.get();
}
set StorageLink3(newValue) {
this.__StorageLink3.set(newValue);
}
get Provide() {
return this.__Provide.get();
}
set Provide(newValue) {
this.__Provide.set(newValue);
}
get Provide1() {
return this.__Provide1.get();
}
set Provide1(newValue) {
this.__Provide1.set(newValue);
}
get Provide2() {
return this.__Provide2.get();
}
set Provide2(newValue) {
this.__Provide2.set(newValue);
}
get Provide3() {
return this.__Provide3.get();
}
set Provide3(newValue) {
this.__Provide3.set(newValue);
}
get Provide4() {
return this.__Provide4.get();
}
set Provide4(newValue) {
this.__Provide4.set(newValue);
}
get Provide5() {
return this.__Provide5.get();
}
set Provide5(newValue) {
this.__Provide5.set(newValue);
}
get Provide6() {
return this.__Provide6.get();
}
set Provide6(newValue) {
this.__Provide6.set(newValue);
}
get Provide7() {
return this.__Provide7.get();
}
set Provide7(newValue) {
this.__Provide7.set(newValue);
}
get Consume() {
return this.__Consume.get();
}
set Consume(newValue) {
this.__Consume.set(newValue);
}
get Consume1() {
return this.__Consume1.get();
}
set Consume1(newValue) {
this.__Consume1.set(newValue);
}
get Consume2() {
return this.__Consume2.get();
}
set Consume2(newValue) {
this.__Consume2.set(newValue);
}
get Consume3() {
return this.__Consume3.get();
}
set Consume3(newValue) {
this.__Consume3.set(newValue);
}
get Consume4() {
return this.__Consume4.get();
}
set Consume4(newValue) {
this.__Consume4.set(newValue);
}
initialRender() {
this.observeComponentCreation2((elmtId, isInitialRender) => {
Row.create();
}, Row);
Row.pop();
}
rerender() {
this.updateDirtyElements();
}
static getEntryName() {
return "Index";
}
}
if (storage && storage.routeName != undefined && storage.storage != undefined) {
registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : storage.storage), storage.routeName, { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", integratedHsp: "false" });
}
else if (storage && storage.routeName != undefined && storage.storage == undefined) {
registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : storage.storage), storage.routeName, { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", integratedHsp: "false" });
}
else if (storage && storage.routeName == undefined && storage.storage != undefined) {
registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : storage.storage), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", integratedHsp: "false" });
}
else if (storage && storage.useSharedStorage != undefined) {
registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : undefined), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", integratedHsp: "false" });
}
else {
registerNamedRoute(() => new Index(undefined, {}, storage), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck", integratedHsp: "false" });
}
//# sourceMappingURL=decoratorKeyCheck.js.map

View File

@ -0,0 +1,44 @@
@Entry
@Component
struct CompA {
@Provide("reviewVote") reviewVotes : number = 0;
@Provide({allowOverride: 'aliasName'}) message: string = '1111'
build() {
Column() {
CompB()
Button() {
Text('' + this.reviewVotes)
.fontSize(30)
}
.onClick(() => {
this.reviewVotes += 1;
})
}
}
}
@Component
struct CompB {
build() {
Column() {
CompC()
}
}
}
@Component
struct CompC {
@Consume("reviewVote") reviewVotes : number;
build() {
Column() {
Button() {
Text('' + this.reviewVotes)
.fontSize(30)
}
.onClick(() => {
this.reviewVotes += 1;
})
}
}
}

View File

@ -0,0 +1,41 @@
let NextID : number = 0;
@Observed class ClassA {
public id : number;
public c: number;
constructor(c: number) {
this.id = NextID++;
this.c = c;
}
}
@Observed class ClassB {
public a: ClassA;
constructor(a: ClassA) {
this.a = a;
}
}
@Component
struct ViewA {
@ObjectLink varA : ClassA;
build() {
Row() {
Text('ViewA-' + this.varA.id)
}
}
}
@Entry
@Component
struct ViewB {
@State varB : ClassB = new ClassB(new ClassA(0));
build() {
Column() {
Row() {
ViewA({ varA: this.varB.a })
Text('ViewB')
}
}
}
}

View File

@ -0,0 +1,49 @@
@Entry
@Component
struct CompA {
@State @Watch("onBasketUpdated") shopBasket: Array<number> = [ 7, 12, 47, 3 ];
@State totalPurchase: number = 0;
@State @Watch('onPutItem') defArray: Array<string> = ['c', 'g', 't', 'z'];
@State resultTip: string = '';
updateTotal() : number {
let sum = 0;
this.shopBasket.forEach((i) => { sum += i; });
this.totalPurchase = (sum < 100) ? sum : 0.9 * sum;
return this.totalPurchase;
}
onBasketUpdated(propName: string) : void {
animateTo({duration: 1000}, () => {
this.updateTotal();
})
}
updateTip() : string {
let tempArray = this.defArray.slice(0, -1);
let addItem = this.defArray[this.defArray.length -1];
this.resultTip = tempArray.includes(addItem) ?
'add item invalid' :
'congratulations! add item success';
return this.resultTip;
}
onPutItem(propName: string) : void {
this.updateTip();
}
build() {
Column(){
Button("add to basket").onClick(() => {
this.shopBasket.push(Math.round(100 * Math.random()))
})
Text('totalPurchase: ' + this.totalPurchase).fontSize(20)
Button("put item").onClick(() => {
let alList = 'abcdefghijklmnopqrstuvwxyz';
let ranItem = alList[Math.floor(Math.random() * 26)];
this.defArray.push(ranItem)
})
Text('tips: ' + this.resultTip).fontSize(20)
}
}
}

View File

@ -0,0 +1,48 @@
import { stringVariable, stringObj, stringFunction } from '../../../../../test/decoratorKeyCheck'
let para:Record<string,number> = { 'PropA': 47 };
let storage: LocalStorage = new LocalStorage(para);
@Entry(storage)
@Component
struct Index {
@LocalStorageLink(stringVariable) LocalStorageLink: string = 'LocalStorageLink';
@LocalStorageLink(stringObj.stringKey) LocalStorageLink1: string = 'LocalStorageLink1';
@LocalStorageLink(stringFunction()) LocalStorageLink2: string = 'LocalStorageLink2';
@LocalStorageLink('LocalStorageLink3') LocalStorageLink3: string = 'LocalStorageLink3';
@LocalStorageProp(stringVariable) LocalStorageProp: string = 'LocalStorageProp';
@LocalStorageProp(stringObj.stringKey) LocalStorageProp1: string = 'LocalStorageProp1';
@LocalStorageProp(stringFunction()) LocalStorageProp2: string = 'LocalStorageProp2';
@LocalStorageProp('LocalStorageProp3') LocalStorageProp3: string = 'LocalStorageProp3';
@StorageProp(stringVariable) StorageProp: string = 'StorageProp';
@StorageProp(stringObj.stringKey) StorageProp1: string = 'StorageProp1';
@StorageProp(stringFunction()) StorageProp2: string = 'StorageProp2';
@StorageProp('StorageProp3') StorageProp3: string = 'StorageProp3';
@StorageLink(stringVariable) StorageLink: string = 'StorageLink';
@StorageLink(stringObj.stringKey) StorageLink1: string = 'StorageLink1';
@StorageLink(stringFunction()) StorageLink2: string = 'StorageLink2';
@StorageLink('StorageLink3') StorageLink3: string = 'StorageLink3';
@Provide(stringVariable) Provide: string = 'Provide';
@Provide(stringObj.stringKey) Provide1: string = 'Provide1';
@Provide(stringFunction()) Provide2: string = 'Provide2';
@Provide('Provide32') Provide3: string = 'Provide3';
@Provide Provide4: string = 'Provide4';
@Provide({allowOverride: stringVariable}) Provide5: string = 'Provide5';
@Provide({allowOverride: stringObj}) Provide6: string = 'Provide6';
@Provide({allowOverride: stringFunction}) Provide7: string = 'Provide7';
@Consume(stringVariable) Consume: string;
@Consume(stringObj.stringKey) Consume1: string;
@Consume(stringFunction()) Consume2: string;
@Consume('Consume3') Consume3: string;
@Consume Consume4: string;
build() {
Row() {
}
}
}

View File

@ -145,7 +145,11 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [
// 'ui_state_management/inner_struct_state_management/@objectLink/@objectLink',
// 'ui_state_management/inner_struct_state_management/@prop/@prop',
// 'ui_state_management/inner_struct_state_management/@prop/@propComplexType',
'ui_state_management/inner_struct_state_management/@state/@state'
// 'ui_state_management/inner_struct_state_management/@state/@state',
// 'ui_state_management/others/@consume_@provide/@consume_@provide',
// 'ui_state_management/others/@observed_@objectLink/@observed_@objectLink',
// 'ui_state_management/others/@watch/@watch',
'ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck'
];
export const UT_VALIDATE_PAGES: string[] = [