未验证 提交 4a033304 编写于 作者: O openharmony_ci 提交者: Gitee

!4235 【杂散】【屏幕锁屏】整改原来的用例接口

Merge pull request !4235 from 张育帅/zysmaster
...@@ -13,21 +13,16 @@ ...@@ -13,21 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import screenLock from '@ohos.app.screenlockability'; import screenLock from '@ohos.screenLock';
import {describe, expect, it} from 'deccjsunit/index' 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_END_SLEEP = 0;
const INTERACTIVE_STATE_BEGIN_WAKEUP = 1; const INTERACTIVE_STATE_USERID = 2;
const INTERACTIVE_STATE_END_WAKEUP = 2;
const INTERACTIVE_STATE_BEGIN_SLEEP = 3; const INTERACTIVE_STATE_BEGIN_SLEEP = 3;
const SLEEP_TIME = 1000; const SLEEP_TIME = 1000;
describe('ScreenLockServiceTest', function () { describe('ScreenLockServiceTest', function () {
console.log("-----------------------ScreenlockTest is starting-----------------------"); console.info("-----------------------ScreenlockTest is starting-----------------------");
function sleep(numberMillis) { function sleep(numberMillis) {
var now = new Date(); var now = new Date();
...@@ -48,24 +43,16 @@ describe('ScreenLockServiceTest', function () { ...@@ -48,24 +43,16 @@ describe('ScreenLockServiceTest', function () {
it("ScreenLock_Test_0100", 0, async function (done) { it("ScreenLock_Test_0100", 0, async function (done) {
console.info("------------------start ScreenLock_Test_0100-------------------"); console.info("------------------start ScreenLock_Test_0100-------------------");
try { 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) => { screenLock.isScreenLocked((err, data) => {
console.log("ScreenLock_Test_0100 isScreenLocked's status is " + data); console.info("ScreenLock_Test_0100 isScreenLocked's status is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.log("logMessage ScreenLock_Test_0100: error = " + error); console.info("logMessage ScreenLock_Test_0100: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_0100-------------------"); console.info("------------------end ScreenLock_Test_0100-------------------");
done();
}); });
/* /*
...@@ -77,30 +64,16 @@ describe('ScreenLockServiceTest', function () { ...@@ -77,30 +64,16 @@ describe('ScreenLockServiceTest', function () {
it("ScreenLock_Test_0200", 0, async function (done) { it("ScreenLock_Test_0200", 0, async function (done) {
console.info("------------------start ScreenLock_Test_0200-------------------"); console.info("------------------start ScreenLock_Test_0200-------------------");
try { 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) => { screenLock.isScreenLocked((err, data) => {
console.log("ScreenLock_Test_0200 isScreenLocked's status is " + data); console.info("ScreenLock_Test_0200 isScreenLocked's status is " + data);
expect(data == false).assertTrue(); 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) { } catch (error) {
console.log("logMessage ScreenLock_Test_0200: error = " + error); console.info("logMessage ScreenLock_Test_0200: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_0200-------------------"); console.info("------------------end ScreenLock_Test_0200-------------------");
done();
}); });
/* /*
...@@ -113,16 +86,15 @@ describe('ScreenLockServiceTest', function () { ...@@ -113,16 +86,15 @@ describe('ScreenLockServiceTest', function () {
console.info("------------------start ScreenLock_Test_0300-------------------"); console.info("------------------start ScreenLock_Test_0300-------------------");
try { try {
screenLock.isSecureMode((err, data) => { screenLock.isSecureMode((err, data) => {
console.log("ScreenLock_Test_0300 isSecureMode's result is " + data); console.info("ScreenLock_Test_0300 isSecureMode's result is " + data);
expect(data == false).assertTrue(); expect(data == false).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.log("logMessage ScreenLock_Test_0300: error = " + error); console.info("logMessage ScreenLock_Test_0300: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_0300-------------------"); console.info("------------------end ScreenLock_Test_0300-------------------");
done();
}); });
/* /*
...@@ -134,41 +106,29 @@ describe('ScreenLockServiceTest', function () { ...@@ -134,41 +106,29 @@ describe('ScreenLockServiceTest', function () {
it("Screenlock_Test_0400", 0, async function (done) { it("Screenlock_Test_0400", 0, async function (done) {
console.info("------------------start Screenlock_Test_0400-------------------"); console.info("------------------start Screenlock_Test_0400-------------------");
try { 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(() => { screenLock.unlockScreen(() => {
console.log("Screenlock_Test_0400: send unlockScreen issue success"); console.info("Screenlock_Test_0400: send unlockScreen issue success");
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
var unlockScreenResult = 0; var unlockScreenResult = 0;
var eventType = 'unlockScreenResult'; var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => { screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => {
console.log("Screenlock_Test_0400: sendScreenLockEvent result is " + data); console.info("Screenlock_Test_0400: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => { screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_0400: isScreenLocked result is " + data); console.info("Screenlock_Test_0400: isScreenLocked result is " + data);
expect(data == false).assertTrue(); 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) { } catch (error) {
console.info("Screenlock_Test_1400: error = " + error); console.info("Screenlock_Test_1400: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end Screenlock_Test_0400-------------------"); console.info("------------------end Screenlock_Test_0400-------------------");
done();
}); });
/* /*
...@@ -180,36 +140,29 @@ describe('ScreenLockServiceTest', function () { ...@@ -180,36 +140,29 @@ describe('ScreenLockServiceTest', function () {
it("Screenlock_Test_0500", 0, async function (done) { it("Screenlock_Test_0500", 0, async function (done) {
console.info("------------------start Screenlock_Test_0500-------------------"); console.info("------------------start Screenlock_Test_0500-------------------");
try { 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(() => { screenLock.unlockScreen(() => {
console.log("Screenlock_Test_0500: send unlockScreen issue success"); console.info("Screenlock_Test_0500: send unlockScreen issue success");
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
var unlockScreenResult = 1; var unlockScreenResult = 1;
var eventType = 'unlockScreenResult'; var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => { screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => {
console.log("Screenlock_Test_0500: sendScreenLockEvent result is " + data); console.info("Screenlock_Test_0500: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => { screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_0500: isScreenLocked result is " + data); console.info("Screenlock_Test_0500: isScreenLocked result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.info("logMessage Screenlock_Test_0500: error = " + error); console.info("logMessage Screenlock_Test_0500: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end Screenlock_Test_0500-------------------"); console.info("------------------end Screenlock_Test_0500-------------------");
done();
}); });
/* /*
...@@ -224,41 +177,34 @@ describe('ScreenLockServiceTest', function () { ...@@ -224,41 +177,34 @@ describe('ScreenLockServiceTest', function () {
console.info("------------------start Screenlock_Test_2100-------------------"); console.info("------------------start Screenlock_Test_2100-------------------");
try { try {
screenLock.isScreenLocked((err, data) => { screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2100: isScreenLocked result is " + data); console.info("Screenlock_Test_2100: isScreenLocked result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
screenLock.unlockScreen(() => { screenLock.unlockScreen(() => {
console.log("Screenlock_Test_2100: send unlockScreen issue success"); console.info("Screenlock_Test_2100: send unlockScreen issue success");
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
var unlockScreenResult = 0; var unlockScreenResult = 0;
var eventType = 'unlockScreenResult'; var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => { screenLock.sendScreenLockEvent(eventType, unlockScreenResult, (err, data) => {
console.log("Screenlock_Test_2100: sendScreenLockEvent result is " + data); console.info("Screenlock_Test_2100: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
screenLock.isScreenLocked((err, data) => { screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2100: isScreenLocked result is " + data); console.info("Screenlock_Test_2100: isScreenLocked result is " + data);
expect(data == false).assertTrue(); 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) { } catch (error) {
console.info("Screenlock_Test_2100: error = " + error); console.info("Screenlock_Test_2100: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end Screenlock_Test_2100-------------------"); console.info("------------------end Screenlock_Test_2100-------------------");
done();
}); });
/* /*
...@@ -268,33 +214,21 @@ describe('ScreenLockServiceTest', function () { ...@@ -268,33 +214,21 @@ describe('ScreenLockServiceTest', function () {
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_2200", 0, async function (done) { it("Screenlock_Test_2200", 0, async function (done) {
console.log("------------------start Screenlock_Test_2200-------------------"); console.info("------------------start Screenlock_Test_2200-------------------");
try { 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) => { screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2200: isScreenLocked is successful, result is " + data); console.info("Screenlock_Test_2200: isScreenLocked is successful, result is " + data);
expect(data == false).assertTrue(); 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) { } catch (error) {
console.log("logMessage Screenlock_Test_2200: error = " + error); console.info("logMessage Screenlock_Test_2200: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end ScreenLock_Test_2200-------------------"); console.info("------------------end ScreenLock_Test_2200-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_2300 * @tc.number Screenlock_Test_2300
* @tc.name After the systemUI is started, it is in the locked state, the lock management sends * @tc.name After the systemUI is started, it is in the locked state, the lock management sends
...@@ -328,356 +262,266 @@ describe('ScreenLockServiceTest', function () { ...@@ -328,356 +262,266 @@ describe('ScreenLockServiceTest', function () {
screenLock.isScreenLocked((err, data) => { screenLock.isScreenLocked((err, data) => {
console.log("Screenlock_Test_2300: isScreenLocked result is " + data); console.log("Screenlock_Test_2300: isScreenLocked result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.info("Screenlock_Test_2300: error = " + error); console.info("Screenlock_Test_2300: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end Screenlock_Test_2300-------------------"); console.info("------------------end Screenlock_Test_2300-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_2400 * @tc.number Screenlock_Test_2400
* @tc.name Device management causes the screen to go off, and run "beginSleep" operate * @tc.name Device management causes the screen to go off, and run "beginWakeUp" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_2400", 0, async function (done) { it("Screenlock_Test_2400", 0, async function (done) {
console.log("------------------start Screenlock_Test_2400-------------------"); console.log("------------------start Screenlock_Test_2400-------------------");
try { try {
var eventType = 'beginSleep'; var eventType = 'beginWakeUp';
var reasonForSleep = 1; screenLock.off(eventType, () => {
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => { console.log("Screenlock_Test_2400: test_getRuntimeState beginWakeUp is successful" );
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) { } catch (error) {
console.log("end Screenlock_Test_2400: error = " + error); console.log("end Screenlock_Test_2400: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_2400-------------------"); console.log("------------------end Screenlock_Test_2400-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_2500 * @tc.number Screenlock_Test_2500
* @tc.name Device management causes the screen to go off, and run "endSleep" operate * @tc.name Device management causes the screen to go off, and run "endWakeUp" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_2500", 0, async function (done) { it("Screenlock_Test_2500", 0, async function (done) {
console.log("------------------start Screenlock_Test_2500-------------------"); console.log("------------------start Screenlock_Test_2500-------------------");
try { try {
var eventType = 'endSleep'; var eventType = 'endWakeUp';
var reasonForSleep = 1; screenLock.off(eventType, () => {
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => { console.log("Screenlock_Test_2500: test_getRuntimeState endWakeUp is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_2500: error = " + error); console.log("end Screenlock_Test_2500: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_2500-------------------"); console.log("------------------end Screenlock_Test_2500-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_2600 * @tc.number Screenlock_Test_2600
* @tc.name Device management causes the screen to go off, and run "beginScreenOff" operate * @tc.name Device management causes the screen to go off, and run "beginScreenOn" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_2600", 0, async function (done) { it("Screenlock_Test_2600", 0, async function (done) {
console.log("------------------start Screenlock_Test_2600-------------------"); console.log("------------------start Screenlock_Test_2600-------------------");
try { try {
var eventType = 'beginScreenOff'; var eventType = 'beginScreenOn';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.off(eventType, () => {
console.log("Screenlock_Test_2600: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_2600: test_getRuntimeState beginScreenOn is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_2600: error = " + error); console.log("end Screenlock_Test_2600: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_2600-------------------"); console.log("------------------end Screenlock_Test_2600-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_2700 * @tc.number Screenlock_Test_2700
* @tc.name Device management causes the screen to go off, and run "endScreenOff" operate * @tc.name Device management causes the screen to go off, and run "endScreenOn" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_2700", 0, async function (done) { it("Screenlock_Test_2700", 0, async function (done) {
console.log("------------------start Screenlock_Test_2700-------------------"); console.log("------------------start Screenlock_Test_2700-------------------");
try { try {
var eventType = 'endScreenOff'; var eventType = 'beginScreenOn';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.off(eventType, () => {
console.log("Screenlock_Test_2700: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_2700: test_getRuntimeState endScreenOn is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_2700: error = " + error); console.log("end Screenlock_Test_2700: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_2700-------------------"); console.log("------------------end Screenlock_Test_2700-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_2800 * @tc.number Screenlock_Test_2800
* @tc.name User causes the screen to go off, and run "beginSleep" operate * @tc.name User causes the screen to go off, and run "beginScreenOff" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_2800", 0, async function (done) { it("Screenlock_Test_2800", 0, async function (done) {
console.log("------------------start Screenlock_Test_2800-------------------"); console.log("------------------start Screenlock_Test_2800-------------------");
try { try {
var eventType = 'beginSleep'; var eventType = 'beginScreenOff';
var reasonForSleep = 2; screenLock.off(eventType, () => {
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => { console.log("Screenlock_Test_2800: test_getRuntimeState beginScreenOff is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_2800: error = " + error); console.log("end Screenlock_Test_2800: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_2800-------------------"); console.log("------------------end Screenlock_Test_2800-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_2900 * @tc.number Screenlock_Test_2900
* @tc.name User causes the screen to go off, and run "endSleep" operate * @tc.name User causes the screen to go off, and run "endScreenOff" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_2900", 0, async function (done) { it("Screenlock_Test_2900", 0, async function (done) {
console.log("------------------start Screenlock_Test_2900-------------------"); console.log("------------------start Screenlock_Test_2900-------------------");
try { try {
var eventType = 'endSleep'; var eventType = 'endScreenOff';
var reasonForSleep = 2; screenLock.off(eventType, () => {
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => { console.log("Screenlock_Test_2900: test_getRuntimeState endScreenOff is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_2900: error = " + error); console.log("end Screenlock_Test_2900: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_2900-------------------"); console.log("------------------end Screenlock_Test_2900-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_3000 * @tc.number Screenlock_Test_3000
* @tc.name User causes the screen to go off, and run "beginScreenOff" operate * @tc.name User causes the screen to go off, and run "unlockScreen" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_3000", 0, async function (done) { it("Screenlock_Test_3000", 0, async function (done) {
console.log("------------------start Screenlock_Test_3000-------------------"); console.log("------------------start Screenlock_Test_3000-------------------");
try { try {
var eventType = 'beginScreenOff'; var eventType = 'unlockScreen';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.off(eventType, () => {
console.log("Screenlock_Test_3000: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3000: test_getRuntimeState unlockScreen is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3000: error = " + error); console.log("end Screenlock_Test_3000: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3000-------------------"); console.log("------------------end Screenlock_Test_3000-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_3100 * @tc.number Screenlock_Test_3100
* @tc.name User causes the screen to go off, and run "endScreenOff" operate * @tc.name User causes the screen to go off, and run "beginExitAnimation" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_3100", 0, async function (done) { it("Screenlock_Test_3100", 0, async function (done) {
console.log("------------------start Screenlock_Test_3100-------------------"); console.log("------------------start Screenlock_Test_3100-------------------");
try { try {
var eventType = 'endScreenOff'; var eventType = 'beginExitAnimation';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.off(eventType, () => {
console.log("Screenlock_Test_3100: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3100: test_getRuntimeState beginExitAnimation is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3100: error = " + error); console.log("end Screenlock_Test_3100: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3100-------------------"); console.log("------------------end Screenlock_Test_3100-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_3200 * @tc.number Screenlock_Test_3200
* @tc.name No operation for a long time causes the screen to go off, and run "beginSleep" operate * @tc.name No operation for a long time causes the screen to go off, and run "screenlockEnabled" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_3200", 0, async function (done) { it("Screenlock_Test_3200", 0, async function (done) {
console.log("------------------start Screenlock_Test_3200-------------------"); console.log("------------------start Screenlock_Test_3200-------------------");
try { try {
var eventType = 'beginSleep'; var eventType = 'screenlockEnabled';
var reasonForSleep = 3; screenLock.off(eventType, () => {
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => { console.log("Screenlock_Test_3200: test_getRuntimeState screenlockEnabled is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3200: error = " + error); console.log("end Screenlock_Test_3200: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3200-------------------"); console.log("------------------end Screenlock_Test_3200-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_3300 * @tc.number Screenlock_Test_3300
* @tc.name No operation for a long time causes the screen to go off, and run "endSleep" operate * @tc.name No operation for a long time causes the screen to go off, and run "beginSleep" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_3300", 0, async function (done) { it("Screenlock_Test_3300", 0, async function (done) {
console.log("------------------start Screenlock_Test_3300-------------------"); console.log("------------------start Screenlock_Test_3300-------------------");
try { try {
var eventType = 'endSleep'; var eventType = 'beginSleep';
var reasonForSleep = 3; screenLock.off(eventType, () => {
screenLock.test_runtimeNotify(eventType, reasonForSleep, (err, data) => { console.log("Screenlock_Test_3300: test_getRuntimeState beginSleep is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3300: error = " + error); console.log("end Screenlock_Test_3300: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3300-------------------"); console.log("------------------end Screenlock_Test_3300-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_3400 * @tc.number Screenlock_Test_3400
* @tc.name No operation for a long time causes the screen to go off, and run "beginScreenOff" operate * @tc.name No operation for a long time causes the screen to go off, and run "endSleep" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_3400", 0, async function (done) { it("Screenlock_Test_3400", 0, async function (done) {
console.log("------------------start Screenlock_Test_3400-------------------"); console.log("------------------start Screenlock_Test_3400-------------------");
try { try {
var eventType = 'beginScreenOff'; var eventType = 'endSleep';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.off(eventType, () => {
console.log("Screenlock_Test_3400: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3400: test_getRuntimeState endSleep is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3400: error = " + error); console.log("end Screenlock_Test_3400: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3400-------------------"); console.log("------------------end Screenlock_Test_3400-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_3500 * @tc.number Screenlock_Test_3500
* @tc.name No operation for a long time causes the screen to go off, and run "endScreenOff" operate * @tc.name No operation for a long time causes the screen to go off, and run "changeUser" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_3500", 0, async function (done) { it("Screenlock_Test_3500", 0, async function (done) {
console.log("------------------start Screenlock_Test_3500-------------------"); console.log("------------------start Screenlock_Test_3500-------------------");
try { try {
var eventType = 'endScreenOff'; var eventType = 'changeUser';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.off(eventType, () => {
console.log("Screenlock_Test_3500: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3500: test_getRuntimeState changeUser is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3500: error = " + error); console.log("end Screenlock_Test_3500: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3500-------------------"); console.log("------------------end Screenlock_Test_3500-------------------");
done();
}); });
/* /*
...@@ -690,22 +534,15 @@ describe('ScreenLockServiceTest', function () { ...@@ -690,22 +534,15 @@ describe('ScreenLockServiceTest', function () {
console.log("------------------start Screenlock_Test_3600-------------------"); console.log("------------------start Screenlock_Test_3600-------------------");
try { try {
var eventType = 'beginWakeUp'; var eventType = 'beginWakeUp';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.on(eventType, () => {
console.log("Screenlock_Test_3600: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3600: test_getRuntimeState beginWakeUp is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3600: error = " + error); console.log("end Screenlock_Test_3600: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3600-------------------"); console.log("------------------end Screenlock_Test_3600-------------------");
done();
}); });
/* /*
...@@ -718,22 +555,15 @@ describe('ScreenLockServiceTest', function () { ...@@ -718,22 +555,15 @@ describe('ScreenLockServiceTest', function () {
console.log("------------------logMessage Screenlock_Test_3700-------------------"); console.log("------------------logMessage Screenlock_Test_3700-------------------");
try { try {
var eventType = 'endWakeUp'; var eventType = 'endWakeUp';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.on(eventType, () => {
console.log("Screenlock_Test_3700: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3700: test_getRuntimeState endWakeUp is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3700: error = " + error); console.log("end Screenlock_Test_3700: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3700-------------------"); console.log("------------------end Screenlock_Test_3700-------------------");
done();
}); });
/* /*
...@@ -746,22 +576,15 @@ describe('ScreenLockServiceTest', function () { ...@@ -746,22 +576,15 @@ describe('ScreenLockServiceTest', function () {
console.log("------------------start Screenlock_Test_3800-------------------"); console.log("------------------start Screenlock_Test_3800-------------------");
try { try {
var eventType = 'beginScreenOn'; var eventType = 'beginScreenOn';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.on(eventType, () => {
console.log("Screenlock_Test_3800: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3800: test_getRuntimeState beginScreenOn is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3800: error = " + error); console.log("end Screenlock_Test_3800: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3800-------------------"); console.log("------------------end Screenlock_Test_3800-------------------");
done();
}); });
/* /*
...@@ -774,145 +597,104 @@ describe('ScreenLockServiceTest', function () { ...@@ -774,145 +597,104 @@ describe('ScreenLockServiceTest', function () {
console.log("------------------start Screenlock_Test_3900-------------------"); console.log("------------------start Screenlock_Test_3900-------------------");
try { try {
var eventType = 'endScreenOn'; var eventType = 'endScreenOn';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.on(eventType, () => {
console.log("Screenlock_Test_3900: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_3900: test_getRuntimeState endScreenOn is successful" );
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_3900: error = " + error); console.log("end Screenlock_Test_3900: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_3900-------------------"); console.log("------------------end Screenlock_Test_3900-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4000 * @tc.number Screenlock_Test_4000
* @tc.name Modify the user ID to 2, and the modification is successful * @tc.name Responding to bright screen events, and run "beginScreenOff" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_4000", 0, async function (done) { it("Screenlock_Test_4000", 0, async function (done) {
console.log("------------------start Screenlock_Test_4000-------------------"); console.log("------------------start Screenlock_Test_4000-------------------");
try { try {
var eventType = 'changeUser'; var eventType = 'beginScreenOff';
var userId = 2; screenLock.on(eventType, () => {
screenLock.test_runtimeNotify(eventType, userId, (err, data) => { console.log("Screenlock_Test_4000: test_getRuntimeState beginScreenOff is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_4000: error = " + error); console.log("end Screenlock_Test_4000: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4000-------------------"); console.log("------------------end Screenlock_Test_4000-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4100 * @tc.number Screenlock_Test_4100
* @tc.name Modify the user ID to 0, and the modification is successful * @tc.name Responding to bright screen events, and run "endScreenOff" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_4100", 0, async function (done) { it("Screenlock_Test_4100", 0, async function (done) {
console.log("------------------logMessage Screenlock_Test_4100-------------------"); console.log("------------------logMessage Screenlock_Test_4100-------------------");
try { try {
var eventType = 'changeUser'; var eventType = 'endScreenOff';
var userId = 0; screenLock.on(eventType, () => {
screenLock.test_runtimeNotify(eventType, userId, (err, data) => { console.log("Screenlock_Test_4100: test_getRuntimeState endScreenOff is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_4100: error = " + error); console.log("end Screenlock_Test_4100: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4100-------------------"); console.log("------------------end Screenlock_Test_4100-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4200 * @tc.number Screenlock_Test_4200
* @tc.name Modify the user ID to -3, and the modification is failed * @tc.name Responding to bright screen events, and run "unlockScreen" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_4200", 0, async function (done) { it("Screenlock_Test_4200", 0, async function (done) {
console.log("------------------start Screenlock_Test_4200-------------------"); console.log("------------------start Screenlock_Test_4200-------------------");
try { try {
var eventType = 'changeUser'; var eventType = 'unlockScreen';
var userId = -3; screenLock.on(eventType, () => {
screenLock.test_runtimeNotify(eventType, userId, (err, data) => { console.log("Screenlock_Test_4200: test_getRuntimeState unlockScreen is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_4200: error = " + error); console.log("end Screenlock_Test_4200: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4200-------------------"); console.log("------------------end Screenlock_Test_4200-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4300 * @tc.number Screenlock_Test_4300
* @tc.name Modify the user ID to 99999999999999, and the modification is failed * @tc.name Responding to bright screen events, and run "beginExitAnimation" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_4300", 0, async function (done) { it("Screenlock_Test_4300", 0, async function (done) {
console.log("------------------start Screenlock_Test_4300-------------------"); console.log("------------------start Screenlock_Test_4300-------------------");
try { try {
var eventType = 'changeUser'; var eventType = 'beginExitAnimation';
var userId = 99999999999999; screenLock.on(eventType, () => {
screenLock.test_runtimeNotify(eventType, userId, (err, data) => { console.log("Screenlock_Test_4300: test_getRuntimeState beginExitAnimation is successful" );
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) { } catch (error) {
console.log("logMessage Screenlock_Test_4300: error = " + error); console.log("end Screenlock_Test_4300: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4300-------------------"); console.log("------------------end Screenlock_Test_4300-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4400 * @tc.number Screenlock_Test_4400
* @tc.name Modify the user ID to 'abc', and the modification is failed * @tc.name Responding to bright screen events, and run "beginSleep" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
...@@ -920,104 +702,81 @@ describe('ScreenLockServiceTest', function () { ...@@ -920,104 +702,81 @@ describe('ScreenLockServiceTest', function () {
console.log("------------------start Screenlock_Test_4400-------------------"); console.log("------------------start Screenlock_Test_4400-------------------");
try { try {
var eventType = 'changeUser'; var eventType = 'changeUser';
var userId = 'abc'; screenLock.on(eventType, (err, data) => {
screenLock.test_runtimeNotify(eventType, userId, (err, data) => { console.log("Screenlock_Test_4400: test_getRuntimeState beginSleep is successful");
console.log("Screenlock_Test_4400: test_runtimeNotify is successful, result is " + data); expect(data == INTERACTIVE_STATE_BEGIN_SLEEP).assertTrue();
});
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) { } catch (error) {
console.log("logMessage Screenlock_Test_4400: error = " + error); console.log("logMessage Screenlock_Test_4400: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4400-------------------"); console.log("------------------end Screenlock_Test_4400-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4500 * @tc.number Screenlock_Test_4500
* @tc.name Settings can lock the screen * @tc.name Responding to bright screen events, and run "endSleep" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_4500", 0, async function (done) { it("Screenlock_Test_4500", 0, async function (done) {
console.log("------------------start Screenlock_Test_4500-------------------"); console.log("------------------start Screenlock_Test_4500-------------------");
try { try {
var eventType = 'screenlockEnabled'; var eventType = 'endSleep';
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) => { screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4500: test_getRuntimeState is successful, result is" + data); console.log("Screenlock_Test_4500: test_getRuntimeState endSleep is successful");
expect(data == isScreenlockEnabled).assertTrue(); expect(data == INTERACTIVE_STATE_END_SLEEP).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.log("logMessage Screenlock_Test_4500: error = " + error); console.log("logMessage Screenlock_Test_4500: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4500-------------------"); console.log("------------------end Screenlock_Test_4500-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4600 * @tc.number Screenlock_Test_4600
* @tc.name Setting can not lock screen * @tc.name Responding to bright screen events, and run "changeUser" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_4600", 0, async function (done) { it("Screenlock_Test_4600", 0, async function (done) {
console.log("------------------start Screenlock_Test_4600-------------------"); console.log("------------------start Screenlock_Test_4600-------------------");
try { try {
var eventType = 'screenlockEnabled'; var eventType = 'changeUser';
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) => { screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4600: test_getRuntimeState is successful, result is" + data); console.log("Screenlock_Test_4600: test_getRuntimeState changeUser is successfuls");
expect(data == isScreenlockEnabled).assertTrue(); expect(data == INTERACTIVE_STATE_USERID).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.log("logMessage Screenlock_Test_4600: error = " + error); console.log("logMessage Screenlock_Test_4600: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4600-------------------"); console.log("------------------end Screenlock_Test_4600-------------------");
done();
}); });
/* /*
* @tc.number Screenlock_Test_4700 * @tc.number Screenlock_Test_4700
* @tc.name Run 'beginExitAnimation' operate * @tc.name Responding to bright screen events, and run "screenlockEnabled" operate
* @tc.desc Function test * @tc.desc Function test
* @tc.level 0 * @tc.level 0
*/ */
it("Screenlock_Test_4700", 0, async function (done) { it("Screenlock_Test_4700", 0, async function (done) {
console.log("------------------start Screenlock_Test_4700-------------------"); console.log("------------------start Screenlock_Test_4700-------------------");
try { try {
var eventType = 'beginExitAnimation'; var eventType = 'screenlockEnabled';
screenLock.test_runtimeNotify(eventType, -100, (err, data) => { screenLock.test_getRuntimeState(eventType, (err, data) => {
console.log("Screenlock_Test_4700: test_runtimeNotify is successful, result is " + data); console.log("Screenlock_Test_4700: test_getRuntimeState screenlockEnabled is successfuls");
expect(data == true).assertTrue(); expect(data == true).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.log("logMessage Screenlock_Test_4700: error = " + error); console.log("logMessage Screenlock_Test_4700: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.log("------------------end Screenlock_Test_4700-------------------"); console.log("------------------end Screenlock_Test_4700-------------------");
done();
}); });
}) })
\ No newline at end of file
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import screenLock from '@ohos.app.screenlockability'; import screenLock from '@ohos.screenLock';
import {describe, expect, it} from 'deccjsunit/index' import {describe, expect, it} from 'deccjsunit/index'
const SLEEP_TIME = 1000; const SLEEP_TIME = 1000;
describe('ScreenLockServicePromiseTest', function () { describe('ScreenLockServicePromiseTest', function () {
console.log("-----------------------ScreenlockPromiseTest is starting-----------------------"); console.info("-----------------------ScreenlockPromiseTest is starting-----------------------");
function sleep(numberMillis) { function sleep(numberMillis) {
var now = new Date(); var now = new Date();
...@@ -41,21 +41,16 @@ describe('ScreenLockServicePromiseTest', function () { ...@@ -41,21 +41,16 @@ describe('ScreenLockServicePromiseTest', function () {
console.info("------------------start ScreenLock_Test_Promise_0100-------------------"); console.info("------------------start ScreenLock_Test_Promise_0100-------------------");
var isScreenLocked = true; var isScreenLocked = true;
try { 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) => { screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0100 isScreenLocked result is " + data); console.info("ScreenLock_Test_Promise_0100 isScreenLocked result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue()
done();
})
}) })
} catch (error) { } catch (error) {
console.log("ScreenLock_Test_Promise_0100 test_setScreenLocked : error = " + error); console.info("ScreenLock_Test_Promise_0100 test_setScreenLocked : error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_Promise_0100-------------------"); console.info("------------------end ScreenLock_Test_Promise_0100-------------------");
done();
}); });
/* /*
...@@ -68,21 +63,16 @@ describe('ScreenLockServicePromiseTest', function () { ...@@ -68,21 +63,16 @@ describe('ScreenLockServicePromiseTest', function () {
console.info("------------------start ScreenLock_Test_Promise_0200-------------------"); console.info("------------------start ScreenLock_Test_Promise_0200-------------------");
var isScreenLocked = false; var isScreenLocked = false;
try { 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) => { screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0200 isScreenLocked result is " + data); console.info("ScreenLock_Test_Promise_0200 isScreenLocked result is " + data);
expect(data == false).assertTrue(); expect(data == false).assertTrue();
done();
});
}); });
} catch (error) { } catch (error) {
console.log("ScreenLock_Test_Promise_0200 test_setScreenLocked : error = " + error); console.info("ScreenLock_Test_Promise_0200 test_setScreenLocked : error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_Promise_0200-------------------"); console.info("------------------end ScreenLock_Test_Promise_0200-------------------");
done();
}); });
/* /*
...@@ -95,16 +85,15 @@ describe('ScreenLockServicePromiseTest', function () { ...@@ -95,16 +85,15 @@ describe('ScreenLockServicePromiseTest', function () {
console.info("------------------start ScreenLock_Test_Promise_0300-------------------"); console.info("------------------start ScreenLock_Test_Promise_0300-------------------");
try { try {
screenLock.isSecureMode().then((data) => { screenLock.isSecureMode().then((data) => {
console.log("ScreenLock_Test_Promise_0300 isScreenLocked result is " + data); console.info("ScreenLock_Test_Promise_0300 isScreenLocked result is " + data);
expect(data == false).assertTrue(); expect(data == false).assertTrue();
done();
}); });
} catch (error) { } catch (error) {
console.log("ScreenLock_Test_Promise_0300 isScreenLocked TRUE: error = " + error); console.info("ScreenLock_Test_Promise_0300 isScreenLocked TRUE: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_Promise_0300-------------------"); console.info("------------------end ScreenLock_Test_Promise_0300-------------------");
done();
}); });
/* /*
...@@ -116,41 +105,27 @@ describe('ScreenLockServicePromiseTest', function () { ...@@ -116,41 +105,27 @@ describe('ScreenLockServicePromiseTest', function () {
it("ScreenLock_Test_Promise_0400", 0, async function (done) { it("ScreenLock_Test_Promise_0400", 0, async function (done) {
console.info("------------------start ScreenLock_Test_Promise_0400-------------------"); console.info("------------------start ScreenLock_Test_Promise_0400-------------------");
try { 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(() => { screenLock.unlockScreen().then(() => {
console.log("ScreenLock_Test_Promise_0400: send unlockScreen issue success"); console.info("ScreenLock_Test_Promise_0400: send unlockScreen issue success");
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
var unlockScreenResult = 0; var unlockScreenResult = 0;
var eventType = 'unlockScreenResult'; var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult).then((data) => { screenLock.sendScreenLockEvent(eventType, unlockScreenResult).then((data) => {
console.log("ScreenLock_Test_Promise_0400: sendScreenLockEvent result is " + data); console.info("ScreenLock_Test_Promise_0400: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
screenLock.isScreenLocked().then((data) => { screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0400: isScreenLocked result is " + data); console.info("ScreenLock_Test_Promise_0400: isScreenLocked result is " + data);
expect(data == false).assertTrue(); 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) { } catch (error) {
console.info("Screenlock_Test_1400: error = " + error); console.info("Screenlock_Test_1400: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_Promise_0400-------------------"); console.info("------------------end ScreenLock_Test_Promise_0400-------------------");
done();
}); });
/* /*
...@@ -162,36 +137,30 @@ describe('ScreenLockServicePromiseTest', function () { ...@@ -162,36 +137,30 @@ describe('ScreenLockServicePromiseTest', function () {
it("ScreenLock_Test_Promise_0500", 0, async function (done) { it("ScreenLock_Test_Promise_0500", 0, async function (done) {
console.info("------------------start ScreenLock_Test_Promise_0500-------------------"); console.info("------------------start ScreenLock_Test_Promise_0500-------------------");
try { 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(() => { screenLock.unlockScreen().then(() => {
console.log("ScreenLock_Test_Promise_0500: send unlockScreen issue success"); console.info("ScreenLock_Test_Promise_0500: send unlockScreen issue success");
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
var unlockScreenResult = 1; var unlockScreenResult = 1;
var eventType = 'unlockScreenResult'; var eventType = 'unlockScreenResult';
screenLock.sendScreenLockEvent(eventType, unlockScreenResult).then((data) => { screenLock.sendScreenLockEvent(eventType, unlockScreenResult).then((data) => {
console.log("ScreenLock_Test_Promise_0500: sendScreenLockEvent result is " + data); console.info("ScreenLock_Test_Promise_0500: sendScreenLockEvent result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(SLEEP_TIME); sleep(SLEEP_TIME);
screenLock.isScreenLocked().then((data) => { screenLock.isScreenLocked().then((data) => {
console.log("ScreenLock_Test_Promise_0500: isScreenLocked result is " + data); console.info("ScreenLock_Test_Promise_0500: isScreenLocked result is " + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
done(); done();
}); });
} catch (error) { } catch (error) {
console.info("logMessage ScreenLock_Test_Promise_0500: error = " + error); console.info("logMessage ScreenLock_Test_Promise_0500: error = " + error);
expect(true).assertTrue(); expect(true).assertTrue();
done();
} }
console.info("------------------end ScreenLock_Test_Promise_0500-------------------"); console.info("------------------end ScreenLock_Test_Promise_0500-------------------");
done();
}); });
}) })
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册