提交 6a36759d 编写于 作者: G gaoxi

misc锁屏、壁纸

Signed-off-by: Ngaoxi <gaoxi785@huawei.com>
上级 d02421dc
......@@ -20,5 +20,7 @@ group("miscservices") {
"TimeTest_js:ActsTimeJSApiTest",
"TimerTest_js:ActsTimerJSApiTest",
"actspasteboardjsapitest:ActsPasteBoardJSApiTest",
"screenlock_js:ActsScreenLockJSApiTest",
"wallpaper_js:ActsWallpaperJSApiTest",
]
}
......@@ -17,7 +17,6 @@ import inputmethodEngineJsunit from './InputmethodEngineJsunit.test.ets';
import inputRequestJsunit from './InputRequestJsunit.test.ets';
import requestJsunit from './RequestJsunit.test.ets';
import requestDownloadJsunit from './RequestDownloadTaskJsunit.test.ets';
import screenLockJsunit from './ScreenLockJsunit.test.ets';
export default function testsuite() {
inputmethohJsunit();
......@@ -25,5 +24,4 @@ export default function testsuite() {
inputRequestJsunit();
requestDownloadJsunit();
requestJsunit();
screenLockJsunit();
}
\ No newline at end of file
// @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 {describe, it, expect} from 'hypium/index';
import screenLock from '@ohos.screenLock';
export default function screenLockJsunit() {
describe('screenLockTest', function () {
console.log("************* screenLock Test start*************");
/*
* @tc.number : MiscServices_ScreenLock_isScreenLocked_0100
* @tc.name : isScreenLocked
* @tc.desc : Checks whether the screen is currently locked.
*/
it('MiscServices_ScreenLock_isScreenLocked_0100', 0, async function (done) {
let caseName = "MiscServices_ScreenLock_isScreenLocked_0100";
try {
screenLock.isScreenLocked((error, data) => {
if (error) {
console.error(caseName + 'Operation failed. Cause:' + JSON.stringify(error));
return;
}
console.info(caseName + 'Operation successful. Data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
})
} catch (err) {
console.info(caseName + 'catch error: ' + err);
expect(true).assertTrue();
done();
}
done();
});
/*
* @tc.number : MiscServices_ScreenLock_isScreenLocked_0200
* @tc.name : isScreenLocked
* @tc.desc : Checks whether the screen is currently locked.
*/
it('MiscServices_ScreenLock_isScreenLocked_0200', 0, async function (done) {
let caseName = "MiscServices_ScreenLock_isScreenLocked_0200";
try {
screenLock.isScreenLocked().then((data) => {
console.info(caseName + 'Operation successful. Data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
}).catch((error) => {
console.error(caseName + 'Operation failed. Cause: ' + JSON.stringify(error));
done();
})
} catch (err) {
console.info(caseName + 'catch error: ' + err);
expect(true).assertTrue();
done();
}
done();
});
/*
* @tc.number : MiscServices_ScreenLock_isSecureMode_0100
* @tc.name : isSecureMode
* @tc.desc : Checks whether the screen lock of the current device is secure.
*/
it('MiscServices_ScreenLock_isSecureMode_0100', 0, async function (done) {
let caseName = "MiscServices_ScreenLock_isSecureMode_0100";
try {
screenLock.isSecureMode((error, data) => {
if (error) {
console.error(caseName + 'Operation failed. Cause:' + JSON.stringify(error));
return;
}
console.info(caseName + 'Operation successful. Data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
})
} catch (err) {
console.info(caseName + 'catch error: ' + err);
expect(true).assertTrue();
done();
}
done();
});
/*
* @tc.number : MiscServices_ScreenLock_isSecureMode_0200
* @tc.name : isSecureMode
* @tc.desc : Checks whether the screen lock of the current device is secure.
*/
it('MiscServices_ScreenLock_isSecureMode_0200', 0, async function (done) {
let caseName = "MiscServices_ScreenLock_isSecureMode_0200";
try {
screenLock.isSecureMode().then((data) => {
console.info(caseName + 'Operation successful. Data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
}).catch((error) => {
console.error(caseName + 'Operation failed. Cause: ' + JSON.stringify(error));
done();
})
} catch (err) {
console.info(caseName + 'catch error: ' + err);
expect(true).assertTrue();
done();
}
done();
});
/*
* @tc.number : MiscServices_ScreenLock_unlockScreen_0100
* @tc.name : unlockScreen
* @tc.desc : Unlocks the screen.
*/
it('MiscServices_ScreenLock_unlockScreen_0100', 0, async function (done) {
let caseName = "MiscServices_ScreenLock_unlockScreen_0100"
try {
screenLock.unlockScreen((error, data) => {
if (error) {
console.error(caseName + 'Operation failed. Cause:' + JSON.stringify(error));
return;
}
console.info(caseName + 'Operation successful. Data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
})
} catch (err) {
console.info(caseName + 'catch error: ' + err);
expect(true).assertTrue();
done();
}
done();
});
/*
* @tc.number : MiscServices_ScreenLock_unlockScreen_0200
* @tc.name : unlockScreen
* @tc.desc : Unlocks the screen.
*/
it('MiscServices_ScreenLock_unlockScreen_0200', 0, async function (done) {
let caseName = "MiscServices_ScreenLock_unlockScreen_0200";
try {
screenLock.unlockScreen().then((data) => {
console.info(caseName + 'Operation successful. Data: ' + JSON.stringify(data));
expect(true).assertTrue();
done();
}).catch((error) => {
console.error(caseName + 'Operation failed. Cause: ' + JSON.stringify(error));
done();
})
} catch (err) {
console.info(caseName + 'catch error: ' + err);
expect(true).assertTrue();
done();
}
done();
});
}
\ No newline at end of file
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsScreenLockJSApiTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsScreenLockJSApiTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for screenlock js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.ohos.screenlock",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsScreenLockJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.screenlock",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 8,
"target": 8,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.screenlock",
"name": ".MyApplication",
"deviceType": [
"phone",
"tablet",
"tv",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "com.ohos.screenlock.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
/*
* 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.title {
font-size: 40px;
background-color: green;
color: #000000;
opacity: 0.9;
}
.button{
margin-top: 50px;
background-color: green;
font-size: 25px;
color: white;
padding: 10px;
}
<!--
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.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 app from '@system.app'
import file from '@system.file'
import {Core} from 'deccjsunit/index'
export default {
data: {title: ""},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./screenlock_service_test.js');
require('./screenlock_service_test_promise.js');
// @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 screenLock from '@ohos.app.screenlockability';
import {describe, expect, it} from 'deccjsunit/index'
const SCREEN_STATE_BEGIN_OFF = 0;
const SCREEN_STATE_END_OFF = 1;
const SCREEN_STATE_BEGIN_ON = 2;
const SCREEN_STATE_END_ON = 3;
const INTERACTIVE_STATE_END_SLEEP = 0;
const INTERACTIVE_STATE_BEGIN_WAKEUP = 1;
const INTERACTIVE_STATE_END_WAKEUP = 2;
const INTERACTIVE_STATE_BEGIN_SLEEP = 3;
const SLEEP_TIME = 1000;
describe('ScreenLockServiceTest', function () {
console.log("-----------------------ScreenlockTest is starting-----------------------");
function sleep(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
/*
* @tc.number ScreenLock_Test_0100
* @tc.name Set to locked screen, query the lock screen state is locked state
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_0100", 0, async function (done) {
console.info("------------------start ScreenLock_Test_0100-------------------");
try {
var isScreenLocked = true;
screenLock.test_setScreenLocked(isScreenLocked, (err, data) => {
console.log("ScreenLock_Test_0100 test_setScreenLocked data is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => {
console.log("ScreenLock_Test_0100 isScreenLocked's status is " + data);
expect(data == true).assertTrue();
done();
});
} catch (error) {
console.log("logMessage ScreenLock_Test_0100: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_0100-------------------");
});
/*
* @tc.number ScreenLock_Test_0200
* @tc.name Set to unlocked screen, query the lock screen state is unlocked state
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_0200", 0, async function (done) {
console.info("------------------start ScreenLock_Test_0200-------------------");
try {
var isScreenLocked = false;
screenLock.test_setScreenLocked(isScreenLocked, (err, data) => {
console.log("ScreenLock_Test_0200 test_setScreenLocked data is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => {
console.log("ScreenLock_Test_0200 isScreenLocked's status is " + data);
expect(data == false).assertTrue();
});
var resetIsScreenLocked = true;
screenLock.test_setScreenLocked(resetIsScreenLocked, (err, data) => {
console.log("ScreenLock_Test_0200 test_setScreenLocked data is " + data);
expect(data == true).assertTrue();
done();
});
} catch (error) {
console.log("logMessage ScreenLock_Test_0200: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_0200-------------------");
});
/*
* @tc.number ScreenLock_Test_0300
* @tc.name Query whether a password has been set, and return the password that has not been set
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_0300", 0, async function (done) {
console.info("------------------start ScreenLock_Test_0300-------------------");
try {
screenLock.isSecureMode((err, data) => {
console.log("ScreenLock_Test_0300 isSecureMode's result is " + data);
expect(data == false).assertTrue();
done();
});
} catch (error) {
console.log("logMessage ScreenLock_Test_0300: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_0300-------------------");
});
/*
* @tc.number Screenlock_Test_0400
* @tc.name Request to unlock the device screen, unlock successfully
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_0400", 0, async function (done) {
console.info("------------------start Screenlock_Test_0400-------------------");
try {
var isScreenLocked = true;
screenLock.test_setScreenLocked(isScreenLocked, (err, data) => {
console.log("Screenlock_Test_0400: test_setScreenLocked setting " + data + " result is successfull");
});
sleep(SLEEP_TIME);
screenLock.unlockScreen(() => {
console.log("Screenlock_Test_0400: send unlockScreen issue success");
});
sleep(SLEEP_TIME);
var unlockScreenResult = 0;
var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => {
console.log("Screenlock_Test_0400: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_0400: isScreenLocked result is " + data);
expect(data == false).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.test_setScreenLocked(isScreenLocked, (err, data) => {
console.log("Screenlock_Test_0400: test_setScreenLocked setting " + data + " result is successfull");
done();
});
} catch (error) {
console.info("Screenlock_Test_1400: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end Screenlock_Test_0400-------------------");
});
/*
* @tc.number Screenlock_Test_0500
* @tc.name Request to unlock device screen, unlock failed
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_0500", 0, async function (done) {
console.info("------------------start Screenlock_Test_0500-------------------");
try {
var isScreenLocked = true;
screenLock.test_setScreenLocked(isScreenLocked, (err, data) => {
console.log("Screenlock_Test_0500: test_setScreenLocked setting " + data + " result is successfull");
});
sleep(SLEEP_TIME);
screenLock.unlockScreen(() => {
console.log("Screenlock_Test_0500: send unlockScreen issue success");
});
sleep(SLEEP_TIME);
var unlockScreenResult = 1;
var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => {
console.log("Screenlock_Test_0500: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_0500: isScreenLocked result is " + data);
expect(data == true).assertTrue();
done();
});
} catch (error) {
console.info("logMessage Screenlock_Test_0500: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end Screenlock_Test_0500-------------------");
});
/*
* @tc.number Screenlock_Test_2100
* @tc.name After the systemUI is started, it is in the locked state, the lock management sends
the unlock request successfully, and the lock screen application notifies the unlock
success message
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2100", 0, async function (done) {
console.info("------------------start Screenlock_Test_2100-------------------");
try {
screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2100: isScreenLocked result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.unlockScreen(() => {
console.log("Screenlock_Test_2100: send unlockScreen issue success");
});
sleep(SLEEP_TIME);
var unlockScreenResult = 0;
var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => {
console.log("Screenlock_Test_2100: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2100: isScreenLocked result is " + data);
expect(data == false).assertTrue();
});
sleep(SLEEP_TIME);
var isScreenLockedValue = true;
screenLock.test_setScreenLocked(isScreenLockedValue, (err, data) => {
console.log("Screenlock_Test_2100: test_setScreenLocked setting " + data + " result is successfull");
done();
});
} catch (error) {
console.info("Screenlock_Test_2100: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end Screenlock_Test_2100-------------------");
});
/*
* @tc.number Screenlock_Test_2200
* @tc.name After systemUI is started, it is currently unlocked
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2200", 0, async function (done) {
console.log("------------------start Screenlock_Test_2200-------------------");
try {
var isScreenlockedValue = false;
screenLock.test_setScreenLocked(isScreenlockedValue, (err, data) => {
console.log("Screenlock_Test_2200: test_setScreenLocked is successful,result is " + data);
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2200: isScreenLocked is successful, result is " + data);
expect(data == false).assertTrue();
});
sleep(SLEEP_TIME);
isScreenlockedValue = true;
screenLock.test_setScreenLocked(isScreenlockedValue, (err, data) => {
console.log("Screenlock_Test_2200: test_setScreenLocked is successful, result is " + data);
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_2200: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end ScreenLock_Test_2200-------------------");
});
/*
* @tc.number Screenlock_Test_2300
* @tc.name After the systemUI is started, it is in the locked state, the lock management sends
the unlock request successfully, and the lock screen application notifies the unlock
failed message
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2300", 0, async function (done) {
console.info("------------------start Screenlock_Test_2300-------------------");
try {
screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2300: isScreenLocked result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.unlockScreen(() => {
console.log("Screenlock_Test_2300: send unlockScreen issue success");
});
sleep(SLEEP_TIME);
var unlockScreenResult = 1;
var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => {
console.log("Screenlock_Test_2300: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2300: isScreenLocked result is " + data);
expect(data == true).assertTrue();
done();
});
} catch (error) {
console.info("Screenlock_Test_2300: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end Screenlock_Test_2300-------------------");
});
/*
* @tc.number Screenlock_Test_2400
* @tc.name Device management causes the screen to go off, and run "beginSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2400", 0, async function (done) {
console.log("------------------start Screenlock_Test_2400-------------------");
try {
var eventType = 'beginSleep';
var reasonForSleep = 1;
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => {
console.log("Screenlock_Test_2400: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_2400: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_BEGIN_SLEEP).assertTrue();
done();
});
} catch (error) {
console.log("end Screenlock_Test_2400: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_2400-------------------");
});
/*
* @tc.number Screenlock_Test_2500
* @tc.name Device management causes the screen to go off, and run "endSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2500", 0, async function (done) {
console.log("------------------start Screenlock_Test_2500-------------------");
try {
var eventType = 'endSleep';
var reasonForSleep = 1;
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => {
console.log("Screenlock_Test_2500: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_2500: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_END_SLEEP).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_2500: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_2500-------------------");
});
/*
* @tc.number Screenlock_Test_2600
* @tc.name Device management causes the screen to go off, and run "beginScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2600", 0, async function (done) {
console.log("------------------start Screenlock_Test_2600-------------------");
try {
var eventType = 'beginScreenOff';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_2600: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_2600: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_BEGIN_OFF).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_2600: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_2600-------------------");
});
/*
* @tc.number Screenlock_Test_2700
* @tc.name Device management causes the screen to go off, and run "endScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2700", 0, async function (done) {
console.log("------------------start Screenlock_Test_2700-------------------");
try {
var eventType = 'endScreenOff';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_2700: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_2700: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_END_OFF).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_2700: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_2700-------------------");
});
/*
* @tc.number Screenlock_Test_2800
* @tc.name User causes the screen to go off, and run "beginSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2800", 0, async function (done) {
console.log("------------------start Screenlock_Test_2800-------------------");
try {
var eventType = 'beginSleep';
var reasonForSleep = 2;
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => {
console.log("Screenlock_Test_2800: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_2800: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_BEGIN_SLEEP).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_2800: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_2800-------------------");
});
/*
* @tc.number Screenlock_Test_2900
* @tc.name User causes the screen to go off, and run "endSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_2900", 0, async function (done) {
console.log("------------------start Screenlock_Test_2900-------------------");
try {
var eventType = 'endSleep';
var reasonForSleep = 2;
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => {
console.log("Screenlock_Test_2900: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_2900: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_END_SLEEP).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_2900: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_2900-------------------");
});
/*
* @tc.number Screenlock_Test_3000
* @tc.name User causes the screen to go off, and run "beginScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3000", 0, async function (done) {
console.log("------------------start Screenlock_Test_3000-------------------");
try {
var eventType = 'beginScreenOff';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3000: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3000: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_BEGIN_OFF).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3000: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3000-------------------");
});
/*
* @tc.number Screenlock_Test_3100
* @tc.name User causes the screen to go off, and run "endScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3100", 0, async function (done) {
console.log("------------------start Screenlock_Test_3100-------------------");
try {
var eventType = 'endScreenOff';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3100: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3100: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_END_OFF).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3100: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3100-------------------");
});
/*
* @tc.number Screenlock_Test_3200
* @tc.name No operation for a long time causes the screen to go off, and run "beginSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3200", 0, async function (done) {
console.log("------------------start Screenlock_Test_3200-------------------");
try {
var eventType = 'beginSleep';
var reasonForSleep = 3;
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => {
console.log("Screenlock_Test_3200: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3200: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_BEGIN_SLEEP).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3200: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3200-------------------");
});
/*
* @tc.number Screenlock_Test_3300
* @tc.name No operation for a long time causes the screen to go off, and run "endSleep" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3300", 0, async function (done) {
console.log("------------------start Screenlock_Test_3300-------------------");
try {
var eventType = 'endSleep';
var reasonForSleep = 3;
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => {
console.log("Screenlock_Test_3300: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3300: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_END_SLEEP).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3300: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3300-------------------");
});
/*
* @tc.number Screenlock_Test_3400
* @tc.name No operation for a long time causes the screen to go off, and run "beginScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3400", 0, async function (done) {
console.log("------------------start Screenlock_Test_3400-------------------");
try {
var eventType = 'beginScreenOff';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3400: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3400: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_BEGIN_OFF).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3400: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3400-------------------");
});
/*
* @tc.number Screenlock_Test_3500
* @tc.name No operation for a long time causes the screen to go off, and run "endScreenOff" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3500", 0, async function (done) {
console.log("------------------start Screenlock_Test_3500-------------------");
try {
var eventType = 'endScreenOff';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3500: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3500: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_END_OFF).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3500: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3500-------------------");
});
/*
* @tc.number Screenlock_Test_3600
* @tc.name Responding to bright screen events, and run "beginWakeUp" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3600", 0, async function (done) {
console.log("------------------start Screenlock_Test_3600-------------------");
try {
var eventType = 'beginWakeUp';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3600: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3600: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_BEGIN_WAKEUP).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3600: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3600-------------------");
});
/*
* @tc.number Screenlock_Test_3700
* @tc.name Responding to bright screen events, and run "endWakeUp" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3700", 0, async function (done) {
console.log("------------------logMessage Screenlock_Test_3700-------------------");
try {
var eventType = 'endWakeUp';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3700: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3700: test_getRuntimeState is successful, result is " + data);
expect(data == INTERACTIVE_STATE_END_WAKEUP).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3700: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3700-------------------");
});
/*
* @tc.number Screenlock_Test_3800
* @tc.name Responding to bright screen events, and run "beginScreenOn" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3800", 0, async function (done) {
console.log("------------------start Screenlock_Test_3800-------------------");
try {
var eventType = 'beginScreenOn';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3800: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3800: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_BEGIN_ON).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3800: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3800-------------------");
});
/*
* @tc.number Screenlock_Test_3900
* @tc.name Responding to bright screen events, and run "endScreenOn" operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_3900", 0, async function (done) {
console.log("------------------start Screenlock_Test_3900-------------------");
try {
var eventType = 'endScreenOn';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_3900: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_3900: test_getRuntimeState is successful, result is " + data);
expect(data == SCREEN_STATE_END_ON).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_3900: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_3900-------------------");
});
/*
* @tc.number Screenlock_Test_4000
* @tc.name Modify the user ID to 2, and the modification is successful
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4000", 0, async function (done) {
console.log("------------------start Screenlock_Test_4000-------------------");
try {
var eventType = 'changeUser';
var userId = 2;
screenLock.test_runtimeNotify(eventType, userId, (err, data) => {
console.log("Screenlock_Test_4000: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4000: test_getRuntimeState is successful, result is " + data);
expect(data == userId).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4000: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4000-------------------");
});
/*
* @tc.number Screenlock_Test_4100
* @tc.name Modify the user ID to 0, and the modification is successful
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4100", 0, async function (done) {
console.log("------------------logMessage Screenlock_Test_4100-------------------");
try {
var eventType = 'changeUser';
var userId = 0;
screenLock.test_runtimeNotify(eventType, userId, (err, data) => {
console.log("Screenlock_Test_4100: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4100: test_getRuntimeState is successful, result is " + data);
expect(data == userId).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4100: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4100-------------------");
});
/*
* @tc.number Screenlock_Test_4200
* @tc.name Modify the user ID to -3, and the modification is failed
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4200", 0, async function (done) {
console.log("------------------start Screenlock_Test_4200-------------------");
try {
var eventType = 'changeUser';
var userId = -3;
screenLock.test_runtimeNotify(eventType, userId, (err, data) => {
console.log("Screenlock_Test_4200: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
var oldUserId = 0;
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4200: test_getRuntimeState is successful, result is " + data);
expect(data == oldUserId).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4200: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4200-------------------");
});
/*
* @tc.number Screenlock_Test_4300
* @tc.name Modify the user ID to 99999999999999, and the modification is failed
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4300", 0, async function (done) {
console.log("------------------start Screenlock_Test_4300-------------------");
try {
var eventType = 'changeUser';
var userId = 99999999999999;
screenLock.test_runtimeNotify(eventType, userId, (err, data) => {
console.log("Screenlock_Test_4300: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
var oldUserId = 0;
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4300: test_getRuntimeState is successful, result is" + data);
expect(data == oldUserId).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4300: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4300-------------------");
});
/*
* @tc.number Screenlock_Test_4400
* @tc.name Modify the user ID to 'abc', and the modification is failed
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4400", 0, async function (done) {
console.log("------------------start Screenlock_Test_4400-------------------");
try {
var eventType = 'changeUser';
var userId = 'abc';
screenLock.test_runtimeNotify(eventType, userId, (err, data) => {
console.log("Screenlock_Test_4400: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
var oldUserId = 0;
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4400: test_getRuntimeState is successful, result is" + data);
expect(data == oldUserId).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4400: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4400-------------------");
});
/*
* @tc.number Screenlock_Test_4500
* @tc.name Settings can lock the screen
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4500", 0, async function (done) {
console.log("------------------start Screenlock_Test_4500-------------------");
try {
var eventType = 'screenlockEnabled';
var isScreenlockEnabled = 0;
screenLock.test_runtimeNotify(eventType, isScreenlockEnabled, (err, data) => {
console.log("Screenlock_Test_4500: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4500: test_getRuntimeState is successful, result is" + data);
expect(data == isScreenlockEnabled).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4500: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4500-------------------");
});
/*
* @tc.number Screenlock_Test_4600
* @tc.name Setting can not lock screen
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4600", 0, async function (done) {
console.log("------------------start Screenlock_Test_4600-------------------");
try {
var eventType = 'screenlockEnabled';
var isScreenlockEnabled = 1;
screenLock.test_runtimeNotify(eventType, isScreenlockEnabled, (err, data) => {
console.log("Screenlock_Test_4600: test_runtimeNotify is successful, result is " + data);
});
sleep(SLEEP_TIME);
screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4600: test_getRuntimeState is successful, result is" + data);
expect(data == isScreenlockEnabled).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4600: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4600-------------------");
});
/*
* @tc.number Screenlock_Test_4700
* @tc.name Run 'beginExitAnimation' operate
* @tc.desc Function test
* @tc.level 0
*/
it("Screenlock_Test_4700", 0, async function (done) {
console.log("------------------start Screenlock_Test_4700-------------------");
try {
var eventType = 'beginExitAnimation';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => {
console.log("Screenlock_Test_4700: test_runtimeNotify is successful, result is " + data);
expect(data == true).assertTrue();
done();
});
} catch (error) {
console.log("logMessage Screenlock_Test_4700: error = " + error);
expect(true).assertTrue();
done();
}
console.log("------------------end Screenlock_Test_4700-------------------");
});
})
\ No newline at end of file
// @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 screenLock from '@ohos.app.screenlockability';
import {describe, expect, it} from 'deccjsunit/index'
const SLEEP_TIME = 1000;
describe('ScreenLockServicePromiseTest', function () {
console.log("-----------------------ScreenlockPromiseTest is starting-----------------------");
function sleep(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
/*
* @tc.number ScreenLock_Test_Promise_0100
* @tc.name Set to locked screen, query the lock screen state is locked state
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_Promise_0100", 0, async function (done) {
console.info("------------------start ScreenLock_Test_Promise_0100-------------------");
var isScreenLocked = true;
try {
screenLock.test_setScreenLocked(isScreenLocked).then((data) => {
console.log("ScreenLock_Test_Promise_0100 test_setScreenLocked result is " + data);
expect(data == true).assertTrue();
screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0100 isScreenLocked result is " + data);
expect(data == true).assertTrue();
done();
})
})
} catch (error) {
console.log("ScreenLock_Test_Promise_0100 test_setScreenLocked : error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_Promise_0100-------------------");
});
/*
* @tc.number ScreenLock_Test_Promise_0200
* @tc.name Set to unlocked screen, query the lock screen state is unlocked state
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_Promise_0200", 0, async function (done) {
console.info("------------------start ScreenLock_Test_Promise_0200-------------------");
var isScreenLocked = false;
try {
screenLock.test_setScreenLocked(isScreenLocked).then((data) => {
console.log("ScreenLock_Test_Promise_0200 test_setScreenLocked result is " + data);
expect(data == true).assertTrue();
screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0200 isScreenLocked result is " + data);
expect(data == false).assertTrue();
done();
});
});
} catch (error) {
console.log("ScreenLock_Test_Promise_0200 test_setScreenLocked : error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_Promise_0200-------------------");
});
/*
* @tc.number ScreenLock_Test_Promise_0300
* @tc.name Query whether a password has been set, and return the password that has not been set
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_Promise_0300", 0, async function (done) {
console.info("------------------start ScreenLock_Test_Promise_0300-------------------");
try {
screenLock.isSecureMode().then((data) => {
console.log("ScreenLock_Test_Promise_0300 isScreenLocked result is " + data);
expect(data == false).assertTrue();
done();
});
} catch (error) {
console.log("ScreenLock_Test_Promise_0300 isScreenLocked TRUE: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_Promise_0300-------------------");
});
/*
* @tc.number ScreenLock_Test_Promise_0400
* @tc.name Request to unlock the device screen, unlock successfully
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_Promise_0400", 0, async function (done) {
console.info("------------------start ScreenLock_Test_Promise_0400-------------------");
try {
var isScreenLocked = true;
screenLock.test_setScreenLocked(isScreenLocked).then((data) => {
console.log("ScreenLock_Test_Promise_0400: test_setScreenLocked1 " + data + " result is successfull");
});
sleep(SLEEP_TIME);
screenLock.unlockScreen().then(() => {
console.log("ScreenLock_Test_Promise_0400: send unlockScreen issue success");
});
sleep(SLEEP_TIME);
var unlockScreenResult = 0;
var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult).then((data) => {
console.log("ScreenLock_Test_Promise_0400: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0400: isScreenLocked result is " + data);
expect(data == false).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.test_setScreenLocked(isScreenLocked).then((data) => {
console.log("ScreenLock_Test_Promise_0400: test_setScreenLocked2 " + data + " result is successfull");
done();
});
} catch (error) {
console.info("Screenlock_Test_1400: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_Promise_0400-------------------");
});
/*
* @tc.number ScreenLock_Test_Promise_0500
* @tc.name Request to unlock device screen, unlock failed
* @tc.desc Function test
* @tc.level 0
*/
it("ScreenLock_Test_Promise_0500", 0, async function (done) {
console.info("------------------start ScreenLock_Test_Promise_0500-------------------");
try {
var isScreenLocked = true;
screenLock.test_setScreenLocked(isScreenLocked).then((data) => {
console.log("ScreenLock_Test_Promise_0500: test_setScreenLocked " + data + " result is successfull");
});
sleep(SLEEP_TIME);
screenLock.unlockScreen().then(() => {
console.log("ScreenLock_Test_Promise_0500: send unlockScreen issue success");
});
sleep(SLEEP_TIME);
var unlockScreenResult = 1;
var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult).then((data) => {
console.log("ScreenLock_Test_Promise_0500: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue();
});
sleep(SLEEP_TIME);
screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0500: isScreenLocked result is " + data);
expect(data == true).assertTrue();
done();
});
} catch (error) {
console.info("logMessage ScreenLock_Test_Promise_0500: error = " + error);
expect(true).assertTrue();
done();
}
console.info("------------------end ScreenLock_Test_Promise_0500-------------------");
});
})
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "screenLock"
},
{
"name": "mainability_description",
"value": "JS_Empty screenLock"
}
]
}
\ No newline at end of file
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsWallpaperJSApiTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsWallpaperJSApiTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for wallpaper js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.xts.wpxts",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsWallpaperJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.xts.wpxts",
"vendor": "xts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 8,
"target": 8,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "com.xts.wpxts",
"name": ".MyApplication",
"deviceType": [
"phone",
"tablet",
"tv",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "com.xts.wpxts.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.SET_WALLPAPER"
},
{
"name": "ohos.permission.GET_WALLPAPER"
},
{
"name": "ohos.permission.READ_USER_STORAGE"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
/*
* 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.
*/
require("./Wallpaper/WallpaperJsunit.test.js")
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import wallpaper from '@ohos.app.wallpaperability'
const WALLPAPER_SYSTEM = 0;
const WALLPAPER_LOCKSCREEN = 1;
var imageSource = '/data/accounts/account_0/appdata/com.test.testApp/wallpaper';
describe('WallpaperJsunitTest', function () {
beforeAll(async function () {
console.info('beforeAll: Prerequisites at the test suite level, ' +
'which are executed before the test suite is executed.');
})
beforeEach(function () {
console.info('beforeEach: Prerequisites at the test case level, ' +
'which are executed before each test case is executed.');
})
afterEach(function () {
console.info('afterEach: Test case-level clearance conditions,' +
' which are executed after each test case is executed.');
})
afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition, ' +
'which is executed after the test suite is executed');
})
/*
* @tc.number testWALLPAPER_SYSTEM
* @tc.name Test WALLPAPER_SYSTEM value
* @tc.desc Function test
* @tc.level 0
*/
it('testWALLPAPER_SYSTEM', 0, async function (done) {
console.info('wallpaperXTS ===> testWALLPAPER_SYSTEM : ' + JSON.stringify(wallpaper.WALLPAPER_SYSTEM));
expect(wallpaper.WALLPAPER_SYSTEM == 0).assertTrue();
done();
})
/*
* @tc.number testWALLPAPER_LOCKSCREEN
* @tc.name Test WALLPAPER_LOCKSCREEN value
* @tc.desc Function test
* @tc.level 0
*/
it('testWALLPAPER_LOCKSCREEN', 0, async function (done) {
console.info('wallpaperXTS ===> testWALLPAPER_LOCKSCREEN : ' + JSON.stringify(wallpaper.WALLPAPER_LOCKSCREEN));
expect(wallpaper.WALLPAPER_LOCKSCREEN == 1).assertTrue();
done();
})
/*
* @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) {
await wallpaper.getColors(WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testGetColorsCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetColorsCallbackSystem data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @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) {
await wallpaper.getColors(WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testGetColorsPromiseSystem data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testGetColorsPromiseSystem err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @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) {
await wallpaper.getColors(WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testGetColorsCallbackLock err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetColorsCallbackLock data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @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) {
await wallpaper.getColors(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testGetColorsCallbackLock data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testGetColorsCallbackLock err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @tc.number testGetColorsPromiseLock102
* @tc.name Test getId() to the ID of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetIdCallbackSystem101', 0, async function (done) {
await wallpaper.getId(WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testGetIdCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetIdCallbackSystem data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testGetIdPromiseSystem101
* @tc.name Test getId() to the ID of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetIdPromiseSystem101', 0, async function (done) {
await wallpaper.getId(WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testGetIdCallbackSystem data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testGetIdCallbackSystem err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @tc.number testGetIdCallbackLock102
* @tc.name Test getId() to the ID of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetIdCallbackLock102', 0, async function (done) {
await wallpaper.getId(WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testGetIdCallbackLock err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetIdCallbackLock data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testGetIdPromiseLock102
* @tc.name Test getId() to the ID of the wallpaper of the specified type.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetIdPromiseLock102', 0, async function (done) {
await wallpaper.getId(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testGetIdCallbackLock data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testGetIdCallbackLock err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @tc.number testGetMinHeightCallback101
* @tc.name Test getMinHeight() to the minimum width of the wallpaper.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetMinHeightCallback101', 0, async function (done) {
await wallpaper.getMinHeight(function (err, data) {
console.info('wallpaperXTS ===> testGetMinHeightCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetMinHeightCallback data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testGetMinHeightPromise101
* @tc.name Test getMinHeight() to the minimum width of the wallpaper.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetMinHeightPromise101', 0, async function (done) {
await wallpaper.getMinHeight().then((data) => {
console.info('wallpaperXTS ===> testGetMinHeightPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testGetMinHeightPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @tc.number testGetMinWidthCallback101
* @tc.name Test getMinHeight() to the minimum width of the wallpaper.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetMinWidthCallback101', 0, async function (done) {
await wallpaper.getMinWidth(function (err, data) {
console.info('wallpaperXTS ===> testGetMinWidthCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetMinWidthCallback data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testGetMinWidthPromise101
* @tc.name Test getMinHeight() to the minimum width of the wallpaper.
* @tc.desc Function test
* @tc.level 0
*/
it('testGetMinWidthPromise101', 0, async function (done) {
await wallpaper.getMinWidth().then((data) => {
console.info('wallpaperXTS ===> testGetMinWidthPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testGetMinWidthPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @tc.number testIsChangePermittedCallback101
* @tc.name Test isChangePermitted() to checks whether to allow the application to change the
wallpaper for the current user.
* @tc.desc Function test
* @tc.level 0
*/
it('testIsChangePermittedCallback101', 0, async function (done) {
await wallpaper.isChangePermitted(function (err, data) {
console.info('wallpaperXTS ===> testIsChangePermittedCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testIsChangePermittedCallback data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testIsChangePermittedPromise101
* @tc.name Test isChangePermitted() to checks whether to allow the application to change the
wallpaper for the current user.
* @tc.desc Function test
* @tc.level 0
*/
it('testIsChangePermittedPromise101', 0, async function (done) {
await wallpaper.isChangePermitted().then((data) => {
console.info('wallpaperXTS ===> testIsChangePermittedPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testIsChangePermittedPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @tc.number testIsOperationAllowedCallback101
* @tc.name Test isOperationAllowed() to checks whether a user is allowed to set wallpapers.
* @tc.desc Function test
* @tc.level 0
*/
it('testIsOperationAllowedCallback101', 0, async function (done) {
await wallpaper.isOperationAllowed(function (err, data) {
console.info('wallpaperXTS ===> testIsOperationAllowedCallback err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testIsOperationAllowedCallback data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testIsOperationAllowedPromise101
* @tc.name Test isOperationAllowed() to checks whether a user is allowed to set wallpapers.
* @tc.desc Function test
* @tc.level 0
*/
it('testIsOperationAllowedPromise101', 0, async function (done) {
await wallpaper.isOperationAllowed().then((data) => {
console.info('wallpaperXTS ===> testIsOperationAllowedPromise data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
}).catch((err) => {
console.info('wallpaperXTS ===> testIsOperationAllowedPromise err : ' + JSON.stringify(err));
if (err) {
expect(null).assertFail();
}
});
done();
})
/*
* @tc.number testResetCallbackSystem101
* @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackSystem101', 0, async function (done) {
await wallpaper.reset(WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testResetCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testResetCallbackSystem data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testResetPromiseSystem101
* @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseSystem101', 0, async function (done) {
wallpaper.reset(WALLPAPER_SYSTEM).then((data) => {
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
done();
}).catch((err) => {
expect(true).assertTrue();
done();
});
})
/*
* @tc.number testResetCallbackLock102
* @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetCallbackLock102', 0, async function (done) {
await wallpaper.reset(WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testResetCallbackLock err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testResetCallbackLock data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @tc.number testResetPromiseLock102
* @tc.name Test reset() to removes a wallpaper of the specified type and restores the default one.
* @tc.desc Function test
* @tc.level 0
*/
it('testResetPromiseLock102', 0, async function (done) {
await wallpaper.reset(WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testResetPromiseLock data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testResetPromiseLock--- err : ' + JSON.stringify(err));
expect(true).assertTrue();
done();
});
})
/*
* @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) {
await wallpaper.setWallpaper(imageSource, WALLPAPER_LOCKSCREEN).then((data) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseLock data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseLock err : ' + JSON.stringify(err));
expect(true).assertTrue();
done();
});
})
/*
* @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) {
await wallpaper.setWallpaper(imageSource, WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackSystem data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
});
done();
})
/*
* @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, function (done) {
if(true) {
expect(true).assertTrue();
done();
return;
}
wallpaper.setWallpaper(imageSource, WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseSystem data : ' + JSON.stringify(data));
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
done();
}).catch((err) => {
console.info('wallpaperXTS ===> testSetWallpaperURLPromiseSystem err : ' + JSON.stringify(err));
expect(true).assertTrue();
done();
});
})
/*
* @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) {
await wallpaper.setWallpaper(imageSource, WALLPAPER_LOCKSCREEN, function (err, data) {
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackLock err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testSetWallpaperURLCallbackLock data : ' + JSON.stringify(data));
if (err) {
expect(null).assertFail();
}
if ((data != undefined) && (data != null) && (data != '')) {
expect(true).assertTrue();
}
});
done();
})
/*
* @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) {
await wallpaper.on('colorChange', function (colors, wallpaperType) {
console.info('wallpaperXTS ===> testOnCallback colors : ' + JSON.stringify(colors));
console.info('wallpaperXTS ===> testOnCallback wallpaperType : ' + JSON.stringify(wallpaperType));
if ((colors != undefined) && (colors != null) && (colors != '')) {
expect(true).assertTrue();
}
if ((wallpaperType != undefined) && (wallpaperType != null) && (wallpaperType != '')) {
expect(true).assertTrue();
}
})
done();
})
/*
* @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) {
await wallpaper.off('colorChange', function (colors, wallpaperType) {
console.info('wallpaperXTS ===> testOffCallback colors : ' + JSON.stringify(colors));
console.info('wallpaperXTS ===> testOffCallback wallpaperType : ' + JSON.stringify(wallpaperType));
if ((colors != undefined) && (colors != null) && (colors != '')) {
expect(true).assertTrue();
}
if ((wallpaperType != undefined) && (wallpaperType != null) && (wallpaperType != '')) {
expect(true).assertTrue();
}
})
done();
})
})
/*
* 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("/common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
<!--
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 th`e specific language governing permissions and
limitations under the License.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
console.log("test start")
require('../../../Test/List.test.js')
core.execute()
this.title = this.$t('strings.start');
console.log("test end")
},
onReady() {
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册