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

!4700 test: 用例删除同步断言

Merge pull request !4700 from ShiJie/OpenHarmony-3.1-Release
...@@ -49,23 +49,17 @@ describe('appInfoTest_battery4', function () { ...@@ -49,23 +49,17 @@ describe('appInfoTest_battery4', function () {
*/ */
const successTest = "get_status_success_test"; const successTest = "get_status_success_test";
it(successTest, 0, function () { it(successTest, 0, function () {
let execSucc = false;
let execcomplete = false;
battery.getStatus({ battery.getStatus({
success: (data) => { success: (data) => {
execSucc = true;
successFunc(data, successTest); successFunc(data, successTest);
}, },
fail: (data, code) => { fail: (data, code) => {
failFunc(data, code, successTest); failFunc(data, code, successTest);
}, },
complete: () => { complete: () => {
execcomplete = true;
completeFunc(successTest); completeFunc(successTest);
} }
}); });
expect(execSucc).assertTrue();
expect(execcomplete).assertTrue();
}); });
/** /**
...@@ -75,18 +69,15 @@ describe('appInfoTest_battery4', function () { ...@@ -75,18 +69,15 @@ describe('appInfoTest_battery4', function () {
*/ */
const successNullTest = "get_status_success_null_test"; const successNullTest = "get_status_success_null_test";
it(successNullTest, 0, function () { it(successNullTest, 0, function () {
let execcomplete = false;
battery.getStatus({ battery.getStatus({
success: null, success: null,
fail: (data, code) => { fail: (data, code) => {
failFunc(data, code, successNullTest); failFunc(data, code, successNullTest);
}, },
complete: () => { complete: () => {
execcomplete = true;
completeFunc(successNullTest); completeFunc(successNullTest);
} }
}); });
expect(execcomplete).assertTrue();
}); });
/** /**
...@@ -96,17 +87,14 @@ describe('appInfoTest_battery4', function () { ...@@ -96,17 +87,14 @@ describe('appInfoTest_battery4', function () {
*/ */
const successEmptyTest = "get_status_success_null_test"; const successEmptyTest = "get_status_success_null_test";
it(successEmptyTest, 0, function () { it(successEmptyTest, 0, function () {
let execcomplete = false;
battery.getStatus({ battery.getStatus({
fail: (data, code) => { fail: (data, code) => {
failFunc(data, code, successEmptyTest); failFunc(data, code, successEmptyTest);
}, },
complete: () => { complete: () => {
execcomplete = true;
completeFunc(successEmptyTest); completeFunc(successEmptyTest);
} }
}); });
expect(execcomplete).assertTrue();
}); });
/** /**
...@@ -116,21 +104,15 @@ describe('appInfoTest_battery4', function () { ...@@ -116,21 +104,15 @@ describe('appInfoTest_battery4', function () {
*/ */
let failNullTest = "get_status_fail_null_test"; let failNullTest = "get_status_fail_null_test";
it(failNullTest, 0, function () { it(failNullTest, 0, function () {
let execSucc = false;
let execcomplete = false;
battery.getStatus({ battery.getStatus({
success: (data) => { success: (data) => {
execSucc = true;
successFunc(data, failNullTest); successFunc(data, failNullTest);
}, },
fail: null, fail: null,
complete: () => { complete: () => {
execcomplete = true;
completeFunc(failNullTest); completeFunc(failNullTest);
} }
}); });
expect(execSucc).assertTrue();
expect(execcomplete).assertTrue();
}); });
/** /**
...@@ -140,20 +122,14 @@ describe('appInfoTest_battery4', function () { ...@@ -140,20 +122,14 @@ describe('appInfoTest_battery4', function () {
*/ */
let failEmptyTest = "get_status_fail_empty_test"; let failEmptyTest = "get_status_fail_empty_test";
it(failEmptyTest, 0, function () { it(failEmptyTest, 0, function () {
let execSucc = false;
let execcomplete = false;
battery.getStatus({ battery.getStatus({
success: () => { success: () => {
execSucc = true;
successFunc(data, failEmptyTest); successFunc(data, failEmptyTest);
}, },
complete: () => { complete: () => {
execcomplete = true;
completeFunc(failEmptyTest); completeFunc(failEmptyTest);
} }
}); });
expect(execSucc).assertTrue();
expect(execcomplete).assertTrue();
}); });
/** /**
...@@ -163,10 +139,8 @@ describe('appInfoTest_battery4', function () { ...@@ -163,10 +139,8 @@ describe('appInfoTest_battery4', function () {
*/ */
let completeNullTest = "get_status_complete_null_test"; let completeNullTest = "get_status_complete_null_test";
it(completeNullTest, 0, function () { it(completeNullTest, 0, function () {
let execSucc = false;
battery.getStatus({ battery.getStatus({
success: (data) => { success: (data) => {
execSucc = true;
successFunc(data, completeNullTest); successFunc(data, completeNullTest);
}, },
fail: (data, code) => { fail: (data, code) => {
...@@ -174,7 +148,6 @@ describe('appInfoTest_battery4', function () { ...@@ -174,7 +148,6 @@ describe('appInfoTest_battery4', function () {
}, },
complete: null complete: null
}); });
expect(execSucc).assertTrue();
}); });
/** /**
...@@ -184,17 +157,14 @@ describe('appInfoTest_battery4', function () { ...@@ -184,17 +157,14 @@ describe('appInfoTest_battery4', function () {
*/ */
let completeEmptyTest = "get_status_complete_empty_test"; let completeEmptyTest = "get_status_complete_empty_test";
it(completeEmptyTest, 0, function () { it(completeEmptyTest, 0, function () {
let execSucc = false;
battery.getStatus({ battery.getStatus({
success: (data) => { success: (data) => {
execSucc = true;
successFunc(data, completeEmptyTest); successFunc(data, completeEmptyTest);
}, },
fail: (data, code) => { fail: (data, code) => {
failFunc(data, code, completeEmptyTest); failFunc(data, code, completeEmptyTest);
} }
}); });
expect(execSucc).assertTrue();
}); });
/** /**
......
...@@ -17,18 +17,14 @@ import brightness from '@system.brightness'; ...@@ -17,18 +17,14 @@ import brightness from '@system.brightness';
import { describe } from 'deccjsunit/index'; import { describe } from 'deccjsunit/index';
const INPUT_ERROR_CODE_CODE = 202; const INPUT_ERROR_CODE_CODE = 202;
const SET_VALUE_MSG = "setValue: value is not an available number"; const SET_VALUE_MSG = "value is not an available number";
const SET_MODE_MSG = "setMode: value is not an available number"; const SET_MODE_MSG = "value is not an available number";
function isNotSupported(data) {
return data === "setMode: Auto adjusting brightness is not supported";
}
function sleep(time){ function sleep(time){
return new Promise((resolve) => setTimeout(resolve, time)); return new Promise((resolve) => setTimeout(resolve, time));
} }
describe('appInfoTest_doisplay1', function () { describe('appInfoTest_display', function () {
console.log("*************System SystemDisplay Unit Test Begin*************"); console.log("*************System SystemDisplay Unit Test Begin*************");
/** /**
...@@ -37,8 +33,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -37,8 +33,6 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc Get brightness success * @tc.desc Get brightness success
*/ */
it('get_value_success', 0, function () { it('get_value_success', 0, function () {
let execSucc = false;
let execComplete = false;
let currValue = 100; let currValue = 100;
let setValue = 120; let setValue = 120;
brightness.getValue({ brightness.getValue({
...@@ -53,7 +47,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -53,7 +47,6 @@ describe('appInfoTest_doisplay1', function () {
}); });
brightness.getValue({ brightness.getValue({
success: (data) => { success: (data) => {
execSucc = true;
expect(setValue === data.value).assertTrue(); expect(setValue === data.value).assertTrue();
}, },
fail: (data, code) => { fail: (data, code) => {
...@@ -61,12 +54,9 @@ describe('appInfoTest_doisplay1', function () { ...@@ -61,12 +54,9 @@ describe('appInfoTest_doisplay1', function () {
expect().assertFail(); expect().assertFail();
}, },
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execSucc).assertTrue();
expect(execComplete).assertTrue();
brightness.setValue({ brightness.setValue({
value: currValue value: currValue
...@@ -79,18 +69,15 @@ describe('appInfoTest_doisplay1', function () { ...@@ -79,18 +69,15 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc Get brightness * @tc.desc Get brightness
*/ */
it('get_status_test_success_not_must', 0, function () { it('get_status_test_success_not_must', 0, function () {
let execComplete = false;
brightness.getValue({ brightness.getValue({
fail: (data, code) => { fail: (data, code) => {
console.log("get_status_test_success_not_must, data: " + data + ", code: " + code); console.log("get_status_test_success_not_must, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
}, },
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execComplete).assertTrue();
}) })
/** /**
...@@ -99,14 +86,11 @@ describe('appInfoTest_doisplay1', function () { ...@@ -99,14 +86,11 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc Get brightness * @tc.desc Get brightness
*/ */
it('get_value_fail_not_must_test', 0, function () { it('get_value_fail_not_must_test', 0, function () {
let execComplete = false;
brightness.getValue({ brightness.getValue({
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execComplete).assertTrue();
}); });
/** /**
...@@ -125,8 +109,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -125,8 +109,6 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc Set brightness success * @tc.desc Set brightness success
*/ */
it('set_value_success_all', 0, function () { it('set_value_success_all', 0, function () {
let execSucc = false;
let execComplete = false;
let setValue = 200; let setValue = 200;
let currValue = 100; let currValue = 100;
brightness.getValue({ brightness.getValue({
...@@ -138,7 +120,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -138,7 +120,6 @@ describe('appInfoTest_doisplay1', function () {
brightness.setValue({ brightness.setValue({
value: setValue, value: setValue,
success: () => { success: () => {
execSucc = true;
brightness.getValue({ brightness.getValue({
success: (data) => { success: (data) => {
expect(data.value === setValue).assertTrue(); expect(data.value === setValue).assertTrue();
...@@ -150,12 +131,9 @@ describe('appInfoTest_doisplay1', function () { ...@@ -150,12 +131,9 @@ describe('appInfoTest_doisplay1', function () {
expect().assertFail(); expect().assertFail();
}, },
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execSucc).assertTrue();
expect(execComplete).assertTrue();
brightness.setValue({ brightness.setValue({
value: currValue value: currValue
...@@ -212,8 +190,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -212,8 +190,6 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc Get mode success * @tc.desc Get mode success
*/ */
it('get_mode_success', 0, function () { it('get_mode_success', 0, function () {
let execSucc = false;
let execComplete = false;
let modeVal = 0; let modeVal = 0;
let exec = true; let exec = true;
brightness.getMode({ brightness.getMode({
...@@ -226,7 +202,7 @@ describe('appInfoTest_doisplay1', function () { ...@@ -226,7 +202,7 @@ describe('appInfoTest_doisplay1', function () {
mode: modeVal ? 0 : 1, mode: modeVal ? 0 : 1,
fail: (data, code) => { fail: (data, code) => {
console.log("get_mode_success, data: " + data + ", code: " + code); console.log("get_mode_success, data: " + data + ", code: " + code);
exec = isNotSupported(data) ? false : true; exec = false;
} }
}) })
if (!exec) { if (!exec) {
...@@ -234,20 +210,16 @@ describe('appInfoTest_doisplay1', function () { ...@@ -234,20 +210,16 @@ describe('appInfoTest_doisplay1', function () {
} }
brightness.getMode({ brightness.getMode({
success: (data) => { success: (data) => {
execSucc = true; expect(data.mode === (modeVal ? 0 : 1)).assertTrue();
expect(data.mode === !modeVal).assertTrue() ;
}, },
fail: (data, code) => { fail: (data, code) => {
console.log("get_mode_success, data: " + data + ", code: " + code); console.log("get_mode_success, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
}, },
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execSucc).assertTrue();
expect(execComplete).assertTrue();
brightness.setMode({ mode: modeVal }); brightness.setMode({ mode: modeVal });
}) })
...@@ -258,18 +230,15 @@ describe('appInfoTest_doisplay1', function () { ...@@ -258,18 +230,15 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc Get mode success is null * @tc.desc Get mode success is null
*/ */
it('get_mode_success_null', 0, function () { it('get_mode_success_null', 0, function () {
let execComplete = false;
brightness.getMode({ brightness.getMode({
fail: (data, code) => { fail: (data, code) => {
console.log("get_mode_success_null, data: " + data + ", code: " + code); console.log("get_mode_success_null, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
}, },
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execComplete).assertTrue();
}); });
/** /**
...@@ -278,8 +247,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -278,8 +247,6 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc set mode success * @tc.desc set mode success
*/ */
it('set_mode_success', 0, function () { it('set_mode_success', 0, function () {
let execSucc = false;
let execComplete = false;
let modeVal = 0; let modeVal = 0;
brightness.getMode({ brightness.getMode({
success: (data) => { success: (data) => {
...@@ -290,32 +257,18 @@ describe('appInfoTest_doisplay1', function () { ...@@ -290,32 +257,18 @@ describe('appInfoTest_doisplay1', function () {
brightness.setMode({ brightness.setMode({
mode: modeVal ? 0 : 1, mode: modeVal ? 0 : 1,
success: () => { success: () => {
execSucc = true;
console.log("set_mode_success success"); console.log("set_mode_success success");
brightness.getMode({ brightness.getMode({
success: (data) => { success: (data) => {
console.log("set_mode_success, data: " + data.mode); console.log("set_mode_success, data: " + data.mode);
expect(data.mode === !modeVal).assertTrue(); expect(data.mode === (modeVal ? 0 : 1)).assertTrue();
} }
}); });
}, },
fail: (data, code) => {
if (!isNotSupported(data)) {
console.log("set_mode_success, data: " + data + ", code: " + code);
expect().assertFail();
} else {
console.log("set_mode_success not supported");
execSucc = true;
expect(isNotSupported(data)).assertTrue();
}
},
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execSucc).assertTrue();
expect(execComplete).assertTrue();
brightness.setMode({ mode: modeVal }); brightness.setMode({ mode: modeVal });
}); });
...@@ -326,7 +279,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -326,7 +279,6 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc set mode fail * @tc.desc set mode fail
*/ */
it('set_mode_fail', 0, function () { it('set_mode_fail', 0, function () {
let execComplete = false;
brightness.setMode({ brightness.setMode({
mode: "0", mode: "0",
success: () => { success: () => {
...@@ -338,11 +290,9 @@ describe('appInfoTest_doisplay1', function () { ...@@ -338,11 +290,9 @@ describe('appInfoTest_doisplay1', function () {
expect(data === SET_MODE_MSG).assertTrue(); expect(data === SET_MODE_MSG).assertTrue();
}, },
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execComplete).assertTrue();
}); });
/** /**
...@@ -351,25 +301,17 @@ describe('appInfoTest_doisplay1', function () { ...@@ -351,25 +301,17 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc set keep screen on true * @tc.desc set keep screen on true
*/ */
it('set_keep_screen_on_true', 0, async function () { it('set_keep_screen_on_true', 0, async function () {
let execSucc = false;
let execComplete = false;
let sleepTime = 35 * 1000; let sleepTime = 35 * 1000;
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: true, keepScreenOn: true,
success: () => {
execSucc = true;
},
fail: (data, code) => { fail: (data, code) => {
console.log("set_keep_screen_on, data: " + data + ", code: " + code); console.log("set_keep_screen_on, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
}, },
complete: () => { complete: () => {
execComplete = true;
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execSucc).assertTrue();
expect(execComplete).assertTrue();
await sleep(sleepTime); await sleep(sleepTime);
power.isScreenOn().then(screenOn => { power.isScreenOn().then(screenOn => {
...@@ -386,14 +328,9 @@ describe('appInfoTest_doisplay1', function () { ...@@ -386,14 +328,9 @@ describe('appInfoTest_doisplay1', function () {
* @tc.desc set keep screen on false * @tc.desc set keep screen on false
*/ */
it('set_keep_screen_on_false', 0, async function () { it('set_keep_screen_on_false', 0, async function () {
let execSucc = false;
let execComplete = false;
let sleepTime = 35 * 1000; let sleepTime = 35 * 1000;
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: false, keepScreenOn: false,
success: () => {
execSucc = true;
},
fail: (data, code) => { fail: (data, code) => {
console.log("set_keep_screen_on_false, data: " + data + ", code: " + code); console.log("set_keep_screen_on_false, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
...@@ -403,8 +340,6 @@ describe('appInfoTest_doisplay1', function () { ...@@ -403,8 +340,6 @@ describe('appInfoTest_doisplay1', function () {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
} }
}); });
expect(execSucc).assertTrue();
expect(execComplete).assertTrue();
await sleep(sleepTime); await sleep(sleepTime);
power.isScreenOn().then(screenOn => { power.isScreenOn().then(screenOn => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册