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

!4534 杂散新增用例

Merge pull request !4534 from 高曦/OpenHarmony-3.1-Release
...@@ -20,6 +20,7 @@ group("miscservices") { ...@@ -20,6 +20,7 @@ group("miscservices") {
"TimeTest_js:ActsTimeJSApiTest", "TimeTest_js:ActsTimeJSApiTest",
"TimerTest_js:ActsTimerJSApiTest", "TimerTest_js:ActsTimerJSApiTest",
"actspasteboardjsapitest:ActsPasteBoardJSApiTest", "actspasteboardjsapitest:ActsPasteBoardJSApiTest",
"screenlock_js:ActsScreenLockJSApiTest",
"wallpaper_js:ActsWallpaperJSApiTest", "wallpaper_js:ActsWallpaperJSApiTest",
] ]
} }
...@@ -335,5 +335,176 @@ export default function requestDownloadJsunit() { ...@@ -335,5 +335,176 @@ export default function requestDownloadJsunit() {
done(); done();
}); });
/**
* @tc.number requestDownload_test_015
* @tc.name Test The request DownloadTask
* @tc.desc Function test
*/
it('requestDownload_test_015', 0, async function (done) {
console.info("requestDownload_test_015 start")
request.download(downloadConfig, (downloadTask) => {
console.info("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.remove().then((result) => {
if (result) {
expect(result != null).assertTrue();
console.info('Download task removed.');
} else {
console.info('Failed to remove the download task.');
}
}).catch((err) => {
expect(true).assertTrue();
console.info('Failed to remove the download task.');
});
});
console.info("requestDownload_test_015 end")
done();
});
/**
* @tc.number requestDownload_test_016
* @tc.name Test The request UploadTask
* @tc.desc Function test
*/
it('requestDownload_test_016', 0, async function (done) {
console.info("requestDownload_test_016 start")
request.download(downloadConfig, (downloadTask) => {
console.info("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.pause().then((result) => {
if (result) {
expect(result != null).assertTrue();
console.info('Download task paused. ');
} else {
console.info('Failed to pause the download task. Cause:' + JSON.stringify(result));
}
}).catch((err) => {
expect(true).assertTrue();
console.info('Failed to pause the download task. Cause:' + JSON.stringify(err));
});
});
console.info("requestDownload_test_016 end")
done();
});
/**
* @tc.number requestDownload_test_017
* @tc.name Test The request UploadTask
* @tc.desc Function test
*/
it('requestDownload_test_017', 0, async function (done) {
console.info("requestDownload_test_017 start")
request.download(downloadConfig, (downloadTask) => {
console.info("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.pause((err, result)=>{
if(err) {
console.info('Failed to pause the download task. Cause:' + JSON.stringify(err));
expect(true).assertTrue();
return;
}
if (result) {
console.info('Download task paused. ');
expect(result != null).assertTrue();
} else {
console.info('Failed to pause the download task. Cause:' + JSON.stringify(result));
}
});
});
console.info("requestDownload_test_017 end")
done();
});
/**
* @tc.number requestDownload_test_018
* @tc.name Test The request UploadTask
* @tc.desc Function test
*/
it('requestDownload_test_018', 0, async function (done) {
console.info("requestDownload_test_018 start")
request.download(downloadConfig, (downloadTask) => {
console.info("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.resume().then((result) => {
if (result) {
expect(result != null).assertTrue();
console.info('Download task resumed.')
} else {
console.error('Failed to resume the download task. ');
}
console.info('Download task resumed.')
}).catch((err) => {
expect(true).assertEqual(true);
console.error('Failed to resume the download task. Cause:' + err);
});
});
console.info("requestDownload_test_018 end")
done();
});
/**
* @tc.number requestDownload_test_019
* @tc.name Test The request UploadTask
* @tc.desc Function test
*/
it('requestDownload_test_019', 0, async function (done) {
console.info("requestDownload_test_019 start")
request.download(downloadConfig, (downloadTask) => {
console.info("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.resume((err, result)=>{
if (err) {
expect(true).assertEqual(true);
console.info('Failed to resume the download task. Cause:' + err);
return;
}
if (result) {
expect(result != null).assertTrue();
console.info('Download task resumed.');
} else {
console.info('Failed to resume the download task.');
}
});
});
console.info("requestDownload_test_019 end")
done();
});
/**
* @tc.number requestDownload_test_020
* @tc.name Test The request UploadTask
* @tc.desc Function test
*/
it('requestDownload_test_020', 0, async function (done) {
console.info("requestDownload_test_020 start")
request.download(downloadConfig, (downloadTask) => {
console.info("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.query().then((downloadInfo) => {
expect(downloadInfo != null).assertTrue();
console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
}) .catch((err) => {
expect(true).assertEqual(true);
console.info('Failed to query the download task. Cause:' + err)
});
});
console.info("requestDownload_test_020 end")
done();
});
/**
* @tc.number requestDownload_test_021
* @tc.name Test The request UploadTask
* @tc.desc Function test
*/
it('requestDownload_test_021', 0, async function (done) {
console.info("requestDownload_test_021 start")
request.download(downloadConfig, (downloadTask) => {
console.info("downloadConfig result:" + JSON.stringify(downloadTask))
downloadTask.queryMimeType().then((data) => {
expect(data != null).assertTrue();
console.info('Download task queried. Data:' + JSON.stringify(data));
}).catch((err) => {
expect(true).assertEqual(true);
console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err))
});
});
console.info("requestDownload_test_021 end")
done();
});
}) })
} }
...@@ -196,6 +196,49 @@ export default function requestJsunit() { ...@@ -196,6 +196,49 @@ export default function requestJsunit() {
console.log("-----------------------request_upload_0006 end-----------------------"); console.log("-----------------------request_upload_0006 end-----------------------");
done(); done();
}) })
/**
* @tc.name: ohos.request_request_upload
* @tc.desc: request_upload Method detection
* @tc.author: kangyuntao
*/
it('request_upload_0007', 0, async function (done) {
console.log("-----------------------Request_test_0006 is starting-----------------------");
console.log("request_upload_0007 getUploadConfig() " + getUploadConfig());
request.upload(getUploadConfig(), (err, uploadTask) => {
uploadTask.remove().then((result) => {
if (result) {
console.info('Upload task removed successfully. ');
} else {
console.error('Failed to remove the upload task. ');
}
}).catch((err) => {
expect(true).assertEqual(true);
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
});
})
console.log("-----------------------request_upload_0007 end-----------------------");
done();
})
/**
* @tc.name: ohos.request_request_upload
* @tc.desc: request_upload Method detection
* @tc.author: kangyuntao
*/
it('request_upload_0008', 0, async function (done) {
console.log("-----------------------request_upload_0008 is starting-----------------------");
let uploadTask;
request.upload(getUploadConfig()).then((data) => {
uploadTask = data;
expect(uploadTask != null).assertTrue();
}).catch((err) => {
expect(true).assertTrue();
console.info('Failed to request the upload. Cause: ' + JSON.stringify(err));
})
console.log("-----------------------request_upload_0008 end-----------------------");
done();
})
}) })
function getUploadConfig() { function getUploadConfig() {
......
...@@ -22,11 +22,12 @@ import { ...@@ -22,11 +22,12 @@ import {
afterAll, afterAll,
it, it,
expect, expect,
} from "deccjsunit/index"; } from "deccjsunit/index";
import systemTime from "@ohos.systemTime"; import systemTime from "@ohos.systemTime";
import request from '@system.request';
describe("TimeTest", function () {
console.log("start################################start"); describe("TimeTest", function () {
console.log("start################################start");
/** /**
* @tc.number SUB_systemTime_getRealActiveTime_JS_API_0100 * @tc.number SUB_systemTime_getRealActiveTime_JS_API_0100
* @tc.name Test systemTime.getRealActiveTime * @tc.name Test systemTime.getRealActiveTime
...@@ -36,16 +37,16 @@ import { ...@@ -36,16 +37,16 @@ import {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it("systemTime_getRealActiveTime_test1", 0, async function (done) { it("systemTime_getRealActiveTime_test1", 0, async function (done) {
console.log("SUB_systemTime_getRealActiveTime_JS_API_0100 start"); console.log("SUB_systemTime_getRealActiveTime_JS_API_0100 start");
systemTime.getRealActiveTime().then((data) => { systemTime.getRealActiveTime().then((data) => {
console.log("f_ActiveTime1: getRealActiveTime data = " + data); console.log("f_ActiveTime1: getRealActiveTime data = " + data);
}); });
expect(true).assertTrue(); expect(true).assertTrue();
console.log("SUB_systemTime_getRealActiveTime_JS_API_0100 end"); console.log("SUB_systemTime_getRealActiveTime_JS_API_0100 end");
done(); done();
}); });
/** /**
* @tc.number SUB_systemTime_getRealTime_JS_API_0100 * @tc.number SUB_systemTime_getRealTime_JS_API_0100
* @tc.name Test systemTime.getRealTime * @tc.name Test systemTime.getRealTime
...@@ -55,14 +56,232 @@ import { ...@@ -55,14 +56,232 @@ import {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it("systemTime_getRealTime_test1", 0, async function (done) { it("systemTime_getRealTime_test1", 0, async function (done) {
console.log("SUB_systemTime_getRealTime_JS_API_0100 start"); console.log("SUB_systemTime_getRealTime_JS_API_0100 start");
systemTime.getRealTime().then((data) => { systemTime.getRealTime().then((data) => {
console.log("f_RealTime1: getRealTime data = " + data); console.log("f_RealTime1: getRealTime data = " + data);
}); });
expect(true).assertTrue(); expect(true).assertTrue();
console.log("SUB_systemTime_getRealTime_JS_API_0100 end"); console.log("SUB_systemTime_getRealTime_JS_API_0100 end");
done(); done();
});
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0100
* @tc.name Test systemTime.getCurrentTime Invalid value
* @tc.desc Test systemTime_getCurrentTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('systemTime_getCurrentTime_test1', 0, async function (done) {
console.info("SUB_systemTime_getCurrentTime_JS_API_0100 start");
systemTime.getCurrentTime().then((data) => {
expect(data != null).assertTrue();
console.info(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => {
expect(true).assertTrue();
console.info(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
});
done();
});
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0200
* @tc.name Test systemTime.getCurrentTime Invalid value
* @tc.desc Test systemTime_getCurrentTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('systemTime_getCurrentTime_test2', 0, async function (done) {
console.info("SUB_systemTime_getCurrentTime_JS_API_0200 start");
systemTime.getCurrentTime(true, (error, data) => {
if (error) {
expect(true).assertTrue();
console.info(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
return;
}
expect(data != null).assertTrue();
console.info(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
});
done();
});
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0200
* @tc.name Test systemTime.getCurrentTime Invalid value
* @tc.desc Test systemTime_getCurrentTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('systemTime_getDate_test1', 0, async function (done) {
console.info("SUB_systemTime_getDate_JS_API_0100 start");
systemTime.getDate((error, data) => {
if (error) {
expect(true).assertTrue();
console.info(`failed to systemTime.getDate because ` + JSON.stringify(error));
return;
}
expect(data != null).assertTrue();
console.info(`systemTime.getDate success data : ` + JSON.stringify(data));
});
done();
});
/**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0200
* @tc.name Test systemTime.getCurrentTime Invalid value
* @tc.desc Test systemTime_getCurrentTime API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('systemTime_getDate_test2', 0, async function (done) {
console.info("SUB_systemTime_getDate_JS_API_0200 start");
systemTime.getDate().then((data) => {
expect(data != null).assertTrue();
console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => {
expect(true).assertTrue();
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));
});
done();
});
/**
* @tc.number SUB_systemTime_getTimezone_JS_API_0200
* @tc.name Test systemTime.getTimezone Invalid value
* @tc.desc Test systemTime_getTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('systemTime_getTimezon_test1', 0, async function (done) {
console.info("SUB_systemTime_getTimezon_JS_API_0100 start");
systemTime.getTimezone((error, data) => {
if (error) {
expect(true).assertTrue();
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
return;
}
expect(data != null).assertTrue();
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
});
done();
});
/**
* @tc.number SUB_systemTime_getTimezone_JS_API_0200
* @tc.name Test systemTime.getTimezone Invalid value
* @tc.desc Test systemTime_getTimezone API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('systemTime_getTimezon_test2', 0, async function (done) {
console.info("SUB_systemTime_getTimezon_JS_API_0200 start");
systemTime.getTimezone().then((data) => {
expect(data != null).assertTrue();
console.info(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => {
expect(true).assertTrue();
console.info(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
});
done();
});
/**
* @tc.number SystemRequest_upload_test01
* @tc.name Test SystemRequest_upload Invalid value
* @tc.desc Test SystemRequest_upload API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SystemRequest_upload_test01', 0, async function (done) {
console.info("SystemRequest_upload_test01 start");
request.upload({
url: 'http://www.path.com',
files: [
{
uri: 'internal://cache/path/to/file.txt',
name: 'file',
filename: 'file.txt',
},
],
data: [
{
name: 'name1',
value: 'value',
},
],
success: function (data) {
expect(data != null).assertTrue();
console.info('upload success, code:' + data.code);
console.info('upload success, code:' + data.data);
console.info('upload success, code:' + data.headers);
},
fail: function () {
expect(true).assertTrue();
console.info('upload fail');
},
complete: null
});
done();
});
/**
* @tc.number SystemRequest_download_test01
* @tc.name Test SystemRequest_download Invalid value
* @tc.desc Test SystemRequest_download API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SystemRequest_download_test01', 0, async function (done) {
console.info("SystemRequest_download_test01 start");
request.download({
url: 'http://www.path.com',
success: function (data) {
expect(data != null).assertTrue();
console.info('call success callback success: ' + data.token);
},
fail: function (data, code) {
console.info('handling fail');
},
filename: "文件名",
header: null,
description: "描述",
complete: null
});
done();
});
/**
* @tc.number SystemRequest_onDownloadComplete_test01
* @tc.name Test SystemRequest_onDownloadComplete Invalid value
* @tc.desc Test SystemRequest_onDownloadComplete API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SystemRequest_onDownloadComplete_test01', 0, async function (done) {
console.info("SystemRequest_onDownloadComplete_test01 start");
request.onDownloadComplete({
token: 'token-index',
success: function (data) {
expect(data != null).assertTrue();
console.info('download success, uri:' + data.uri);
},
fail: function (data, code) {
expect(true).assertTrue();
console.info('download fail');
},
complete: null
});
done();
}); });
}); });
\ No newline at end of file
...@@ -13,4 +13,5 @@ ...@@ -13,4 +13,5 @@
* limitations under the License. * limitations under the License.
*/ */
require('./PasteBoardJsunit.test.js') require('./PasteBoardJsunit.test.js')
\ No newline at end of file require('./PasteBoard2Jsunit.test.js')
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import pasteboard from '@ohos.pasteboard'
describe('PasteBoardTest2', function () {
console.log('start################################start');
/**
* @tc.number SUB_pasteBoard_function_JS_API_7100
* @tc.name 复制文本、uri格式
* @tc.desc Test pasteBoard API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('pasteboard_function_test71', 0, async function (done) {
console.info('SUB_pasteBoard_function_JS_API_7100 start')
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText((err, data) => {
if (err) {
expect(true).assertTrue();
console.info('convertToText failed because ' + JSON.stringify(err));
return;
}
expect(data != null).assertTrue();
console.info('convertToText success data : ' + JSON.stringify(data));
});
console.info('SUB_pasteBoard_function_JS_API_7100 end');
done();
})
/**
* @tc.number SUB_pasteBoard_function_JS_API_7200
* @tc.name 复制文本、uri格式
* @tc.desc Test pasteBoard API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('pasteboard_function_test72', 0, async function (done) {
console.info('SUB_pasteBoard_function_JS_API_7200 start')
var html = "<!DOCTYPE html>\n"
+ "<html>\n" + "<head>\n"
+ "<meta charset=\"utf-8\">\n"
+ "<title>HTML-PASTEBOARD_HTML</title>\n"
+ "</head>\n"
+ "<body>\n"
+ " <h1>HEAD</h1>\n"
+ " <p></p>\n"
+ "</body>\n"
+ "</html>";
var pasteData = pasteboard.createHtmlData(html);
var htmlText = pasteData.getPrimaryHtml();
expect(htmlText != null).assertTrue();
console.info('SUB_pasteBoard_function_JS_API_7200 end');
done();
})
/**
* @tc.number SUB_pasteBoard_function_JS_API_7300
* @tc.name 复制文本、uri格式
* @tc.desc Test pasteBoard API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('pasteboard_function_test73', 0, async function (done) {
console.info('SUB_pasteBoard_function_JS_API_7300 start')
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText().then((data) => {
expect(data != null).assertTrue();
console.info('convertToText success data : ' + JSON.stringify(data));
}).catch((error) => {
expect(true).assertTrue();
console.info('convertToText failed because ' + JSON.stringify(error));
});
console.info('SUB_pasteBoard_function_JS_API_7300 end');
done();
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册