提交 9d8453b7 编写于 作者: C chensi10

Merge branch 'master' of https://gitee.com/openharmony/xts_acts

Signed-off-by: Nchensi10 <chensi52@huawei.com>
......@@ -30,6 +30,7 @@ group("ability_runtime") {
"actsdataabilityaccessdatasharetest:dataabilityaccessdatashare",
"actsfwkdataaccessortest:dataability",
"actsqueryfunctiontest:actsqueryfunctiontest",
"actsrequestdialogtest:actsrequestdialogtest",
"actsserviceabilityclienttest:serviceability",
"actsshellcommandfunctionalitytest:actsshellcommandfunctionalitytest",
"actsstartrunnertest:ActsStartRunnerTest",
......
# Copyright (C) 2023 Huawei Device Co., Ltd.
# 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
......@@ -13,25 +13,9 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("mediaLibrary_store_hap") {
hap_profile = "./src/main/config.json"
js2abc = true
deps = [
":mediaLibrary_store_js_assets",
":mediaLibrary_store_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsMediaLibraryStoreTest"
subsystem_name = "multimedia"
part_name = "multimedia_player_framework"
}
ohos_js_assets("mediaLibrary_store_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("mediaLibrary_store_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
group("actsrequestdialogtest") {
testonly = true
if (is_standard_system) {
deps = [ "actsrequestdialog:ActsRequestDialogTest" ]
}
}
{
"app":{
"bundleName":"com.acts.example.requestdialog",
"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":9,
"targetAPIVersion":9,
"car":{
"apiCompatibleVersion":9,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsRequestDialogTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsrequestdialog_js_assets",
":actsrequestrecent_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsRequestDialogTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsrequestdialog_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsrequestdialog_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsrequestrecent_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsrequestdialog_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.example.requestdialog",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsRequestDialogTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ActsRequestDialogTest.hap->/data/test/ActsRequestDialogTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap"
]
}
]
}
\ 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 AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate");
globalThis.stageContext = this.context;
}
}
/*
* 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 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("MainAbility onCreate");
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
globalThis.applicationContext = this.context.getApplicationContext();
globalThis.requestDialogSuccess = false;
globalThis.validRequestInfo = false;
globalThis.validRequestCallback = false;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy");
globalThis.applicationContext.killAllProcesses().then((data)=>{
console.log(`MainAbility getRunningProcessInformation data ${JSON.stringify(data)}`);
}).catch((err)=>{
console.log(`MainAbility getRunningProcessInformation err ${JSON.stringify(err)}`);
})
globalThis.applicationContext.killAllProcesses((err, data)=>{
console.log(`MainAbility getRunningProcessInformation data ${JSON.stringify(data)}
err: ${JSON.stringify(err)}`);
})
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
}
};
\ 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 router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
var testTime = 0;
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
if(testTime++==0){
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ 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 Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent'
import dialogRequest from '@ohos.app.ability.dialogRequest'
async function publishEvent() {
var event = 'ACTS_REQUEST_DIALOG_EVENT1';
var commonEventPublishData = {
parameters: {
instanceCount: 1,
}
};
commonEvent.publish(event, commonEventPublishData, () => {
console.log('============>publish event success.==========>>')
});
}
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility2 onCreate");
globalThis.abilityWant2 = want;
globalThis.requestDialogSuccess = true;
try {
let requestInfo = dialogRequest.getRequestInfo(want);
if (requestInfo) {
globalThis.validRequestInfo = true;
console.log("MainAbility2 requestInfo is valid");
} else {
console.log("MainAbility2 requestInfo is invalid");
}
let requestCallback = dialogRequest.getRequestCallback(want);
if (requestCallback) {
console.log("MainAbility2 requestCallback is valid");
globalThis.validRequestCallback = true;
let resultCode = {
result : dialogRequest.ResultCode.RESULT_CANCEL,
};
let resultCode2 ={
result : dialogRequest.ResultCode.RESULT_OK,
};
console.log(`resultCjode2 is ${JSON.stringify(resultCode2)}`);
requestCallback.setRequestResult(resultCode);
} else {
console.log("MainAbility2 requestCallback is invalid");
}
publishEvent();
} catch {
console.log("MainAbility2 testRequest fail");
}
console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify( globalThis.abilityWant2));
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility2 onWindowStageCreate")
globalThis.abilityContext2 = this.context;
windowStage.setUIContent(this.context, "MainAbility/pages/second/second", null);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
}
};
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* 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
......@@ -12,50 +12,39 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
import Ability from '@ohos.app.ability.UIAbility'
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate');
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
onDestroy() {
console.log('TestAbility onDestroy');
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate');
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("/common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy');
}
.title {
font-size: 100px;
color: #FFFFFF;
onForeground() {
console.log('TestAbility onForeground');
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
onBackground() {
console.log('TestAbility onBackground');
}
}
};
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* 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
......@@ -12,22 +12,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
setTimeout(()=>{
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},100)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* 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
......@@ -12,48 +12,67 @@
* 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 itName',
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
targetParams = `${targetParams} ${key} ${parameters[key]}`;
}
}
return targetParams.trim()
return targetParams.trim();
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err));
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ");
}
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
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.acts.example.requestdialog.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, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
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) 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 { describe, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
var subscriberInfo = {
events: ["ACTS_REQUEST_DIALOG_EVENT1", "ACTS_REQUEST_DIALOG_EVENT2"]
};
const CASE_TIMEOUT = 3000;
console.info("====>in Ability.test====>");
export default function abilityTest() {
describe('ActsRequestDialogTest', function () {
console.info("====>in ActsRequestDialogTest====>");
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
/*
* @tc.number: ACTS_requestDialog_0100
* @tc.name: Start Recent Ability with no permission.
* @tc.desc: reguest dialog service
*/
it('ACTS_requestDialog_0100', 0, async function (done) {
console.log('ACTS_requestDialog_0100====<begin');
var subscriber;
let id;
let resultCode;
async function subscribeCallBack(err, data) {
console.info("====>ACTS_requestDialog_0100 Subscribe CallBack data:====>" + JSON.stringify(data));
async function processInfoCheck(data) {
console.info('====> ACTS_requestDialog_0100 processInfoCheck=====>');
expect(globalThis.requestDialogSuccess).assertTrue();
expect(globalThis.validRequestInfo).assertTrue();
expect(globalThis.validRequestCallback).assertTrue();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
done();
}
if (data.event == "ACTS_REQUEST_DIALOG_EVENT1") {
console.info('====> ACTS_startRecent_0100 ACTS_StartAbility_CommonEvent1 success=====>');
await sleep(500);
processInfoCheck(data);
}
}
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.info("====>ACTS_requestDialog_0100 Create Subscriber====>");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
try {
await globalThis.abilityContext.requestDialogService(
{
bundleName: 'com.acts.example.requestdialog',
abilityName: 'com.acts.example.requestdialog.MainAbility2',
}).then((data) => {
console.info("====>ACTS_requestDialog_0100 request end + data:" + JSON.stringify(data));
resultCode = data.result;
})
} catch (paramError) {
console.info("====>ACTS_requestDialog_0100 requestDialogSerivce paramError====>");
}
})
function unSubscribeCallback() {
console.info("====>UnSubscribe0100 CallBack====>");
}
function timeout() {
console.log('ACTS_requestDialog_0100 timeout.');
done();
}
id = setTimeout(timeout, CASE_TIMEOUT);
console.log('Start ACTS_requestDialog_0100 timer id : ' + id);
})
})
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* 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
......@@ -12,8 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import abilityTest from './Ability.test.ets'
import ActsMediaLibraryStoreTest from './ActsMediaLibraryStoreTest.test.js'
export default function testsuite() {
ActsMediaLibraryStoreTest()
}
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.example.requestdialog.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"
]
}
]
},
{
"name": "com.acts.example.requestdialog.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType":"standard",
"orientation": "portrait"
}
]
}
}
\ 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/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
......@@ -12,16 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { describe, afterEach, it, expect } from '@ohos/hypium'
import formProvider from '@ohos.application.formProvider';
import FormInfo from '@ohos.application.formInfo';
import formInfoNew from '@ohos.app.form.formInfo';
import formError from '@ohos.application.formError';
import formHost from '@ohos.application.formHost';
import errorManager from '@ohos.app.ability.errorManager';
import abilityConstant from '@ohos.app.ability.AbilityConstant'
import appManager from '@ohos.application.appManager'
import appManagerNew from '@ohos.app.ability.appManager'
import commonEvent from '@ohos.commonEvent';
import ability from '@ohos.ability.ability';
......@@ -29,12 +26,11 @@ import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
import common from '@ohos.app.ability.common';
import contextConstant from "@ohos.app.ability.contextConstant"
var EXTENSION_INFO_ERR = 16000001
var INNER_ERROR = 16000050
var CROSS_USER_DENY = 201
var INVALID_PARAM = 401
var trueInfo;
var array = new Array();
let EXTENSION_INFO_ERR = 16000001;
let INNER_ERROR = 16000050;
let CROSS_USER_DENY = 201;
let array = new Array();
let TAG = '';
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
......@@ -661,5 +657,115 @@ export default function ApiCoverTest() {
done()
})
})
/*
* @tc.number SUB_AA_AbilityAppManager_0100
* @tc.name The form of a promise getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AbilityAppManager_0100', 0, async function (done) {
TAG = 'SUB_AA_AbilityAppManager_0100';
await appManagerNew.getRunningProcessInformation().then((data)=>{
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
}).catch((err)=>{
console.log(`${TAG} getRunningProcessInformation err ${JSON.stringify(err)}`);
expect().assertFail();
done();
})
})
/*
* @tc.number SUB_AA_AbilityAppManager_0200
* @tc.name The form of a callback getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AbilityAppManager_0200', 0, async function (done) {
TAG = 'SUB_AA_AbilityAppManager_0100';
appManagerNew.getRunningProcessInformation((err, data) => {
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}
err: ${JSON.stringify(err)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
})
})
/*
* @tc.number SUB_AA_ApplicationContext_0100
* @tc.name The form of a promise getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ApplicationContext_0100', 0, async function (done) {
TAG = 'SUB_AA_ApplicationContext_0100';
await globalThis.applicationContext.getRunningProcessInformation().then((data)=>{
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
}).catch((err)=>{
console.log(`${TAG} getRunningProcessInformation err ${JSON.stringify(err)}`);
expect().assertFail();
done();
})
})
/*
* @tc.number SUB_AA_ApplicationContext_0200
* @tc.name The form of a callback getRunningProcessInformation
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ApplicationContext_0200', 0, async function (done) {
TAG = 'SUB_AA_ApplicationContext_0200';
globalThis.applicationContext.getRunningProcessInformation((err, data) => {
console.log(`${TAG} getRunningProcessInformation data ${JSON.stringify(data.length)}
err: ${JSON.stringify(err)}`);
for (let i = 0; i < data.length; i++) {
console.log(`${TAG} getRunningProcessInformation${i} : JSON.stringify(data[i])`);
expect(typeof (data[i].pid)).assertEqual("number");
expect(data[i].pid).assertLarger(0);
expect(typeof (data[i].uid)).assertEqual("number");
expect(data[i].uid).assertLarger(0);
expect(typeof (data[i].processName)).assertEqual("string");
expect(data[i].processName.length).assertLarger(0);
expect(Array.isArray(data[i].bundleNames)).assertEqual(true);
expect(data[i].bundleNames.length).assertLarger(0);
}
done();
})
})
})
}
......@@ -67,8 +67,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -130,8 +132,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -207,8 +211,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -263,8 +269,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......@@ -365,8 +373,10 @@ export default function verificationTest(){
console.info(TAG + "startAbility data = " + JSON.stringify(data) + ";" + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
if (err.code != 16000017) {
expect().assertFail();
done();
}
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
......
......@@ -14,6 +14,7 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import wantAgent from '@ohos.app.ability.wantAgent';
import wantConstant from '@ohos.app.ability.wantConstant'
var TAG
export default function wantAgentCoverTest() {
......@@ -60,6 +61,8 @@ export default function wantAgentCoverTest() {
});
setTimeout(() => {
expect(wantConstant.Params.ABILITY_BACK_TO_OTHER_MISSION_STACK)
.assertEqual('ability.params.backToOtherMissionStack');
expect(status).assertTrue();
expect(code1).assertEqual(2);
done()
......
......@@ -376,7 +376,7 @@ export default function abilityTest() {
},CASE_TIME_OUT)
})
/*
/*
* @tc.number: Acts_AppRecovery_0700
* @tc.name: Fault recovery of multi-Ability application
* @tc.desc: If the restart recovery status is not set, the Ability application pre-failure state will not be
......@@ -444,6 +444,440 @@ export default function abilityTest() {
}, 800);
}
setTimeout(()=>{
if(flag==false){
expect().assertFail();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
},CASE_TIME_OUT)
})
/*
* @tc.number: Acts_AppRecovery_0800
* @tc.name: Fault recovery of multi-Ability application
* @tc.desc: If the restart recovery status is not set, the Ability application pre-failure state will not be
* restored after the application exits abnormally and restarts.
*/
it('Acts_AppRecovery_0800',0, async function (done) {
let subscriber;
let flag = false;
let countFirst = 0;
let countSecond = 0;
console.info("Acts_AppRecovery_0800====> start")
commonEvent.createSubscriber(ACTS_AppRecovery).then(async (data) => {
console.debug("Acts_AppRecovery_0800====> Create Subscribe");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_0800_once"
},(err)=>{
console.debug("Acts_AppRecovery_0800====> startAbility err:"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
function subscribeCallBack(err, data) {
console.debug("Acts_AppRecovery_0800====> subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_First") {
countFirst++;
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
if (countFirst < 2) {
return;
}
setTimeout(() => {
commonEvent.subscribe(subscriber, subscribeCallBackSecond);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_0800_twice"
},
(err) => {
console.debug("Acts_AppRecovery_0800====> second startAbility err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
}
);
}, 800);
}
}
function subscribeCallBackSecond(err, data) {
console.debug("Acts_AppRecovery_0800====> second subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_Second") {
countSecond++;
flag=true;
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
if (countSecond < 2) {
return;
}
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
}
function unSubscribeCallback() {
setTimeout(() => {
console.debug("Acts_AppRecovery_0800====> unSubscribeCallback");
done();
}, 800);
}
setTimeout(()=>{
if(flag==false){
expect().assertFail();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
},CASE_TIME_OUT)
})
/*
* @tc.number: Acts_AppRecovery_0900
* @tc.name: Fault recovery of multi-Ability application
* @tc.desc: When the application settings restart recovery status is valid, the application exits abnormally
* and restarts to restore the pre-failure state of Ability application.
*/
it('Acts_AppRecovery_0900',0, async function (done) {
let subscriber;
let flag = false;
console.info("Acts_AppRecovery_0900====> start")
commonEvent.createSubscriber(ACTS_AppRecovery).then(async (data) => {
console.debug("Acts_AppRecovery_0900====> Create Subscribe");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoveryrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_0900_once"
},(err)=>{
console.debug("Acts_AppRecovery_0900====> startAbility err:"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
function subscribeCallBack(err, data) {
console.debug("Acts_AppRecovery_0900====> subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_First") {
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
let pkillCmd = "pkill -f com.example.apprecoveryrely";
console.debug("Acts_AppRecovery_0900====> shell command call " + pkillCmd);
abilityDelegator.executeShellCommand(pkillCmd, 1, (err, data) => {
console.debug("Acts_AppRecovery_0900====> shell command callback " + JSON.stringify(err) + " " + JSON.stringify(data));
setTimeout(() => {
commonEvent.subscribe(subscriber, subscribeCallBackSecond);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoveryrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_0900_twice"
},
(err) => {
console.debug("Acts_AppRecovery_0900====> second startAbility err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
}
);
}, 800);
});
}
}
function subscribeCallBackSecond(err, data) {
console.debug("Acts_AppRecovery_0900====> second subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_Second") {
flag=true;
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
}
function unSubscribeCallback() {
setTimeout(() => {
console.debug("Acts_AppRecovery_0900====> unSubscribeCallback");
done();
}, 800);
}
setTimeout(()=>{
if(flag==false){
expect().assertFail();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
},CASE_TIME_OUT)
})
/*
* @tc.number: Acts_AppRecovery_1000
* @tc.name: Fault recovery of multi-Ability application
* @tc.desc: When the application settings restart recovery status is valid, the application exits abnormally
* and restarts to restore the pre-failure state of Ability application.
*/
it('Acts_AppRecovery_1000',0, async function (done) {
let subscriber;
let flag = false;
let countFirst = 0;
let countSecond = 0;
console.info("Acts_AppRecovery_1000====> start")
commonEvent.createSubscriber(ACTS_AppRecovery).then(async (data) => {
console.debug("Acts_AppRecovery_1000====> Create Subscribe");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_1000_once"
},(err)=>{
console.debug("Acts_AppRecovery_1000====> startAbility err:"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
function subscribeCallBack(err, data) {
console.debug("Acts_AppRecovery_1000====> subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_First") {
countFirst++;
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
if (countFirst < 2) {
return;
}
let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
let pkillCmd = "pkill -f com.example.apprecoverysrely";
abilityDelegator.executeShellCommand(pkillCmd, 1, (err, data) => {
setTimeout(() => {
commonEvent.subscribe(subscriber, subscribeCallBackSecond);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_1000_twice"
},
(err) => {
console.debug("Acts_AppRecovery_1000====> second startAbility err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
}
);
}, 800);
});
}
}
function subscribeCallBackSecond(err, data) {
console.debug("Acts_AppRecovery_1000====> second subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_Second") {
countSecond++;
flag=true;
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
if (countSecond < 2) {
return;
}
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
}
function unSubscribeCallback() {
setTimeout(() => {
console.debug("Acts_AppRecovery_1000====> unSubscribeCallback");
done();
}, 800);
}
setTimeout(()=>{
if(flag==false){
expect().assertFail();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
},CASE_TIME_OUT)
})
/*
* @tc.number: Acts_AppRecovery_1100
* @tc.name: Fault recovery of multi-Ability application
* @tc.desc: When setting restart recovery status is valid, exit the application by clearing the task list and
* do not restore the pre-failure state of the Ability application after the application restart.
*/
it('Acts_AppRecovery_1100',0, async function (done) {
let subscriber;
let flag = false;
console.info("Acts_AppRecovery_1100====> start")
commonEvent.createSubscriber(ACTS_AppRecovery).then(async (data) => {
console.debug("Acts_AppRecovery_1100====> Create Subscribe");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoveryrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_1100_once"
},(err)=>{
console.debug("Acts_AppRecovery_1100====> startAbility err:"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
function subscribeCallBack(err, data) {
console.debug("Acts_AppRecovery_1100====> subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_First") {
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
let pkillCmd = "pkill -f com.example.apprecoveryrely";
abilityDelegator.executeShellCommand(pkillCmd, 1, (err, data) => {
setTimeout(() => {
commonEvent.subscribe(subscriber, subscribeCallBackSecond);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoveryrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_1100_twice"
},
(err) => {
console.debug("Acts_AppRecovery_1100====> second startAbility err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
}
);
}, 800);
});
}
}
function subscribeCallBackSecond(err, data) {
console.debug("Acts_AppRecovery_1100====> second subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_Second") {
flag=true;
let message = data.parameters.message;
expect(message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertTrue();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
}
function unSubscribeCallback() {
setTimeout(() => {
console.debug("Acts_AppRecovery_1100====> unSubscribeCallback");
done();
}, 800);
}
setTimeout(()=>{
if(flag==false){
expect().assertFail();
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
},CASE_TIME_OUT)
})
/*
* @tc.number: Acts_AppRecovery_1200
* @tc.name: Fault recovery of multi-Ability application
* @tc.desc: When setting restart recovery status is valid, exit the application by clearing the task list and
* do not restore the pre-failure state of the Ability application after the application restart.
*/
it('Acts_AppRecovery_1200',0, async function (done) {
let subscriber;
let flag = false;
let countFirst = 0;
let countSecond = 0;
console.info("Acts_AppRecovery_1200====> start")
commonEvent.createSubscriber(ACTS_AppRecovery).then(async (data) => {
console.debug("Acts_AppRecovery_1200====> Create Subscribe");
subscriber = data;
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_1200_once"
},(err)=>{
console.debug("Acts_AppRecovery_1200====> startAbility err:"+JSON.stringify(err));
expect(err.code).assertEqual(0);
})
})
function subscribeCallBack(err, data) {
console.debug("Acts_AppRecovery_1200====> subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_First") {
countFirst++;
let message = data.parameters.message;
let strJson = JSON.stringify(data.parameters.message);
if (data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"] == undefined) {
expect(true).assertTrue();
} else {
expect(data.parameters.message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertFalse();
}
if (countFirst < 2) {
return;
}
let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
let pkillCmd = "pkill -f com.example.apprecoverysrely";
abilityDelegator.executeShellCommand(pkillCmd, 1, (err, data) => {
setTimeout(() => {
commonEvent.subscribe(subscriber, subscribeCallBackSecond);
globalThis.abilityContext.startAbility(
{
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbility",
action: "Acts_AppRecovery_1200_twice"
},
(err) => {
console.debug("Acts_AppRecovery_1200====> second startAbility err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
}
);
}, 800);
});
}
}
function subscribeCallBackSecond(err, data) {
console.debug("Acts_AppRecovery_1200====> second subscribeCallBack data:" + JSON.stringify(data));
if(data.event == "ACTS_AppRecovery_Second") {
countSecond++;
flag=true;
let message = data.parameters.message;
expect(message["ohos.aafwk.param.AbilityRecoveryRestart"]).assertTrue();
if (countSecond < 2) {
return;
}
commonEvent.unsubscribe(subscriber, unSubscribeCallback);
}
}
function unSubscribeCallback() {
setTimeout(() => {
console.debug("Acts_AppRecovery_1200====> unSubscribeCallback");
done();
}, 800);
}
setTimeout(()=>{
if(flag==false){
expect().assertFail();
......
......@@ -69,11 +69,9 @@ export default class EntryAbility extends Ability {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
// 第一次启动设置项目
if (strAction == "Acts_AppRecovery_0100_once" || strAction == "Acts_AppRecovery_0300_once" ||
strAction == "Acts_AppRecovery_0700_once" || strAction == "Acts_AppRecovery_0900_once" ||
strAction == "Acts_AppRecovery_1100_once") {
// 是否包存状态
if (strAction == "Acts_AppRecovery_0100_once" || strAction == "Acts_AppRecovery_0300_once" ||
strAction == "Acts_AppRecovery_1100_once") {
appRecovery.saveAppState(this.context);
......@@ -81,11 +79,9 @@ export default class EntryAbility extends Ability {
} else {
console.log(strAction + "Rely====> not saveAppState");
}
// 回复ACTS_AppRecovery_First消息
setTimeout(() => {
commonEvent.publish("ACTS_AppRecovery_First",commonEventData,(err)=>{
console.log(strAction + "Rely====> publish err:" + JSON.stringify(err));
// 是否退出
if (strAction == "Acts_AppRecovery_0100_once" ||
strAction == "Acts_AppRecovery_0700_once") {
setTimeout(()=>{
......@@ -100,7 +96,6 @@ export default class EntryAbility extends Ability {
}, 200);
}
// 第二次启动设置项目
if (strAction == "Acts_AppRecovery_0100_twice" || strAction == "Acts_AppRecovery_0300_twice" ||
strAction == "Acts_AppRecovery_0700_twice" || strAction == "Acts_AppRecovery_0900_twice" ||
strAction == "Acts_AppRecovery_1100_twice") {
......
......@@ -67,11 +67,9 @@ export default class EntryAbility extends Ability {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
// 第一次启动
if (strAction == "Acts_AppRecovery_0200_once" || strAction == "Acts_AppRecovery_0400_once" ||
strAction == "Acts_AppRecovery_0800_once" ||
strAction == "Acts_AppRecovery_1000_once" || strAction == "Acts_AppRecovery_1200_once") {
// 需要包存状态的用例
if (strAction == "Acts_AppRecovery_0200_once" ||
strAction == "Acts_AppRecovery_0400_once" ||
strAction == "Acts_AppRecovery_1200_once") {
......@@ -86,7 +84,6 @@ export default class EntryAbility extends Ability {
})
}, 200);
}
// 第二次启动
if (strAction == "Acts_AppRecovery_0200_twice" || strAction == "Acts_AppRecovery_0400_twice" ||
strAction == "Acts_AppRecovery_0800_twice" ||
strAction == "Acts_AppRecovery_1000_twice" || strAction == "Acts_AppRecovery_1200_twice") {
......@@ -96,14 +93,12 @@ export default class EntryAbility extends Ability {
})
}, 200);
}
// 拉起第二个Ability
this.context.startAbility({
bundleName: "com.example.apprecoverysrely",
abilityName: "EntryAbilitySec",
action: strAction
},(err) => {
console.debug(strAction + "Rely1====> startAbility err:"+JSON.stringify(err));
// 需要自己正常退出的用例
if (strAction == "Acts_AppRecovery_0200_once" || strAction == "Acts_AppRecovery_0200_twice" ||
strAction == "Acts_AppRecovery_0400_twice" ||
strAction == "Acts_AppRecovery_0800_once" || strAction == "Acts_AppRecovery_0800_twice" ||
......
......@@ -45,6 +45,10 @@
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
],
"abilities": [
......
......@@ -46,11 +46,12 @@ export default function ActsAccountAppAccess() {
parameters:
{},
},
},
)
await sleep(1500);
}, (err, data) => {
console.debug("====>accountauthenticatorfeatureAbility.startAbilityForResult err:" + JSON.stringify(err))
console.debug("====>accountauthenticatorfeatureAbility.startAbilityForResult data:" + JSON.stringify(data))
done();
})
console.debug("====>ActsAccountAuthenticator beforeAll end====");
done();
});
beforeEach(async (done)=>{
console.debug("====>afterEach start====");
......
......@@ -60,6 +60,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0300', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -124,6 +125,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0400', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -192,6 +194,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0500', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0500 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -251,6 +254,7 @@ export default function ActsAccountOnOff() {
*/
it('ActsAccountOnOff_0600', 0, async function (done) {
testInit();
await sleep(500);
console.debug("====>ActsAccountOnOff_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......
......@@ -32,7 +32,7 @@ export default function testsuite() {
ActsAccountRemoveAccount()
ActsAccountErrPermission()
ActsAccountAuthToken()
ActsAccountOnOff()
ActsAccountAuthenticator()
ActsAccountErrCode()
ActsAccountOnOff()
}
\ No newline at end of file
......@@ -42,6 +42,10 @@
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
......
......@@ -32,7 +32,8 @@ export default function ActsAccountAppAccess() {
console.info(`sleep #{time} over ...`)
})
}
beforeAll(async function (done) {
beforeAll(async function (done) {
console.debug("====>accountauthenticatorbeforeAll start====");
await featureAbility.startAbility(
{
want:
......@@ -44,10 +45,12 @@ export default function ActsAccountAppAccess() {
parameters:
{},
},
},
)
await sleep(1000)
done();
}, (err, data) => {
console.debug("====>accountauthenticatorfeatureAbility.startAbility err:" + JSON.stringify(err))
console.debug("====>accountauthenticatorfeatureAbility.startAbility data:" + JSON.stringify(data))
done();
})
console.debug("====>accountauthenticatorfeatureAbility.startAbility end")
});
beforeEach(async function (done) {
console.debug("====>afterEach start====");
......
......@@ -33,6 +33,6 @@ export default function testsuite() {
ActsAccountSetGetExtraInfo()
ActsAccountNoPermission()
ActsAccountOAuthToken()
ActsAccountChangeOnOff()
ActsAccountAuthenticator()
ActsAccountChangeOnOff()
}
\ No newline at end of file
......@@ -60,6 +60,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0100', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -129,6 +130,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0200', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -193,6 +195,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0300', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -257,6 +260,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0400', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -325,6 +329,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0500', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0500 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -384,6 +389,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0600', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -456,6 +462,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_0700', 0, async function (done) {
testInit();
await sleep(1000);
console.debug("====>ActsAccountChangeOnOff_0700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
......@@ -520,6 +527,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_0800', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_0800 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_0800 start");
......@@ -575,6 +583,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_0900', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_0900 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add first account ActsAccountChangeOnOff_0900 start");
......@@ -642,6 +651,7 @@ export default function ActsAccountChangeOnOff() {
console.debug("====>ActsAccountChangeOnOff_1000 start====");
let dataMapFir = new Map();
let dataMapSec = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1000 start");
......@@ -718,6 +728,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_1100', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1100 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1100 start");
......@@ -778,6 +789,7 @@ export default function ActsAccountChangeOnOff() {
it('ActsAccountChangeOnOff_1200', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1200 start====");
let dataMap = new Map();
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1200 start");
......@@ -838,6 +850,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_1300', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1300 start====");
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1300 start");
......@@ -884,6 +897,7 @@ export default function ActsAccountChangeOnOff() {
*/
it('ActsAccountChangeOnOff_1400', 0, async function (done) {
console.debug("====>ActsAccountChangeOnOff_1400 start====");
await sleep(1000);
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat appAccountManager finish");
console.debug("====>add account ActsAccountChangeOnOff_1400 start");
......
......@@ -261,7 +261,7 @@ class MyAuthenticator extends rpc.RemoteObject {
case 5 :
name = readString8(data)
callback = new MyAuthenticatorCallback(data.readRemoteObject())
this.authenticatorImpl.isAccountRemovable(name, callback)
this.authenticatorImpl.checkAccountRemovable(name, callback)
break
}
return true
......@@ -345,7 +345,7 @@ class MyAuthenticatorImpl {
callback.onResult(10016, {})
}
isAccountRemovable(name, callback) {
checkAccountRemovable(name, callback) {
console.log(TAG + "name: " + name)
var isRemovable = this.accountRemovability[name]
if (isRemovable == undefined || isRemovable == false) {
......
......@@ -160,7 +160,7 @@ class MyAuthenticator extends account_appAccount.Authenticator {
callback.onResult(10016, {})
}
isAccountRemovable(name, callback) {
checkAccountRemovable(name, callback) {
console.log(TAG + "name: " + name)
var isRemovable = false;
try {
......
......@@ -36,9 +36,10 @@ export default {
data: {
},
onShow() {
this.title = "scene on off";
// this.title = "scene on off";
},
onInit() {
this.title = "scene on off";
console.debug("====>change on off scene start====");
var appAccountManager = account.createAppAccountManager();
var commonEventSubscribeInfo = {
......@@ -51,11 +52,12 @@ export default {
console.debug("====>publish call back scene err:" + JSON.stringify(err));
console.debug("====>scene off start====");
appAccountManager.off('accountChange', function (){
appAccountManager.off('change', function (){
console.debug("====>scene off finish====");
});
console.debug("====>scene off accountChange finish====");
});
appAccountManager.off('change', function (){
console.debug("====>scene off change finish====");
});
// featureAbility.terminateSelf()
featureAbility.terminateSelf()
}
// Subscribe to the callback of account information changes, verify the received account information, and send
......
......@@ -213,7 +213,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
console.debug("====>get type err: " + JSON.stringify(err));
console.debug("====>type obtained by process:" + JSON.stringify(accountType));
expect(err).assertEqual(null);
expect(accountType.ADMIN).assertEqual(0);
expect(accountType).assertEqual(0);
console.debug("====>ActsOsAccountGetTypeFormProcess_0100 end====");
done();
});
......@@ -230,7 +230,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
console.debug("====>get AccountManager finish====");
var accountType = await osAccountManager.getOsAccountTypeFromProcess();
console.debug("====>type obtained by process:" + JSON.stringify(accountType));
expect(accountType.ADMIN).assertEqual(0);
expect(accountType).assertEqual(0);
console.debug("====>ActsOsAccountGetTypeFormProcess_0200 end====");
done();
});
......@@ -354,7 +354,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
expect(err).assertEqual(null);
expect(data.localName).assertEqual("osAccountNameIdSerialA");
expect(data.domainInfo.accountName == "").assertEqual(true)
expect(data.type.NORMAL).assertEqual(1);
expect(data.type).assertEqual(1);
expect(data.constraints.length > 0).assertEqual(true);
expect(data.isVerified).assertEqual(false);
expect(data.distributedInfo.name != null).assertEqual(true);
......@@ -644,7 +644,7 @@ export default function ActsOsAccountThirdPartyTest_third_2() {
var data = await AccountManager.queryCurrentOsAccount();
console.debug("====>queryCurrentOsAccount data:" + JSON.stringify(data));
expect(data.localId).assertEqual(100);
expect(data.type.ADMIN).assertEqual(0);
expect(data.type).assertEqual(0);
var serialNumberStr = data.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
......
......@@ -65,6 +65,7 @@ export default function appearJsunit() {
console.info("testAppear01 on appearEvent err : " + JSON.stringify(err));
}
console.info("testAppear01 click result is: " + JSON.stringify(sendEventByKey('appear', 10, "")));
await Utils.sleep(1000);
console.info('[testAppear01] END');
console.info('[testAppear02] START');
......
......@@ -126,7 +126,7 @@ export default function scrollOnScrollBeginJsunit() {
console.info("[testscrollOnScrollBegin0005] component align strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Scroll');
expect(obj.$attrs.scrollBarWidth).assertEqual("30.00px");
expect(obj.$attrs.scrollBarWidth).assertEqual("30.00vp");
console.info("[testscrollOnScrollBegin0005] scrollBarWidth value :" + obj.$attrs.scrollBarWidth);
done();
});
......
......@@ -25,7 +25,7 @@ const TAG = 'ets_apiLack_add';
struct Second {
private content: string = "这是第二页"
@State text: string = router.getParams()['text']
@State data: any = router.getParams()['data']
@State data: number[] = router.getParams()['data']
@State secondData : string = ''
build() {
......@@ -37,7 +37,7 @@ struct Second {
.fontSize(30)
.key("DataText")
.onClick(()=>{
this.secondData = (this.data.array[1]).toString()
this.secondData = (this.data[1]).toString()
try {
var backData = {
data: {
......
......@@ -25,7 +25,7 @@ const TAG = 'ets_apiLack_add';
struct Second {
private content: string = "这是第二页"
@State text: string = router.getParams()['text']
@State data: any = router.getParams()['data']
@State data: number[] = router.getParams()['data']
@State secondData : string = ''
build() {
......@@ -37,7 +37,7 @@ struct Second {
.fontSize(30)
.key("SingleDataText")
.onClick(()=>{
this.secondData = (this.data.array[1]).toString()
this.secondData = (this.data[1]).toString()
try {
var backData = {
data: {
......
......@@ -30,9 +30,7 @@ struct RouterStandard {
url: 'pages/page1',
params: {
text: '这是第一页的值',
data: {
array: [12, 45, 78]
}
data: [12, 45, 78]
}
}
try {
......
......@@ -63,7 +63,7 @@ export default function alertDialogCenterStartJsunit() {
var callback = (eventData) => {
console.info("testalertDialogCenterStart0001 get event data is: " + JSON.stringify(eventData));
expect(eventData.data.Result).assertEqual(true);
console.info('testalertDialogCenterStart0011 END');
console.info('testalertDialogCenterStart0001 END');
done();
}
console.info("testalertDialogCenterStart0001 click result is: " + JSON.stringify(sendEventByKey('CenterStartButton', 10, "")));
......@@ -85,7 +85,7 @@ export default function alertDialogCenterStartJsunit() {
let measureOptions = {textContent : "alertDialog-CenterStart"};
let width = measure.measureText(measureOptions);
console.info("++++++++++++++++++++++" + width.toString());
expect(width > 0).assertFalse();
expect(width > 0).assertTrue();
done();
} catch (err) {
console.info("testMeasureText0001 err : " + JSON.stringify(err));
......
......@@ -56,7 +56,7 @@ export default function appVersionCodeJsunit() {
}
var callback = (eventData) => {
console.info("testappVersionCode_0011 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.Code).assertEqual("1");
expect(eventData.data.Code).assertEqual(1000000);
}
console.info("testappVersion click result is: " + JSON.stringify(sendEventByKey('versionCodeText', 10, "")));
events_emitter.on(innerEvent, callback);
......
......@@ -75,7 +75,7 @@ export default function checkBoxGroupPartJsunit() {
}
var callback = (eventData) => {
console.info("testcheckBoxGroup0001 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.STATUS).assertEqual(2);
expect(eventData.data.STATUS).assertEqual(0);
done();
}
events_emitter.on(innerEvent, callback);
......
......@@ -62,7 +62,7 @@ export default function unitsModuleNameJsunit() {
}
var callback = (eventData) => {
console.info("testunitsModuleName0001 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.ModuleName).assertEqual(true);
expect(eventData.data.ModuleName).assertFalse();
}
events_emitter.on(innerEvent, callback);
} catch (err) {
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -20,36 +20,37 @@ import prompt from '@system.prompt'
@Entry
@Component
struct ohosMatrix4 {
@State rotateValue: object= {
@State rotateValue: RotateOptions = {
x: 1,
y: 1,
z: 1,
centerX: '50%',
centerY: '50%',
centerX: 7,
centerY: 8,
angle: 300
}
@State translateValue: object= { x: 100, y: 5 }
@State scaleValue: object= { x: 2, y: 0.5 }
@State transformValue: object= Matrix4.identity().translate({ x: 100, y: 100, z: 30 })
@State transformValue: object= Matrix4.identity().translate({ x: 100, y: 100, z: 30 })
@State transformValue1: object= Matrix4.identity().translate({ x: 100, y: 100, z: 30 })
@State matrix1: object= Matrix4.identity().transformPoint([100, 10])
@State matrix2: object = Matrix4.identity().translate({ x: 300 }).copy()
@State matrix3: object = Matrix4.identity().scale({ x: 3 }).copy()
@State matrix2: Matrix4.Matrix4Transit = Matrix4.identity().translate({ x: 300 }).copy()
@State matrix3: Matrix4.Matrix4Transit = Matrix4.identity().scale({ x: 3 }).copy()
@State matrix4: object = Matrix4.identity().rotate({x:1, y:1, z:2, angle:30})
@State matrix5: object = Matrix4.identity().scale({x:5, y:1, z:1, centerX:50, centerY:50})
@State matrix6: object = Matrix4.identity().translate({x:100, y:200, z:30})
@State matrix7: Matrix4.Matrix4Transit = Matrix4.identity().translate({ x: 300 }).combine(Matrix4.identity().scale({ x: 3 }));
@State onClickValue:boolean = false;
private stateChangCallBack = (eventData) => {
console.info("transFormExample page state change called:" + JSON.stringify(eventData));
if (eventData != null) {
console.info("eventData value is");
if (eventData.data.matrix2 != null && eventData.data.matrix3 != null) {
console.info("this.matrix2 value is" + Matrix4.identity()
.translate(eventData.data.matrix2)
.copy() + "2" + JSON.stringify(Matrix4.identity().translate(eventData.data.matrix2).copy()));
this.matrix2 = Matrix4.identity().translate(eventData.data.matrix2).copy();
console.info("this.matrix3 value is");
this.matrix3 = Matrix4.identity().scale(eventData.data.matrix3).copy();
let matrixV = Matrix4.identity().translate(eventData.data.matrix2);
if (matrixV != null) {
this.matrix2 = Matrix4.identity().translate(eventData.data.matrix2).copy();
this.matrix3 = Matrix4.identity().scale(eventData.data.matrix3).copy();
}
} else {
console.info("this.matrix value is not");
}
......@@ -129,7 +130,7 @@ struct ohosMatrix4 {
}).backgroundColor(0x2788D9).key('rotate5')
Image('/images/bg.jpg')
.padding(5)
.transform(this.matrix2.combine(this.matrix3))
.transform(this.matrix7)
.width("40%")
.height(100)
.margin({ top: 5 })
......
......@@ -169,9 +169,7 @@ export default function ohosMatrix4Jsunit() {
let objNew = JSON.parse(strJsonNew);
console.info("[test_OhosMatrix4_006] component objNew is: " + JSON.stringify(objNew));
console.info("[test_OhosMatrix4_006] component transform is: " + JSON.stringify(objNew.$attrs.transform));
expect(JSON.stringify(objNew.$attrs.transform)).assertEqual('{"type":"matrix",' +
'"matrix":"0.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,' +
'0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,0.000000,"}');
expect(JSON.stringify(objNew.$attrs.transform)).assertEqual('{"type":"matrix","matrix":"3.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,0.000000,0.000000,0.000000,1.000000,0.000000,900.000000,0.000000,0.000000,1.000000,"}');
done();
});
})
......
......@@ -156,7 +156,7 @@ struct DragExample {
try {
var backData = {
data: {
"ACTION": 'onDragMove onAction'
"ACTION": "onDragMove onAction"
}
}
var backEvent = {
......
......@@ -86,8 +86,8 @@ export default function dragEventJsunit(){
await Utils.drag(downX, downY, upX, upY, 10)
let callback = (indexEvent) => {
console.info("dragEventTest_0200 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.pointX).assertNotEqual(Null);
expect(indexEvent.data.pointY).assertNotEqual(Null);
expect(Number.isNaN(indexEvent.data.pointX)).assertFalse();
expect(Number.isNaN(indexEvent.data.pointY)).assertFalse();
}
let indexEvent = {
eventId: 87,
......@@ -115,7 +115,7 @@ export default function dragEventJsunit(){
await Utils.drag(downX, downY, upX, upY, 10)
let callback = (indexEvent) => {
console.info("dragEventTest_0300 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.ACTION).assertEqual('onDragMove onAction');
expect(indexEvent.data.ACTION).assertEqual("onDragMove onAction");
}
let indexEvent = {
eventId: 88,
......@@ -143,7 +143,7 @@ export default function dragEventJsunit(){
await Utils.drag(downX, downY, upX, upY, 10)
let callback = (indexEvent) => {
console.info("dragEventTest_0400 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.ACTION).assertEqual('onDragLeave onAction');
expect(indexEvent.data.ACTION).assertEqual("onDragLeave onAction");
}
let indexEvent = {
eventId: 89,
......@@ -171,7 +171,7 @@ export default function dragEventJsunit(){
await Utils.drag(downX, downY, upX, upY, 10)
let callback = (indexEvent) => {
console.info("dragEventTest_0500 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.ACTION).assertEqual('onDrop onAction');
expect(indexEvent.data.ACTION).assertEqual("onDrop onAction");
}
let indexEvent = {
eventId: 90,
......
......@@ -66,12 +66,12 @@ export default function imageJsunit() {
let obj = JSON.parse(strJson);
console.info("imageTest_0200 obj.$attrs.src is: " + obj.$attrs.src);
console.info("imageTest_0200 obj.obj.$type is: " + obj.$type);
var res = obj.$attrs.src.indexOf('rawfile/test.png');
var res = obj.$attrs.src.indexOf('RAWFILE/test.png');
console.info("imageTest_0200 result is: " + res);
var sres = obj.$attrs.src.slice(res, res + 16);
console.info("imageTest_0200 slice result is: " + sres);
expect(obj.$type).assertEqual('Image');
expect(obj.$attrs.src.slice(res, res + 16)).assertEqual('rawfile/test.png');
expect(obj.$attrs.src.slice(res, res + 16)).assertEqual('RAWFILE/test.png');
console.info('imageTest_0200 END');
done();
});
......
......@@ -55,7 +55,7 @@ export default function playModeJsunit(){
}
let callback= (indexEvent) => {
console.info("playModeTest_0100 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.playMode).assertEqual(PlayMode.AlternateReverse)
expect(indexEvent.data.playMode).assertEqual(PlayMode.AlternateReverse)
}
try {
events_emitter.on(indexEvent, callback);
......
......@@ -28,9 +28,9 @@ struct QrCode {
var colorValue = eventData.data.color;
if (colorValue != null && colorValue.length != 0) {
this.qrCodeColor = colorValue;
console.info("qrCodeColor:" + qrCodeColor);
console.info("qrCodeColor:" + this.qrCodeColor);
} else {
console.info("qrCodeColor is null or empty " + qrCodeColor);
console.info("qrCodeColor is null or empty " + this.qrCodeColor);
}
} else {
console.info("qrCode page color not change called:" + JSON.stringify(eventData));
......@@ -42,9 +42,9 @@ struct QrCode {
var backgroundColorValue = eventData.data.backgroundColor;
if (backgroundColorValue != null && backgroundColorValue.length != 0) {
this.qrCodeBackgroundColor = backgroundColorValue;
console.info("qrCodeBackgroundColor:" + qrCodeBackgroundColor);
console.info("qrCodeBackgroundColor:" + this.qrCodeBackgroundColor);
} else {
console.info("backgroundColorValue is null or empty " + qrCodeColor);
console.info("backgroundColorValue is null or empty " + this.qrCodeColor);
}
} else {
console.info("qrCode page backgroundColorValue not change called:" + JSON.stringify(eventData));
......
......@@ -25,7 +25,7 @@ struct ClickExample {
Button('Click').backgroundColor(0x2788D9)
.key('button')
.onClick((event: ClickEvent) => {
this.text = event.timestamp
this.text = event.timestamp.toString()
console.info(this.text)
try {
var backData = {
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -332,7 +332,7 @@ export default function buttonJsunit() {
try {
var eventData = {
data: {
"buttonTypeValue": qaq,
"buttonTypeValue": "qaq",
}
}
var innerEvent = {
......@@ -403,7 +403,7 @@ export default function buttonJsunit() {
let callback = (indexEvent) => {
console.info("testButton15 get state result is: " + JSON.stringify(indexEvent))
console.info("testButton15 indexEvent.data.fontColorValue is: " + indexEvent.data.fontColorValue)
expect(indexEvent.data.fontColorValue).assertEqual('ab996')
expect(indexEvent.data.fontColorValue).assertEqual("ab996")
console.info('[testButton15] END');
done();
}
......
......@@ -55,7 +55,7 @@ export default function scrollCodeJsunit() {
expect(obj.$attrs.scrollable).assertEqual('ScrollDirection.Vertical');
expect(obj.$attrs.scrollBar).assertEqual('BarState.On');
expect(obj.$attrs.scrollBarColor).assertEqual('#FF0000FF');
expect(obj.$attrs.scrollBarWidth).assertEqual('30.00px');
expect(obj.$attrs.scrollBarWidth).assertEqual('30.00vp');
done();
});
......@@ -159,7 +159,7 @@ export default function scrollCodeJsunit() {
let strJson = getInspectorByKey('ScrollCode');
let obj = JSON.parse(strJson);
console.info("[test_scrollCode_005] component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.scrollBarWidth).assertEqual('40.00px');
expect(obj.$attrs.scrollBarWidth).assertEqual('40.00vp');
done();
});
......
......@@ -64,12 +64,12 @@ export default function textJsunit() {
console.info("testText_0200 component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("testText_0200 component obj is: " + JSON.stringify(obj));
var res = obj.$attrs.src.indexOf('rawfile/test.png');
var res = obj.$attrs.src.indexOf('RAWFILE/test.png');
console.info("testText_0200 result is: " + res);
var sres = obj.$attrs.src.slice(res, res + 16);
console.info("testText_0200 slice result is: " + sres);
expect(obj.$type).assertEqual('Image');
expect(obj.$attrs.src.slice(res, res + 16)).assertEqual('rawfile/test.png');
expect(obj.$attrs.src.slice(res, res + 16)).assertEqual('RAWFILE/test.png');
console.info('testText_0200 END');
done();
});
......
......@@ -50,7 +50,7 @@ export default function timeStampJsunit() {
await Utils.sleep(1500);
let callback = (indexEvent) => {
console.info("timeStampTest_0100 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.Text).assertNotEqual(null);
expect(isNaN(indexEvent.data.Text)).assertFalse();
}
let indexEvent = {
eventId: 230,
......
......@@ -77,7 +77,7 @@ struct ImageAnimatorExample {
try {
var backData = {
data: {
"string": 'Repeat'
"string": "Repeat"
}
}
var backEvent = {
......
......@@ -32,8 +32,7 @@ struct ScrollBarExample {
this.directionValue = directionObject.directionValue;
}
if (eventData.data.stateValue != null) {
let stateObject = JSON.parse(eventData.data.stateObject);
this.stateValue = stateObject.stateValue;
this.stateValue = eventData.data.stateValue;
}
}
}
......
......@@ -49,10 +49,10 @@ export default function imageAnimatorJsunit(){
it('imageAnimatorTest_0100', 0, async function (done) {
console.info('imageAnimatorTest_0100 START');
await Utils.sleep(500);
await Utils.sleep(1500);
let callback = (indexEvent) => {
console.info("imageAnimatorTest_0100 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.state).assertEqual(1);
console.info("imageAnimatorTest_0100 get state result is: " + JSON.stringify(indexEvent.data.state));
expect(indexEvent.data.state).assertEqual(AnimationStatus.Running);
done();
}
let indexEvent = {
......@@ -163,7 +163,7 @@ export default function imageAnimatorJsunit(){
await Utils.sleep(1500);
let callback = (indexEvent) => {
console.info("imageAnimatorTest_0600 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.string).assertEqual('repeat');
expect(indexEvent.data.string).assertEqual('Repeat');
}
let indexEvent = {
eventId: 114,
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -59,7 +59,7 @@ export default function scrollBarJsunit() {
it('testScrollBar002', 0, async function (done) {
console.info('[testScrollBar002] START');
let object = {
"directionValue": ScrollBarDirection.Horizontal
"directionValue": "ScrollBarDirection.Horizontal"
};
try {
var eventData = {
......@@ -101,7 +101,7 @@ export default function scrollBarJsunit() {
try {
let eventData = {
data: {
"stateValue":"BarState.On"
"stateValue": BarState.On
}
}
let indexEvent = {
......@@ -118,7 +118,7 @@ export default function scrollBarJsunit() {
console.info("[testScrollBar004] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testScrollBar004] state:" + obj.$attrs.state);
expect(obj.$attrs.state).assertEqual('BarState.Off');
expect(obj.$attrs.state).assertEqual("BarState.On");
done();
});
......@@ -144,7 +144,7 @@ export default function scrollBarJsunit() {
console.info("[testScrollBar005] component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("[testScrollBar005] state:" + obj.$attrs.state);
expect(obj.$attrs.state).assertEqual('BarState.Off');
expect(obj.$attrs.state).assertEqual("BarState.Auto");
done();
});
})
......
......@@ -14,6 +14,9 @@
group("componnetUxTest") {
testonly = true
if (is_standard_system) {
deps = [ "ace_ets_component_swiper:ActsAceSwiperTest" ]
deps = [
"ace_ets_component_sidebar:ActsAceSideBarTest",
"ace_ets_component_swiper:ActsAceSwiperTest",
]
}
}
{
"app": {
"bundleName": "com.example.acesidebartest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"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":"MyApplication"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceSideBarTest") {
hap_profile = "src/main/module.json"
js_build_mode = "debug"
deps = [
":ace_ets_component_sidebar_js_assets",
":ace_ets_component_sidebar_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAceSideBarTest"
part_name = "ace_engine"
subsystem_name = "arkui"
}
ohos_app_scope("ace_ets_component_sidebar_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("ace_ets_component_sidebar_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("ace_ets_component_sidebar_resources") {
sources = [ "src/main/resources" ]
deps = [ ":ace_ets_component_sidebar_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.acesidebartest",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 240000
},
"kits": [{
"test-file-name": [
"ActsAceSideBarTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ 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 hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
/*
* 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 events_emitter from '@ohos.events.emitter';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import hilog from '@ohos.hilog';
import testsuite from '../../test/List.test'
@Entry
@Component
struct SideBarTest {
@State strokeWidthStr: string = '10px'
@State dividerColorStr: string = '#000000'
@State startMarginStr: string = '5px'
@State endMarginStr: string = '5px'
@State nullFlag: boolean = false
@State dividerColor: Color = Color.Red
@State strokeWidthNum: number = 10
@State dividerColorNum: number = 0x000000
@State startMarginNum: number = 5
@State endMarginNum: number = 5
@State strokeWidthRes: Resource = $r('app.string.Divider_width')
@State dividerColorRes: Resource = $r('app.color.Divider_color')
@State startMarginRes: Resource = $r('app.string.Divider_startMargin')
@State endMarginRes: Resource = $r('app.string.Divider_endMargin')
private stateChangCallBack = (eventData) => {
console.info("sideBar page state change called:" + JSON.stringify(eventData));
if (eventData != null) {
if (eventData.data.dividerColorStr != null) {
this.dividerColorStr = eventData.data.dividerColorStr;
}
if (eventData.data.strokeWidthStr != null) {
this.strokeWidthStr = eventData.data.strokeWidthStr;
}
if (eventData.data.startMarginStr != null) {
this.startMarginStr = eventData.data.startMarginStr;
}
if (eventData.data.endMarginStr != null) {
this.endMarginStr = eventData.data.endMarginStr;
}
if (eventData.data.nullFlag != null) {
this.nullFlag = eventData.data.nullFlag;
}
if (eventData.data.dividerColor != null) {
this.dividerColor = eventData.data.dividerColor;
}
if (eventData.data.strokeWidthNum != null) {
this.strokeWidthNum = eventData.data.strokeWidthNum;
}
if (eventData.data.dividerColorNum != null) {
this.dividerColorNum = eventData.data.dividerColorNum;
}
if (eventData.data.startMarginNum != null) {
this.startMarginNum = eventData.data.startMarginNum;
}
if (eventData.data.endMarginNum != null) {
this.endMarginNum = eventData.data.endMarginNum;
}
if (eventData.data.dividerColorRes != null) {
this.dividerColorRes = eventData.data.dividerColorRes;
}
if (eventData.data.strokeWidthRes != null) {
this.strokeWidthRes = eventData.data.strokeWidthRes;
}
if (eventData.data.startMarginRes != null) {
this.startMarginRes = eventData.data.startMarginRes;
}
if (eventData.data.endMarginRes != null) {
this.endMarginRes = eventData.data.endMarginRes;
}
}
}
aboutToAppear(){
var stateChangeEvent = {
eventId: 183,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Column() {
SideBarContainer(SideBarContainerType.Embed)
{
Column() {}
Column() {}
}
.showSideBar(true)
.sideBarWidth(120)
.minSideBarWidth(100)
.maxSideBarWidth(150)
.sideBarPosition(SideBarPosition.Start)
.height('200vp')
.key('sideBarTest1')
.controlButton({
left: 16, top: 48, width: 32, height: 32,
icons: {shown: $r("app.media.icon"),
hidden: $r("app.media.icon"),
switching: $r("app.media.icon")}
})
SideBarContainer(SideBarContainerType.Embed)
{
Column() {}
Column() {}
}
.showSideBar(true)
.sideBarWidth(120)
.minSideBarWidth(100)
.maxSideBarWidth(150)
.sideBarPosition(SideBarPosition.Start)
.height('200vp')
.key('sideBarTest2')
.controlButton({
left: 16, top: 48, width: 32, height: 32,
icons: {shown: $r("app.media.icon"),
hidden: $r("app.media.icon"),
switching: $r("app.media.icon")}
})
.divider(this.nullFlag ? null : { strokeWidth: this.strokeWidthNum,
color: this.dividerColorNum,
startMargin: this.startMarginNum,
endMargin: this.endMarginNum
})
SideBarContainer(SideBarContainerType.Embed)
{
Column() {}
Column() {}
}
.showSideBar(true)
.sideBarWidth(120)
.minSideBarWidth(100)
.maxSideBarWidth(150)
.sideBarPosition(SideBarPosition.Start)
.height('200vp')
.key('sideBarTest3')
.controlButton({
left: 16, top: 48, width: 32, height: 32,
icons: {shown: $r("app.media.icon"),
hidden: $r("app.media.icon"),
switching: $r("app.media.icon")}
})
.divider({ strokeWidth: this.strokeWidthStr,
color: this.dividerColorStr,
startMargin: this.startMarginStr,
endMargin: this.endMarginStr
})
SideBarContainer(SideBarContainerType.Embed)
{
Column() {}
Column() {}
}
.showSideBar(true)
.sideBarWidth(120)
.minSideBarWidth(100)
.maxSideBarWidth(150)
.sideBarPosition(SideBarPosition.Start)
.height('200vp')
.key('sideBarTest4')
.controlButton({
left: 16, top: 48, width: 32, height: 32,
icons: {shown: $r("app.media.icon"),
hidden: $r("app.media.icon"),
switching: $r("app.media.icon")}
})
.divider({ strokeWidth: this.strokeWidthRes,
color: this.dividerColorRes,
startMargin: this.startMarginRes,
endMargin: this.endMarginRes
})
SideBarContainer(SideBarContainerType.Embed)
{
Column() {}
Column() {}
}
.showSideBar(true)
.sideBarWidth(120)
.minSideBarWidth(100)
.maxSideBarWidth(150)
.sideBarPosition(SideBarPosition.Start)
.height('200vp')
.key('sideBarTest5')
.controlButton({
left: 16, top: 48, width: 32, height: 32,
icons: {shown: $r("app.media.icon"),
hidden: $r("app.media.icon"),
switching: $r("app.media.icon")}
})
.divider({ strokeWidth: this.strokeWidthNum,
color: this.dividerColor,
startMargin: this.startMarginNum,
endMargin: this.endMarginNum
})
SideBarContainer(SideBarContainerType.Embed)
{
Column() {}
Column() {}
}
.showSideBar(true)
.sideBarWidth(120)
.minSideBarWidth(100)
.maxSideBarWidth(150)
.sideBarPosition(SideBarPosition.Start)
.height('200vp')
.key('sideBarTest6')
.controlButton({
left: 16, top: 48, width: 32, height: 32,
icons: {shown: $r("app.media.icon"),
hidden: $r("app.media.icon"),
switching: $r("app.media.icon")}
})
.divider({ strokeWidth: this.strokeWidthNum })
}
}
}
/*
* 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 hilog from '@ohos.hilog';
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() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', '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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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 sidebar from './SideBar'
export default function testsuite() {
sidebar()
}
\ 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.
*/
export default class Utils {
static sleep(time){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
resolve("ok")
},time)
}).then(()=>{
console.info(`sleep ${time} over...`)
})
}
}
{
"module": {
"name": "phone",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"metadata": [{
"name": "ArkTSPartialUpdate",
"value": "true"
}],
"abilities": [
{
"name": "TestAbility",
"srcEntrance": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"metadata": [{
"name": "ArkTSPartialUpdate",
"value": "true"
}]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "Divider_color",
"value": "#000000"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
},
{
"name": "Divider_width",
"value": "10px"
},
{
"name": "Divider_startMargin",
"value": "5px"
},
{
"name": "Divider_endMargin",
"value": "5px"
}
]
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ import {MessageManager,Callback} from './../../../../common/MessageManager';
@Entry
@Component
struct AlignCenter_AddOffset {
@State OneOffset: any = { x: 0, y: 0 }
@State OneOffset: object = { x: 0, y: 0 }
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddOffset onPageShow');
......
......@@ -17,7 +17,7 @@ import {MessageManager,Callback} from './../../../../common/MessageManager';
@Entry
@Component
struct AlignEnd_AddOffset {
@State OneOffset: any = { x: 0, y: 0 }
@State OneOffset: object = { x: 0, y: 0 }
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddOffset onPageShow');
......
......@@ -17,7 +17,7 @@ import {MessageManager,Callback} from './../../../../common/MessageManager';
@Entry
@Component
struct AlignSpaceEvenly_AddOffset {
@State OneOffset: any = { x: 0, y: 0 }
@State OneOffset: object = { x: 0, y: 0 }
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_NoSpace onPageShow');
......
......@@ -17,7 +17,7 @@ import {MessageManager,Callback} from './../../../../common/MessageManager';
@Entry
@Component
struct AlignStart_AddOffset {
@State OneOffset: any = { x: 0, y: 0 }
@State OneOffset: object = { x: 0, y: 0 }
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('AlignSpaceEvenly_AddOffset onPageShow');
......
......@@ -101,9 +101,9 @@ export default function flexExceed_AutoJsunit() {
expect(textExceed01.bottom - textExceed01.top).assertEqual(vp2px(50))
expect(textExceed02.bottom - textExceed02.top).assertEqual(vp2px(100))
expect(textExceed03.bottom - textExceed03.top).assertEqual(vp2px(150))
expect(textExceed01.right - textExceed01.left).assertEqual(vp2px(440/3))
expect(textExceed02.right - textExceed02.left).assertEqual(vp2px(440/3))
expect(textExceed03.right - textExceed03.left).assertEqual(vp2px(440/3))
expect(Math.round(textExceed01.right - textExceed01.left)).assertEqual(Math.round(vp2px(440/3)))
expect(Math.round(textExceed02.right - textExceed02.left)).assertEqual(Math.round(vp2px(440/3)))
expect(Math.round(textExceed03.right - textExceed03.left)).assertEqual(Math.round(vp2px(440/3)))
expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0700 END');
......
......@@ -102,9 +102,9 @@ export default function flexPadding_AutoJsunit() {
expect(textFlexPadding01.bottom - textFlexPadding01.top).assertEqual(vp2px(50))
expect(textFlexPadding02.bottom - textFlexPadding02.top).assertEqual(vp2px(100))
expect(textFlexPadding03.bottom - textFlexPadding03.top).assertEqual(vp2px(150))
expect(textFlexPadding01.right - textFlexPadding01.left).assertEqual(vp2px(440/3))
expect(textFlexPadding02.right - textFlexPadding02.left).assertEqual(vp2px(440/3))
expect(textFlexPadding03.right - textFlexPadding03.left).assertEqual(vp2px(440/3))
expect(Math.round(textFlexPadding01.right - textFlexPadding01.left)).assertEqual(Math.round(vp2px(440/3)))
expect(Math.round(textFlexPadding02.right - textFlexPadding02.left)).assertEqual(Math.round(vp2px(440/3)))
expect(Math.round(textFlexPadding03.right - textFlexPadding03.left)).assertEqual(Math.round(vp2px(440/3)))
expect(obj1.$attrs.constructor.direction).assertEqual('FlexDirection.Row')
expect(obj1.$attrs.constructor.alignItems).assertEqual('ItemAlign.Auto')
console.info('new SUB_ACE_FLEXALIGNITEMS_AUTO_0400 END');
......
......@@ -148,7 +148,7 @@ struct Index {
case "emitOnProgressChange":{
this.isProgressFinish=true
await Utils.sleep(1000)
this.controller.loadUrl({url:"https://gitee.com/"})
this.controller.loadUrl({url:"resource://rawfile/index.html"})
break;
}
case "emitOnRefreshAccessedHistory":{
......
......@@ -45,6 +45,7 @@ struct Second {
console.info("key==>"+this.str);
switch(this.str){
case "emitOverviewModeAccessTrue":{
this.controller.loadUrl({url:"resource://rawfile/overview.html"})
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
console.info("getViewResult==>"+res);
this.overviewScale=res;
......
......@@ -78,7 +78,6 @@ def writemulbuildgn():
pagenametext = suitename + "-" + casenamecap
pagefilename = hapdirpath + G_PATHDIRPATH + suitename + ".ets"
attrtmp = G_TMPPATH + G_PAGEATTRTEMPPATH
#print("addattr:", subattcnt, pagename, attrtmp)
with open(attrtmp, encoding="utf-8", mode="r") as attrtmpfile:
for attrtempline in attrtmpfile:
attrtempline = attrtempline.replace(" ", "\ ")
......@@ -109,7 +108,6 @@ def writemulbuildgn():
#追加page里的attr
pagenametext = suitename + "-" + casenamecap
attrtmp = G_TMPPATH + G_PAGEATTRTEMPPATH
#print("addattr:", subattcnt, pagename, attrtmp)
with open(attrtmp, encoding="utf-8", mode="r") as attrtmpfile:
for attrtempline in attrtmpfile:
attrtempline = attrtempline.replace(" ", "\ ")
......@@ -121,7 +119,6 @@ def writemulbuildgn():
temptestfilename = G_TMPPATH + G_TESTCASETEMPPATH
testfilename = hapdirpath + G_TESTDIRPATH + suitename + ".test.ets"
#print("createpage:", subgncnt, dirpath, pagefilename, testfilename)
os.system(r"cp {} {}".format(temptestfilename, testfilename))
#替换test里的名称
os.system(r"sed -i 's/{}/{}/g' {}".format(G_ATTRNAMEPATTERN, testname, testfilename))
......@@ -136,7 +133,6 @@ def writemulbuildgn():
buildgnname = hapdirpath + G_BUILDGNPATH
os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, buildgnname))
# formate gn
#print("Formate: dirpath:",buildgnname)
formatcmd = "cat "+buildgnname+" | ~/workspace/oh31/prebuilts/build-tools/linux-x86/bin/gn format --stdin > FORMAT_RESULT.gn;cp -f FORMAT_RESULT.gn "+buildgnname+";rm FORMAT_RESULT.gn"
os.system(formatcmd)
#替换index.ets里的名称
......@@ -147,12 +143,9 @@ def writemulbuildgn():
testjsonname = hapdirpath + G_TESTJSONPATH
os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, testjsonname))
#G_IMPORTTEST = "import {} from './{}Jsunit.test';\n"
importtestheads.append(G_IMPORTTEST.format(testname, suitename))
importtests.append(G_IMPORTTESTCASE.format(testname))
subcasecnt += 1
#print("importtestheads:", importtestheads)
#print("importtests:", importtests)
#插入List.test.ets,装载多个testcase
ind = 16
for importtestsline in importtests:
......@@ -187,7 +180,6 @@ def new_report(bakdir, str):
files = os.listdir(bakdir)
lists = [] #列出目录的下所有文件和文件夹保存到lists
for f in files:
# if f.startswith(str):
if "latest" in f:
continue
lists.append(f)
......@@ -239,7 +231,6 @@ if __name__ == '__main__':
total +=1
failcnt += 1
testcaselist.append(caseline[1]+"-false")
#print("tasklogfile line:", caseline[0], caseline[1])
#将testcase信息生成文件
xmlfile = open(tmpfile, mode='w+')
xmlfile.write("<?xml version='1.0' encoding='UTF-8'?>\n")
......
......@@ -908,6 +908,23 @@ describe('ActsAbilityTest', function () {
done();
})
it('TaskPoolTestClass061', 0, async function (done) {
function Sum(value1, value2) {
"use concurrent"
return value1 + value2;
}
var task1 = new taskpool.Task(Sum, 10, 20);
var task2 = new taskpool.Task(Sum, 30, 40);
var task3 = new taskpool.Task(Sum, 50, 60);
var result1 = await taskpool.execute(task1,taskpool.Priority.LOW);
var result2 = await taskpool.execute(task2,taskpool.Priority.HIGH);
var result3 = await taskpool.execute(task3,taskpool.Priority.MEDIUM);
expect(result1).assertEqual(30);
expect(result2).assertEqual(70);
expect(result3).assertEqual(110);
done();
})
/**
* @tc.number : TaskPoolTestClass049
* @tc.name : Async Function Cancel task
......
/*
* 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 "console"
import "elf"
rule OpenHarmony_SA_2022_0803
{
meta:
date="2023-03-03"
openharmony_sa="OpenHarmony-SA-2022-08-03"
affected_files="libtel_sms_mms.z.so"
strings:
$fix1="data length invalid tempLen:%{public}d, pduLen:%{public}d."
$fix2="data length error, pduLen %{public}d offset %{public}d"
condition:
$fix1 and $fix2 and console.log("OpenHarmony-SA-2022-08-03 testcase pass")
}
/*
* 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 "console"
import "elf"
rule OpenHarmony_SA_2022_1101
{
meta:
date = "2023-03-02"
openharmony_sa = "OpenHarmony-SA-2022-1101"
cve = "CVE-2022-43451"
severity = "high"
affacted_files = "nwebspawn"
affected_func = "main"
strings:
$features = "strncpy_s appspawn server name error" nocase wide ascii
condition:
(elf.machine == elf.EM_ARM) and $features and console.log("OpenHarmony-SA-2022-1101 testcase pass")
}
/*
* 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 "console"
import "elf"
rule OpenHarmony_SA_2023_0102
{
meta:
date="2023-02-17"
openharmony_sa="OpenHarmony-SA-2023-0102"
cve="CVE-2023-0036"
affected_files="libinputmethod_service.z.so"
strings:
/*
.text:00045E0E LDRB.W R3, [SP,#0x68+var_34]
.text:00045E12 ADD R0, PC ;
.text:00045E14 LDR R2, [SP,#0x68+var_30]
*/
$fix={9D F8 34 30 78 44 0E 9A}
condition:
$fix and console.log("OpenHarmony-SA-2023-0102 testcase pass")
}
\ 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 "console"
import "elf"
rule OpenHarmony_SA_2023_0301
{
meta:
date = "2023-03-08"
openharmony_sa = "OpenHarmony-SA-2023-0301"
cve = "CVE-2023-24465"
severity = "medium"
affacted_files = "libwifi_scan_ability.z.so"
affected_func = "WifiScanStub::OnScanByParams"
strings:
$features = "run OnScanByParams code %{public}u, datasize %{public}zu" nocase wide ascii
/* 3.1.4 vul code
.text:0000B0D0 01 46 MOV R1, R0
.text:0000B0D2 20 46 MOV R0, R4
*/
$vul = {01 46 ?? 46}
/* 3.1.4 with patch
.text:0000B0DA 7D 44 ADD R5, PC ; ""
.text:0000B0DC 08 BF IT EQ
.text:0000B0DE 29 46 MOVEQ R1, R5
*/
$fix = {7? 44 08 BF ?? 46}
condition:
(elf.machine == elf.EM_ARM) and $features and ((not $vul) or $fix) and console.log("OpenHarmony-SA-2023-0301 testcase pass")
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册