Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c02d5c4e
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c02d5c4e
编写于
8月 01, 2022
作者:
O
openharmony_ci
提交者:
Gitee
8月 01, 2022
浏览文件
操作
浏览文件
下载
差异文件
!4743 Adapt to the new framework
Merge pull request !4743 from jiyong/local-20220801-0005
上级
97201a1e
52b603f1
变更
51
隐藏空白更改
内联
并排
Showing
51 changed file
with
1065 addition
and
222 deletion
+1065
-222
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json
...inforquery/actsamsstaticabilitystagecontexttest/Test.json
+6
-4
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/MainAbility/MainAbility.ts
...contexttest/entry/src/main/ets/MainAbility/MainAbility.ts
+1
-1
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/MainAbility/pages/index/index.ets
...test/entry/src/main/ets/MainAbility/pages/index/index.ets
+10
-18
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/MainAbility/pages/second/second.ets
...st/entry/src/main/ets/MainAbility/pages/second/second.ets
+0
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestAbility/TestAbility.ts
...contexttest/entry/src/main/ets/TestAbility/TestAbility.ts
+50
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestAbility/pages/index.ets
...ontexttest/entry/src/main/ets/TestAbility/pages/index.ets
+48
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/index/index.ets
...stagecontexttest/entry/src/main/ets/pages/index/index.ets
+0
-66
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets
...stagecontexttest/entry/src/main/ets/test/Ability.test.ets
+13
-14
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/List.test.ets
...itystagecontexttest/entry/src/main/ets/test/List.test.ets
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/Test.json
...extualinforquery/actsamsstaticextensioninfotest/Test.json
+6
-4
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/MainAbility/MainAbility.ts
...ioninfotest/entry/src/main/ets/MainAbility/MainAbility.ts
+1
-1
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/MainAbility/pages/index/index.ets
...test/entry/src/main/ets/MainAbility/pages/index/index.ets
+10
-20
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/MainAbility/pages/second/second.ets
...st/entry/src/main/ets/MainAbility/pages/second/second.ets
+0
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/TestAbility/TestAbility.ts
...ioninfotest/entry/src/main/ets/TestAbility/TestAbility.ts
+50
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/TestAbility/pages/index.ets
...oninfotest/entry/src/main/ets/TestAbility/pages/index.ets
+48
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/Ability.test.ets
...xtensioninfotest/entry/src/main/ets/test/Ability.test.ets
+6
-6
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/List.test.ets
...icextensioninfotest/entry/src/main/ets/test/List.test.ets
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json
...tualinforquery/actsamsstaticinfomationquerytest/Test.json
+5
-3
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/MainAbility/MainAbility.ts
...onquerytest/entry/src/main/ets/MainAbility/MainAbility.ts
+1
-1
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/MainAbility/pages/index/index.ets
...test/entry/src/main/ets/MainAbility/pages/index/index.ets
+10
-18
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/MainAbility/pages/second/second.ets
...st/entry/src/main/ets/MainAbility/pages/second/second.ets
+0
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestAbility/TestAbility.ts
...onquerytest/entry/src/main/ets/TestAbility/TestAbility.ts
+50
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestAbility/pages/index.ets
...nquerytest/entry/src/main/ets/TestAbility/pages/index.ets
+48
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets
...omationquerytest/entry/src/main/ets/test/Ability.test.ets
+10
-10
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/List.test.ets
...infomationquerytest/entry/src/main/ets/test/List.test.ets
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/Test.json
...inforquery/actsamsstaticinformationmultipletest/Test.json
+6
-4
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/MainAbility/MainAbility.ts
...ultipletest/entry/src/main/ets/MainAbility/MainAbility.ts
+1
-1
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/MainAbility/pages/index/index.ets
...test/entry/src/main/ets/MainAbility/pages/index/index.ets
+10
-20
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/MainAbility/pages/second/second.ets
...st/entry/src/main/ets/MainAbility/pages/second/second.ets
+0
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/TestAbility/TestAbility.ts
...ultipletest/entry/src/main/ets/TestAbility/TestAbility.ts
+50
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/TestAbility/pages/index.ets
...ltipletest/entry/src/main/ets/TestAbility/pages/index.ets
+48
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets
...tionmultipletest/entry/src/main/ets/test/Ability.test.ets
+3
-3
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/List.test.ets
...rmationmultipletest/entry/src/main/ets/test/List.test.ets
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/Test.json
...ualinforquery/actsamsstaticinformationmultitest/Test.json
+6
-4
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/MainAbility.ts
...onmultitest/entry/src/main/ets/MainAbility/MainAbility.ts
+1
-1
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/pages/index/index.ets
...test/entry/src/main/ets/MainAbility/pages/index/index.ets
+56
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/pages/second/second.ets
...st/entry/src/main/ets/MainAbility/pages/second/second.ets
+0
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/TestAbility/TestAbility.ts
...onmultitest/entry/src/main/ets/TestAbility/TestAbility.ts
+50
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/TestAbility/pages/index.ets
...nmultitest/entry/src/main/ets/TestAbility/pages/index.ets
+48
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets
...rmationmultitest/entry/src/main/ets/test/Ability.test.ets
+3
-3
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/List.test.ets
...nformationmultitest/entry/src/main/ets/test/List.test.ets
+2
-2
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+2
-2
未找到文件。
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json
浏览文件 @
c02d5c4e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"120000"
,
"package"
:
"com.example.staticabilitystagecontext"
,
"shell-timeout"
:
"60000"
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"180000"
,
"bundle-name"
:
"com.example.staticabilitystagecontext"
,
"module-name"
:
"com.example.staticabilitystagecontext"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
c02d5c4e
...
...
@@ -30,7 +30,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability
console
.
log
(
"
MainAbility onWindowStageCreate
"
)
globalThis
.
abilityStageContext
=
this
.
context
windowStage
.
setUIContent
(
this
.
context
,
"
pages/index/index
"
,
null
)
windowStage
.
setUIContent
(
this
.
context
,
"
MainAbility/
pages/index/index
"
,
null
)
}
onWindowStageDestroy
()
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstatic
informationmultitest/entry/src/main/ets
/pages/index/index.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstatic
abilitystagecontexttest/entry/src/main/ets/MainAbility
/pages/index/index.ets
浏览文件 @
c02d5c4e
...
...
@@ -14,8 +14,10 @@
*/
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets"
import router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
...
...
@@ -24,22 +26,12 @@ struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/second/second.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/
MainAbility/
pages/second/second.ets
浏览文件 @
c02d5c4e
文件已移动
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestAbility/TestAbility.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
'
export
default
class
TestAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
TestAbility onCreate
'
)
}
onDestroy
()
{
console
.
log
(
'
TestAbility onDestroy
'
)
}
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
;
}
onWindowStageDestroy
()
{
console
.
log
(
'
TestAbility onWindowStageDestroy
'
)
}
onForeground
()
{
console
.
log
(
'
TestAbility onForeground
'
)
}
onBackground
()
{
console
.
log
(
'
TestAbility onBackground
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestAbility/pages/index.ets
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
TestRunner
from
'
@ohos.application.testRunner
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
var
abilityDelegator
=
undefined
var
abilityDelegatorArguments
=
undefined
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s it
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s dryRun
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
}
}
return
targetParams
.
trim
()
}
async
function
onAbilityCreateCallback
()
{
console
.
log
(
"
onAbilityCreateCallback
"
);
}
async
function
addAbilityMonitorCallback
(
err
:
any
)
{
console
.
info
(
"
addAbilityMonitorCallback :
"
+
JSON
.
stringify
(
err
))
}
export
default
class
OpenHarmonyTestRunner
implements
TestRunner
{
constructor
()
{
}
onPrepare
()
{
console
.
info
(
"
OpenHarmonyTestRunner OnPrepare
"
)
}
async
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.MainAbility
'
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
var
cmd
=
'
aa start -d 0 -a com.example.staticabilitystagecontext.MainAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
"
-D
"
]
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
console
.
info
(
'
cmd :
'
+
cmd
)
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
console
.
info
(
'
executeShellCommand : err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
stdResult
);
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
exitCode
);
})
console
.
info
(
'
OpenHarmonyTestRunner onRun end
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/index/index.ets
已删除
100644 → 0
浏览文件 @
97201a1e
/*
* 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityStageContext)
core.execute()
}
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
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -12,12 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index
"
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium
"
export default function abilityTest(abilityStageContext) {
describe('ActsAbilityStageContextTest', function () {
export default function abilityTest() {
describe('ActsglobalThis.abilityStageContextTest', function () {
/**
* @tc.number: ACTS_getApplicationInfo_0300
* @tc.name: Application query applicationInfo Static information.
...
...
@@ -26,7 +25,7 @@ export default function abilityTest(abilityStageContext) {
*/
it('ACTS_getApplicationInfo_0300', 0, async function (done) {
console.log("ACTS_getApplicationInfo_0300 --- start ability=====>'+ abilityContext.applicationInfo")
checkApplicationInfo(abilityStageContext.applicationInfo);
checkApplicationInfo(
globalThis.
abilityStageContext.applicationInfo);
done();
})
...
...
@@ -38,7 +37,7 @@ export default function abilityTest(abilityStageContext) {
*/
it('ACTS_getHapModuleInfo_0300', 0, async function (done) {
console.log("ACTS_getHapModuleInfo_0300 --- start ability=====>'+ abilityContext.currentHapModuleInfo")
checkHapModuleInfo(abilityStageContext.currentHapModuleInfo);
checkHapModuleInfo(
globalThis.
abilityStageContext.currentHapModuleInfo);
done();
})
...
...
@@ -94,7 +93,7 @@ export default function abilityTest(abilityStageContext) {
expect(typeof (data.removable)).assertEqual("boolean");
console.log("checkApplicationInfo_expect_typeof_end")
expect(data.name).assertEqual("com.example.static
abilitystagec
ontext");
expect(data.name).assertEqual("com.example.static
globalThis.abilityStageC
ontext");
expect(data.description).assertEqual("$string:description_application");
expect(data.descriptionId).assertLarger(0);
expect(data.systemApp).assertEqual(true);
...
...
@@ -107,15 +106,15 @@ export default function abilityTest(abilityStageContext) {
expect(data.supportedModes).assertEqual(0);
expect(data.moduleSourceDirs.length).assertEqual(1);
expect(data.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" +
"com.example.static
abilitystagecontext/com.example.staticabilitystagec
ontext");
"com.example.static
globalThis.abilityStageContext/com.example.staticglobalThis.abilityStageC
ontext");
expect(data.moduleInfos.length).assertEqual(1);
expect(data.moduleInfos[0].moduleName).assertEqual("com.example.static
abilitystagec
ontext");
expect(data.moduleInfos[0].moduleName).assertEqual("com.example.static
globalThis.abilityStageC
ontext");
expect(data.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" +
"com.example.static
abilitystagecontext/com.example.staticabilitystagec
ontext");
"com.example.static
globalThis.abilityStageContext/com.example.staticglobalThis.abilityStageC
ontext");
expect(data.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.example.static
abilitystagecontext/com.example.staticabilitystagec
ontext");
"com.example.static
globalThis.abilityStageContext/com.example.staticglobalThis.abilityStageC
ontext");
expect(data.codePath).assertEqual("/data/app/el1/bundle/public/" +
"com.example.static
abilitystagec
ontext");
"com.example.static
globalThis.abilityStageC
ontext");
expect(data.removable).assertEqual(true);
console.log("checkApplicationInfo end " + data);
}
...
...
@@ -155,7 +154,7 @@ export default function abilityTest(abilityStageContext) {
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.mainAbilityName)).assertEqual("string");
console.log("checkHapModuleInfo_expect_typeof_end")
expect(data.name).assertEqual("com.example.static
abilitystagec
ontext");
expect(data.name).assertEqual("com.example.static
globalThis.abilityStageC
ontext");
expect(data.description).assertEqual("$string:phone_entry_dsc");
expect(data.descriptionId).assertEqual(undefined);
expect(data.icon).assertEqual("$media:icon");
...
...
@@ -168,7 +167,7 @@ export default function abilityTest(abilityStageContext) {
expect(data.reqCapabilities[0]).assertEqual(undefined);
expect(data.deviceTypes.length).assertEqual(1);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(data.moduleName).assertEqual("com.example.static
abilitystagec
ontext")
expect(data.moduleName).assertEqual("com.example.static
globalThis.abilityStageC
ontext")
expect(data.mainAbilityName).assertEqual("MainAbility");
expect(data.installationFree).assertEqual(undefined);
console.log("checkHapModuleInfo end " + data);
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/List.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(
context
) {
export default function testsuite() {
abilityTest(
context
)
abilityTest()
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
c02d5c4e
{
"src"
:
[
"pages/index/index"
,
"pages/second/second"
"
MainAbility/
pages/index/index"
,
"
MainAbility/
pages/second/second"
]
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/Test.json
浏览文件 @
c02d5c4e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"120000"
,
"package"
:
"com.example.staticextensioninfo"
,
"shell-timeout"
:
"60000"
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"180000"
,
"bundle-name"
:
"com.example.staticextensioninfo"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
c02d5c4e
...
...
@@ -30,7 +30,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability
console
.
log
(
"
MainAbility onWindowStageCreate
"
)
globalThis
.
abilityContext
=
this
.
context
windowStage
.
setUIContent
(
this
.
context
,
"
pages/index/index
"
,
null
)
windowStage
.
setUIContent
(
this
.
context
,
"
MainAbility/
pages/index/index
"
,
null
)
}
onWindowStageDestroy
()
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/pages/index/index.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/
MainAbility/
pages/index/index.ets
浏览文件 @
c02d5c4e
...
...
@@ -12,10 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
file from '@system.file
';
import {
Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from
"../../test/List.test.ets"
import
router from '@ohos.router
';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import {
Hypium } from '@ohos/hypium'
import testsuite from
'../../../test/List.test'
@Entry
...
...
@@ -24,22 +24,12 @@ struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/pages/second/second.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/
MainAbility/
pages/second/second.ets
浏览文件 @
c02d5c4e
文件已移动
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/TestAbility/TestAbility.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
'
export
default
class
TestAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
TestAbility onCreate
'
)
}
onDestroy
()
{
console
.
log
(
'
TestAbility onDestroy
'
)
}
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
;
}
onWindowStageDestroy
()
{
console
.
log
(
'
TestAbility onWindowStageDestroy
'
)
}
onForeground
()
{
console
.
log
(
'
TestAbility onForeground
'
)
}
onBackground
()
{
console
.
log
(
'
TestAbility onBackground
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/TestAbility/pages/index.ets
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
TestRunner
from
'
@ohos.application.testRunner
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
var
abilityDelegator
=
undefined
var
abilityDelegatorArguments
=
undefined
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s it
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s dryRun
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
}
}
return
targetParams
.
trim
()
}
async
function
onAbilityCreateCallback
()
{
console
.
log
(
"
onAbilityCreateCallback
"
);
}
async
function
addAbilityMonitorCallback
(
err
:
any
)
{
console
.
info
(
"
addAbilityMonitorCallback :
"
+
JSON
.
stringify
(
err
))
}
export
default
class
OpenHarmonyTestRunner
implements
TestRunner
{
constructor
()
{
}
onPrepare
()
{
console
.
info
(
"
OpenHarmonyTestRunner OnPrepare
"
)
}
async
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.MainAbility
'
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
var
cmd
=
'
aa start -d 0 -a com.example.staticextensioninfo.MainAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
"
-D
"
]
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
console
.
info
(
'
cmd :
'
+
cmd
)
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
console
.
info
(
'
executeShellCommand : err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
stdResult
);
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
exitCode
);
})
console
.
info
(
'
OpenHarmonyTestRunner onRun end
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -14,7 +14,7 @@
*/
import commonEvent from "@ohos.commonEvent"
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
'deccjsunit/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
"@ohos/hypium"
const START_ABILITY_TIMEOUT = 5000;
var subscriberInfoStartAbility_0100 = {
...
...
@@ -24,7 +24,7 @@ var subscriberInfoStartAbility_0200 = {
events: ["ACTS_ConnectAbility_0200_CommonEvent"],
};
export default function abilityTest(
abilityContext
) {
export default function abilityTest() {
describe('ActsExtensionAbilityTest', function () {
...
...
@@ -56,7 +56,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_getExtensionInfo_0100_Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack);
connId = await abilityContext.connectAbility(
connId = await
globalThis.
abilityContext.connectAbility(
{
bundleName: "com.example.staticextensioninfo",
abilityName: "com.example.staticextensioninfo.ServiceAbility",
...
...
@@ -238,7 +238,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_getExtensionInfo_0200_Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack);
connId = await abilityContext.connectAbility(
connId = await
globalThis.
abilityContext.connectAbility(
{
bundleName: "com.example.staticextensioninfotest",
abilityName: "com.example.staticextensioninfotest.ServiceAbility",
...
...
@@ -418,7 +418,7 @@ export default function abilityTest(abilityContext) {
console.debug("====>ACTS_getExtensionInfo_0300_Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack);
connId = await abilityContext.connectAbility(
connId = await
globalThis.
abilityContext.connectAbility(
{
bundleName: "com.example.extensionmodule",
abilityName: "ServiceExtAbility",
...
...
@@ -433,7 +433,7 @@ export default function abilityTest(abilityContext) {
function timeout() {
expect().assertFail();
abilityContext.disconnectAbility(
globalThis.
abilityContext.disconnectAbility(
connId,
(error, data) => {
console.log('DisconnectAbility_0300 result errCode : ' + error.code + " data: " + data)
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/List.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(
context
) {
export default function testsuite() {
abilityTest(
context
)
abilityTest()
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
c02d5c4e
{
"src"
:
[
"pages/index/index"
,
"pages/second/second"
"
MainAbility/
pages/index/index"
,
"
MainAbility/
pages/second/second"
]
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json
浏览文件 @
c02d5c4e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"type"
:
"
OH
JSUnitTest"
,
"test-timeout"
:
"300000"
,
"package"
:
"com.example.staticinfomationquery"
,
"shell-timeout"
:
"300000"
"bundle-name"
:
"com.example.staticinfomationquery"
,
"module-name"
:
"com.example.staticinfomationquery"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
c02d5c4e
...
...
@@ -30,7 +30,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability
console
.
log
(
"
MainAbility onWindowStageCreate
"
)
globalThis
.
abilityContext
=
this
.
context
windowStage
.
setUIContent
(
this
.
context
,
"
pages/index/index
"
,
null
)
windowStage
.
setUIContent
(
this
.
context
,
"
MainAbility/
pages/index/index
"
,
null
)
}
onWindowStageDestroy
()
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/pages/index/index.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/
MainAbility/
pages/index/index.ets
浏览文件 @
c02d5c4e
...
...
@@ -14,8 +14,10 @@
*/
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets"
import router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
...
...
@@ -24,22 +26,12 @@ struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/pages/second/second.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/
MainAbility/
pages/second/second.ets
浏览文件 @
c02d5c4e
文件已移动
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestAbility/TestAbility.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
'
export
default
class
TestAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
TestAbility onCreate
'
)
}
onDestroy
()
{
console
.
log
(
'
TestAbility onDestroy
'
)
}
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
;
}
onWindowStageDestroy
()
{
console
.
log
(
'
TestAbility onWindowStageDestroy
'
)
}
onForeground
()
{
console
.
log
(
'
TestAbility onForeground
'
)
}
onBackground
()
{
console
.
log
(
'
TestAbility onBackground
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestAbility/pages/index.ets
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
TestRunner
from
'
@ohos.application.testRunner
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
var
abilityDelegator
=
undefined
var
abilityDelegatorArguments
=
undefined
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s it
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s dryRun
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
}
}
return
targetParams
.
trim
()
}
async
function
onAbilityCreateCallback
()
{
console
.
log
(
"
onAbilityCreateCallback
"
);
}
async
function
addAbilityMonitorCallback
(
err
:
any
)
{
console
.
info
(
"
addAbilityMonitorCallback :
"
+
JSON
.
stringify
(
err
))
}
export
default
class
OpenHarmonyTestRunner
implements
TestRunner
{
constructor
()
{
}
onPrepare
()
{
console
.
info
(
"
OpenHarmonyTestRunner OnPrepare
"
)
}
async
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.MainAbility
'
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
var
cmd
=
'
aa start -d 0 -a com.example.staticinfomationquery.MainAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
"
-D
"
]
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
console
.
info
(
'
cmd :
'
+
cmd
)
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
console
.
info
(
'
executeShellCommand : err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
stdResult
);
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
exitCode
);
})
console
.
info
(
'
OpenHarmonyTestRunner onRun end
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index
"
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium
"
import commonEvent from '@ohos.commonEvent'
...
...
@@ -24,7 +24,7 @@ var subscriberInfo_MainAbility_ability_0300 = {
events: ["MainAbility_Start_CommonEvent_ability_0300","SecondAbility_Start_CommonEvent_ability_0300"],
};
export default function abilityTest(
abilityContext
) {
export default function abilityTest() {
describe('ActsStaticInfoMationQueryTest', function () {
/**
* @tc.number: ACTS_getAbilityInfo_0100
...
...
@@ -33,8 +33,8 @@ export default function abilityTest(abilityContext) {
* information is the same as that in the configuration file.
*/
it('ACTS_getAbilityInfo_0100', 0, async function (done) {
console.log("ACTS_getAbilityInfo_0100 --- start ability=====>'+ abilityContext.abilityInfo")
checkAbilityInfo(abilityContext.abilityInfo);
console.log("ACTS_getAbilityInfo_0100 --- start ability=====>'+
globalThis.
abilityContext.abilityInfo")
checkAbilityInfo(
globalThis.
abilityContext.abilityInfo);
done();
})
...
...
@@ -45,8 +45,8 @@ export default function abilityTest(abilityContext) {
* information is the same as that in the configuration file.
*/
it('ACTS_getApplicationInfo_0100', 0, async function (done) {
console.log("ACTS_getApplicationInfo_0100 --- start ability=====>'+ abilityContext.applicationInfo")
checkApplicationInfo(abilityContext.applicationInfo);
console.log("ACTS_getApplicationInfo_0100 --- start ability=====>'+
globalThis.
abilityContext.applicationInfo")
checkApplicationInfo(
globalThis.
abilityContext.applicationInfo);
done();
})
...
...
@@ -57,8 +57,8 @@ export default function abilityTest(abilityContext) {
* information is the same as that in the configuration file.
*/
it('ACTS_getHapModuleInfo_0100', 0, async function (done) {
console.log("ACTS_getHapModuleInfo_0100 --- start ability=====>'+ abilityContext.currentHapModuleInfo")
checkHapModuleInfo(abilityContext.currentHapModuleInfo);
console.log("ACTS_getHapModuleInfo_0100 --- start ability=====>'+
globalThis.
abilityContext.currentHapModuleInfo")
checkHapModuleInfo(
globalThis.
abilityContext.currentHapModuleInfo);
done();
})
...
...
@@ -108,10 +108,10 @@ export default function abilityTest(abilityContext) {
Subscriber.getSubscribeInfo().then((data)=>{
console.log('ACTS_getAbilityInfo_0200 - Subscriber: ' + JSON.stringify(data))
})
abilityContext.startAbility({
globalThis.
abilityContext.startAbility({
bundleName: "com.example.staticquerytesttwo",
abilityName: "com.example.staticquerytesttwo.MainAbility",
action:"get
A
bilityContext"
action:"get
globalThis.a
bilityContext"
}, (error, data) => {
console.log('ACTS_getAbilityInfo_0200_startMainAbility: ' + JSON.stringify(error) +
", " + JSON.stringify(data))
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/List.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(
context
) {
export default function testsuite() {
abilityTest(
context
)
abilityTest()
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
c02d5c4e
{
"src"
:
[
"pages/index/index"
,
"pages/second/second"
"
MainAbility/
pages/index/index"
,
"
MainAbility/
pages/second/second"
]
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/Test.json
浏览文件 @
c02d5c4e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"120000"
,
"package"
:
"com.example.staticinformationmultiple"
,
"shell-timeout"
:
"60000"
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"180000"
,
"bundle-name"
:
"com.example.staticinformationmultiple"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
c02d5c4e
...
...
@@ -30,7 +30,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability
console
.
log
(
"
MainAbility onWindowStageCreate
"
)
globalThis
.
abilityContext
=
this
.
context
windowStage
.
setUIContent
(
this
.
context
,
"
pages/index/index
"
,
null
)
windowStage
.
setUIContent
(
this
.
context
,
"
MainAbility/
pages/index/index
"
,
null
)
}
onWindowStageDestroy
()
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/pages/index/index.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/
MainAbility/
pages/index/index.ets
浏览文件 @
c02d5c4e
...
...
@@ -12,10 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
file from '@system.file
';
import {
Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from
"../../test/List.test.ets"
import
router from '@ohos.router
';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import {
Hypium } from '@ohos/hypium'
import testsuite from
'../../../test/List.test'
@Entry
...
...
@@ -24,22 +24,12 @@ struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/pages/second/second.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/
MainAbility/
pages/second/second.ets
浏览文件 @
c02d5c4e
文件已移动
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/TestAbility/TestAbility.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
'
export
default
class
TestAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
TestAbility onCreate
'
)
}
onDestroy
()
{
console
.
log
(
'
TestAbility onDestroy
'
)
}
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
;
}
onWindowStageDestroy
()
{
console
.
log
(
'
TestAbility onWindowStageDestroy
'
)
}
onForeground
()
{
console
.
log
(
'
TestAbility onForeground
'
)
}
onBackground
()
{
console
.
log
(
'
TestAbility onBackground
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/TestAbility/pages/index.ets
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
TestRunner
from
'
@ohos.application.testRunner
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
var
abilityDelegator
=
undefined
var
abilityDelegatorArguments
=
undefined
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s it
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s dryRun
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
}
}
return
targetParams
.
trim
()
}
async
function
onAbilityCreateCallback
()
{
console
.
log
(
"
onAbilityCreateCallback
"
);
}
async
function
addAbilityMonitorCallback
(
err
:
any
)
{
console
.
info
(
"
addAbilityMonitorCallback :
"
+
JSON
.
stringify
(
err
))
}
export
default
class
OpenHarmonyTestRunner
implements
TestRunner
{
constructor
()
{
}
onPrepare
()
{
console
.
info
(
"
OpenHarmonyTestRunner OnPrepare
"
)
}
async
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.MainAbility
'
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
var
cmd
=
'
aa start -d 0 -a com.example.staticinformationmultiple.MainAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
"
-D
"
]
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
console
.
info
(
'
cmd :
'
+
cmd
)
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
console
.
info
(
'
executeShellCommand : err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
stdResult
);
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
exitCode
);
})
console
.
info
(
'
OpenHarmonyTestRunner onRun end
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index";
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent';
var subscriberInfo = {
...
...
@@ -21,7 +21,7 @@ var subscriberInfo = {
};
export default function abilityTest(
abilityContext
) {
export default function abilityTest() {
describe('ActsAbilityMultipleTest', function () {
/*
...
...
@@ -35,7 +35,7 @@ export default function abilityTest(abilityContext) {
var EntryHap = false;
var FeatureHap = false;
abilityContext.startAbility({
globalThis.
abilityContext.startAbility({
bundleName: "com.example.staticquerytesttwo",
abilityName: "com.example.staticquerytesttwo.MainAbility",
action:"startmultiple"
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/List.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(
context
) {
export default function testsuite() {
abilityTest(
context
)
abilityTest()
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
c02d5c4e
{
"src"
:
[
"pages/index/index"
,
"pages/second/second"
"
MainAbility/
pages/index/index"
,
"
MainAbility/
pages/second/second"
]
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/Test.json
浏览文件 @
c02d5c4e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"120000"
,
"package"
:
"com.example.staticinformationmultihap"
,
"shell-timeout"
:
"60000"
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"180000"
,
"bundle-name"
:
"com.example.staticinformationmultihap"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
70000
},
"kits"
:
[
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
c02d5c4e
...
...
@@ -30,7 +30,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability
console
.
log
(
"
MainAbility onWindowStageCreate
"
)
globalThis
.
abilityContext
=
this
.
context
windowStage
.
setUIContent
(
this
.
context
,
"
pages/index/index
"
,
null
)
windowStage
.
setUIContent
(
this
.
context
,
"
MainAbility/
pages/index/index
"
,
null
)
}
onWindowStageDestroy
()
{
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/pages/index/index.ets
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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'
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
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
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/pages/second/second.ets
→
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/
MainAbility/
pages/second/second.ets
浏览文件 @
c02d5c4e
文件已移动
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/TestAbility/TestAbility.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
'
export
default
class
TestAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
TestAbility onCreate
'
)
}
onDestroy
()
{
console
.
log
(
'
TestAbility onDestroy
'
)
}
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
;
}
onWindowStageDestroy
()
{
console
.
log
(
'
TestAbility onWindowStageDestroy
'
)
}
onForeground
()
{
console
.
log
(
'
TestAbility onForeground
'
)
}
onBackground
()
{
console
.
log
(
'
TestAbility onBackground
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/TestAbility/pages/index.ets
0 → 100644
浏览文件 @
c02d5c4e
/*
* 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
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
c02d5c4e
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
TestRunner
from
'
@ohos.application.testRunner
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
var
abilityDelegator
=
undefined
var
abilityDelegatorArguments
=
undefined
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s it
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s dryRun
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
}
}
return
targetParams
.
trim
()
}
async
function
onAbilityCreateCallback
()
{
console
.
log
(
"
onAbilityCreateCallback
"
);
}
async
function
addAbilityMonitorCallback
(
err
:
any
)
{
console
.
info
(
"
addAbilityMonitorCallback :
"
+
JSON
.
stringify
(
err
))
}
export
default
class
OpenHarmonyTestRunner
implements
TestRunner
{
constructor
()
{
}
onPrepare
()
{
console
.
info
(
"
OpenHarmonyTestRunner OnPrepare
"
)
}
async
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.MainAbility
'
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
var
cmd
=
'
aa start -d 0 -a com.example.staticinformationmultihap.MainAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
"
-D
"
]
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
console
.
info
(
'
cmd :
'
+
cmd
)
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
console
.
info
(
'
executeShellCommand : err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
stdResult
);
console
.
info
(
'
executeShellCommand : data :
'
+
d
.
exitCode
);
})
console
.
info
(
'
OpenHarmonyTestRunner onRun end
'
)
}
};
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index";
import {
describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent';
var subscriberInfo = {
...
...
@@ -21,7 +21,7 @@ var subscriberInfo = {
};
export default function abilityTest(
abilityContext
) {
export default function abilityTest() {
describe('ActsAbilityMultiTest', function () {
/**
...
...
@@ -35,7 +35,7 @@ export default function abilityTest(abilityContext) {
var EntryHap = false;
var FeatureHap = false;
abilityContext.startAbility({
globalThis.
abilityContext.startAbility({
bundleName: "com.example.staticinformationmultihappackage",
abilityName: "com.example.staticinformationmultihappackage.MainAbility",
action:"startHapA"
...
...
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/List.test.ets
浏览文件 @
c02d5c4e
...
...
@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(
context
) {
export default function testsuite() {
abilityTest(
context
)
abilityTest()
}
\ No newline at end of file
ability/ability_runtime/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
c02d5c4e
{
"src"
:
[
"pages/index/index"
,
"pages/second/second"
"
MainAbility/
pages/index/index"
,
"
MainAbility/
pages/second/second"
]
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录