提交 9e7320cb 编写于 作者: H hk_js

add testcase of callback interface

Signed-off-by: Nhk_js <hekun18@huawei.com>
上级 b403a943
......@@ -206,5 +206,189 @@ describe('display_test', function () {
}
})
/**
* @tc.number SUB_WMS_WATERFALLDISPLAYAREARECTS_JSAPI_001
* @tc.name Test waterfallDisplayAreaRects_Test_001.
* @tc.desc To test value of waterfallDisplayAreaRects.
*/
it('waterfallDisplayAreaRects_Test_001', 0, async function (done) {
console.info('test the value of waterfallDisplayAreaRects begin');
try {
var waterfallDisplayAreaRects = {
left : {
left:20,
top:20,
width:20,
height:20
},
right : {
left:800,
top:0,
width:600,
height:600
},
top : {
left:20,
top:20,
width:20,
height:20
},
bottom : {
left:20,
top:20,
width:600,
height:600
},
}
expect(waterfallDisplayAreaRects.left != null).assertTrue();
expect(waterfallDisplayAreaRects.right != null).assertTrue();
expect(waterfallDisplayAreaRects.top != null).assertTrue();
expect(waterfallDisplayAreaRects.bottom != null).assertTrue();
done();
} catch (err) {
console.error('test value of waterfallDisplayAreaRects error ' + JSON.stringify(err));
expect.assertFail();
done();
}
})
/**
* @tc.number SUB_WMS_RECT_JSAPI_001
* @tc.name Test RECT_Test_001.
* @tc.desc To test value of RECT.
*/
it('displayAreaRects_Test_001', 0, async function (done) {
console.info('test the value of aRect begin');
try {
var rect = {
left : 20,
right : 40,
width : 100,
height : 200
}
expect(20).assertEqual(rect.left);
expect(40).assertEqual(rect.right);
expect(100).assertEqual(rect.width);
expect(200).assertEqual(rect.height);
done();
} catch (err) {
console.error('test value of rect error ' + JSON.stringify(err));
expect.assertFail();
done();
}
})
/**
* @tc.number SUB_WMS_CutoutInfo_JSAPI_001
* @tc.name Test CutoutInfo_Test_001.
* @tc.desc To test value of CutoutInfo.
*/
it('CutoutInfo_Test_001', 0, async function (done) {
console.info('test the CutoutInfo of aRect begin');
try {
var cutoutInfo = {
boudingRects : [{
left : 20,
right : 40,
width : 100,
height : 200
}],
waterfallDisplayAreaRects : {
left : {
left:20,
top:20,
width:20,
height:20
},
right : {
left:800,
top:0,
width:600,
height:600
},
top : {
left:20,
top:20,
width:20,
height:20
},
bottom : {
left:20,
top:20,
width:600,
height:600
},
}
}
expect(1).assertEqual(cutoutInfo.boudingRects.length);
expect(cutoutInfo.waterfallDisplayAreaRects.left != null).assertTrue();
expect(cutoutInfo.waterfallDisplayAreaRects.right != null).assertTrue();
expect(cutoutInfo.waterfallDisplayAreaRects.top != null).assertTrue();
expect(cutoutInfo.waterfallDisplayAreaRects.bottom != null).assertTrue();
done();
} catch (err) {
console.error('test value of CutoutInfo error ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
/**
* @tc.number SUB_WMS_GETDISPLAYCUtOUTINFO_JSAPI_001
* @tc.name Test getDisplayCutoutInfo_Test_001
* @tc.desc To test the function of getCutoutInfo
*/
it('getDisplayCutoutInfo_Test_001', 0, async function (done) {
console.info('getCutoutInfo begin');
display.getDefaultDisplay().then(dsp => {
console.info('displayTest getCutoutInfo getDefaultDisplay id :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
dsp.getCutoutInfo((err, data) => {
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
if (err.code) {
console.error('Failed to get cutoutInfo. Cause: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.error('success to get cutoutInfo. Cause: ' + JSON.stringify(err));
expect(data != null).assertTrue();
done();
}
})
}, (err) => {
console.log('displayTest getgetCutoutInfo getDefaultDisplay failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_GETDISPLAYCUtOUTINFO_JSAPI_002
* @tc.name Test getDisplayCutoutInfo_Test_002
* @tc.desc To test the function of getCutoutInfo
*/
it('getDisplayCutoutInfo_Test_002', 0, async function (done) {
console.info('getCutoutInfo begin');
display.getDefaultDisplay().then(dsp => {
console.info('displayTest getCutoutInfo getDefaultDisplay id2 :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
dsp.getCutoutInfo().then(data => {
console.info('Succeeded in getting cutoutInfo2. data: ' + JSON.stringify(data));
expect(data != null).assertTrue();
done();
} ,err => {
console.log('displayTest getCutoutInfo getDefaultDisplay id2 failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('displayTest getgetCutoutInfo getDefaultDisplay failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
})
})
})
}
......@@ -2645,7 +2645,6 @@ describe('window_test', function () {
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
......@@ -3052,5 +3051,480 @@ describe('window_test', function () {
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLORCALLBACK_JSAPI_001
* @tc.name Test setBackgroundColorCALLBack_Test_001
* @tc.desc Set the window background color to red and Default opacity
*/
it('setBackgroundColorCallBack_Test_001', 0, async function (done) {
console.info('windowTest setBackgroundColorCallBackTest1 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorBackTest1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#ffff00",(err, data) => {
if (err.code) {
console.error('Failed to set the background color. Cause: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data));
wnd.getProperties().then(data => {
expect(!data.isTransparent).assertTrue();
done();
}, (err) => {
console.log('windowTest setBackgroundColorCallBackTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.info('windowTest setBackgroundColorCallBackTest1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLORCALLBACK_JSAPI_002
* @tc.name Test setBackgroundColorCallBack_Test_002
* @tc.desc Set the window background color to red opaque
*/
it('setBackgroundColorCallBack_Test_002', 0, async function (done) {
console.log('windowTest setBackgroundColorCallBackTest2 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTestCallBack2 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#ffffff00",(err, data) => {
if (err.code) {
console.error('Failed to set the background color2. Cause: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.info('Succeeded in setting the background color2. Data: ' + JSON.stringify(data));
wnd.getProperties().then(data => {
expect(!data.isTransparent).assertTrue();
done();
}, (err) => {
console.log('windowTest setBackgroundColorCallBackTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.log('windowTest setBackgroundColorTest2 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLORCallBack_JSAPI_003
* @tc.name Test setBackgroundColorBack_Test_003
* @tc.desc Set the window background color to red transparent
*/
it('setBackgroundColorCallBack_Test_003', 0, async function (done) {
console.log('windowTest setBackgroundColorTestCallBack3 begin');
window.getTopWindow().then(wnd => {
console.info('windowTest setBackgroundColorTest3 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#00ffff00",(err, data) => {
if (err.code) {
console.error('Failed to set the background color2. Cause: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.info('Succeeded in setting the background color2. Data: ' + JSON.stringify(data));
wnd.getProperties().then(data => {
expect(data.isTransparent).assertTrue();
done();
}, (err) => {
console.info('windowTest setBackgroundColorCallBackTest3 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.log('windowTest setBackgroundColorCallBackTest3 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLORBACK_JSAPI_004
* @tc.name Test setBackgroundColorBack_Test_004
* @tc.desc Set the background color input parameter as an outlier
*/
it('setBackgroundColorBack_Test_004', 0, async function (done) {
console.info('windowTest setBackgroundColorCallBackTest4 begin');
window.getTopWindow().then(wnd => {
console.info('windowTest setBackgroundColorTestCallBack4 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("ff00",(err, data) => {
if (err.code) {
console.error('Failed to set the background color2. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(1003);
done();
} else {
console.info('Succeeded in setting the background color2. Data: ' + JSON.stringify(data));
expect().assertFail();
done();
}
})
}, (err) => {
console.info('windowTest setBackgroundColorCallBackTest4 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLORCallBack_JSAPI_005
* @tc.name Test setBackgroundColorCallBack_Test_005
* @tc.desc Setting window background color input exception ARGB
*/
it('setBackgroundColorCallBack_Test_005', 0, async function (done) {
console.log('windowTest setBackgroundColorCallBackTest5 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorBackTest5 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#hhgghhgg",(err, data) => {
if (err.code) {
console.error('Failed to set the background color5. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(1003);
done();
} else {
console.info('Succeeded in setting the background color5. Data: ' + JSON.stringify(data));
expect().assertFail();
done();
}
})
}, (err) => {
console.info('windowTest setBackgroundColorTest5 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBACKGROUNDCOLORCallBack_JSAPI_006
* @tc.name Test setBackgroundColorBack_Test_006
* @tc.desc Setting window background color input exception RGB
*/
it('setBackgroundColorCallBack_Test_006', 0, async function (done) {
console.log('windowTest setBackgroundColorTestCallBack6 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBackgroundColorTestCallBack6 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBackgroundColor("#gghhkk",(err, data) => {
if (err.code) {
console.error('Failed to set the background color6. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(1003);
done();
} else {
console.info('Succeeded in setting the background color6. Data: ' + JSON.stringify(data));
expect().assertFail();
done();
}
})
}, (err) => {
console.log('windowTest setBackgroundColorTest6 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESSCALLBACK_JSAPI_002
* @tc.name Test setBrightnessCallBack_Test_002
* @tc.desc Set the brightness bar input parameter to decimal
*/
it('setBrightnessCallBack_Test_002', 0, async function (done) {
console.log('windowTest setBrightnessTestCallBack2 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTestCallBack2 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(1, (err, data) => {
if (err.code) {
console.error('Failed to set the brightness2. Cause: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.info('Succeeded in setting the brightness2. Data: ' + JSON.stringify(data));
wnd.getProperties().then(data => {
console.info('windowTest setBrightnessTest2 getProperties data ' + data);
expect(data.brightness).assertEqual(1);
done();
}, (err) => {
console.log('windowTest setBrightnessTest2 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.log('windowTest setBrightnessTest2 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESSCALLBACK_JSAPI_003
* @tc.name Test setBrightnessCallBack_Test_003
* @tc.desc Set the brightness bar input parameter to number max
*/
it('setBrightnessCallBack_Test_003', 0, async function (done) {
console.log('windowTest setBrightnessTest3 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest3 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(Number.MAX_VALUE, (err, data) => {
if (err.code) {
console.log('windowTest setBrightnessTest3 setBrightness failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(1003);
done();
} else {
console.log('windowTest setBrightnessTest3 setBrightness(Number.MAX_VALUE) success ');
expect().assertFail();
done();
}
})
}, (err) => {
console.log('windowTest setBrightnessTest3 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESSCALLBACK_JSAPI_004
* @tc.name Test setBrightnessCallBack_Test_004
* @tc.desc Set the brightness bar input parameter to number min
*/
it('setBrightnessCallBack_Test_004', 0, async function (done) {
console.log('windowTest setBrightnessTest4 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest4 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(Number.MIN_VALUE, (err, data) => {
if (err.code) {
console.log('windowTest setBrightnessTest4 setBrightness failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(1003);
done();
} else {
console.log('windowTest setBrightnessTest4 setBrightness(Number.MIN_VALUE) success ');
expect(TRUE_WINDOW).assertTrue();
done();
}
})
}, (err) => {
console.log('windowTest setBrightnessTest4 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETBRIGHTNESSCALLBACK_JSAPI_005
* @tc.name Test setBrightnessCALLBACK_Test_005
* @tc.desc Setting brightness bar input parameter exception
*/
it('setBrightnessCallBack_Test_005', 0, async function (done) {
console.log('windowTest setBrightnessTest5 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setBrightnessTest5 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setBrightness(1.1, (err, data) => {
if (err.code) {
console.log('windowTest setBrightnessTest5 setBrightness failed: err' + JSON.stringify(err));
expect(err.code).assertEqual(1003);
done();
} else {
console.log('windowTest setBrightnessTest5 setBrightness(1.1) success ');
expect().assertFail();
done();
}
})
}, (err) => {
console.log('windowTest setBrightnessTest5 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETTOUCHABLECALLBACK_JSAPI_001
* @tc.name Test setTouchableCallBack_Test_001
* @tc.desc Set whether the window can be touched or not
*/
it('setTouchableCallBack_Test_001', 0, async function (done) {
window.getTopWindow().then(wnd => {
console.log('windowTest setTouchableTestCallBack1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setTouchable(false, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
wnd.getProperties().then(data => {
expect(!data.touchable).assertTrue();
wnd.setTouchable(true, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
wnd.getProperties().then(data => {
expect(data.touchable).assertTrue();
done();
}, (err) => {
console.info('windowTest setTouchableTestCallBack1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.log('windowTest setTouchableTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.log('windowTest setTouchableTest1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETFOCUSABLECALLBACK_JSAPI_001
* @tc.name Test setFocusable_Test_001
* @tc.desc Setting window focus acquisition and defocus
*/
it('setFocusableCallBack_Test_001', 0, async function (done) {
console.log('windowTest setFocusableTest1 begin');
window.getTopWindow().then(wnd => {
console.log('windowTest setFocusableCallBack1 getTopWindow wnd' + wnd);
expect(wnd != null).assertTrue();
wnd.setFocusable(false, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
wnd.getProperties().then(data => {
expect(!data.focusable).assertTrue();
wnd.setFocusable(true, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
wnd.getProperties().then(data => {
expect(data.focusable).assertTrue();
done();
}, (err) => {
console.info('windowTest setFocusableTestCallBack1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.log('windowTest setFocusableTest1 getProperties failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}
})
}, (err) => {
console.log('windowTest setFocusable1 getTopWindow failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_ENUM_AVOIDAREATYPE_JSAPI_001
* @tc.name Test avoidareatype_Test_001.
* @tc.desc To test the enum value of avoidareatype.
*/
it('enumAvoidAreaType_Test_001', 0, async function (done) {
console.info('test the enum AvoidArea of orientation begin');
try {
expect(0).assertEqual(window.AvoidAreaType.TYPE_SYSTEM);
expect(1).assertEqual(window.AvoidAreaType.TYPE_CUTOUT);
expect(2).assertEqual(window.AvoidAreaType.TYPE_SYSTEM_GESTURE);
expect(3).assertEqual(window.AvoidAreaType.TYPE_KEYBOARD);
done();
} catch (err) {
console.info('test enum value of AvoidArea error ' + JSON.stringify(err));
expect().assertFail();
done();
}
})
/**
* @tc.number SUB_WMS_GETAVOIDAREAADD_JSAPI_001
* @tc.name Test getAvoidAreaAdd_Test_001
* @tc.desc Get System type avoidance area
*/
it('getAvoidAreaAdd_Test_001', 0, async function (done) {
console.log('windowTest getAvoidAreaAdd_Test_001 begin');
window.getTopWindow().then(wnd => {
console.info('windowTest getAvoidAreaTestAdd window.getTopWindow wnd: ' + wnd);
expect(wnd != null).assertTrue();
wnd.getAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD, (err, data) => {
if (err.code != 0) {
console.log('windowTest getAvoidAreaTestAdd1 wnd.getAvoidArea callback fail' + JSON.stringify(err));
expect().assertFail();
done();
} else {
expect(data.topRect != null).assertTrue();
expect(data.rightRect != null).assertTrue();
expect(data.bottomRect != null).assertTrue();
expect(data.leftRect != null).assertTrue();
done();
}
})
})
})
/**
* @tc.number SUB_WMS_GETAVOIDAREAADD_JSAPI_002
* @tc.name Test getAvoidAreaAdd_Test_002
* @tc.desc Get invalid parameter avoidarea
*/
it('getAvoidAreaAdd_Test_002', 0, async function (done) {
console.log('windowTest getAvoidAreaAdd_Test_002 begin');
window.getTopWindow().then(wnd => {
console.info('windowTest getAvoidAreaTestAdd002 window.getTopWindow wnd: ' + wnd);
expect(wnd != null).assertTrue();
wnd.getAvoidArea(-1, (err, data) => {
console.info('windowTest getAvoidAreaTestAdd2' + JSON.stringify(data));
if (err.code != 0) {
console.log('windowTest getAvoidAreaTestAdd002 wnd.getAvoidArea callback fail' + JSON.stringify(err));
expect().assertFail();
done();
} else {
expect(data.topRect != null).assertTrue();
expect(data.rightRect != null).assertTrue();
expect(data.bottomRect != null).assertTrue();
expect(data.leftRect != null).assertTrue();
done();
}
})
})
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册