diff --git a/miscservices/BUILD.gn b/miscservices/BUILD.gn
index c0513d9fde06a2e19b79a45278ac97c4d1776f3c..0e05ce9deed5713b662f3e7e90de49b4a25346bc 100755
--- a/miscservices/BUILD.gn
+++ b/miscservices/BUILD.gn
@@ -20,5 +20,7 @@ group("miscservices") {
"TimeTest_js:ActsTimeJSApiTest",
"TimerTest_js:ActsTimerJSApiTest",
"actspasteboardjsapitest:ActsPasteBoardJSApiTest",
+ "screenlock_js:ActsScreenLockJSApiTest",
+ "wallpaper_js:ActsWallpaperJSApiTest",
]
}
diff --git a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets b/miscservices/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets
index ac554fb05e6c8b90dcde5413eec0b992870535c1..3f31d27d328560988fbaffeb81bd2d894d03da10 100644
--- a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets
+++ b/miscservices/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets
@@ -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
diff --git a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/ScreenLockJsunit.test.ets b/miscservices/InputMethodTest_ets/entry/src/main/ets/test/ScreenLockJsunit.test.ets
deleted file mode 100644
index 2b40e193502fdc94358f94cca1ed80072f32f071..0000000000000000000000000000000000000000
--- a/miscservices/InputMethodTest_ets/entry/src/main/ets/test/ScreenLockJsunit.test.ets
+++ /dev/null
@@ -1,169 +0,0 @@
-// @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
diff --git a/miscservices/screenlock_js/BUILD.gn b/miscservices/screenlock_js/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..dcd63eff70d4744ae623f2e6b0da5fab18efc7cb
--- /dev/null
+++ b/miscservices/screenlock_js/BUILD.gn
@@ -0,0 +1,31 @@
+# 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"
+}
diff --git a/miscservices/screenlock_js/Test.json b/miscservices/screenlock_js/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..6ac4304d1cbd8c8d83bcb5c2f3ef3aeb5e227351
--- /dev/null
+++ b/miscservices/screenlock_js/Test.json
@@ -0,0 +1,18 @@
+{
+ "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
+ }
+ ]
+}
diff --git a/miscservices/screenlock_js/signature/openharmony_sx.p7b b/miscservices/screenlock_js/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858
Binary files /dev/null and b/miscservices/screenlock_js/signature/openharmony_sx.p7b differ
diff --git a/miscservices/screenlock_js/src/main/config.json b/miscservices/screenlock_js/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..33a4e152eccea288c77a15e8f29c074688a54f2f
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/config.json
@@ -0,0 +1,65 @@
+{
+ "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
+ }
+ }
+ ]
+ }
+}
diff --git a/miscservices/screenlock_js/src/main/js/default/app.js b/miscservices/screenlock_js/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..4b241cccbaa71f0c5cbd9e7dc437a0feb224c7d5
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * 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');
+ }
+};
diff --git a/miscservices/screenlock_js/src/main/js/default/common/images/Wallpaper.png b/miscservices/screenlock_js/src/main/js/default/common/images/Wallpaper.png
new file mode 100644
index 0000000000000000000000000000000000000000..60d4841a80eb20c63de74306cb7f8350d6a85c48
Binary files /dev/null and b/miscservices/screenlock_js/src/main/js/default/common/images/Wallpaper.png differ
diff --git a/miscservices/screenlock_js/src/main/js/default/common/images/bg-tv.jpg b/miscservices/screenlock_js/src/main/js/default/common/images/bg-tv.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..88f17e14af28db45eed4cc67cfdbbfc23de5c0ae
Binary files /dev/null and b/miscservices/screenlock_js/src/main/js/default/common/images/bg-tv.jpg differ
diff --git a/miscservices/screenlock_js/src/main/js/default/i18n/en-US.json b/miscservices/screenlock_js/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/miscservices/screenlock_js/src/main/js/default/i18n/zh-CN.json b/miscservices/screenlock_js/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/miscservices/screenlock_js/src/main/js/default/pages/index/index.css b/miscservices/screenlock_js/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..a6bb21f7f1df91f0b4ffdd1495a558f2e554f276
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/default/pages/index/index.css
@@ -0,0 +1,36 @@
+/*
+ * 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;
+}
diff --git a/miscservices/screenlock_js/src/main/js/default/pages/index/index.hml b/miscservices/screenlock_js/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..4b91ca46b05bd693db5dbcdcd6008eed76657123
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,19 @@
+
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/miscservices/screenlock_js/src/main/js/default/pages/index/index.js b/miscservices/screenlock_js/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..50b8148231c98f440e5c15e3b6223ea6f2937e96
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/default/pages/index/index.js
@@ -0,0 +1,33 @@
+/*
+ * 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
diff --git a/miscservices/screenlock_js/src/main/js/test/List.test.js b/miscservices/screenlock_js/src/main/js/test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..2dcc2fdbf78824f2a96a2214973b818b65bba464
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/test/List.test.js
@@ -0,0 +1,16 @@
+/*
+ * 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');
diff --git a/miscservices/screenlock_js/src/main/js/test/screenlock_service_test.js b/miscservices/screenlock_js/src/main/js/test/screenlock_service_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..db7cb8e08c04421973ee53384d2398129ee6d219
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/test/screenlock_service_test.js
@@ -0,0 +1,1023 @@
+// @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
diff --git a/miscservices/screenlock_js/src/main/js/test/screenlock_service_test_promise.js b/miscservices/screenlock_js/src/main/js/test/screenlock_service_test_promise.js
new file mode 100644
index 0000000000000000000000000000000000000000..bc11d63386f12b46f29713d25056b31008dc9101
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/js/test/screenlock_service_test_promise.js
@@ -0,0 +1,197 @@
+// @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
diff --git a/miscservices/screenlock_js/src/main/resources/base/element/string.json b/miscservices/screenlock_js/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..6353a8a8925dc24c56859f8c4ee71d8afc19a6b0
--- /dev/null
+++ b/miscservices/screenlock_js/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "screenLock"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Empty screenLock"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/miscservices/screenlock_js/src/main/resources/base/media/icon.png b/miscservices/screenlock_js/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/miscservices/screenlock_js/src/main/resources/base/media/icon.png differ
diff --git a/miscservices/wallpaper_js/BUILD.gn b/miscservices/wallpaper_js/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..fe9e4c3d89d9b1b244245ee6fc7d43fe0249e2b7
--- /dev/null
+++ b/miscservices/wallpaper_js/BUILD.gn
@@ -0,0 +1,31 @@
+# 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"
+}
diff --git a/miscservices/wallpaper_js/Test.json b/miscservices/wallpaper_js/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..4fb2b6f57f5a9b749abd5d35cd75276572e86a49
--- /dev/null
+++ b/miscservices/wallpaper_js/Test.json
@@ -0,0 +1,18 @@
+{
+ "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
+ }
+ ]
+}
diff --git a/miscservices/wallpaper_js/signature/openharmony_sx.p7b b/miscservices/wallpaper_js/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858
Binary files /dev/null and b/miscservices/wallpaper_js/signature/openharmony_sx.p7b differ
diff --git a/miscservices/wallpaper_js/src/main/config.json b/miscservices/wallpaper_js/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..6e7f3b17cbe2214f43819a798e53fca6fabbd027
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/config.json
@@ -0,0 +1,76 @@
+{
+ "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
+ }
+ }
+ ]
+ }
+}
diff --git a/miscservices/wallpaper_js/src/main/js/Test/List.test.js b/miscservices/wallpaper_js/src/main/js/Test/List.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..32f283ffaa51bfd14c0c5d5c5aaec35323176b1f
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/Test/List.test.js
@@ -0,0 +1,15 @@
+/*
+ * 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
diff --git a/miscservices/wallpaper_js/src/main/js/Test/Wallpaper/WallpaperJsunit.test.js b/miscservices/wallpaper_js/src/main/js/Test/Wallpaper/WallpaperJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..df22bd043fe13a86c919ab6220194b9457a5af37
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/Test/Wallpaper/WallpaperJsunit.test.js
@@ -0,0 +1,602 @@
+/*
+ * 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();
+ })
+})
diff --git a/miscservices/wallpaper_js/src/main/js/default/app.js b/miscservices/wallpaper_js/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..4b241cccbaa71f0c5cbd9e7dc437a0feb224c7d5
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * 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');
+ }
+};
diff --git a/miscservices/wallpaper_js/src/main/js/default/common/images/Wallpaper.png b/miscservices/wallpaper_js/src/main/js/default/common/images/Wallpaper.png
new file mode 100644
index 0000000000000000000000000000000000000000..60d4841a80eb20c63de74306cb7f8350d6a85c48
Binary files /dev/null and b/miscservices/wallpaper_js/src/main/js/default/common/images/Wallpaper.png differ
diff --git a/miscservices/wallpaper_js/src/main/js/default/common/images/bg-tv.jpg b/miscservices/wallpaper_js/src/main/js/default/common/images/bg-tv.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..88f17e14af28db45eed4cc67cfdbbfc23de5c0ae
Binary files /dev/null and b/miscservices/wallpaper_js/src/main/js/default/common/images/bg-tv.jpg differ
diff --git a/miscservices/wallpaper_js/src/main/js/default/i18n/en-US.json b/miscservices/wallpaper_js/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/miscservices/wallpaper_js/src/main/js/default/i18n/zh-CN.json b/miscservices/wallpaper_js/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/miscservices/wallpaper_js/src/main/js/default/pages/index/index.css b/miscservices/wallpaper_js/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..a55e7142ee316f771692297c5a43b9a788720df7
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/default/pages/index/index.css
@@ -0,0 +1,60 @@
+/*
+ * 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;
+ }
+}
diff --git a/miscservices/wallpaper_js/src/main/js/default/pages/index/index.hml b/miscservices/wallpaper_js/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..2de473acd4107f67baf13a849b2d0302cea12058
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,19 @@
+
+
+
+ {{ $t('strings.hello') }} {{ title }}
+
+
diff --git a/miscservices/wallpaper_js/src/main/js/default/pages/index/index.js b/miscservices/wallpaper_js/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..dc0e1186d2aae4fe33cd39b75ffd7b61b7efcea1
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/js/default/pages/index/index.js
@@ -0,0 +1,42 @@
+/*
+ * 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() {
+ }
+}
diff --git a/miscservices/wallpaper_js/src/main/resources/base/element/string.json b/miscservices/wallpaper_js/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0
--- /dev/null
+++ b/miscservices/wallpaper_js/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Empty Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/miscservices/wallpaper_js/src/main/resources/base/media/icon.png b/miscservices/wallpaper_js/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/miscservices/wallpaper_js/src/main/resources/base/media/icon.png differ