Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7c1a2e7e
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看板
提交
7c1a2e7e
编写于
7月 06, 2022
作者:
G
gaoxi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xts
Signed-off-by:
N
gaoxi
<
gaoxi785@huawei.com
>
上级
e00b9d52
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
218 addition
and
9 deletion
+218
-9
miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/InputRequestJsunit.test.ets
...src/main/ets/MainAbility/test/InputRequestJsunit.test.ets
+92
-0
miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/InputmethodEngineJsunit.test.ets
...ain/ets/MainAbility/test/InputmethodEngineJsunit.test.ets
+40
-8
miscservices/actspasteboardjsapitest/entry/src/main/js/default/test/PasteBoardJsunit.test.js
...t/entry/src/main/js/default/test/PasteBoardJsunit.test.js
+82
-1
miscservices/wallpaper_js/src/main/js/Test/Wallpaper/WallpaperJsunit.test.js
...per_js/src/main/js/Test/Wallpaper/WallpaperJsunit.test.js
+4
-0
未找到文件。
miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/InputRequestJsunit.test.ets
浏览文件 @
7c1a2e7e
// @ts-nocheck
/**
* 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, eithe// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -16,6 +27,87 @@
import {describe, it, expect} from "deccjsunit/index.ets";
import request from '@ohos.request';
export default function inputRequestJsunit() {
describe('inputRequestTest', function () {
console.log("************* request Test start*************");
/**
* @tc.number inputRequest_DownloadConfig_Test_001
* @tc.name Request DownloadConfig
* @tc.desc interface DownloadConfig
*/
it('inputRequest_DownloadConfig_Test_001', 0, async function (done) {
let caseName: string = "inputRequest_DownloadConfig_Test_001";
console.log(`==========> ${caseName} Test start ==========>`);
let downloadConfig = {
header: "HTTP",
url: "www.testdownload.com",
enableMetered: false,
enableRoaming: false,
description: "test download",
title: "",
networkType: "",
};
try {
let promise = request.download(downloadConfig);
expect(promise).assertEqual(undefined);
} catch (err) {
console.log(`${caseName} fail,case success,error:${toString(err)}`);
expect(true).assertTrue();
done();
return;
}
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
/**
* @tc.number inputRequest_DownloadInfo_Test_002
* @tc.name Request DownloadInfo
* @tc.desc interface DownloadInfo
*/
it('inputRequest_DownloadInfo_Test_002', 0, async function (done) {
let caseName: string = "inputRequest_DownloadInfo_Test_002";
try {
request.download({
url: "www.testdownload.com"
}).then(downloadTask => {
if (downloadTask !== undefined) {
downloadTask.query((err, downloadInfo) => {
if (downloadInfo !== undefined) {
expect("info").assertEqual(downloadInfo.description);
expect(100).assertEqual(downloadInfo.downloadedBytes);
expect(1).assertEqual(downloadInfo.downloadId);
expect(101).assertEqual(downloadInfo.failedReason);
expect("download.txt").assertEqual(downloadInfo.fileName);
expect("C://").assertEqual(downloadInfo.filePath);
expect(102).assertEqual(downloadInfo.pausedReason);
expect(200).assertEqual(downloadInfo.status);
expect("download url").assertEqual(downloadInfo.targetURI);
expect("download test").assertEqual(downloadInfo.downloadTitle);
expect(1000).assertEqual(downloadInfo.downloadTotalBytes);
}
});
}
}).catch(err => {
});
} catch (err) {
console.log(`${caseName} fail,case success,error:${toString(err)}`);
expect(true).assertTrue();
done();
return;
}
console.log(`==========> ${caseName} Test end ==========>`);
done();
});
})
}r express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from "deccjsunit/index.ets";
import request from '@ohos.request';
export default function inputRequestJsunit() {
describe('inputRequestTest', function () {
console.log("************* request Test start*************");
...
...
miscservices/InputMethodTest_ets/entry/src/main/ets/MainAbility/test/InputmethodEngineJsunit.test.ets
浏览文件 @
7c1a2e7e
...
...
@@ -64,12 +64,16 @@ export default function inputMethodEngineJsunit() {
});
mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
mKeyboardDelegate.on('keyDown', (keyEvent) => {
console.
log("inputMethodEngine beforeEach keyDown:" + keyEvent
);
console.
info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode
);
expect(keyEvent.keyCode).assertEqual('1');
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('1');
});
mKeyboardDelegate.on('keyUp', (keyEvent) => {
console.
log
("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
console.
info
("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1');
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('0');
});
mKeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.log("inputMethodEngine beforeEach cursorContextChange x:" + x);
...
...
@@ -433,7 +437,7 @@ export default function inputMethodEngineJsunit() {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.getEditorAttribute(1, (editorAttribute) => {
console.log("inputMethodEngine_test_03
6
getEditorAttribute:" + value);
console.log("inputMethodEngine_test_03
8
getEditorAttribute:" + value);
expect(editorAttribute.inputPattern).assertEqual(1);
expect(editorAttribute.enterKeyType).assertEqual(1);
});
...
...
@@ -447,11 +451,11 @@ export default function inputMethodEngineJsunit() {
} else {
let promise = textInputClient.getEditorAttribute();
promise.then(res => {
console.info("inputMethodEngine_test_03
7
getEditorAttribute promise result-----" + JSON.stringify(res));
console.info("inputMethodEngine_test_03
9
getEditorAttribute promise result-----" + JSON.stringify(res));
expect(res.inputPattern).assertEqual(1);
expect(res.enterKeyType).assertEqual(1);
}).catch(err => {
console.info("inputMethodEngine_test_03
7
getEditorAttribute promise error----" + JSON.stringify(err));
console.info("inputMethodEngine_test_03
9
getEditorAttribute promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
...
...
@@ -476,15 +480,43 @@ export default function inputMethodEngineJsunit() {
} else {
let promise = kbController.hideKeyboard();
promise.then(res => {
console.info("inputMethodEngine_test_0
37
hideKeyboard promise result-----" + JSON.stringify(res));
console.info("inputMethodEngine_test_0
41
hideKeyboard promise result-----" + JSON.stringify(res));
expect(1 == 1).assertTrue();
}).catch(err => {
console.info("inputMethodEngine_test_0
37
hideKeyboard promise error----" + JSON.stringify(err));
console.info("inputMethodEngine_test_0
41
hideKeyboard promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_042', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.getBackward(1, (value) => {
console.info("inputMethodEngine_test_042 getBackward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_043', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.getBackward(1);
promise.then(res => {
console.info("inputMethodEngine_test_043 getBackward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("inputMethodEngine_test_043 getBackward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
})
})
}
miscservices/actspasteboardjsapitest/entry/src/main/js/default/test/PasteBoardJsunit.test.js
浏览文件 @
7c1a2e7e
...
...
@@ -49,6 +49,11 @@ describe('PasteBoardTest', function() {
console
.
log
(
'
f_test1: systemPasteboard.hasPasteData promise data =
'
+
data
);
expect
(
data
===
true
||
data
===
false
).
assertTrue
();
var
types
=
pasteData
.
getMimeTypes
();
console
.
info
(
'
f_test1: getMimeTypes =
'
+
types
);
console
.
info
(
'
f_test1: getMimeTypes =
'
+
typeof
(
types
));
expect
(
"
text/plain
"
).
assertEqual
(
types
[
0
]);
console
.
log
(
'
f_test1: Checks the number of records
'
);
systemPasteboard
.
getPasteData
().
then
((
data
)
=>
{
console
.
log
(
'
f_test1: systemPasteboard.getPasteData data =
'
+
JSON
.
stringify
(
data
));
...
...
@@ -59,6 +64,13 @@ describe('PasteBoardTest', function() {
var
primaryText
=
pasteData1
.
getPrimaryText
()
console
.
log
(
'
f_test1: primaryText =
'
+
primaryText
);
console
.
info
(
'
Checks pasteboard MAX_RECORD_NUM
'
+
pasteboard
.
MAX_RECORD_NUM
);
expect
(
pasteboard
.
MAX_RECORD_NUM
==
128
).
assertTrue
();
console
.
info
(
'
Checks PasteDataProperty.localOnly
'
)
var
pasteDataProperty
=
pasteData1
.
getProperty
()
console
.
info
(
'
Checks: localOnly =
'
+
pasteDataProperty
.
localOnly
)
console
.
log
(
'
Checks there is a MIMETYPE_TEXT_PLAIN MIME type of data
'
+
pasteboard
.
MIMETYPE_TEXT_PLAIN
);
console
.
log
(
'
f_test1: getPrimaryMimeType =
'
+
pasteData1
.
getPrimaryMimeType
());
...
...
@@ -448,6 +460,11 @@ describe('PasteBoardTest', function() {
var
pasteData1
=
data
;
expect
(
pasteData1
.
getRecordCount
()
==
1
).
assertTrue
();
console
.
info
(
'
f_test9: Checks the pasteboard content
'
);
var
primaryUri
=
pasteData1
.
getPrimaryUri
()
console
.
info
(
'
f_test9: getPrimaryUri =
'
+
primaryUri
);
expect
(
primaryUri
==
uriText
).
assertTrue
();
console
.
log
(
'
Checks there is a MIMETYPE_TEXT_URI MIME type of data
'
+
pasteboard
.
MIMETYPE_TEXT_URI
);
expect
(
pasteData1
.
hasMimeType
(
pasteboard
.
MIMETYPE_TEXT_URI
)
===
true
||
pasteData1
.
hasMimeType
(
pasteboard
.
MIMETYPE_TEXT_URI
)
===
false
).
assertTrue
();
...
...
@@ -570,6 +587,8 @@ describe('PasteBoardTest', function() {
abilityName
:
"
com.example.myapplication8.MainAbility
"
}
console
.
log
(
'
f_test12: createWantData want =
'
+
want
);
console
.
info
(
'
f_test12: createWantData want.bundleName =
'
+
want
.
bundleName
);
console
.
info
(
'
f_test12: createWantData want.bundleName =
'
+
want
.
abilityName
);
var
pasteData
=
pasteboard
.
createWantData
(
want
);
console
.
log
(
'
f_test12: createWantData pasteData =
'
+
JSON
.
stringify
(
pasteData
));
...
...
@@ -588,6 +607,13 @@ describe('PasteBoardTest', function() {
var
pasteData1
=
data
;
expect
(
pasteData1
.
getRecordCount
()
==
1
).
assertTrue
();
console
.
info
(
'
f_test12: Checks the pasteboard content
'
);
var
primaryWant
=
pasteData1
.
getPrimaryWant
()
console
.
info
(
'
f_test12: createWantData want.bundleName =
'
+
primaryWant
.
bundleName
);
console
.
info
(
'
f_test12: createWantData want.bundleName =
'
+
primaryWant
.
abilityName
);
expect
(
want
.
bundleName
).
assertEqual
(
primaryWant
.
bundleName
);
expect
(
want
.
abilityName
).
assertEqual
(
primaryWant
.
abilityName
);
console
.
log
(
'
Checks there is a MIMETYPE_TEXT_WANT MIME type of data
'
+
pasteboard
.
MIMETYPE_TEXT_WANT
);
expect
(
pasteData1
.
hasMimeType
(
pasteboard
.
MIMETYPE_TEXT_WANT
)
===
true
||
pasteData1
.
hasMimeType
(
pasteboard
.
MIMETYPE_TEXT_WANT
)
===
false
).
assertTrue
();
...
...
@@ -879,6 +905,13 @@ describe('PasteBoardTest', function() {
var
uriText
=
'
https://www.baidu.com/
'
console
.
log
(
'
f_test18: addUriRecord =
'
+
uriText
)
pasteData
.
addUriRecord
(
uriText
)
var
want
=
{
bundleName
:
"
com.example.myapplication8
"
,
abilityName
:
"
com.example.myapplication8.MainAbility
"
}
console
.
info
(
'
f_test18: addWantRecord =
'
+
want
)
pasteData
.
addWantRecord
(
want
)
console
.
log
(
'
f_test18: Writes PasteData to the pasteboard
'
);
systemPasteboard
.
setPasteData
(
pasteData
).
then
(()
=>
{
...
...
@@ -893,7 +926,7 @@ describe('PasteBoardTest', function() {
systemPasteboard
.
getPasteData
().
then
((
data
)
=>
{
console
.
log
(
'
f_test18: systemPasteboard.getPasteData data =
'
+
JSON
.
stringify
(
data
));
var
pasteData1
=
data
;
expect
(
pasteData1
.
getRecordCount
()
==
3
).
assertTrue
();
expect
(
pasteData1
.
getRecordCount
()
==
4
).
assertTrue
();
console
.
log
(
'
SUB_pasteBoard_function_JS_API_1800 end
'
);
done
();
...
...
@@ -3438,6 +3471,7 @@ describe('PasteBoardTest', function() {
console
.
log
(
'
f_test66 Converts the PlainTextData to text
'
)
var
pasteDataRecord
=
pasteData1
.
getRecordAt
(
0
)
console
.
info
(
'
checks pasteDataRecord.mimeType =
'
+
pasteDataRecord
.
mimeType
)
console
.
log
(
'
f_test66 pasteDataRecord.convertToText =
'
+
pasteDataRecord
.
convertToText
);
console
.
log
(
'
f_test66 SUB_pasteBoard_function_JS_API_6600 end
'
);
...
...
@@ -3591,6 +3625,53 @@ describe('PasteBoardTest', function() {
});
});
})
/**
* @tc.number SUB_pasteBoard_function_JS_API_7000
* @tc.name 复制文本、uri格式
* @tc.desc Test pasteBoard API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
pasteboard_function_test70
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
SUB_pasteBoard_function_JS_API_7000 start
'
)
var
systemPasteboard
=
pasteboard
.
getSystemPasteboard
();
systemPasteboard
.
clear
().
then
(()
=>
{
var
textData0
=
'
Hello World0
'
console
.
info
(
'
f_test70: createPlainTextData =
'
+
textData0
)
var
pasteData
=
pasteboard
.
createPlainTextData
(
textData0
)
console
.
info
(
'
f_test70: createPlainTextData =
'
+
JSON
.
stringify
(
pasteData
))
var
uriText
=
pasteboard
.
createUriRecord
(
"
https://www.baidu.com/
"
);
pasteData
.
addRecord
(
uriText
);
console
.
info
(
'
f_test70: addRecord(uriText) =
'
+
pasteData
)
console
.
info
(
'
f_test70: addRecord(uriText) =
'
+
JSON
.
stringify
(
pasteData
))
systemPasteboard
.
setPasteData
(
pasteData
).
then
(()
=>
{
systemPasteboard
.
hasPasteData
().
then
((
data
)
=>
{
console
.
info
(
'
f_test70: systemPasteboard.hasPasteData promise data =
'
+
data
);
expect
(
data
===
true
||
data
===
false
).
assertTrue
();
systemPasteboard
.
getPasteData
().
then
((
data
)
=>
{
console
.
info
(
'
f_test70: systemPasteboard.getPasteData data =
'
+
JSON
.
stringify
(
data
));
var
pasteData1
=
data
;
var
recordCount
=
pasteData1
.
getRecordCount
();
console
.
info
(
'
f_test70: recordCount=
'
+
recordCount
);
expect
(
pasteData1
.
getRecordCount
()
==
2
).
assertTrue
();
console
.
info
(
'
SUB_pasteBoard_function_JS_API_7000 end
'
);
done
();
})
});
});
});
})
/**
* The callback function is used for pasteboard content changes
...
...
miscservices/wallpaper_js/src/main/js/Test/Wallpaper/WallpaperJsunit.test.js
浏览文件 @
7c1a2e7e
...
...
@@ -71,6 +71,10 @@ describe('WallpaperJsunitTest', function () {
await
wallpaper
.
getColors
(
WALLPAPER_SYSTEM
,
function
(
err
,
data
)
{
console
.
info
(
'
wallpaperXTS ===> testGetColorsCallbackSystem err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
wallpaperXTS ===> testGetColorsCallbackSystem data :
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
wallpaperXTS ===> testGetColorsCallbackSystem data :
'
+
data
[
0
][
0
]);
console
.
info
(
'
wallpaperXTS ===> testGetColorsCallbackSystem data :
'
+
data
[
0
][
1
]);
console
.
info
(
'
wallpaperXTS ===> testGetColorsCallbackSystem data :
'
+
data
[
0
][
2
]);
console
.
info
(
'
wallpaperXTS ===> testGetColorsCallbackSystem data :
'
+
data
[
0
][
3
]);
if
(
err
)
{
expect
(
null
).
assertFail
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录