Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e38fcb97
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看板
未验证
提交
e38fcb97
编写于
4月 12, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 12, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8406 【master】【杂散】【主题子系统】新增壁纸无权限用例
Merge pull request !8406 from 张育帅/master
上级
bf2e4f97
676648f0
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
1237 addition
and
440 deletion
+1237
-440
theme/BUILD.gn
theme/BUILD.gn
+1
-0
theme/wallpaper_authority_ets/BUILD.gn
theme/wallpaper_authority_ets/BUILD.gn
+39
-0
theme/wallpaper_authority_ets/Test.json
theme/wallpaper_authority_ets/Test.json
+29
-0
theme/wallpaper_authority_ets/entry/src/main/config.json
theme/wallpaper_authority_ets/entry/src/main/config.json
+122
-0
theme/wallpaper_authority_ets/entry/src/main/ets/MainAbility/app.ets
...aper_authority_ets/entry/src/main/ets/MainAbility/app.ets
+33
-0
theme/wallpaper_authority_ets/entry/src/main/ets/MainAbility/pages/index.ets
...hority_ets/entry/src/main/ets/MainAbility/pages/index.ets
+38
-0
theme/wallpaper_authority_ets/entry/src/main/ets/TestAbility/app.ets
...aper_authority_ets/entry/src/main/ets/TestAbility/app.ets
+33
-0
theme/wallpaper_authority_ets/entry/src/main/ets/TestAbility/pages/index.ets
...hority_ets/entry/src/main/ets/TestAbility/pages/index.ets
+50
-0
theme/wallpaper_authority_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...ts/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
theme/wallpaper_authority_ets/entry/src/main/ets/test/List.test.ets
...paper_authority_ets/entry/src/main/ets/test/List.test.ets
+20
-0
theme/wallpaper_authority_ets/entry/src/main/ets/test/wallpaperauthorityTest.ets
...ty_ets/entry/src/main/ets/test/wallpaperauthorityTest.ets
+445
-0
theme/wallpaper_authority_ets/entry/src/main/resources/base/element/string.json
...ity_ets/entry/src/main/resources/base/element/string.json
+20
-0
theme/wallpaper_authority_ets/entry/src/main/resources/base/media/icon.png
...uthority_ets/entry/src/main/resources/base/media/icon.png
+0
-0
theme/wallpaper_authority_ets/signature/ActsWallpapernAuthorityETSApiTest.p7b
...ority_ets/signature/ActsWallpapernAuthorityETSApiTest.p7b
+0
-0
theme/wallpaper_ets/entry/src/main/config.json
theme/wallpaper_ets/entry/src/main/config.json
+1
-26
theme/wallpaper_ets/entry/src/main/ets/test/List.test.ets
theme/wallpaper_ets/entry/src/main/ets/test/List.test.ets
+2
-0
theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets
...e/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets
+0
-414
theme/wallpaper_ets/entry/src/main/ets/test/wallpapernopermissionTest.ets
...ets/entry/src/main/ets/test/wallpapernopermissionTest.ets
+326
-0
theme/wallpaper_ets/signature/ActsWallpaperEtsAPITest.p7b
theme/wallpaper_ets/signature/ActsWallpaperEtsAPITest.p7b
+0
-0
未找到文件。
theme/BUILD.gn
浏览文件 @
e38fcb97
...
...
@@ -16,6 +16,7 @@ group("theme") {
testonly = true
deps = [
"screenlock_ets:ActsScreenLockETSApiTest",
"wallpaper_authority_ets:ActsWallpapernAuthorityETSApiTest",
"wallpaper_ets:ActsWallpaperETSApiTest",
]
}
theme/wallpaper_authority_ets/BUILD.gn
0 → 100644
浏览文件 @
e38fcb97
# 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("//build/ohos.gni")
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsWallpapernAuthorityETSApiTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":wallPaper_ets_assets",
":wallPaper_ets_resources",
":wallPaper_ets_test_assets",
]
ets2abc = true
subsystem_name = "theme"
part_name = "wallpaper_mgr"
certificate_profile = "./signature/ActsWallpapernAuthorityETSApiTest.p7b"
hap_name = "ActsWallpapernAuthorityETSApiTest"
}
ohos_js_assets("wallPaper_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("wallPaper_ets_resources") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("wallPaper_ets_test_assets") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
theme/wallpaper_authority_ets/Test.json
0 → 100644
浏览文件 @
e38fcb97
{
"description"
:
"Configuration for wallpaper js api Tests"
,
"driver"
:
{
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"600000"
,
"bundle-name"
:
"com.acts.theme.wallpaperauthoritytest"
,
"package-name"
:
"com.acts.theme.wallpaperauthoritytest"
,
"shell-timeout"
:
"600000"
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsWallpapernAuthorityETSApiTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
},
{
"type"
:
"PushKit"
,
"pre-push"
:
[
"mount -o rw,remount /"
,
"mkdir -p /data/app/el2/100/base/com.acts.theme.wallpaperauthoritytest/haps"
],
"push"
:
[
"./resource/wallpaper/wp.png ->/data/app/el2/100/base/com.acts.theme.wallpaperauthoritytest/haps/wp.png"
]
}
]
}
theme/wallpaper_authority_ets/entry/src/main/config.json
0 → 100644
浏览文件 @
e38fcb97
{
"app"
:
{
"bundleName"
:
"com.acts.theme.wallpaperauthoritytest"
,
"vendor"
:
"open"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
},
"apiVersion"
:
{
"compatible"
:
7
,
"releaseType"
:
"Release"
,
"target"
:
9
}
},
"deviceConfig"
:
{},
"module"
:
{
"package"
:
"com.acts.theme.wallpaperauthoritytest"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
"com.acts.theme.wallpaperauthoritytest.MainAbility"
,
"deviceType"
:
[
"tablet"
,
"default"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
,
"moduleType"
:
"entry"
,
"installationFree"
:
false
},
"abilities"
:
[
{
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"orientation"
:
"unspecified"
,
"visible"
:
true
,
"srcPath"
:
"MainAbility"
,
"name"
:
".MainAbility"
,
"srcLanguage"
:
"ets"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:description_mainability"
,
"formsEnabled"
:
false
,
"label"
:
"$string:entry_MainAbility"
,
"type"
:
"page"
,
"launchType"
:
"standard"
},
{
"orientation"
:
"unspecified"
,
"visible"
:
true
,
"srcPath"
:
"TestAbility"
,
"name"
:
".TestAbility"
,
"srcLanguage"
:
"ets"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:TestAbility_desc"
,
"formsEnabled"
:
false
,
"label"
:
"$string:TestAbility_label"
,
"type"
:
"page"
,
"launchType"
:
"standard"
}
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.SET_WALLPAPER"
,
"reason"
:
"need use ohos.permission.SET_WALLPAPER"
,
"usedScene"
:
{
"ability"
:
[
"com.acts.theme.wallpapertest.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.GET_WALLPAPER"
,
"reason"
:
"need use ohos.permission.GET_WALLPAPER"
,
"usedScene"
:
{
"ability"
:
[
"com.acts.theme.wallpapertest.MainAbility"
],
"when"
:
"inuse"
}
}
],
"js"
:
[
{
"mode"
:
{
"syntax"
:
"ets"
,
"type"
:
"pageAbility"
},
"pages"
:
[
"pages/index"
],
"name"
:
".MainAbility"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
},
{
"mode"
:
{
"syntax"
:
"ets"
,
"type"
:
"pageAbility"
},
"pages"
:
[
"pages/index"
],
"name"
:
".TestAbility"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
]
}
}
\ No newline at end of file
theme/wallpaper_authority_ets/entry/src/main/ets/MainAbility/app.ets
0 → 100644
浏览文件 @
e38fcb97
// @ts-nocheck
/**
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
export default {
onCreate() {
console.info('Application onCreate');
var abilityDelegator: any;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var abilityDelegatorArguments: any;
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
console.info('start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
},
onDestroy() {
console.info('Application onDestroy');
},
}
\ No newline at end of file
theme/wallpaper_authority_ets/entry/src/main/ets/MainAbility/pages/index.ets
0 → 100644
浏览文件 @
e38fcb97
// @ts-nocheck
/**
* 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 MyComponent {
aboutToAppear() {
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('WALLPAPERNORMAL ETS TEST')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
theme/wallpaper_authority_ets/entry/src/main/ets/TestAbility/app.ets
0 → 100644
浏览文件 @
e38fcb97
// @ts-nocheck
/**
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
export default {
onCreate() {
console.info('Application onCreate');
var abilityDelegator: any;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var abilityDelegatorArguments: any;
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
console.info('start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
},
onDestroy() {
console.info('Application onDestroy');
},
}
\ No newline at end of file
theme/wallpaper_authority_ets/entry/src/main/ets/TestAbility/pages/index.ets
0 → 100644
浏览文件 @
e38fcb97
// @ts-nocheck
/**
* 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 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
theme/wallpaper_authority_ets/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
e38fcb97
// @ts-nocheck
/**
* 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
TestRunner
from
'
@ohos.application.testRunner
'
;
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
;
var
abilityDelegator
=
undefined
;
var
abilityDelegatorArguments
=
undefined
;
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s itName
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s package
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
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
'
);
}
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
);
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
();
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
var
testAbilityName
=
abilityDelegatorArguments
.
parameters
[
'
-p
'
]
+
'
.MainAbility
'
;
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
);
var
cmd
=
'
aa start -d 0 -a
'
+
testAbilityName
+
'
-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 call abilityDelegator.getAppContext
'
);
var
context
=
abilityDelegator
.
getAppContext
();
console
.
info
(
'
getAppContext :
'
+
JSON
.
stringify
(
context
));
console
.
info
(
'
OpenHarmonyTestRunner onRun end
'
);
}
};
\ No newline at end of file
theme/wallpaper_authority_ets/entry/src/main/ets/test/List.test.ets
0 → 100644
浏览文件 @
e38fcb97
/*
* 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 wallpaperAuthorityJSUnit from './wallpaperauthorityTest';
export default function testsuite() {
wallpaperAuthorityJSUnit();
}
\ No newline at end of file
theme/wallpaper_authority_ets/entry/src/main/ets/test/wallpaperauthorityTest.ets
0 → 100644
浏览文件 @
e38fcb97
/*
* 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 wallpaper from '@ohos.wallpaper';
import image from '@ohos.multimedia.image';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
const WALLPAPER_SYSTEM = 0;
const WALLPAPER_LOCKSCREEN = 1;
let imageSourceSystem = '/data/storage/el2/base/haps/wp.png';
let imageSourceLockscreen = '/data/storage/el2/base/haps/wp.png';
export default function wallpaperAuthorityJSUnit() {
describe('wallpaperAuthorityJSUnit', function () {
/*
* @tc.number testGetColorsCallbackSystem101
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsCallbackSystem101', 0, async function (done) {
console.info('--------------testGetColorsCallbackSystem101 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_SYSTEM);
wallpaper.getColors(WALLPAPER_SYSTEM, (err, RgbaColors) => {
try {
if (err) {
console.info('====>testGetColorsCallbackSystem101 fail: ' + JSON.stringify(err));
expect(null).assertFail();
done();
}
console.info('====>testGetColorsCallbackSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
} catch (err) {
console.info('====>testGetColorsCallbackSystem101 catch err: ' + JSON.stringify(err));
done();
};
});
console.info('--------------testGetColorsCallbackSystem101 end-----------------');
});
/*
* @tc.number testGetColorsPromiseSystem101
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsPromiseSystem101', 0, async function (done) {
console.info('--------------testGetColorsPromiseSystem101 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_SYSTEM);
await wallpaper.getColors(WALLPAPER_SYSTEM).then((RgbaColors) => {
console.info('====>testGetColorsPromiseSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
}).catch((err) => {
console.info('====>testGetColorsPromiseSystem101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetColorsPromiseSystem101 end-----------------');
});
/*
* @tc.number testGetColorsCallbackLock102
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsCallbackLock102', 0, async function (done) {
console.info('--------------testGetColorsCallbackLock102 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN);
wallpaper.getColors(WALLPAPER_LOCKSCREEN, (err, RgbaColors) => {
try {
if (err) {
console.info('====>testGetColorsCallbackLock102 fail: ' + JSON.stringify(err));
expect(null).assertFail();
done();
}
console.info('====>testGetColorsCallbackLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
} catch (err) {
console.info('====>testGetColorsCallbackLock102 catch err: ' + JSON.stringify(err));
done();
};
});
console.info('--------------testGetColorsCallbackLock102 end-----------------');
});
/*
* @tc.number testGetColorsPromiseLock102
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsPromiseLock102', 0, async function (done) {
console.info('--------------testGetColorsPromiseLock102 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN);
await wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((RgbaColors) => {
console.info('====>testGetColorsPromiseLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
}).catch((err) => {
console.info('====>testGetColorsPromiseLock102 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetColorsPromiseLock102 end-----------------');
})
/*
* @tc.number testResetCallbackSystem101
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackSystem101', 0, async function (done) {
console.info('--------------testResetCallbackSystem101 start-----------------');
wallpaper.reset(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
console.info('====>testResetCallbackSystem101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('====>testResetCallbackSystem101 successful data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
} catch (err) {
console.info('====>testResetCallbackSystem101 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testResetCallbackSystem101 end-----------------');
});
/*
* @tc.number testResetPromiseSystem101
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseSystem101', 0, async function (done) {
console.info('--------------testResetPromiseSystem101 start-----------------');
await wallpaper.reset(WALLPAPER_SYSTEM).then((data) => {
console.info('====>testResetPromiseSystem101 successful data : ' + JSON.stringify(data));
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testResetPromiseSystem101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testResetPromiseSystem101 end-----------------');
});
/*
* @tc.number testResetCallbackLock102
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackLock102', 0, async function (done) {
console.info('--------------testResetCallbackLock102 start-----------------');
wallpaper.reset(WALLPAPER_LOCKSCREEN, (err, data) => {
try {
if (err) {
console.info('====>testResetCallbackLock102 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('====>testResetCallbackLock102 successful data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
} catch (err) {
console.info('====>testResetCallbackLock102 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testResetCallbackLock102 end-----------------');
});
/*
* @tc.number testResetPromiseLock102
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseLock102', 0, async function (done) {
console.info('--------------testResetPromiseLock102 start-----------------');
await wallpaper.reset(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testResetPromiseLock102 successful data : ' + JSON.stringify(data));
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testResetPromiseLock102 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testResetPromiseLock102 end-----------------');
});
/*
* @tc.number testSetWallpaperURLPromiseLock104
* @tc.name Test setPixelMap() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLPromiseLock104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseLock104 start------------------' );
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testSetWallpaperURLPromiseLock104 successful data : ' + data);
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testSetWallpaperURLPromiseLock104 fail: ' + err);
expect().assertFail();
done();
});
console.info('--------------------testSetWallpaperURLPromiseLock104 end------------------' );
});
/*
* @tc.number testSetWallpaperURLCallbackSystem103
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLCallbackSystem103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackSystem103 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_SYSTEM, (err, data) => {
try{
if (err) {
console.info('====->testSetWallpaperURLCallbackSystem103 err : ' + err);
expect().assertFail();
done();
}
console.info('====>testSetWallpaperURLCallbackSystem103 successful data: ' + data);
expect(true).assertTrue();
done();
}catch(error){
console.info('testSetWallpaperURLCallbackSystem103 catch error: ' + error);
done();
}
});
console.info('--------------------testSetWallpaperURLCallbackSystem103 end------------------' );
});
/*
* @tc.number testSetWallpaperURLPromiseSystem103
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLPromiseSystem103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseSystem103 start------------------' );
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testSetWallpaperURLPromiseSystem103 successful data : ' + data);
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testSetWallpaperURLPromiseSystem103 fail: ' + err);
expect().assertFail();
done();
});
console.info('--------------------testSetWallpaperURLPromiseSystem103 end------------------' );
});
/*
* @tc.number testSetWallpaperURLCallbackLock104
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLCallbackLock104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackLock104 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_LOCKSCREEN, (err, data) => {
try{
if (err) {
console.info('====->testSetWallpaperURLCallbackLock104 err : ' + err);
expect().assertFail();
done();
}
console.info('====>testSetWallpaperURLCallbackLock104 successful data: ' + data);
expect(true).assertTrue();
done();
}catch(error){
console.info('testSetWallpaperURLCallbackLock104 catch error: ' + error);
done();
}
});
console.info('--------------------testSetWallpaperURLCallbackLock104 end------------------' );
});
/*
* @tc.number testOnCallback101
* @tc.name Test on_colorChange to registers a listener for wallpaper color changes to
receive notifications about the changes.
* @tc.desc Function test
* @tc.level 0
*/
it('testOnCallback101', 0, async function (done) {
console.info('--------------testOnCallback101 start-----------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
await wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
try {
wallpaper.on('colorChange', async (colors, wallpaperType) => {
try {
console.info('====>testOnCallback101 colors: ' + JSON.stringify(colors));
console.info('====>testOnCallback101 wallpaperType: ' + JSON.stringify(wallpaperType));
expect(colors != null).assertTrue();
expect(wallpaperType != null).assertTrue();
wallpaper.off('colorChange')
console.info('====>testOnCallback101 off');
done();
} catch (err) {
console.info('====>testOnCallback101 setWallpaper or other err : ' + JSON.stringify(err));
done();
}
});
} catch (err) {
console.info('====>testOnCallback101 catch err : ' + JSON.stringify(err));
done();
}
await wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
console.info('====>testOnCallback10 setWallpaper successful');
console.info('--------------testOnCallback101 end-----------------');
});
/*
* @tc.number testOffCallback101
* @tc.name Test on_colorChange to registers a listener for wallpaper color changes to
receive notifications about the changes.
* @tc.desc Function test
* @tc.level 0
*/
it('testOffCallback101', 0, async function (done) {
console.info('--------------testOffCallback101 start-----------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
let callbackTimes = 0;
await wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM)
try {
wallpaper.on('colorChange', async (colors, wallpaperType) => {
try {
console.info('====>testOffCallback101 colors: ' + JSON.stringify(colors));
console.info('====>testOffCallback101 wallpaperType: ' + JSON.stringify(wallpaperType));
callbackTimes = callbackTimes + 1;
console.info('====>testOffCallback101 on callbackTime: ' + callbackTimes);
expect(callbackTimes == 1).assertTrue();
wallpaper.off('colorChange');
await wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
await wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
console.info('====>testOffCallback101 setWallpaper successful');
console.info('--------------testOffCallback101 end-----------------');
done();
} catch (err) {
console.info('====>testOffCallback101 setWallpaper or other err : ' + JSON.stringify(err));
done();
}
});
} catch (err) {
console.info('====>testOffCallback101 catch err : ' + JSON.stringify(err));
done();
}
await wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM)
});
/*
* @tc.number testGetFileCallback101
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFileCallback101', 0, async function (done) {
console.info('--------------testGetFileCallback101 start-----------------');
wallpaper.getFile(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
console.info('====>testGetFileCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('====>testGetFileCallback101 successful data: ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
} catch (err) {
console.info('====>testGetFileCallback101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetFileCallback101 end-----------------');
});
/*
* @tc.number testGetFilePromise101
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFilePromise101', 0, async function (done) {
console.info('--------------testGetFilePromise101 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN);
await wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testGetFilePromise101 successful data : ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
}).catch((err) => {
console.info('====>testGetFilePromise101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetFilePromise101 end-----------------');
});
});
};
theme/wallpaper_authority_ets/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
e38fcb97
{
"string"
:
[
{
"name"
:
"entry_MainAbility"
,
"value"
:
"ActsWallpapernAuthorityETSApiTest"
},
{
"name"
:
"description_mainability"
,
"value"
:
"ETS_Empty Ability"
},
{
"name"
:
"TestAbility_desc"
,
"value"
:
"description"
},
{
"name"
:
"TestAbility_label"
,
"value"
:
"label"
}
]
}
\ No newline at end of file
theme/wallpaper_authority_ets/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
e38fcb97
6.6 KB
theme/wallpaper_authority_ets/signature/ActsWallpapernAuthorityETSApiTest.p7b
0 → 100644
浏览文件 @
e38fcb97
文件已添加
theme/wallpaper_ets/entry/src/main/config.json
浏览文件 @
e38fcb97
...
...
@@ -20,10 +20,7 @@
"deviceType"
:
[
"tablet"
,
"default"
,
"phone"
,
"tv"
,
"wearable"
"default"
],
"distro"
:
{
"deliveryWithInstall"
:
true
,
...
...
@@ -69,28 +66,6 @@
"launchType"
:
"standard"
}
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.SET_WALLPAPER"
,
"reason"
:
"need use ohos.permission.SET_WALLPAPER"
,
"usedScene"
:
{
"ability"
:
[
"com.acts.theme.wallpapertest.MainAbility"
],
"when"
:
"inuse"
}
},
{
"name"
:
"ohos.permission.GET_WALLPAPER"
,
"reason"
:
"need use ohos.permission.GET_WALLPAPER"
,
"usedScene"
:
{
"ability"
:
[
"com.acts.theme.wallpapertest.MainAbility"
],
"when"
:
"inuse"
}
}
],
"js"
:
[
{
"mode"
:
{
...
...
theme/wallpaper_ets/entry/src/main/ets/test/List.test.ets
浏览文件 @
e38fcb97
...
...
@@ -14,7 +14,9 @@
*/
import wallpaperJSUnit from './wallpaperTest';
import wallpaperNoPermissionTest from './wallpapernopermissionTest';
export default function testsuite() {
wallpaperJSUnit();
wallpaperNoPermissionTest();
}
\ No newline at end of file
theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets
浏览文件 @
e38fcb97
...
...
@@ -54,114 +54,6 @@ export default function wallpaperJSUnit() {
console.info('--------------testWALLPAPER_LOCKSCREEN end-----------------');
});
/*
* @tc.number testGetColorsCallbackSystem101
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsCallbackSystem101', 0, async function (done) {
console.info('--------------testGetColorsCallbackSystem101 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_SYSTEM);
wallpaper.getColors(WALLPAPER_SYSTEM, (err, RgbaColors) => {
try {
if (err) {
console.info('====>testGetColorsCallbackSystem101 fail: ' + JSON.stringify(err));
expect(null).assertFail();
done();
}
console.info('====>testGetColorsCallbackSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
} catch (err) {
console.info('====>testGetColorsCallbackSystem101 catch err: ' + JSON.stringify(err));
done();
};
});
console.info('--------------testGetColorsCallbackSystem101 end-----------------');
});
/*
* @tc.number testGetColorsPromiseSystem101
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsPromiseSystem101', 0, async function (done) {
console.info('--------------testGetColorsPromiseSystem101 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_SYSTEM);
await wallpaper.getColors(WALLPAPER_SYSTEM).then((RgbaColors) => {
console.info('====>testGetColorsPromiseSystem101 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
}).catch((err) => {
console.info('====>testGetColorsPromiseSystem101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetColorsPromiseSystem101 end-----------------');
});
/*
* @tc.number testGetColorsCallbackLock102
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsCallbackLock102', 0, async function (done) {
console.info('--------------testGetColorsCallbackLock102 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN);
wallpaper.getColors(WALLPAPER_LOCKSCREEN, (err, RgbaColors) => {
try {
if (err) {
console.info('====>testGetColorsCallbackLock102 fail: ' + JSON.stringify(err));
expect(null).assertFail();
done();
}
console.info('====>testGetColorsCallbackLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
} catch (err) {
console.info('====>testGetColorsCallbackLock102 catch err: ' + JSON.stringify(err));
done();
};
});
console.info('--------------testGetColorsCallbackLock102 end-----------------');
});
/*
* @tc.number testGetColorsPromiseLock102
* @tc.name Test getColors() to obtains the wallpaper colors for the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetColorsPromiseLock102', 0, async function (done) {
console.info('--------------testGetColorsPromiseLock102 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN);
await wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((RgbaColors) => {
console.info('====>testGetColorsPromiseLock102 succesful RgbaColors: ' + JSON.stringify(RgbaColors));
expect(Number.isInteger(RgbaColors[0].red)).assertTrue();
expect(Number.isInteger(RgbaColors[0].green)).assertTrue();
expect(Number.isInteger(RgbaColors[0].blue)).assertTrue();
expect(Number.isInteger(RgbaColors[0].alpha)).assertTrue();
done();
}).catch((err) => {
console.info('====>testGetColorsPromiseLock102 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetColorsPromiseLock102 end-----------------');
})
/*
* @tc.number testGetIdCallbackSystem101
* @tc.name Test getId() to the ID of the wallpaper of the specified type.
...
...
@@ -442,313 +334,7 @@ export default function wallpaperJSUnit() {
console.info('--------------testIsOperationAllowedPromise101 end-----------------');
});
/*
* @tc.number testResetCallbackSystem101
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackSystem101', 0, async function (done) {
console.info('--------------testResetCallbackSystem101 start-----------------');
wallpaper.reset(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
console.info('====>testResetCallbackSystem101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('====>testResetCallbackSystem101 successful data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
} catch (err) {
console.info('====>testResetCallbackSystem101 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testResetCallbackSystem101 end-----------------');
});
/*
* @tc.number testResetPromiseSystem101
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseSystem101', 0, async function (done) {
console.info('--------------testResetPromiseSystem101 start-----------------');
await wallpaper.reset(WALLPAPER_SYSTEM).then((data) => {
console.info('====>testResetPromiseSystem101 successful data : ' + JSON.stringify(data));
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testResetPromiseSystem101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testResetPromiseSystem101 end-----------------');
});
/*
* @tc.number testResetCallbackLock102
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackLock102', 0, async function (done) {
console.info('--------------testResetCallbackLock102 start-----------------');
wallpaper.reset(WALLPAPER_LOCKSCREEN, (err, data) => {
try {
if (err) {
console.info('====>testResetCallbackLock102 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('====>testResetCallbackLock102 successful data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
} catch (err) {
console.info('====>testResetCallbackLock102 catch err : ' + JSON.stringify(err));
done();
}
})
console.info('--------------testResetCallbackLock102 end-----------------');
});
/*
* @tc.number testResetPromiseLock102
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseLock102', 0, async function (done) {
console.info('--------------testResetPromiseLock102 start-----------------');
await wallpaper.reset(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testResetPromiseLock102 successful data : ' + JSON.stringify(data));
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testResetPromiseLock102 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testResetPromiseLock102 end-----------------');
});
/*
* @tc.number testSetWallpaperURLPromiseLock104
* @tc.name Test setPixelMap() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLPromiseLock104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseLock104 start------------------' );
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testSetWallpaperURLPromiseLock104 successful data : ' + data);
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testSetWallpaperURLPromiseLock104 fail: ' + err);
expect().assertFail();
done();
});
console.info('--------------------testSetWallpaperURLPromiseLock104 end------------------' );
});
/*
* @tc.number testSetWallpaperURLCallbackSystem103
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLCallbackSystem103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackSystem103 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_SYSTEM, (err, data) => {
try{
if (err) {
console.info('====->testSetWallpaperURLCallbackSystem103 err : ' + err);
expect().assertFail();
done();
}
console.info('====>testSetWallpaperURLCallbackSystem103 successful data: ' + data);
expect(true).assertTrue();
done();
}catch(error){
console.info('testSetWallpaperURLCallbackSystem103 catch error: ' + error);
done();
}
});
console.info('--------------------testSetWallpaperURLCallbackSystem103 end------------------' );
});
/*
* @tc.number testSetWallpaperURLPromiseSystem103
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLPromiseSystem103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseSystem103 start------------------' );
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testSetWallpaperURLPromiseSystem103 successful data : ' + data);
expect(true).assertTrue();
done();
}).catch((err) => {
console.info('====>testSetWallpaperURLPromiseSystem103 fail: ' + err);
expect().assertFail();
done();
});
console.info('--------------------testSetWallpaperURLPromiseSystem103 end------------------' );
});
/*
* @tc.number testSetWallpaperURLCallbackLock104
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLCallbackLock104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackLock104 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_LOCKSCREEN, (err, data) => {
try{
if (err) {
console.info('====->testSetWallpaperURLCallbackLock104 err : ' + err);
expect().assertFail();
done();
}
console.info('====>testSetWallpaperURLCallbackLock104 successful data: ' + data);
expect(true).assertTrue();
done();
}catch(error){
console.info('testSetWallpaperURLCallbackLock104 catch error: ' + error);
done();
}
});
console.info('--------------------testSetWallpaperURLCallbackLock104 end------------------' );
});
/*
* @tc.number testOnCallback101
* @tc.name Test on_colorChange to registers a listener for wallpaper color changes to
receive notifications about the changes.
* @tc.desc Function test
* @tc.level 0
*/
it('testOnCallback101', 0, async function (done) {
console.info('--------------testOnCallback101 start-----------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
await wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
try {
wallpaper.on('colorChange', async (colors, wallpaperType) => {
try {
console.info('====>testOnCallback101 colors: ' + JSON.stringify(colors));
console.info('====>testOnCallback101 wallpaperType: ' + JSON.stringify(wallpaperType));
expect(colors != null).assertTrue();
expect(wallpaperType != null).assertTrue();
wallpaper.off('colorChange')
console.info('====>testOnCallback101 off');
done();
} catch (err) {
console.info('====>testOnCallback101 setWallpaper or other err : ' + JSON.stringify(err));
done();
}
});
} catch (err) {
console.info('====>testOnCallback101 catch err : ' + JSON.stringify(err));
done();
}
await wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
console.info('====>testOnCallback10 setWallpaper successful');
console.info('--------------testOnCallback101 end-----------------');
});
/*
* @tc.number testOffCallback101
* @tc.name Test on_colorChange to registers a listener for wallpaper color changes to
receive notifications about the changes.
* @tc.desc Function test
* @tc.level 0
*/
it('testOffCallback101', 0, async function (done) {
console.info('--------------testOffCallback101 start-----------------');
let wallpaperPath = "/data/storage/el2/base/haps/wp.png";
let callbackTimes = 0;
await wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM)
try {
wallpaper.on('colorChange', async (colors, wallpaperType) => {
try {
console.info('====>testOffCallback101 colors: ' + JSON.stringify(colors));
console.info('====>testOffCallback101 wallpaperType: ' + JSON.stringify(wallpaperType));
callbackTimes = callbackTimes + 1;
console.info('====>testOffCallback101 on callbackTime: ' + callbackTimes);
expect(callbackTimes == 1).assertTrue();
wallpaper.off('colorChange');
await wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
await wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN)
console.info('====>testOffCallback101 setWallpaper successful');
console.info('--------------testOffCallback101 end-----------------');
done();
} catch (err) {
console.info('====>testOffCallback101 setWallpaper or other err : ' + JSON.stringify(err));
done();
}
});
} catch (err) {
console.info('====>testOffCallback101 catch err : ' + JSON.stringify(err));
done();
}
await wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM)
});
/*
* @tc.number testGetFileCallback101
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFileCallback101', 0, async function (done) {
console.info('--------------testGetFileCallback101 start-----------------');
wallpaper.getFile(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
console.info('====>testGetFileCallback101 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
console.info('====>testGetFileCallback101 successful data: ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
} catch (err) {
console.info('====>testGetFileCallback101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetFileCallback101 end-----------------');
});
/*
* @tc.number testGetFilePromise101
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFilePromise101', 0, async function (done) {
console.info('--------------testGetFilePromise101 start-----------------');
await wallpaper.setWallpaper(imageSourceLockscreen, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN);
await wallpaper.getFile(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('====>testGetFilePromise101 successful data : ' + JSON.stringify(data));
expect(Number.isInteger(data)).assertTrue();
done();
}).catch((err) => {
console.info('====>testGetFilePromise101 err : ' + JSON.stringify(err));
expect().assertFail();
done();
});
console.info('--------------testGetFilePromise101 end-----------------');
});
});
};
theme/wallpaper_ets/entry/src/main/ets/test/wallpapernopermissionTest.ets
0 → 100644
浏览文件 @
e38fcb97
/*
* 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 wallpaper from '@ohos.wallpaper';
import image from '@ohos.multimedia.image';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
const WALLPAPER_SYSTEM = 0;
const WALLPAPER_LOCKSCREEN = 1;
let imageSourceSystem = '/data/storage/el2/base/haps/wp.png';
let imageSourceLockscreen = '/data/storage/el2/base/haps/wp.png';
export default function wallpaperNoPermissionJSUnit() {
describe('wallpaperNoPermissionTest', function () {
/*
* @tc.number testResetCallbackSystemNoPermission101
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackSystemNoPermission101', 0, async function (done) {
console.info('--------------testResetCallbackSystemNoPermission101 start-----------------');
wallpaper.reset(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
console.info('====>testResetCallbackSystemNoPermission101 NoPermission check: ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
done();
}else {
console.info('====>testResetCallbackSystemNoPermission101 error: ' + JSON.stringify(data));
expect().assertFail();
done();
}
} catch (err) {
console.info('====>testResetCallbackSystemNoPermission101 catch err : ' + JSON.stringify(err));
done();
console.info('--------------testResetCallbackSystemNoPermission101 end-----------------');
}
})
});
/*
* @tc.number testResetPromiseSystemNoPermission101
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseSystemNoPermission101', 0, async function (done) {
console.info('--------------testResetPromiseSystemNoPermission101 start-----------------');
try{
console.info('====>testResetPromiseSystemNoPermission101 NoPermission check');
await wallpaper.reset(WALLPAPER_SYSTEM);
expect().assertFail();
done();
}catch(err){
console.info('====>testResetPromiseSystemNoPermission101 err : ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
expect(err.message).assertContain("async call failed");
done();
console.info('--------------testResetPromiseSystemNoPermission101 end-----------------');
}
});
/*
* @tc.number testResetCallbackLockNoPermission102
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackLockNoPermission102', 0, async function (done) {
console.info('--------------testResetCallbackLockNoPermission102 start-----------------');
wallpaper.reset(WALLPAPER_LOCKSCREEN, (err, data) => {
try {
if (err) {
console.info('====>testResetCallbackLockNoPermission102 NoPermission check: ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
done();
}else {
console.info('====>testResetCallbackLockNoPermission102 error: ' + JSON.stringify(data));
expect().assertFail();
done();
}
} catch (err) {
console.info('====>testResetCallbackLockNoPermission102 catch err : ' + JSON.stringify(err));
done();
console.info('--------------testResetCallbackLockNoPermission102 end-----------------');
}
})
});
/*
* @tc.number testResetPromiseLockNoPermission102
* @tc.name Test reset() to removes a wallpaper of the specified type and reset the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseLockNoPermission102', 0, async function (done) {
console.info('--------------testResetPromiseLockNoPermission102 start-----------------');
try{
console.info('====>testResetPromiseLockNoPermission102 NoPermission check');
await wallpaper.reset(WALLPAPER_LOCKSCREEN);
expect().assertFail();
done();
}catch(err){
console.info('====>testResetPromiseLockNoPermission102 err : ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
expect(err.message).assertContain("async call failed");
done();
console.info('--------------testResetPromiseLockNoPermission102 end-----------------');
}
});
/*
* @tc.number testSetWallpaperURLPromiseLockNoPermission104
* @tc.name Test setPixelMap() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLPromiseLockNoPermission104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseLockNoPermission104 start------------------' );
try{
console.info('====>testSetWallpaperURLPromiseLockNoPermission104 NoPermission check');
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_LOCKSCREEN);
expect().assertFail();
done();
}catch(err){
console.info('====>testSetWallpaperURLPromiseLockNoPermission104 err : ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
expect(err.message).assertContain("async call failed");
done();
console.info('--------------testSetWallpaperURLPromiseLockNoPermission104 end-----------------');
}
});
/*
* @tc.number testSetWallpaperURLCallbackSystemNoPermission103
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLCallbackSystemNoPermission103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackSystemNoPermission103 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_SYSTEM, (err, data) => {
try{
if (err) {
console.info('====->testSetWallpaperURLCallbackSystemNoPermission103 NoPermission check: ' + err);
expect(err.code).assertEqual(undefined);
done();
}else{
console.info('====>testSetWallpaperURLCallbackSystemNoPermission103 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
}catch(error){
console.info('testSetWallpaperURLCallbackSystemNoPermission103 catch error: ' + error);
done();
console.info('--------------------testSetWallpaperURLCallbackSystemNoPermission103 end------------------' );
}
});
});
/*
* @tc.number testSetWallpaperURLPromiseSystemNoPermission103
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLPromiseSystemNoPermission103', 0, async function (done) {
console.info('--------------------testSetWallpaperURLPromiseSystemNoPermission103 start------------------' );
try{
console.info('====>testSetWallpaperURLPromiseSystemNoPermission103 NoPermission check');
await wallpaper.setWallpaper(imageSourceLockscreen, WALLPAPER_SYSTEM);
expect().assertFail();
done();
}catch(err){
console.info('====>testSetWallpaperURLPromiseSystemNoPermission103 err : ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
expect(err.message).assertContain("async call failed");
done();
console.info('--------------testSetWallpaperURLPromiseSystemNoPermission103 end-----------------');
}
});
/*
* @tc.number testSetWallpaperURLCallbackLockNoPermission104
* @tc.name Test setWallpaper() to sets a wallpaper of the specified type based on the uri path from a
JPEG or PNG file or the pixel map of a PNG file.
* @tc.desc Function test
* @tc.level 0
*/
it('testSetWallpaperURLCallbackLockNoPermission104', 0, async function (done) {
console.info('--------------------testSetWallpaperURLCallbackLockNoPermission104 start------------------' );
wallpaper.setWallpaper(imageSourceSystem, WALLPAPER_LOCKSCREEN, (err, data) => {
try{
if (err) {
console.info('====->testSetWallpaperURLCallbackLockNoPermission104 NoPermission check: ' + err);
expect(err.code).assertEqual(undefined);
done();
}else{
console.info('====>testSetWallpaperURLCallbackLockNoPermission104 fail: ' + JSON.stringify(err));
expect().assertFail();
done();
}
}catch(error){
console.info('testSetWallpaperURLCallbackLockNoPermission104 catch error: ' + error);
done();
console.info('--------------------testSetWallpaperURLCallbackLockNoPermission104 end------------------' );
}
});
});
/*
* @tc.number testGetFileCallbackNoPermission101
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFileCallbackNoPermission101', 0, async function (done) {
console.info('--------------testGetFileCallbackNoPermission101 start-----------------');
wallpaper.getFile(WALLPAPER_SYSTEM, (err, data) => {
try {
if (err) {
console.info('====>testGetFileCallbackNoPermission101 NoPermission check: ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
done();
}else{
console.info('====>testGetFileCallbackNoPermission101 fail: ' + JSON.stringify(data));
expect().assertFail();
done();
}
} catch (err) {
console.info('====>testGetFileCallbackNoPermission101 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetFileCallbackNoPermission101 end-----------------');
});
/*
* @tc.number testGetFilePromiseNoPermission101
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFilePromiseNoPermission101', 0, async function (done) {
console.info('--------------testGetFilePromiseNoPermission101 start-----------------');
try{
console.info('====>testGetFilePromiseNoPermission101 NoPermission check');
await wallpaper.getFile(WALLPAPER_LOCKSCREEN);
expect().assertFail();
done();
}catch(err){
console.info('====>testGetFilePromiseNoPermission101 err : ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
expect(err.message).assertContain("async call failed");
done();
console.info('--------------testGetFilePromiseNoPermission101 end-----------------');
}
});
/*
* @tc.number testGetFileCallbackNoPermission102
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFileCallbackNoPermission102', 0, async function (done) {
console.info('--------------testGetFileCallbackNoPermission102 start-----------------');
wallpaper.getFile(WALLPAPER_LOCKSCREEN, (err, data) => {
try {
if (err) {
console.info('====>testGetFileCallbackNoPermission102 NoPermission check: ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
done();
}else{
console.info('====>testGetFileCallbackNoPermission102 fail: ' + JSON.stringify(data));
expect().assertFail();
done();
}
} catch (err) {
console.info('====>testGetFileCallbackNoPermission102 catch err : ' + JSON.stringify(err));
done();
}
});
console.info('--------------testGetFileCallbackNoPermission102 end-----------------');
});
/*
* @tc.number testGetFilePromiseNoPermission102
* @tc.name Obtains a file of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetFilePromiseNoPermission102', 0, async function (done) {
console.info('--------------testGetFilePromiseNoPermission102 start-----------------');
try{
console.info('====>testGetFilePromiseNoPermission102 NoPermission check');
await wallpaper.getFile(WALLPAPER_SYSTEM);
expect().assertFail();
done();
}catch(err){
console.info('====>testGetFilePromiseNoPermission102 err : ' + JSON.stringify(err));
expect(err.code).assertEqual(undefined);
expect(err.message).assertContain("async call failed");
done();
console.info('--------------testGetFilePromiseNoPermission102 end-----------------');
}
});
});
};
theme/wallpaper_ets/signature/ActsWallpaperEtsAPITest.p7b
浏览文件 @
e38fcb97
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录