提交 e6953c87 编写于 作者: X xuchenghua09

codex

Signed-off-by: Nxuchenghua09 <xuchenghua09@huawei.com>
上级 9f64f660
/*
* 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';
@Entry
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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 abilityTest from './Ability.test'
export default function testsuite() {
......
{
"app": {
"bundleName": "com.example.actskillprocesswithaccountclosetest",
"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
}
}
}
# 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_hap("ActSkillProcessWithAccountCloseTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
hap_name = "ActSkillProcessWithAccountCloseTest"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":actskillprocesswithaccountclosetest_js_assets",
":actskillprocesswithaccountclosetest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
}
ohos_app_scope("actskillprocesswithaccountclosetest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actskillprocesswithaccountclosetest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actskillprocesswithaccountclosetest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actskillprocesswithaccountclosetest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.actskillprocesswithaccountclosetest",
"module-name": "entry",
"shell-timeout": "600000"
}
}
/*
* 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.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'TestAbility/pages/index', null)
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility 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';
@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) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.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)
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) 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
export default function abilityTest() {
describe('ActsAbilityTest', function () {
it('assertContain',0, function () {
console.info("it begin")
let a = 'abc'
let b = 'b'
expect(a).assertContain(b)
expect(a).assertEqual(a)
})
})
}
\ 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 abilityTest from './Ability.test'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "app_name",
"value": "ActskillProcessWithAccountCloseTest"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
group("actsshellcommandfunctionalitytest") {
testonly = true
if (is_standard_system) {
deps = [
"ActskillProcessWithAccountCloseTest:ActSkillProcessWithAccountCloseTest",
"ExecuteShellCommand:ExecuteShellCommand",
]
}
}
{
"app": {
"bundleName": "com.example.executeshellcommand",
"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
}
}
}
# 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("ExecuteShellCommand") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":executeshellcommand_js_assets",
":executeshellcommand_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ExecuteShellCommand"
}
ohos_app_scope("executeshellcommand_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("executeshellcommand_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("executeshellcommand_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":executeshellcommand_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.executeshellcommand",
"module-name": "entry",
"shell-timeout": "600000"
},
"kits": [
{
"type": "PushKit",
"push": [
"ActSkillProcessWithAccountCloseTest.hap->/data/ActSkillProcessWithAccountCloseTest.hap"
]
},
{
"test-file-name": [
"ActSkillProcessWithAccountCloseTest.hap",
"ExecuteShellCommand.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ 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 Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
console.log('MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('MainAbility onForeground')
}
onBackground() {
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';
@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) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: MainAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
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) 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import appManager from '@ohos.application.AppManager';
export default function abilityTest() {
describe('ACTS_ExecuteShellCommandTest', function () {
/**
* @tc.number: ACTS_ExecuteShellCommand_Callback_0100
* @tc.name: Execute a shell command without arguments (AsyncCallback).
* @tc.desc: Verify that the interface executes the Shell command successfully.
*/
it('ACTS_ExecuteShellCommand_Callback_0100', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Callback_0100 --- start")
var cmd = 'aa help'
var escresult = 'usage: aa <command> <options>'
globalThis.abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.log('ACTS_ExecuteShellCommand_Callback_0100 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Callback_0100 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf(escresult);
console.log('ACTS_ExecuteShellCommand_Callback_0100 query string i = ' + i);
expect(i == -1).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Callback_0100 exitCode = ' + data.exitCode)
expect(data.exitCode).assertEqual(0);
console.log('ACTS_ExecuteShellCommand_Callback_0100 - executeShellCommand: end')
done()
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Callback_0200
* @tc.name: Execute shell command with timeout parameter (AsyncCallback)
* @tc.desc: Verify that the interface executes the Shell command successfully.
*/
it('ACTS_ExecuteShellCommand_Callback_0200', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Callback_0200 --- start")
var cmd = 'aa start -a MainAbility -b com.example.actskillprocesswithaccountclosetest'
globalThis.abilityDelegator.executeShellCommand(cmd, 1,(err, data) => {
console.log('ACTS_ExecuteShellCommand_Callback_0200 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Callback_0200 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf('start ability successfully.');
console.log('ACTS_ExecuteShellCommand_Callback_0200 query string i = ' + i);
expect(i == -1).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Callback_0200 exitCode = ' + data.exitCode)
expect(data.exitCode).assertEqual(0);
console.log('ACTS_ExecuteShellCommand_Callback_0200 - executeShellCommand: end')
done()
})
setTimeout(async() => {
appManager.killProcessWithAccount('com.example.actskillProcessWithAccountclosetest', 100).then(() => {
console.log('ACTS_ExecuteShellCommand_Callback_0200 killProcess ======> start');
})
}, 3000 )
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Callback_0300
* @tc.name: Execute non-existing shell command (AsyncCallback).
* @tc.desc: Failed to execute shell command on authentication interface.
*/
it('ACTS_ExecuteShellCommand_Callback_0300', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Callback_0300 --- start")
var cmd = 'ppwd -L'
globalThis.abilityDelegator.executeShellCommand(cmd, 1,(err, data) => {
console.log('ACTS_ExecuteShellCommand_Callback_0300 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Callback_0300 stdResult = ' + data.stdResult)
var i = data.stdResult.length
console.log('ACTS_ExecuteShellCommand_Callback_0300 query string i = ' + i);
expect(i == 0).assertEqual(true);
console.log('ACTS_ExecuteShellCommand_Callback_0300 exitCode = ' + data.exitCode)
expect(data.exitCode == 0).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Callback_0300 - executeShellCommand: end')
done();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Callback_0400
* @tc.name: Execute shell command timeout (AsyncCallback)
* @tc.desc: The authentication interface executes the shell command timed out.
*/
it('ACTS_ExecuteShellCommand_Callback_0400', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Callback_0400 --- start")
var cmd = 'aa help'
var escresult = 'usage: aa <command> <options>'
globalThis.abilityDelegator.executeShellCommand(cmd,0, (err, data) => {
console.log('ACTS_ExecuteShellCommand_Callback_0400 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Callback_0400 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf(escresult);
console.log('ACTS_ExecuteShellCommand_Callback_0400 query string i = ' + i);
expect(i == -1).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Callback_0100 exitCode = ' + data.exitCode)
expect(data.exitCode).assertEqual(0);
console.log('ACTS_ExecuteShellCommand_Callback_0400 - executeShellCommand: end')
done();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Callback_0500
* @tc.name: Invalid timeout parameter for executing shell command (AsyncCallback)
* @tc.desc: The timeout parameter for executing shell commands on the authentication interface is invalid.
*/
it('ACTS_ExecuteShellCommand_Callback_0500', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Callback_0500 --- start")
var cmd = 'aa help'
var escresult = 'usage: aa <command> <options>'
globalThis.abilityDelegator.executeShellCommand(cmd,-1, (err, data) => {
console.log('ACTS_ExecuteShellCommand_Callback_0500 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Callback_0500 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf(escresult);
console.log('ACTS_ExecuteShellCommand_Callback_0500 query string i = ' + i);
expect(i == -1).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Callback_0500 exitCode = ' + data.exitCode)
expect(data.exitCode).assertEqual(0);
console.log('ACTS_ExecuteShellCommand_Callback_0500 - executeShellCommand: end')
done();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Callback_0600
* @tc.name: The executed shell command parameter is null (AsyncCallback)
* @tc.desc: Failed to execute shell command on authentication interface.
*/
it('ACTS_ExecuteShellCommand_Callback_0600', 0, async function (done) {
let flag=true;
console.log("ACTS_ExecuteShellCommand_Callback_0600 --- start")
globalThis.abilityDelegator.executeShellCommand("",1,(err, data) => {
console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand:data'+JSON.stringify(data))
expect(data).assertEqual(undefined);
console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand: end')
flag=false;
done();
})
setTimeout(()=>{
if(flag==true){
console.log('ACTS_ExecuteShellCommand_Callback_0600 timeout')
expect().assertFail();
done();
}
},5000)
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Callback_0700
* @tc.name: The timeout parameter of the execution is null (AsyncCallback)
* @tc.desc: Verify that the interface executes the Shell command successfully.
*/
it('ACTS_ExecuteShellCommand_Callback_0700', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_0700 --- start")
var cmd = 'aa help'
var code = null
setTimeout(() => {
console.log('ACTS_ExecuteShellCommand_Callback_0700 code:'+JSON.stringify(code))
if(code!=undefined){
expect().assertFail();
}
done();
}, 3000)
code = globalThis.abilityDelegator.executeShellCommand(cmd,null,() => {
console.log('ACTS_ExecuteShellCommand_Callback_0700 fail:')
expect().assertFail();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Promise_0100
* @tc.name: Execute a shell command without arguments (Promise).
* @tc.desc: Verify that the interface executes the Shell command successfully.
*/
it('ACTS_ExecuteShellCommand_Promise_0100', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Promise_0100 --- start")
var cmd = 'aa help'
var escresult = 'usage: aa <command> <options>'
globalThis.abilityDelegator.executeShellCommand(cmd, 1).then((data) => {
console.log('ACTS_ExecuteShellCommand_Promise_0100 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Promise_0100 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf(escresult);
console.log('ACTS_ExecuteShellCommand_Promise_0100 query string i = ' + i);
expect(i == -1).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Promise_0100 exitCode = ' + data.exitCode)
expect(data.exitCode).assertEqual(0);
done();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Promise_0200
* @tc.name: Execute shell command with timeout parameter (Promise)
* @tc.desc: Verify that the interface executes the Shell command successfully.
*/
it('ACTS_ExecuteShellCommand_Promise_0200', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Promise_0200 --- start")
var cmd = 'aa start -d 0 -a MainAbility -b com.example.actskillprocesswithaccountclosetest'
globalThis.abilityDelegator.executeShellCommand(cmd, 1).then((data) => {
console.log('ACTS_ExecuteShellCommand_Promise_0200 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Promise_0200 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf('start ability successfully.');
console.log('ACTS_ExecuteShellCommand_Promise_0200 query string i = ' + i);
expect(i == -1).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Promise_0200 exitCode = ' + data.exitCode)
expect(data.exitCode).assertEqual(0);
console.log('ACTS_ExecuteShellCommand_Promise_0200 - executeShellCommand: end')
done()
})
setTimeout(async() => {
appManager.killProcessWithAccount('com.example.actskillProcessWithAccountclosetest', 100).then(() => {
console.log('ACTS_ExecuteShellCommand_Promise_0200 killProcess ======> start');
})
}, 3000 )
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Promise_0300
* @tc.name: Execute non-existing shell command (Promise).
* @tc.desc: Failed to execute shell command on authentication interface.
*/
it('ACTS_ExecuteShellCommand_Promise_0300', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Promise_0300 --- start")
var cmd = 'ppwd -L'
globalThis.abilityDelegator.executeShellCommand(cmd, 1).then((data) => {
console.log('ACTS_ExecuteShellCommand_Promise_0300 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Promise_0300 stdResult = ' + data.stdResult)
var i = data.stdResult.length
console.log('ACTS_ExecuteShellCommand_Promise_0300 query string i = ' + i);
expect(i == 0).assertEqual(true);
console.log('ACTS_ExecuteShellCommand_Promise_0300 exitCode = ' + data.exitCode)
expect(data.exitCode == 0).assertEqual(false);
console.log('ACTS_ExecuteShellCommand_Promise_0300 - executeShellCommand: end')
done();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Promise_0400
* @tc.name: Execute shell command timeout (Promise)
* @tc.desc: The authentication interface executes the shell command timed out.
*/
it('ACTS_ExecuteShellCommand_Promise_0400', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Promise_0400 --- start")
var cmd = 'aa help'
var escresult = 'usage: aa <command> <options>'
globalThis.abilityDelegator.executeShellCommand(cmd, 0).then((data) => {
console.log('ACTS_ExecuteShellCommand_Promise_0400 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Promise_0400 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf(escresult);
console.log('ACTS_ExecuteShellCommand_Promise_0400 query string i = ' + i);
expect(data.exitCode).assertEqual(0);
console.log('ACTS_ExecuteShellCommand_Promise_0400 - executeShellCommand: end')
done();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Promise_0500
* @tc.name: Invalid timeout parameter for executing shell command (Promise)
* @tc.desc: The timeout parameter for executing shell commands on the authentication interface is invalid.
*/
it('ACTS_ExecuteShellCommand_Promise_0500', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Promise_0500 --- start")
var cmd = 'aa help'
var escresult = 'usage: aa <command> <options>'
globalThis.abilityDelegator.executeShellCommand(cmd, -1).then((data) => {
console.log('ACTS_ExecuteShellCommand_Promise_0500 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Promise_0500 stdResult = ' + data.stdResult)
var i = data.stdResult.indexOf(escresult);
console.log('ACTS_ExecuteShellCommand_Promise_0500 query string i = ' + i);
expect(data.exitCode).assertEqual(0);
console.log('ACTS_ExecuteShellCommand_Promise_0500 - executeShellCommand: end')
done();
})
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Promise_0600
* @tc.name: The executed shell command parameter is null (Promise)
* @tc.desc: Failed to execute shell command on authentication interface.
*/
it('ACTS_ExecuteShellCommand_Promise_0600', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Promise_0600 --- start")
let flag = true;
globalThis.abilityDelegator.executeShellCommand("",1).then((data) => {
console.log('ACTS_ExecuteShellCommand_Promise_0600 - executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Promise_0600 - executeShellCommand:data'+JSON.stringify(data))
expect(data).assertEqual(undefined);
console.log('ACTS_ExecuteShellCommand_Callback_0600 - executeShellCommand: end')
flag=false;
done();
},(data) => {
console.log('ACTS_ExecuteShellCommand_Promise_0600 -2 executeShellCommand: start ')
console.log('ACTS_ExecuteShellCommand_Promise_0600 -2 executeShellCommand:data'+JSON.stringify(data))
expect(data.code).assertEqual(-1);
console.log('ACTS_ExecuteShellCommand_Callback_0600 -2 executeShellCommand: end')
flag=false;
done();
}).catch((err) => {
console.log('ACTS_ExecuteShellCommand_Promise_0600 -2 executeShellCommand:err'+JSON.stringify(err))
})
setTimeout(()=>{
if(flag==true){
console.log('ACTS_ExecuteShellCommand_Callback_0600 timeout')
expect().assertFail();
done();
}
},5000)
})
/**
* @tc.number: ACTS_ExecuteShellCommand_Promise_0700
* @tc.name: The timeout parameter of the execution is null (Promise)
* @tc.desc: Verify that the interface executes the Shell command successfully.
*/
it('ACTS_ExecuteShellCommand_Promise_0700', 0, async function (done) {
console.log("ACTS_ExecuteShellCommand_Promise_0700 --- start")
var cmd = 'aa help'
var code = null
code = globalThis.abilityDelegator.executeShellCommand(cmd, null)
setTimeout(() => {
console.log('ACTS_ExecuteShellCommand_Callback_0700 code:'+JSON.stringify(code))
if(code!=undefined){
expect().assertFail();
}
done();
}, 3000)
})
})
};
/*
* 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 abilityTest from './Ability.test'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "app_name",
"value": "ExecuteShellCommand"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ 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';
import file from '@system.file';
@Entry
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
actsstartrunnertest/entry/src/main/ets/pages/index3.ets
@Entry
@Component
struct Index {
......
/*
* 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.
*/
@Entry
@Component
struct Index {
......
/*
* 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 abilityTest from './Ability.test'
export default function testsuite() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册