未验证 提交 3db03e9b 编写于 作者: O openharmony_ci 提交者: Gitee

!8667 【OpenHarmony 4.0.7.2】【Master】【ARKUI子系统】【TOD】【rk3568】【必现】新增状态管理

Merge pull request !8667 from 边鑫博/master
{
"app": {
"bundleName": "com.open.harmony.acestatetest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceStateTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_state_test_js_assets",
":ace_ets_state_test_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceStateTest"
}
ohos_app_scope("ace_ets_state_test_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_state_test_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("ace_ets_state_test_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":ace_ets_state_test_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.open.harmony.acestatetest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [{
"test-file-name": [
"ActsAceStateTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
globalThis.windowStage = windowStage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/state", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* Copyright (c) 2021~2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio';
import prompt from '@system.prompt';
let loadedUrl;
let storage: LocalStorage = new LocalStorage({ 'PropA': 47 });
@Entry
@Component
struct Index {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State outputStr: string = ''
@State playing: boolean = false
@State str:string="emitOnLoadIntercept"
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
};
events_emitter.on(valueChangeEvent,this.valueChangeCallBack);
}
private valueChangeCallBack=(eventData)=>{
console.info("web page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build(){
Column(){
Row(){
Button("web click").key('webcomponent').onClick(async ()=>{
console.info("key==>"+this.str)
switch(this.str){
case "emitOnLoadIntercept":{
this.controller.loadUrl("https://www.baidu.com/")
break;
}
case "emitClear":{
AppStorage.SetOrCreate('PropA', 47);
let res: boolean = AppStorage.Clear();
console.log("emitClear====>"+res)
Utils.emitEvent(res,6)
break;
}
case "emitKeys":{
AppStorage.SetOrCreate('PropA', 48);
let keys: IterableIterator<string> = AppStorage.Keys();
Utils.emitEvent(JSON.stringify(Array.from(keys)),8)
break;
}
case "emitSize":{
AppStorage.SetOrCreate('PropA', 48);
let res: number = AppStorage.Size();
console.log("emitSize====>"+res)
Utils.emitEvent(res,10)
await Utils.sleep(3000)
console.log("emitSize"+AppStorage.Delete('emitSize'))
break;
}
case "emitLocalStorageSize":{
Utils.emitEvent(storage.size(),12)
break;
}
case "emitLink":{
AppStorage.SetOrCreate('Link', 47);
let linkToPropA1 = AppStorage.Link('Link');
let linkToPropA2 = AppStorage.Link('Link');
linkToPropA1.set(48);
Utils.emitEvent(linkToPropA2.get(),14)
break;
}
case "emitLinkUndefined":{
AppStorage.SetOrCreate('LinkUndefined', 47);
Utils.emitEvent(AppStorage.Link('PropB'),16)
break;
}
case "emitSetAndLinkCreate":{
let link:SubscribedAbstractProperty<number> = AppStorage.SetAndLink('LinkCreate', 49);
Utils.emitEvent(link.get(),18)
break;
}
case "emitProp":{
AppStorage.SetOrCreate('Prop', 47);
let prop1 = AppStorage.Prop('Prop');
let prop2 = AppStorage.Prop('Prop');
prop1.set(1);
console.log("emitProp====>"+prop2.get())
Utils.emitEvent(prop2.get(),20)
break;
}
case "emitPropUndefined":{
Utils.emitEvent(AppStorage.Prop('xxxxxx'),22)
break;
}
case "emitSetAndLink":{
AppStorage.SetOrCreate('SetAndLink', 47);
let link: SubscribedAbstractProperty<number> = AppStorage.SetAndLink('SetAndLink', 50);
console.log("emitSetAndLink====>"+link.get())
Utils.emitEvent(link.get(),24)
break;
}
case "emitSetAndPropNull":{
AppStorage.SetOrCreate('SetAndPropNull', 47);
let prop: SubscribedAbstractProperty<number> = AppStorage.SetAndProp('SetAndPropNull1', 49);
console.log("emitSetAndPropNull====>"+prop.get())
Utils.emitEvent(prop.get(),26)
break;
}
case "emitSetAndProp":{
AppStorage.SetOrCreate('SetAndProp', 47);
let prop: SubscribedAbstractProperty<number> = AppStorage.SetAndProp('SetAndProp', 49);
console.log("emitSetAndProp====>"+prop.get())
Utils.emitEvent(prop.get(),28)
break;
}
case "emitDelete":{
AppStorage.SetOrCreate('Delete', 48);
let res: boolean = AppStorage.Delete('Delete');
console.log("emitDelete====>"+res)
Utils.emitEvent(res,30)
break;
}
default:
console.info("can not match case")
}
})
}
Web({src:"www.example.com",controller:this.controller})
.onLoadIntercept((event) => {
console.log('url:' + event.data.getRequestUrl())
Utils.emitEvent(event.data.getRequestUrl(),2)
console.log('isMainFrame:' + event.data.isMainFrame())
console.log('isRedirect:' + event.data.isRedirect())
console.log('isRequestGesture:' + event.data.isRequestGesture())
return false
})
.onErrorReceive((event) => {
console.log('getErrorInfo:' + event.error.getErrorInfo())
Utils.emitEvent(event.error.getErrorInfo(),3)
})
}
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import stateJsunit from './StateJsunit.test'
import stateTwoJsunit from './StateTwoJsunit.test'
export default function testsuite() {
stateJsunit()
stateTwoJsunit()
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
let emitKey = "emitOnLoadIntercept";
export default function stateJsunit() {
describe('ActsAceStateTest', function () {
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("state beforeEach start");
done();
})
afterEach(async function (done) {
console.info("state afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_002
*tc.name OnLoadIntercept *tc.desic Injects the JavaScript object into window and invoke the function in window
*/
it('OnLoadIntercept',0,async function(done){
emitKey="emitClear";
Utils.registerEvent("OnLoadIntercept","https://www.baidu.com/",2,done);
sendEventByKey('webcomponent',10,'');
})
it('Clear',0,async function(done){
emitKey="emitKeys";
Utils.registerEvent("Clear",true,6,done);
sendEventByKey('webcomponent',10,'');
})
it('Keys',0,async function(done){
emitKey="emitSize";
let value =["PropA"]
Utils.registerEvent("Keys",JSON.stringify(value),8,done);
sendEventByKey('webcomponent',10,'');
})
it('Size',0,async function(done){
emitKey="emitLocalStorageSize";
Utils.registerEvent("Size",1,10,done);
sendEventByKey('webcomponent',10,'');
})
it('LocalStorageSize',0,async function(done){
emitKey="emitLink";
Utils.registerEvent("LocalStorageSize",1,12,done);
sendEventByKey('webcomponent',10,'');
})
it('Link',0,async function(done){
emitKey="emitLinkUndefined";
Utils.registerEvent("Link",48,14,done);
sendEventByKey('webcomponent',10,'');
})
it('LinkUndefined',0,async function(done){
emitKey="emitSetAndLinkCreate";
Utils.registerEvent("LinkUndefined",undefined,16,done);
sendEventByKey('webcomponent',10,'');
})
it('SetAndLinkCreate',0,async function(done){
emitKey="emitProp";
Utils.registerEvent("SetAndLinkCreate",49,18,done);
sendEventByKey('webcomponent',10,'');
})
it('Prop',0,async function(done){
emitKey="emitPropUndefined";
Utils.registerEvent("Prop",47,20,done);
sendEventByKey('webcomponent',10,'');
})
it('PropUndefined',0,async function(done){
emitKey="emitSetAndLink";
Utils.registerEvent("PropUndefined",undefined,22,done);
sendEventByKey('webcomponent',10,'');
})
it('SetAndLink',0,async function(done){
emitKey="emitSetAndPropNull";
Utils.registerEvent("SetAndLink",47,24,done);
sendEventByKey('webcomponent',10,'');
})
it('SetAndPropNull',0,async function(done){
emitKey="emitSetAndProp";
Utils.registerEvent("SetAndPropNull",49,26,done);
sendEventByKey('webcomponent',10,'');
})
it('SetAndProp',0,async function(done){
emitKey="emitDelete";
Utils.registerEvent("SetAndProp",47,28,done);
sendEventByKey('webcomponent',10,'');
})
it('Delete',0,async function(done){
emitKey="emitDelete";
Utils.registerEvent("Delete",true,30,done);
sendEventByKey('webcomponent',10,'');
})
})
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import router from '@system.router';
import Utils from './Utils.ets';
let emitKey = "emitGetCertificate";
export default function stateTwoJsunit() {
describe('ActsAceStateTwoTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/stateTwo',
}
try {
router.clear();
let pages = router.getState();
console.info("get stateTwo state success " + JSON.stringify(pages));
if (!("stateTwo" == pages.name)) {
console.info("get stateTwo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push stateTwo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push stateTwo page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("stateTwo beforeEach start");
done();
})
afterEach(async function (done) {
console.info("stateTwo afterEach start:"+emitKey);
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
await Utils.sleep(2000);
done();
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_001
*tc.name GetCertificate
*tc.desic Sets allow the Web access overview mode
*/
it('GetCertificate',0,async function(done){
emitKey="emitGet";
Utils.registerEvent("GetCertificate","getCertificate success: len = 0",4,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('Get',0,async function(done){
emitKey="emitHas";
Utils.registerEvent("Get",47,32,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('Has',0,async function(done){
emitKey="emitSet";
Utils.registerEvent("Has",true,5,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('Set',0,async function(done){
emitKey="emitSetFalse";
Utils.registerEvent("Set",true,6,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('SetFalse',0,async function(done){
emitKey="emitGetUndefined";
Utils.registerEvent("SetFalse",false,40,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('GetUndefined',0,async function(done){
emitKey="emitIsMutable";
Utils.registerEvent("GetUndefined",undefined,34,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('IsMutable',0,async function(done){
emitKey="emitHasFalse";
Utils.registerEvent("IsMutable",true,36,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('HasFalse',0,async function(done){
emitKey="emitSetOrCreate";
Utils.registerEvent("HasFalse",false,38,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('SetOrCreate',0,async function(done){
emitKey="emitSetOrCreateTwo";
Utils.registerEvent("SetOrCreate",121,42,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('SetOrCreateTwo',0,async function(done){
emitKey="emitLocalStorageClear";
Utils.registerEvent("SetOrCreateTwo",121,44,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageClear',0,async function(done){
emitKey="emitLocalStorageClearFalse";
Utils.registerEvent("LocalStorageClear",true,64,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageClearFalse',0,async function(done){
emitKey="emitLocalStorageHas";
Utils.registerEvent("LocalStorageClearFalse",false,66,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageHas',0,async function(done){
emitKey="emitLocalStorageHasNull";
Utils.registerEvent("LocalStorageHas",true,46,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageHasNull',0,async function(done){
emitKey="emitLocalStorageSet";
Utils.registerEvent("LocalStorageHasNull",false,48,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageSet',0,async function(done){
emitKey="emitLocalStorageSetNull";
Utils.registerEvent("LocalStorageSet",true,50,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageSetNull',0,async function(done){
emitKey="emitLocalStoragesetOrCreate";
Utils.registerEvent("LocalStorageSetNull",false,52,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragesetOrCreate',0,async function(done){
emitKey="emitLocalStoragesetOrCreateNull";
Utils.registerEvent("LocalStoragesetOrCreate",true,54,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragesetOrCreateNull',0,async function(done){
emitKey="emitLocalStorageLink";
Utils.registerEvent("LocalStoragesetOrCreateNull",true,56,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageLink',0,async function(done){
emitKey="emitLocalStorageLinkNull";
Utils.registerEvent("LocalStorageLink",48,58,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageLinkNull',0,async function(done){
emitKey="emitLocalStoragesetsetAndLink";
Utils.registerEvent("LocalStorageLinkNull",undefined,60,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragesetsetAndLink',0,async function(done){
emitKey="emitLocalStoragesetsetAndLinkTwo";
Utils.registerEvent("LocalStoragesetsetAndLink",49,68,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragesetsetAndLinkTwo',0,async function(done){
emitKey="emitLocalStorageProp";
Utils.registerEvent("LocalStoragesetsetAndLinkTwo",48,70,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageProp',0,async function(done){
emitKey="emitLocalStoragePropNull";
Utils.registerEvent("LocalStorageProp",48,72,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragePropNull',0,async function(done){
emitKey="emitLocalStorageSetAndProp";
Utils.registerEvent("LocalStoragePropNull",undefined,74,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageSetAndProp',0,async function(done){
emitKey="emitLocalStorageSetAndPropTwo";
Utils.registerEvent("LocalStorageSetAndProp",49,76,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageSetAndPropTwo',0,async function(done){
emitKey="emitLocalStorageDelete";
Utils.registerEvent("LocalStorageSetAndPropTwo",48,78,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageDelete',0,async function(done){
emitKey="emitLocalStorageDeleteFalse";
Utils.registerEvent("LocalStorageDelete",true,80,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageDeleteFalse',0,async function(done){
emitKey="emitLocalStorageGet";
Utils.registerEvent("LocalStorageDeleteFalse",false,82,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageGet',0,async function(done){
emitKey="emitLocalStorageGetFalse";
Utils.registerEvent("LocalStorageGet",48,84,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageGetFalse',0,async function(done){
emitKey="emitLocalStorageKeys";
Utils.registerEvent("LocalStorageGetFalse",undefined,86,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageKeys',0,async function(done){
emitKey="emitPersistPropCover";
let result = ["PropA"]
Utils.registerEvent("LocalStorageKeys",JSON.stringify(result),88,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('PersistPropCover',0,async function(done){
emitKey="emitPersistKeys";
Utils.registerEvent("PersistPropCover",666,90,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('PersistKeys',0,async function(done){
emitKey="emitPersistPropLasting";
let persistKeys=["highScore"]
Utils.registerEvent("PersistKeys",JSON.stringify(persistKeys),96,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('PersistPropLasting',0,async function(done){
emitKey="emitDeleteProp";
Utils.registerEvent("PersistPropLasting",false,92,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('DeleteProp',0,async function(done){
emitKey="emitPersistProps";
let deleteProp=["highScore","Lasting"]
Utils.registerEvent("DeleteProp",JSON.stringify(deleteProp),94,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('PersistProps',0,async function(done){
emitKey="emitEnvironmentKeys";
Utils.registerEvent("PersistProps","1",98,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('EnvironmentKeys',0,async function(done){
emitKey="emitGetShared";
let environmentKeys = ["aa","bb","cc"]
Utils.registerEvent("EnvironmentKeys",JSON.stringify(environmentKeys),100,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('GetShared',0,async function(done){
emitKey="emitLocalStoragePropBind";
Utils.registerEvent("GetShared",undefined,102,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragePropBind',0,async function(done){
emitKey="emitLocalStoragePropBindTwo";
Utils.registerEvent("LocalStoragePropBind",88,104,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragePropBindTwo',0,async function(done){
emitKey="emitLocalStoragePropBindNull";
Utils.registerEvent("LocalStoragePropBindTwo",100,106,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragePropBindNull',0,async function(done){
emitKey="emitLocalStorageLinkBind";
Utils.registerEvent("LocalStoragePropBindNull",1,108,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageLinkBind',0,async function(done){
emitKey="emitLocalStoragePropCaseNull";
Utils.registerEvent("LocalStorageLinkBind",1000,110,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragePropCaseNull',0,async function(done){
emitKey="emitEnvironmentTypeString";
Utils.registerEvent("LocalStoragePropCaseNull",1,112,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('EnvironmentTypeString',0,async function(done){
emitKey="emitEnvironmentTypeNum";
Utils.registerEvent("EnvironmentTypeString",true,114,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('EnvironmentTypeNum',0,async function(done){
emitKey="emitEnvironmentTypeBoo";
Utils.registerEvent("EnvironmentTypeNum",true,116,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('EnvironmentTypeBoo',0,async function(done){
emitKey="emitEnvironmentTypeEnum";
Utils.registerEvent("EnvironmentTypeBoo",true,118,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('EnvironmentTypeEnum',0,async function(done){
emitKey="emitLocalStorageLinkType";
Utils.registerEvent("EnvironmentTypeEnum",true,120,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageLinkType',0,async function(done){
emitKey="emitLocalStorageLinkTypeTwo";
Utils.registerEvent("LocalStorageLinkType",true,122,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageLinkTypeTwo',0,async function(done){
emitKey="emitLocalStoragePropTypeTwo";
Utils.registerEvent("LocalStorageLinkTypeTwo",true,124,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStoragePropTwo',0,async function(done){
emitKey="emitLocalStoragePropType";
let LocalStoragePropTwo=[3,"enen",true,1]
Utils.registerEvent("LocalStoragePropTwo",JSON.stringify(LocalStoragePropTwo),126,done);
sendEventByKey('webcomponenttwo',10,'');
})
it('LocalStorageLinkTypeTwo',0,async function(done){
emitKey="emitLocalStoragePropType";
Utils.registerEvent("LocalStorageLinkTypeTwo",true,128,done);
sendEventByKey('webcomponenttwo',10,'');
})
})
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import events_emitter from '@ohos.events.emitter';
import { expect } from "@ohos/hypium";
export default class Utils {
static sleep(time){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok")
},time)
}).then(()=>{
console.info(`sleep ${time} over...`)
})
}
static registerEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertEqual(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEvent(actualValue,eventId){
try {
let backData = {
data: {
"ACTION": actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerEventTwo(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100);
expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100));
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static emitEventTwo(expectedValue,actualValue,eventId){
try {
let backData = {
data: {
"expectedValue":expectedValue,
"actualValue":actualValue
}
}
let backEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
console.info("webFlag start to emit action state");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("webFlag emit action state err: " + JSON.stringify(err));
}
}
static registerContainEvent(testCaseName,expectedValue,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertContain(expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
static commitKey(emitKey){
try {
let backData = {
data: {
"ACTION": emitKey
}
}
let backEvent = {
eventId:10,
priority:events_emitter.EventPriority.LOW
}
console.info("start send emitKey");
events_emitter.emit(backEvent, backData);
} catch (err) {
console.info("emit emitKey err: " + JSON.stringify(err));
}
}
static registerLargerEvent(testCaseName,eventId,done){
console.info(`[${testCaseName}] START`);
try{
let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue);
console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done()
}
let innerEvent = {
eventId:eventId,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(innerEvent,callBack)
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "true"
}
],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"requestPermissions": [
{
"name": "ohos.permission.LOCATION"
},
{
"name": "ohos.permission.INTERNET"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/state",
"MainAbility/pages/stateTwo"
]
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let aaa = 1
localStorage.setItem('变量', JSON.stringify(a));
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>music</title>
</head>
<body>
<audio src="../base/media/gequ.mp3" loop="loop" controls="controls" autoplay="autoplay"></audio>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册