Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
290a61c1
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看板
提交
290a61c1
编写于
11月 12, 2022
作者:
C
chengxingzhen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xts-AppContext新增用例
Signed-off-by:
N
chengxingzhen
<
chengxingzhen@huawei.com
>
上级
b2ebd159
变更
20
显示空白变更内容
内联
并排
Showing
20 changed file
with
837 addition
and
0 deletion
+837
-0
ability/ability_runtime/context/BUILD.gn
ability/ability_runtime/context/BUILD.gn
+1
-0
ability/ability_runtime/context/actsstageappcontext/BUILD.gn
ability/ability_runtime/context/actsstageappcontext/BUILD.gn
+25
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/AppScope/app.json
...stageappcontext/actsstageappcontexttest/AppScope/app.json
+21
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/AppScope/resources/base/element/string.json
...ppcontexttest/AppScope/resources/base/element/string.json
+8
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/AppScope/resources/base/media/app_icon.png
...appcontexttest/AppScope/resources/base/media/app_icon.png
+0
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/BUILD.gn
...text/actsstageappcontext/actsstageappcontexttest/BUILD.gn
+43
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/Test.json
...ext/actsstageappcontext/actsstageappcontexttest/Test.json
+21
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/Application/MyAbilityStage.ts
...texttest/entry/src/main/ets/Application/MyAbilityStage.ts
+23
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/MainAbility/MainAbility.ts
...contexttest/entry/src/main/ets/MainAbility/MainAbility.ts
+61
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts
...ttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts
+44
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+75
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/pages/index/index.ets
...geappcontexttest/entry/src/main/ets/pages/index/index.ets
+44
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/pages/second/second.ets
...appcontexttest/entry/src/main/ets/pages/second/second.ets
+43
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/test/List.test.ets
...stageappcontexttest/entry/src/main/ets/test/List.test.ets
+20
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/test/StageAppContext.test.ets
...texttest/entry/src/main/ets/test/StageAppContext.test.ets
+318
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/module.json
...ontext/actsstageappcontexttest/entry/src/main/module.json
+52
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/resources/base/element/string.json
...exttest/entry/src/main/resources/base/element/string.json
+32
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/resources/base/media/icon.png
...pcontexttest/entry/src/main/resources/base/media/icon.png
+0
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+6
-0
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/signature/openharmony_sx.p7b
...text/actsstageappcontexttest/signature/openharmony_sx.p7b
+0
-0
未找到文件。
ability/ability_runtime/context/BUILD.gn
浏览文件 @
290a61c1
...
...
@@ -21,6 +21,7 @@ group("context") {
"actscreatemodulecontextassist:ActsCreateModuleContextAssist",
"actscreatemodulecontextassistone:ActsCreateModuleContextAssistOne",
"actscreatemodulecontexttest:ActsCreateModuleContextTest",
"actsstageappcontext:actsstageappcontext",
"actsstagecontext:actsstagecontext",
"scene/defpermission:DefPermission",
]
...
...
ability/ability_runtime/context/actsstageappcontext/BUILD.gn
0 → 100644
浏览文件 @
290a61c1
# 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("actsstageappcontext") {
testonly = true
if (is_standard_system) {
deps = [
#"actsstagecontextassistone:ActsStageContextAssistOne",
#"actsstagecontextassisttwo:ActsStageContextAssistTwo",
"actsstageappcontexttest:ActsStageAppContextTest",
]
}
}
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/AppScope/app.json
0 → 100644
浏览文件 @
290a61c1
{
"app"
:
{
"bundleName"
:
"com.example.stageappcontexttest"
,
"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
}
}
}
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/AppScope/resources/base/element/string.json
0 → 100644
浏览文件 @
290a61c1
{
"string"
:
[
{
"name"
:
"app_name"
,
"value"
:
"AbilityStageMonitor"
}
]
}
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/AppScope/resources/base/media/app_icon.png
0 → 100644
浏览文件 @
290a61c1
6.6 KB
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/BUILD.gn
0 → 100644
浏览文件 @
290a61c1
# 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("ActsStageAppContextTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":stageappcontext_js_assets",
":stageappcontext_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsStageAppContextTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("stageappcontext_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("stageappcontext_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("stageappcontext_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":stageappcontext_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/Test.json
0 → 100644
浏览文件 @
290a61c1
{
"description"
:
"Configuration for aceceshi Tests"
,
"driver"
:
{
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"600000"
,
"bundle-name"
:
"com.example.stageappcontexttest"
,
"module-name"
:
"entry_test"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
"15000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsStageAppContextTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/Application/MyAbilityStage.ts
0 → 100644
浏览文件 @
290a61c1
/*
* 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
.
info
(
"
MyAbilityStageAppContext onCreate
"
)
globalThis
.
abilityStageContext
=
this
.
context
}
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/MainAbility/MainAbility.ts
0 → 100644
浏览文件 @
290a61c1
/*
* 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
'
@ohos/hypium
'
import
testsuite
from
'
../test/List.test
'
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
// Ability is creating, initialize resources for this ability
console
.
log
(
"
ActsStageAppContextTest MainAbility onCreate
"
)
globalThis
.
abilityWant
=
want
;
globalThis
.
abilityContext
=
this
.
context
let
abilityDelegator
:
any
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
let
abilityDelegatorArguments
:
any
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
console
.
info
(
'
start run testcase!!!
'
)
Hypium
.
hypiumTest
(
abilityDelegator
,
abilityDelegatorArguments
,
testsuite
)
}
onDestroy
()
{
// Ability is destroying, release resources for this ability
console
.
log
(
"
ActsStageAppContextTest MainAbility onDestroy
"
)
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
"
ActsStageAppContextTest MainAbility onWindowStageCreate
"
)
windowStage
.
setUIContent
(
this
.
context
,
"
pages/index/index
"
,
null
)
console
.
log
(
"
ActsStageAppContextTest MainAbility onWindowStageCreate finish
"
)
}
onWindowStageDestroy
()
{
// Main window is destroyed, release UI related resources
console
.
log
(
"
ActsStageAppContextTest MainAbility onWindowStageDestroy
"
)
}
onForeground
()
{
// Ability has brought to foreground
console
.
log
(
"
ActsStageAppContextTest MainAbility onForeground
"
)
}
onBackground
()
{
// Ability has back to background
console
.
log
(
"
ActsStageAppContextTest MainAbility onBackground
"
)
}
};
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts
0 → 100644
浏览文件 @
290a61c1
/*
* 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
rpc
from
'
@ohos.rpc
'
;
import
ServiceExtension
from
'
@ohos.application.ServiceExtensionAbility
'
export
default
class
ServiceAbility
extends
ServiceExtension
{
onCreate
(
want
)
{
console
.
log
(
'
ActsStageAppContextTest ServiceAbility onCreate, want:
'
+
want
.
abilityName
);
globalThis
.
serviceExtenxionAbilityContext
=
this
.
context
}
onRequest
(
want
,
startId
)
{
console
.
log
(
'
ServiceAbility onRequest, want:
'
+
want
.
abilityName
+
'
, startId:
'
+
startId
);
}
onConnect
(
want
)
{
console
.
log
(
'
ActsStageAppContextTest ServiceAbility onConnect, want:
'
+
want
.
abilityName
);
if
(
want
.
action
==
'
StartAbilityPromise
'
)
{
console
.
log
(
'
stub SerivceAbilityServer OnConnect start 1
'
);
console
.
log
(
'
=======startAbilityPromise=======
'
);
return
new
rpc
.
RemoteObject
(
'
ServiceAbility
'
);
}
}
onDisconnect
(
want
)
{
console
.
log
(
'
ActsStageAppContextTest ServiceAbility onDisconnect, want:
'
+
want
.
abilityName
);
}
onDestroy
()
{
console
.
log
(
'
ActsStageAppContextTest ServiceAbility onDestroy
'
);
}
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
290a61c1
/*
* 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
'
let
abilityDelegator
=
undefined
let
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
()
globalThis
.
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
let
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.MainAbility
'
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
let
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
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/pages/index/index.ets
0 → 100644
浏览文件 @
290a61c1
/*
* 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 {
aboutToAppear(){
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('MainAbility 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/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/pages/second/second.ets
0 → 100644
浏览文件 @
290a61c1
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "SecondMainAbility Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/test/List.test.ets
0 → 100644
浏览文件 @
290a61c1
/*
* 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 stageAppContextTest from './StageAppContext.test'
export default function testsuite() {
stageAppContextTest(globalThis.abilityContext)
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/ets/test/StageAppContext.test.ets
0 → 100644
浏览文件 @
290a61c1
/*
* 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, it, expect, beforeAll } from '@ohos/hypium'
let TAG;
export default function stageAppContextTest(abilityContext) {
describe('ActsStageAppContextTest', function () {
beforeAll(async (done) => {
console.log("ActsStageContextPropertiesTest afterAll called");
await abilityContext.startAbility({
bundleName: "com.example.stageappcontexttest",
abilityName: "ServiceAbility",
}).then((data) => {
console.log('ActsStageContextPropertiesTest - ServiceAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log("ActsStageContextPropertiesTest - ServiceAbility failed: "
+ JSON.stringify(err));
done()
})
setTimeout(function () {
console.log("ActsStageContextPropertiesTest afterAll end");
done();
}, 1000);
})
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0100
* @tc.name: Validating the context obtained by the AbilityContext call
* getApplicationContext can be obtained using createBundleContext
* @tc.desc: Function test
* @tc.level 0
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0100', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0100";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = context.createBundleContext('com.example.stageappcontexttest')
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/app/el2/100/base/com.example.stageappcontexttest/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0200
* @tc.name: Validating the context obtained by the AbilityContext call
* getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 0
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0200', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0200";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = context.getApplicationContext()
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/storage/el2/base/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0300
* @tc.name: Verify that the AbilityContext call getApplicationContext
* gets the context using resourceManger
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0300', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0300";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = await context.resourceManager.getString(16777219);
console.log(TAG + " result = " + JSON.stringify(result));
expect(result).assertEqual("entry_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0400
* @tc.name: Verify that the AbilityContext call getApplicationContext
* gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0400', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0400";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = context.applicationInfo.name;
console.log(TAG + " result = " + JSON.stringify(result));
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0500
* @tc.name: Validating the context obtained by the AbilityStageContext call
* getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0500', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0500";
console.log(TAG + " --- start");
let context = globalThis.abilityStageContext.getApplicationContext();
let result = context.getApplicationContext()
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/storage/el2/base/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0600
* @tc.name: Verify that the AbilityStageContext call getApplicationContext
* gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0600', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0600";
console.log(TAG + " --- start");
let context = globalThis.abilityStageContext.getApplicationContext();
let result = context.applicationInfo.name;
console.log(TAG + " result = " + JSON.stringify(result));
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0700
* @tc.name: Validating the context obtained by the ExtensionContext call
* getApplicationContext can be obtained using createBundleContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0700', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0700";
console.log(TAG + " --- start");
let context = globalThis.serviceExtenxionAbilityContext.getApplicationContext();
let result = context.createBundleContext('com.example.stageappcontexttest')
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/app/el2/100/base/com.example.stageappcontexttest/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0800
* @tc.name: Validating the context obtained by the ExtensionContext call
* getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0800', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0800";
console.log(TAG + " --- start");
let serviceContext = globalThis.serviceExtenxionAbilityContext.getApplicationContext()
console.log(TAG + "servicecontext" + serviceContext)
let result = serviceContext.getApplicationContext();
console.log(TAG + " result = " + result);
let dir = serviceContext.cacheDir
console.log(TAG + " dir = " + dir);
expect(dir).assertEqual("/data/storage/el2/base/cache");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0900
* @tc.name: Verify that the ExtensionContext call getApplicationContext
* gets the context using resourceManger
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0900', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0900";
console.log(TAG + " --- start");
let serviceContext = globalThis.serviceExtenxionAbilityContext.getApplicationContext();
let result = await serviceContext.resourceManager.getString(16777219);
console.log(TAG + " result = " + result);
expect(result).assertEqual("entry_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1000
* @tc.name: Verify that the ExtensionContext call getApplicationContext
* gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1000', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1000";
console.log(TAG + " --- start");
let serviceContext = globalThis.serviceExtenxionAbilityContext.getApplicationContext();
let result = serviceContext.applicationInfo.name;
console.log(TAG + " result = " + result);
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1100
* @tc.name: Verify that the application-level context call interface
* getApplicationContext gets the context using createBundleContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1100', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1100";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.createBundleContext("com.example.stageappcontexttest");
let dir = result.cacheDir;
console.log(TAG + " dir = " + dir);
expect(dir).assertEqual("/data/app/el2/100/base/com.example.stageappcontexttest/cache");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1200
* @tc.name: Verify that the app-level context calls the interface
* getApplicationContext to get the context using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1200', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1200";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.getApplicationContext();
let dir = result.cacheDir;
console.log(TAG + " dir = " + dir);
expect(dir).assertEqual("/data/storage/el2/base/cache");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1300
* @tc.name: Verify that the context obtained by the application-level
* context calling interface getApplicationContext can use resourceManger
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1300', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1300";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = await context2.resourceManager.getString(16777219);
console.log(TAG + " result = " + result);
expect(result).assertEqual("entry_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1400
* @tc.name: Verify that the application-level context calling interface
* getApplicationContext gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1400', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1400";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.applicationInfo.name;
console.log(TAG + " result = " + result);
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1500
* @tc.name: Verify that the context obtained by the app-level context
* calling interface getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1500', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1500";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.getApplicationContext();
console.log(TAG + " result = " + JSON.stringify(result));
expect(result.tempDir).assertEqual("/data/storage/el2/base/temp");
expect(result.filesDir).assertEqual("/data/storage/el2/base/files");
expect(result.distributedFilesDir).assertEqual("/data/storage/el2/distributedfiles");
expect(result.databaseDir).assertEqual("/data/storage/el2/database");
expect(result.preferencesDir).assertEqual("/data/storage/el2/base/preferences");
expect(result.bundleCodeDir).assertEqual("/data/storage/el1/bundle");
done();
});
})
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/module.json
0 → 100644
浏览文件 @
290a61c1
{
"module"
:
{
"name"
:
"entry_test"
,
"type"
:
"entry"
,
"srcEntrance"
:
"./ets/Application/MyAbilityStage.ts"
,
"description"
:
"$string:entry_test_desc"
,
"mainElement"
:
"MainAbility"
,
"deviceTypes"
:
[
"default"
,
"tablet"
],
"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"
]
}
]
}
],
"extensionAbilities"
:
[
{
"name"
:
"ServiceAbility"
,
"srcEntrance"
:
"./ets/ServiceAbility/ServiceAbility.ts"
,
"label"
:
"$string:form_ServiceAbility_label"
,
"description"
:
"$string:form_ServiceAbility_desc"
,
"type"
:
"service"
}
],
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.START_ABILITIES_FROM_BACKGROUND"
,
"reason"
:
"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
290a61c1
{
"string"
:
[
{
"name"
:
"entry_test_desc"
,
"value"
:
"description"
},
{
"name"
:
"app_name"
,
"value"
:
"ActsStageContextPropertiesTest"
},
{
"name"
:
"description_application"
,
"value"
:
"demo for test"
},
{
"name"
:
"MainAbility_desc"
,
"value"
:
"description"
},
{
"name"
:
"MainAbility_label"
,
"value"
:
"entry_MainAbility"
},
{
"name"
:
"form_ServiceAbility_desc"
,
"value"
:
"form_description"
},
{
"name"
:
"form_ServiceAbility_label"
,
"value"
:
"form_label"
}
]
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
290a61c1
6.6 KB
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/entry/src/main/resources/base/profile/main_pages.json
0 → 100644
浏览文件 @
290a61c1
{
"src"
:
[
"pages/index/index"
,
"pages/second/second"
]
}
\ No newline at end of file
ability/ability_runtime/context/actsstageappcontext/actsstageappcontexttest/signature/openharmony_sx.p7b
0 → 100644
浏览文件 @
290a61c1
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录