Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8a85b179
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8a85b179
编写于
11月 07, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6396 【上传下载】sleep modifed setTimeout
Merge pull request !6396 from 何海涛/r1105
上级
9522a420
dc9cb627
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
160 addition
and
48 deletion
+160
-48
request/RequestTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts
...tTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts
+2
-0
request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets
...st_Stage/entry/src/main/ets/test/requestDownload.test.ets
+22
-17
request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets
...Test_Stage/entry/src/main/ets/test/requestUpload.test.ets
+136
-31
未找到文件。
request/RequestTest_Stage/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
8a85b179
...
...
@@ -35,6 +35,8 @@ export default class MainAbility extends Ability {
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onWindowStageCreate
'
);
globalThis
.
abilityContext
=
this
.
context
;
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
ERROR
);
...
...
request/RequestTest_Stage/entry/src/main/ets/test/requestDownload.test.ets
浏览文件 @
8a85b179
...
...
@@ -19,34 +19,34 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export default function requestDownloadJSUnit() {
describe('requestDownloadJSUnit', function () {
console.info('################################request download Test start');
console.info('
====>
################################request download Test start');
/**
* beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/
beforeAll(function () {
console.info('beforeAll: Prerequisites are executed.');
console.info('
====>
beforeAll: Prerequisites are executed.');
});
/**
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/
beforeEach(function () {
console.info('beforeEach: Prerequisites is executed.');
console.info('
====>
beforeEach: Prerequisites is executed.');
});
/**
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/
afterEach(function () {
console.info('afterEach: Test case-level clearance conditions is executed.');
console.info('
====>
afterEach: Test case-level clearance conditions is executed.');
});
/**
* afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/
afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition is executed');
console.info('
====>
afterAll: Test suite-level cleanup condition is executed');
});
let downloadTask;
...
...
@@ -72,21 +72,24 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001', 0, async function (done) {
console.info("
-----
------------------SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 is starting-----------------------");
console.info("
====>
------------------SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 is starting-----------------------");
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let context = abilityDelegator.getAppContext();
try {
request.download(context, downloadConfig, (data)=>{
request.download(context, downloadConfig, (
err,
data)=>{
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask);
console.info("
====>
SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 downloadTask: " + downloadTask);
expect(true).assertEqual(downloadTask != undefined);
});
} catch (err) {
console.
error("
SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 error: " + err);
console.
info("====>
SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 error: " + err);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 end-----------------------");
setTimeout(()=>{
console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_CALLBACK_0001 end-----------------------");
done();
},5000)
});
/**
...
...
@@ -97,19 +100,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2
*/
it('SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001', 0, async function (done) {
console.info("
-----
------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 is starting-----------------------");
console.info("
====>
------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 is starting-----------------------");
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let context = abilityDelegator.getAppContext();
request.download(context, downloadConfig).then(data => {
downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask);
console.info("
====>
SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 downloadTask: " + downloadTask);
expect(true).assertEqual(downloadTask != undefined);
}).catch(err => {
console.
error("
SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 error: " + err);
console.
info("====>
SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 error: " + err);
expect().assertFail();
})
console.info("-----------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 end-----------------------");
setTimeout(()=>{
console.info("====>------------------SUB_REQUEST_DOWNLOAD_STAGE_API_PROMISE_0001 end-----------------------");
done();
},5000)
});
});
}
\ No newline at end of file
request/RequestTest_Stage/entry/src/main/ets/test/requestUpload.test.ets
浏览文件 @
8a85b179
...
...
@@ -19,34 +19,34 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export default function requestUploadJSUnit() {
describe('requestUploadJSUnit', function () {
console.info('################################request upload Test start');
console.info('
====>
################################request upload Test start');
/**
* beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/
beforeAll(function () {
console.info('beforeAll: Prerequisites are executed.');
console.info('
====>
beforeAll: Prerequisites are executed.');
});
/**
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/
beforeEach(function () {
console.info('beforeEach: Prerequisites is executed.');
console.info('
====>
beforeEach: Prerequisites is executed.');
});
/**
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/
afterEach(function () {
console.info('afterEach: Test case-level clearance conditions is executed.');
console.info('
====>
afterEach: Test case-level clearance conditions is executed.');
});
/**
* afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/
afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition is executed');
console.info('
====>
afterAll: Test suite-level cleanup condition is executed');
});
/**
...
...
@@ -88,37 +88,38 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 1
*/
it('SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001', 0, async function (done) {
console.info("
-----
------------------SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 is starting-----------------------");
console.info("
====>
------------------SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 is starting-----------------------");
try {
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig));
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig));
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let appContext = abilityDelegator.getAppContext();
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 context = " + appContext);
request.upload(appContext, uploadConfig, (data) => {
request.upload(globalThis.abilityContext, uploadConfig, (err, data) => {
uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask));
console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask));
console.info("====>SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 progress uploadTask =" + uploadTask);
expect(true).assertEqual(uploadTask != undefined);
uploadTask.on('progress', function (data1, data2) {
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 on data1 =" + data1);
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 on data2 =" + data2);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 on data1 =" + data1);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 on data2 =" + data2);
});
uploadTask.off('progress', function (data1, data2) {
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 off data1 =" + data1);
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 off data2 =" + data2);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 off data1 =" + data1);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 off data2 =" + data2);
});
uploadTask.remove((err, data) => {
console.info("SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 remove =" + data);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 remove =" + data);
});
});
} catch (err) {
console.
error("
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 error: " + err);
console.
info("====>
SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 error: " + err);
expect().assertFail();
}
console.info("-----------------------SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 end-----------------------");
setTimeout(()=>{
console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_CALLBACK_0001 end-----------------------");
done();
}, 10000)
});
/*
...
...
@@ -130,38 +131,142 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 1
*/
it('SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001', 0, async function (done) {
console.info("
-----
------------------SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 is starting-----------------------");
console.info("
====>
------------------SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 is starting-----------------------");
try {
console.info("SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig));
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig));
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let appContext = abilityDelegator.getAppContext();
console.info("SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 context = " + appContext);
request.upload(appContext, uploadConfig).then((data) => {
request.upload(globalThis.abilityContext, uploadConfig).then((data) => {
uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 uploadTask = " + uploadTask);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 uploadTask = " + uploadTask);
expect(true).assertEqual(uploadTask != undefined);
uploadTask.on('headerReceive', (header) => {
console.info("SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 header = " + header);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 header = " + header);
expect(true).assertEqual((header != undefined) || (header != "") || (header != {}));
});
uploadTask.off('headerReceive', (header) => {
console.info("SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 header = " + header);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 header = " + header);
expect(true).assertEqual((header != undefined) || (header != "") || (header != {}));
});
uploadTask.remove().then((result)=>{
console.info("SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 remove result = " + result);
console.info("
====>
SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 remove result = " + result);
expect(result).assertEqual(true);
});
});
} catch (e) {
console.
error("
SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 error: " + JSON.stringify(e));
console.
info("====>
SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 error: " + JSON.stringify(e));
expect(e).assertFail();
}
console.info("-----------------------SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 end-----------------------");
setTimeout(()=>{
console.info("====>------------------SUB_REQUEST_UPLOAD_STAGE_API_PROMISE_0001 end-----------------------");
done();
}, 10000)
});
/**
* @tc.number : SUB_REQUEST_UPLOAD_API_PROMISE_0002
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.desc : Called when the current upload session complete or fail.
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_REQUEST_UPLOAD_API_PROMISE_0002', 0, async function (done) {
console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0002 is starting-----------------------");
try {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 UploadConfig = " + JSON.stringify(uploadConfig));
request.upload(globalThis.abilityContext, uploadConfig).then((data) => {
try{
uploadTask = data;
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 uploadTask = " + uploadTask);
expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {}));
uploadTask.on('complete', (TaskState) => {
for(let i = 0; i < TaskState.length; i++){
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState = " + JSON.stringify(TaskState[i]))
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState.path = " + TaskState[i].path);
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState.responseCode = " + TaskState[i].responseCode);
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 complete TaskState.TaskState.message = " + TaskState[i].message);
expect(typeof(TaskState[i].path) == "string").assertEqual(true);
expect(typeof(TaskState[i].responseCode) == "number").assertEqual(true);
expect(typeof(TaskState[i].message) == "string").assertEqual(true);
}
done();
});
uploadTask.on('fail', (TaskState) => {
for(let i = 0; i < TaskState.length; i++){
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState = " + JSON.stringify(TaskState[i]))
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState.path = " + TaskState[i].path);
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState.responseCode = " + TaskState[i].responseCode);
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 fail TaskState.TaskState.message = " + TaskState[i].message);
expect(typeof(TaskState[i].path) == "string").assertEqual(true);
expect(typeof(TaskState[i].responseCode) == "number").assertEqual(true);
expect(typeof(TaskState[i].message) == "string").assertEqual(true);
}
expect(true).assertEqual(true);
});
}catch(err){
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 error: " + JSON.stringify(err));
expect(true).assertFail(true);
}
}).catch((err)=>{
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 error: " + JSON.stringify(err));
expect(true).assertFail(true);
})
} catch (e) {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0002 throw_error: " + JSON.stringify(e));
expect(true).assertFail(true);
}
setTimeout(()=>{
console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0002 end-----------------------");
done();
}, 10000)
});
/**
* @tc.number : SUB_REQUEST_UPLOAD_API_PROMISE_0003
* @tc.name : Use getEntries get the value by mixing the string key
* @tc.desc : Called when the current upload session complete or fail.
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('SUB_REQUEST_UPLOAD_API_PROMISE_0003', 0, async function (done) {
console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0003 is starting-----------------------");
try {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 UploadConfig = " + JSON.stringify(uploadConfig));
request.upload(globalThis.abilityContext, uploadConfig).then((data) => {
try{
uploadTask = data;
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 uploadTask = " + uploadTask);
expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {}));
uploadTask.off('complete', () => {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 TaskState success");
expect(true).assertEqual(true);
});
uploadTask.off('fail', () => {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 TaskState success");
expect(true).assertEqual(true);
});
}catch(err){
expect().assertFail();
done();
}
});
} catch (e) {
console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0003 error: " + JSON.stringify(e));
expect(true).assertFail(true);
}
setTimeout(()=>{
console.info("====>------------------SUB_REQUEST_UPLOAD_API_PROMISE_0003 end-----------------------");
done();
}, 10000)
});
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录