You need to sign in or sign up before continuing.
提交 afc3ee46 编写于 作者: L liziqiang

fix window screen time and fix interface errocode

Signed-off-by: Nliziqiang <liziqiang8@huawei.com>
上级 82dd4cb3
...@@ -24,5 +24,8 @@ export default { ...@@ -24,5 +24,8 @@ export default {
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.$t('strings.world');
const configService = core.getDefaultService('config');
this.timeout = 15000;
configService.setConfig(this);
} }
} }
...@@ -17,5 +17,5 @@ require('./window.api.part2.js') ...@@ -17,5 +17,5 @@ require('./window.api.part2.js')
require('./window.test.js') require('./window.test.js')
require('./window.parameter.js') require('./window.parameter.js')
require('./window.promise.js') require('./window.promise.js')
require('./display.screenshot.api.js') require('./screenshot.test.js')
...@@ -12,15 +12,13 @@ ...@@ -12,15 +12,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 app from '@system.app'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import display from '@ohos.display' import display from '@ohos.display'
import screenshot from '@ohos.screenshot' import screenshot from '@ohos.screenshot'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image'
import screen from '@ohos.screen'
describe('screenshot_test', function () { describe('screenshot_test', function () {
const TRUE_FLAG = true;
const FALSE_FLAG = false;
beforeAll(function () { beforeAll(function () {
}) })
...@@ -33,13 +31,14 @@ describe('screenshot_test', function () { ...@@ -33,13 +31,14 @@ describe('screenshot_test', function () {
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_001 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_001
* @tc.name Test screenShotSaveTest1 * @tc.name Test screenShotSave_Test_001
* @tc.desc Set the screenshot area to be larger than the screen width and height * @tc.desc Set the screenshot area to be larger than the screen width and height
*/ */
it('screenShotSaveTest1', 0, function (done) { it('screenShotSave_Test_001', 0, function (done) {
console.log('jsunittest screenShotSaveTest1 begin'); console.log('screenshotTest screenShotSaveTest1 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest1 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest1 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -54,30 +53,31 @@ describe('screenshot_test', function () { ...@@ -54,30 +53,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest1 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest1 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest1 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest1 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue(); expect(err.code == 120).assertTrue();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest1 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest1 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_002 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_002
* @tc.name Test screenShotSaveTest2 * @tc.name Test screenShotSave_Test_002
* @tc.desc Set the size of the screenshot area and the generated image to be larger than the screen width and height * @tc.desc Set the size of the screenshot area and the generated image to be larger than the screen width and height
*/ */
it('screenShotSaveTest2', 0, function (done) { it('screenShotSave_Test_002', 0, function (done) {
console.log('jsunittest screenShotSaveTest2 begin'); console.log('screenshotTest screenShotSaveTest2 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest2 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest2 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -92,30 +92,31 @@ describe('screenshot_test', function () { ...@@ -92,30 +92,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest2 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest2 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest2 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest2 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue(); expect(err.code == 120).assertTrue();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest2 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest2 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done() done()
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_003 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_003
* @tc.name Test screenShotSaveTest3 * @tc.name Test screenShotSave_Test_003
* @tc.desc Set the screenshot area and the size of the generated image to be smaller than the screen width and height * @tc.desc Set the screenshot area and the size of the generated image to be smaller than the screen width and height
*/ */
it('screenShotSaveTest3', 0, function (done) { it('screenShotSave_Test_003', 0, function (done) {
console.log('jsunittest screenShotSaveTest3 begin'); console.log('screenshotTest screenShotSaveTest3 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest3 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest3 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -130,30 +131,31 @@ describe('screenshot_test', function () { ...@@ -130,30 +131,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest3 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest3 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue(); expect(data != null).assertTrue();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest3 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest3 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest3 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest3 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_004 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_004
* @tc.name Test screenShotSaveTest4 * @tc.name Test screenShotSave_Test_004
* @tc.desc Set the size of the generated image to be smaller than the screen width and height * @tc.desc Set the size of the generated image to be smaller than the screen width and height
*/ */
it('screenShotSaveTest4', 0, function (done) { it('screenShotSave_Test_004', 0, function (done) {
console.log('jsunittest screenShotSaveTest4 begin'); console.log('screenshotTest screenShotSaveTest4 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest4 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest4 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -168,30 +170,31 @@ describe('screenshot_test', function () { ...@@ -168,30 +170,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest4 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest4 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue() expect(data != null).assertTrue();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest4 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest4 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest4 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest4 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_005 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_005
* @tc.name Test screenShotSaveTest5 * @tc.name Test screenShotSave_Test_005
* @tc.desc Set the screenshot area to a negative value * @tc.desc Set the screenshot area to a negative value
*/ */
it('screenShotSaveTest5', 0, function (done) { it('screenShotSave_Test_005', 0, function (done) {
console.log('jsunittest screenShotSaveTest5 begin'); console.log('screenshotTest screenShotSaveTest5 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest5 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest5 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: -50, left: -50,
...@@ -206,30 +209,31 @@ describe('screenshot_test', function () { ...@@ -206,30 +209,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest5 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest5 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest5 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest5 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue(); expect(err.code == 120).assertTrue();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest5 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest5 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_006 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_006
* @tc.name Test screenShotSaveTest6 * @tc.name Test screenShotSave_Test_006
* @tc.desc Set the screenshot area to 0 * @tc.desc Set the screenshot area to 0
*/ */
it('screenShotSaveTest6', 0, function (done) { it('screenShotSave_Test_006', 0, function (done) {
console.log('jsunittest screenShotSaveTest6 begin'); console.log('screenshotTest screenShotSaveTest6 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest6 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest6 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -244,30 +248,31 @@ describe('screenshot_test', function () { ...@@ -244,30 +248,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest6 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest6 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue() expect(data != null).assertTrue();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest6 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest6 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done() done()
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest6 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest6 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_007 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_007
* @tc.name Test screenShotSaveTest7 * @tc.name Test screenShotSave_Test_007
* @tc.desc Set the generated image size to a negative value * @tc.desc Set the generated image size to a negative value
*/ */
it('screenShotSaveTest7', 0, function (done) { it('screenShotSave_Test_007', 0, function (done) {
console.log('jsunittest screenShotSaveTest7 begin'); console.log('screenshotTest screenShotSaveTest7 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest7 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest7 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -282,30 +287,31 @@ describe('screenshot_test', function () { ...@@ -282,30 +287,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest7 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest7 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest7 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest7 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue(); expect(err.code == 120).assertTrue();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest7 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest7 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_008 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_008
* @tc.name Test screenShotSaveTest8 * @tc.name Test screenShotSave_Test_008
* @tc.desc Set the generated image size to 0 * @tc.desc Set the generated image size to 0
*/ */
it('screenShotSaveTest8', 0, function (done) { it('screenShotSave_Test_008', 0, function (done) {
console.log('jsunittest screenShotSaveTest8 begin'); console.log('screenshotTest screenShotSaveTest8 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest8 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest8 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -320,30 +326,31 @@ describe('screenshot_test', function () { ...@@ -320,30 +326,31 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest8 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest8 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue() expect(data != null).assertTrue();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest8 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest8 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest8 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest8 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_009 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_009
* @tc.name Test screenShotSaveTest9 * @tc.name Test screenShotSave_Test_009
* @tc.desc Set the screenshot area and the size of the generated image to be equal to the screen width and height * @tc.desc Set the screenshot area and the size of the generated image to be equal to the screen width and height
*/ */
it('screenShotSaveTest9', 0, function (done) { it('screenShotSave_Test_009', 0, function (done) {
console.log('jsunittest screenShotSaveTest9 begin'); console.log('screenshotTest screenShotSaveTest9 begin');
display.getDefaultDisplay().then((dsp) => { display.getDefaultDisplay().then((dsp) => {
console.log('jsunittest screenShotSaveTest9 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp)); console.log('screenshotTest screenShotSaveTest9 display.getDefaultDisplay success, dsp :' + JSON.stringify(dsp));
expect(dsp != null).assertTrue();
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -358,27 +365,27 @@ describe('screenshot_test', function () { ...@@ -358,27 +365,27 @@ describe('screenshot_test', function () {
displayId: dsp.id displayId: dsp.id
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest9 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest9 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue() expect(data != null).assertTrue();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest9 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest9 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
}) })
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest9 display.getDefaultDisplay failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest9 display.getDefaultDisplay failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}) })
}) })
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_010 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_010
* @tc.name Test screenShotSaveTest10 * @tc.name Test screenShotSave_Test_010
* @tc.desc Take a screenshot of a screen that doesn't exist * @tc.desc Take a screenshot of a screen that doesn't exist
*/ */
it('screenShotSaveTest10', 0, function (done) { it('screenShotSave_Test_010', 0, function (done) {
console.log('jsunittest screenShotSaveTest10 begin'); console.log('screenshotTest screenShotSaveTest10 begin');
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
...@@ -393,11 +400,11 @@ describe('screenshot_test', function () { ...@@ -393,11 +400,11 @@ describe('screenshot_test', function () {
displayId: null displayId: null
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest10 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest10 screenshot.save success, data :' + JSON.stringify(data));
expect(!!data).assertTrue() expect(data != null).assertTrue()
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest10 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest10 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect(TRUE_FLAG).assertFail();
done(); done();
}) })
...@@ -405,17 +412,16 @@ describe('screenshot_test', function () { ...@@ -405,17 +412,16 @@ describe('screenshot_test', function () {
/** /**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_011 * @tc.number SUB_SCREENSHOT_SAVE_JSAPI_011
* @tc.name Test screenShotSaveTest11 * @tc.name Test screenShotSave_Test_011
* @tc.desc Test screenshot.save API function test11. * @tc.desc Test screenshot.save API function test11
*/ */
it('screenShotSaveTest11', 0, function (done) { it('screenShotSave_Test_011', 0, function (done) {
console.log('jsunittest screenShotSaveTest11 begin'); console.log('screenshotTest screenShotSaveTest11 begin');
var screenshotOptions = { var screenshotOptions = {
screenRect: { screenRect: {
left: 0, left: 0,
top: 0, top: 0,
width: 100, width: 100,
height: 100, height: 100,
}, },
imageSize: { imageSize: {
...@@ -425,14 +431,13 @@ describe('screenshot_test', function () { ...@@ -425,14 +431,13 @@ describe('screenshot_test', function () {
displayId: 1000 displayId: 1000
}; };
screenshot.save(screenshotOptions).then((data) => { screenshot.save(screenshotOptions).then((data) => {
console.log('jsunittest screenShotSaveTest11 screenshot.save success, data :' + JSON.stringify(data)); console.log('screenshotTest screenShotSaveTest11 screenshot.save success, data :' + JSON.stringify(data));
expect(TRUE_FLAG).assertFail(); expect().assertFail();
done(); done();
}, (err) => { }, (err) => {
console.log('jsunittest screenShotSaveTest11 screenshot.save failed, err : ' + JSON.stringify(err)); console.log('screenshotTest screenShotSaveTest11 screenshot.save failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertTrue(); expect(err.code == 120).assertTrue();
done(); done();
}) })
}) })
}) })
\ No newline at end of file
...@@ -29,16 +29,15 @@ describe('window_api_test', function() { ...@@ -29,16 +29,15 @@ describe('window_api_test', function() {
* @tc.name Test faModelOnOffTest1. * @tc.name Test faModelOnOffTest1.
* @tc.desc To verify the function of enabling and disabling the monitoring function for tone change on the system bar.. * @tc.desc To verify the function of enabling and disabling the monitoring function for tone change on the system bar..
*/ */
it('faModelOnOffTest1', 0, async function(done) { it('faModelOnOffTest1', 0, async function(done) {
console.log('jsunittest faModelOnOffTest1 begin'); console.log('jsunittest faModelOnOffTest1 begin');
var listenerStatus; //1表示开启 其他为关闭 var listenerStatus;
var callback = (data) => { var callback = (data) => {
console.log('jsunittest faModelOnOffTest1 create callback ' + JSON.stringify(data)); console.log('jsunittest faModelOnOffTest1 create callback ' + JSON.stringify(data));
listenerStatus = 1; listenerStatus = 1;
console.log('jsunittest faModelOnOffTest1 listenerStatus 1: ' + listenerStatus); console.log('jsunittest faModelOnOffTest1 listenerStatus 1: ' + listenerStatus);
} }
window.on('systemBarTintChange', callback); window.on('systemBarTintChange', callback);
setTimeout(() => {
window.getTopWindow((err, data) => { window.getTopWindow((err, data) => {
if (err.code != 0) { if (err.code != 0) {
console.log('jsunittest faModelOnOffTest1 getTopWindow callback fail ' + JSON.stringify(err.code)); console.log('jsunittest faModelOnOffTest1 getTopWindow callback fail ' + JSON.stringify(err.code));
...@@ -52,10 +51,10 @@ describe('window_api_test', function() { ...@@ -52,10 +51,10 @@ describe('window_api_test', function() {
expect().assertFail(); expect().assertFail();
done(); done();
} else { } else {
setTimeout(() => {
expect(listenerStatus == 1).assertTrue(); expect(listenerStatus == 1).assertTrue();
window.off('systemBarTintChange'); window.off('systemBarTintChange');
listenerStatus = 0; listenerStatus = 0;
}
data.setLayoutFullScreen(false, (err) => { data.setLayoutFullScreen(false, (err) => {
console.log('jsunittest faModelOnOffTest1 listenerStatus 2:' + listenerStatus); console.log('jsunittest faModelOnOffTest1 listenerStatus 2:' + listenerStatus);
if (err.code != 0 || listenerStatus == 1) { if (err.code != 0 || listenerStatus == 1) {
...@@ -68,10 +67,10 @@ describe('window_api_test', function() { ...@@ -68,10 +67,10 @@ describe('window_api_test', function() {
done(); done();
} }
}) })
}, 2000);
}
}) })
}) })
}, 1000);
}) })
/** /**
...@@ -101,7 +100,6 @@ describe('window_api_test', function() { ...@@ -101,7 +100,6 @@ describe('window_api_test', function() {
if (err.code != 0) { if (err.code != 0) {
console.log('jsunittest faModelOnOffTest2 setLayoutFullScreen callback fail ' + JSON.stringify(err.code)); console.log('jsunittest faModelOnOffTest2 setLayoutFullScreen callback fail ' + JSON.stringify(err.code));
expect().assertFail(); expect().assertFail();
done();
} else { } else {
setTimeout((async function() { setTimeout((async function() {
console.log('jsunittest faModelOnOffTest2 listenerStatus 111: ' + listenerStatus); console.log('jsunittest faModelOnOffTest2 listenerStatus 111: ' + listenerStatus);
...@@ -759,7 +757,7 @@ describe('window_api_test', function() { ...@@ -759,7 +757,7 @@ describe('window_api_test', function() {
console.log('jsunittest faModelSetColorSpaceTest4 setColorSpace callback begin' + JSON.stringify(err)); console.log('jsunittest faModelSetColorSpaceTest4 setColorSpace callback begin' + JSON.stringify(err));
if (err.code != 0) { if (err.code != 0) {
console.log('jsunittest faModelSetColorSpaceTest4 setColorSpace callback fail' + JSON.stringify(err.code)); console.log('jsunittest faModelSetColorSpaceTest4 setColorSpace callback fail' + JSON.stringify(err.code));
expect(err.code).assertEqual(120); expect(err.code).assertEqual(130);
done(); done();
} else { } else {
expect().assertFail(); expect().assertFail();
......
...@@ -84,7 +84,7 @@ describe('window_test', function() { ...@@ -84,7 +84,7 @@ describe('window_test', function() {
done(); done();
}).catch((err) => { }).catch((err) => {
console.log('jsunittest faModelSetColorSpaceTest2 wnd.setColorSpace failed, err :' + JSON.stringify(err)); console.log('jsunittest faModelSetColorSpaceTest2 wnd.setColorSpace failed, err :' + JSON.stringify(err));
expect(err.code).assertEqual(120); expect(err.code).assertEqual(130);
done(); done();
}) })
}).catch((err) => { }).catch((err) => {
...@@ -462,7 +462,7 @@ describe('window_test', function() { ...@@ -462,7 +462,7 @@ describe('window_test', function() {
done(); done();
}) })
}) })
}, 1000) }, 3000)
}).catch((err) => { }).catch((err) => {
console.log('jsunittest faModelMinimizeAllTest1 minimizeAll failed, err :' + JSON.stringify(err)); console.log('jsunittest faModelMinimizeAllTest1 minimizeAll failed, err :' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册