提交 7f542d85 编写于 作者: L liangzhenyu123

接口用例覆盖;问题用例整改

Signed-off-by: Nliangzhenyu123 <liangzhenyu6@huawei.com>
上级 b6347d95
......@@ -15,7 +15,9 @@
import pasteBoardJEtsunitTest from './PasteBoardEtsunitTest';
import pasteBoardTest from './PasteBoeadPixelMapJsunit.test';
import pasteBoardSupportBinaryDataTest from './PasteBoardSupportBinaryData.test';
export default function testsuite() {
pasteBoardSupportBinaryDataTest()
pasteBoardJEtsunitTest()
pasteBoardTest()
}
\ 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.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import pasteboard from '@ohos.pasteboard'
export default function pasteBoardSupportBinaryDataTest(){
describe('pasteBoardSupportBinaryDataTest', function() {
console.info('start################################start');
/**
* @tc.number SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0100
* @tc.name Create pasteData use binary parameter
* @tc.desc Test pasteBoard API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0100', 0, async function (done) {
console.info("SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0100 start")
var systemPasteBoard = pasteboard.getSystemPasteboard();
await systemPasteBoard.clear().then(async () => {
var pasteData = undefined;
console.info("systemPasteBoard clear data success")
var dataUri = new ArrayBuffer(256)
pasteData = pasteboard.createData("text/uri",dataUri)
var addUri = new ArrayBuffer(128)
pasteData.addRecord("text/uri", addUri)
var recordUri = new ArrayBuffer(96)
var pasteDataRecord = pasteboard.createRecord("text/uri", recordUri)
pasteData.addRecord(pasteDataRecord)
await systemPasteBoard.setPasteData(pasteData).then(async () => {
console.info("Set pastedata success")
await systemPasteBoard.hasPasteData().then(async (data) => {
console.info("Check pastedata has data success, result: " + data)
expect(data).assertTrue();
await systemPasteBoard.getPasteData().then(async (data) => {
console.info("Get paste data success")
expect(data.getRecordCount()).assertEqual(3)
})
})
})
})
done();
})
/**
* @tc.number SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0200
* @tc.name Create pasteData use binary parameter
* @tc.desc Test pasteBoard API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0200', 0, async function (done) {
console.info("SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0200 start")
var systemPasteBoard = pasteboard.getSystemPasteboard();
await systemPasteBoard.clear().then(async () => {
var pasteData = undefined;
console.info("systemPasteBoard clear data success")
var dataHtml = new ArrayBuffer(256)
pasteData = pasteboard.createData("text/html",dataHtml)
var addHtml = new ArrayBuffer(128)
pasteData.addRecord("text/html", addHtml)
var recordHtml = new ArrayBuffer(64)
var pasteDataRecord = pasteboard.createRecord("text/html", recordHtml)
pasteData.addRecord(pasteDataRecord)
await systemPasteBoard.setPasteData(pasteData).then(async () => {
console.info("set pastedata success")
await systemPasteBoard.hasPasteData().then(async (data) => {
console.info("Check pastedata has data success, result: " + data)
expect(data).assertTrue();
await systemPasteBoard.getPasteData().then(async (data) => {
console.info("get paste data success")
expect(data.getRecordCount()).assertEqual(3)
})
})
})
})
done();
})
/**
* @tc.number SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0300
* @tc.name Create pasteData use binary parameter
* @tc.desc Test pasteBoard API functionality.
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0300', 0, async function (done) {
console.info("SUB_PASTEBOARD_BINARY_FUNCTION_ETS_TEST_0300 start")
var systemPasteBoard = pasteboard.getSystemPasteboard();
await systemPasteBoard.clear().then(async () => {
console.info("systemPasteBoard clear data success")
var pasteData = undefined
var pasteRecord = undefined;
var dataHtml = new ArrayBuffer(256)
pasteData = pasteboard.createData("x".repeat(1025),dataHtml)
expect(pasteData).assertEqual(undefined)
pasteData = pasteboard.createData("x".repeat(1024),dataHtml)
expect(pasteData != undefined).assertTrue();
var addHtml = new ArrayBuffer(128)
pasteData.addRecord("x".repeat(1025),dataHtml)
expect(pasteData.getRecordCount()).assertEqual(1)
pasteData.addRecord("x".repeat(1024),dataHtml)
expect(pasteData.getRecordCount()).assertEqual(2)
var recordHtml = new ArrayBuffer(64)
pasteRecord = pasteboard.createRecord("x".repeat(1025),dataHtml)
expect(pasteRecord).assertEqual(undefined);
pasteRecord = pasteboard.createRecord("x".repeat(1024),dataHtml)
expect(pasteRecord != undefined).assertTrue();;
pasteData.addRecord(pasteRecord)
await systemPasteBoard.setPasteData(pasteData).then(async () => {
console.info("set pastedata success")
await systemPasteBoard.hasPasteData().then(async (data) => {
console.info("Check pastedata has data success, result: " + data)
expect(data).assertTrue();
await systemPasteBoard.getPasteData().then(async (data) => {
console.info("get paste data success")
expect(data.getRecordCount()).assertEqual(3)
})
})
})
})
done();
})
console.info('end################################end');
});
}
......@@ -29,7 +29,7 @@ var mPreferences;
var context;
export default function preferencesPromiseTest(){
describe('preferencesPromiseTest', function () {
describe('preferencesPromiseTest', function () {
beforeAll(async function () {
console.info('beforeAll')
context = featureAbility.getContext()
......@@ -357,17 +357,14 @@ describe('preferencesPromiseTest', function () {
* @tc.desc put boolean promise interface test
*/
it('testPreferencesPutBoolean0121', 0, async function (done) {
const promise = mPreferences.put(KEY_TEST_BOOLEAN_ELEMENT, true);
promise.then(async (ret) => {
await mPreferences.clear();
let promise = mPreferences.put(KEY_TEST_BOOLEAN_ELEMENT, true);
await promise;
let per = await mPreferences.get(KEY_TEST_BOOLEAN_ELEMENT, false);
expect(true).assertEqual(per);
await mPreferences.flush();
let per2 = await mPreferences.get(KEY_TEST_BOOLEAN_ELEMENT, false);
expect(true).assertEqual(per2);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
......@@ -377,17 +374,14 @@ describe('preferencesPromiseTest', function () {
* @tc.desc put float promise interface test
*/
it('testPreferencesPutFloat0131', 0, async function (done) {
await mPreferences.clear();
const promise = mPreferences.put(KEY_TEST_FLOAT_ELEMENT, 4.0);
promise.then(async (ret) => {
await promise;
let per = await mPreferences.get(KEY_TEST_FLOAT_ELEMENT, 0.0);
expect(4.0).assertEqual(per);
await mPreferences.flush();
let per2 = await mPreferences.get(KEY_TEST_FLOAT_ELEMENT, 0.0);
expect(4.0).assertEqual(per2);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
......@@ -397,17 +391,14 @@ describe('preferencesPromiseTest', function () {
* @tc.desc put int promise interface test
*/
it('testPreferencesPutInt0141', 0, async function (done) {
const promise = mPreferences.put(KEY_TEST_INT_ELEMENT, 4);
promise.then(async (ret) => {
await mPreferences.clear();
let promise = mPreferences.put(KEY_TEST_INT_ELEMENT, 4);
await promise;
let per = await mPreferences.get(KEY_TEST_INT_ELEMENT, 0);
expect(4).assertEqual(per);
await mPreferences.flush();
let per2 = await mPreferences.get(KEY_TEST_INT_ELEMENT, 0);
expect(4).assertEqual(per2);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
......@@ -417,17 +408,13 @@ describe('preferencesPromiseTest', function () {
* @tc.desc put long promise interface test
*/
it('testPreferencesPutLong0151', 0, async function (done) {
const promise = mPreferences.put(KEY_TEST_LONG_ELEMENT, 4);
promise.then(async (ret) => {
let promise = mPreferences.put(KEY_TEST_LONG_ELEMENT, 4);
await promise;
let per = await mPreferences.get(KEY_TEST_LONG_ELEMENT, 0);
expect(4).assertEqual(per);
await mPreferences.flush();
let per2 = await mPreferences.get(KEY_TEST_LONG_ELEMENT, 0);
expect(4).assertEqual(per2);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
......@@ -437,17 +424,13 @@ describe('preferencesPromiseTest', function () {
* @tc.desc put String promise interface test
*/
it('testPreferencesPutString0161', 0, async function (done) {
const promise = mPreferences.put(KEY_TEST_STRING_ELEMENT, '');
promise.then(async (ret) => {
let promise = mPreferences.put(KEY_TEST_STRING_ELEMENT, '');
await promise;
let per = await mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultvalue")
expect('').assertEqual(per);
await mPreferences.flush();
let per2 = await mPreferences.get(KEY_TEST_STRING_ELEMENT, "defaultvalue")
expect('').assertEqual(per2);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
......@@ -458,7 +441,7 @@ describe('preferencesPromiseTest', function () {
*/
it('testPreferencesGetDefValue00162', 0, async function (done) {
await mPreferences.clear();
const promise = mPreferences.get(KEY_TEST_BOOLEAN_ELEMENT, true);
let promise = mPreferences.get(KEY_TEST_BOOLEAN_ELEMENT, true);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
......@@ -467,5 +450,5 @@ describe('preferencesPromiseTest', function () {
await promise;
done();
})
})
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册