提交 a45ec152 编写于 作者: 华华小仙女 提交者: Gitee

Merge branch 'monthly_20221018' of gitee.com:openharmony/xts_acts into monthly_20221018

Signed-off-by: N华华小仙女 <zhurong18@h-partners.com>
...@@ -21,7 +21,6 @@ group("communication") { ...@@ -21,7 +21,6 @@ group("communication") {
"bluetooth_profile:ActsBluetoothProFileJsTest", "bluetooth_profile:ActsBluetoothProFileJsTest",
"bluetooth_standard:ActsBluetoothJsTest", "bluetooth_standard:ActsBluetoothJsTest",
"dsoftbus/rpc:ActsRpcJsTest", "dsoftbus/rpc:ActsRpcJsTest",
"dsoftbus/rpc_server:ActsRpcJsServer",
"nfc_Controller:ActsNFCJSTest", "nfc_Controller:ActsNFCJSTest",
"wifi_p2p:ActsP2PJSTest", "wifi_p2p:ActsP2PJSTest",
"wifi_standard:ActsWifiJSTest", "wifi_standard:ActsWifiJSTest",
......
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"ActsRpcHapTest.hap", "ActsRpcHapTest.hap"
"ActsRpcHapServer.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
......
...@@ -17,12 +17,15 @@ import rpc from '@ohos.rpc' ...@@ -17,12 +17,15 @@ import rpc from '@ohos.rpc'
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import FA from '@ohos.ability.featureAbility' import FA from '@ohos.ability.featureAbility'
import {describe, expect, beforeAll, it} from 'deccjsunit/index' import {describe, expect, beforeAll, it} from 'deccjsunit/index'
var gIRemoteObject = null;
export default function actsRpcClientJsTest() { export default function actsRpcClientJsTest() {
var gIRemoteObject = undefined;
describe('ActsRpcClientJsTest', function(){ describe('ActsRpcClientJsTest', function(){
console.info("-----------------------SUB_Softbus_IPC_Compatibility_MessageParce_Test is starting-----------------------"); console.info("-----------------------SUB_Softbus_IPC_Compatibility_MessageParce_Test is starting-----------------------");
beforeAll(async function () {
console.info('beforeAll called')
gIRemoteObject = new Stub("rpcTestAbility");
return gIRemoteObject;
});
beforeEach(async function (){ beforeEach(async function (){
console.info('beforeEach called'); console.info('beforeEach called');
...@@ -73,87 +76,6 @@ export default function actsRpcClientJsTest() { ...@@ -73,87 +76,6 @@ export default function actsRpcClientJsTest() {
const CODE_ONREMOTEMESSAGE_OR_ONREMOTE = 32; const CODE_ONREMOTEMESSAGE_OR_ONREMOTE = 32;
const CODE_ONREMOTEMESSAGEREQUEST = 33; const CODE_ONREMOTEMESSAGEREQUEST = 33;
const ErrorCode = {
/* Check param failed */
CHECK_PARAM_ERROR:401,
/* Os mmap function failed */
OS_MMAP_ERROR:1900001,
/* Os ioctl function failed */
OS_IOCTL_ERROR:1900002,
/* Write to ashmem failed */
WRITE_TO_ASHMEM_ERROR:1900003,
/* Read from ashmem failed */
READ_FROM_ASHMEM_ERROR:1900004,
/* Only proxy object permitted */
ONLY_PROXY_OBJECT_PERMITTED_ERROR:1900005,
/* Only remote object permitted */
ONLY_REMOTE_OBJECT_PERMITTED_ERROR:1900006,
/* Communication failed */
COMMUNICATION_ERROR:1900007,
/* Proxy or remote object is invalid */
PROXY_OR_REMOTE_OBJECT_INVALID_ERROR:1900008,
/* Write data to message sequence failed */
WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR:1900009,
/* Read data from message sequence failed */
READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR:1900010,
/* Parcel memory alloc failed */
PARCEL_MEMORY_ALLOC_ERROR:1900011,
/* Call js method failed */
CALL_JS_METHOD_ERROR:1900012,
/* Os dup function failed */
OS_DUP_ERROR:1900013
}
function connectAbility() {
let want = {
"bundleName":"ohos.rpc.test.server",
"abilityName": "ohos.rpc.test.server.ServiceAbility",
};
let connect = {
onConnect:function (elementName, remoteProxy) {
console.info('RpcClient: onConnect called, instance of proxy: '
+ (remoteProxy instanceof rpc.RemoteProxy))
gIRemoteObject = remoteProxy
},
onDisconnect:function (elementName) {
console.info("RpcClient: onDisconnect")
},
onFailed:function () {
console.info("RpcClient: onFailed")
gIRemoteObject = null
}
};
FA.connectAbility(want, connect)
try {
let descriptor = gIRemoteObject.getDescriptor();
console.info("RpcClient: descriptor is " + descriptor);
} catch(error) {
console.info("rpc get interface descriptor fail, errorCode " + error.code);
console.info("rpc get interface descriptor fail, errorMessage " + error.message);
}
return new Promise((resolve, reject) =>{
console.info("start connect local ability, wait 5 seconds")
setTimeout(()=>{
console.info("resolve proxy: " + gIRemoteObject)
resolve(gIRemoteObject)
}, 5000)
})
}
function sleep(numberMillis) function sleep(numberMillis)
{ {
var now = new Date(); var now = new Date();
...@@ -218,6 +140,444 @@ export default function actsRpcClientJsTest() { ...@@ -218,6 +140,444 @@ export default function actsRpcClientJsTest() {
} }
} }
class Stub extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
}
onRemoteRequest(code, data, reply, option) {
try{
console.info("onRemoteRequest: " + code)
if (code === 32){
console.info("case 32 start")
let tmp1 = data.readString()
let result = reply.writeString("onRemoteRequest invoking")
return true
} else if (code === 33){
console.info("case 33 start")
let tmp1 = data.readString()
let result = reply.writeString(tmp1)
return true
}else {
console.error("default case " + code)
return super.onRemoteRequest(code, data, reply, option)
}
} catch (error) {
console.info("onRemoteRequest: " + error);
}
return false
}
onRemoteMessageRequest(code, data, reply, option) {
try{
console.info("onRemoteMessageRequest: " + code)
switch(code) {
case 1:
{
console.info("case 1 start")
let tmp1 = data.readByteArray()
let result = reply.writeByteArray(tmp1)
return true
}
case 2:
{
console.info("case 2 start")
let tmp1 = data.readIntArray()
let result = reply.writeIntArray(tmp1)
return true
}
case 3:
{
console.info("case 3 start")
let tmp1 = data.readFloatArray()
let result = reply.writeFloatArray(tmp1)
return true
}
case 4:
{
console.info("case 4 start")
let tmp1 = data.readShort()
let result = reply.writeShort(tmp1)
return true
}
case 5:
{
console.info("case 5 start")
let tmp1 = data.readLong()
let result = reply.writeLong(tmp1)
return true
}
case 6:
{
console.info("case 6 start")
let tmp1 = data.readDouble()
let result = reply.writeDouble(tmp1)
return true
}
case 7:
{
console.info("case 7 start")
let tmp1 = data.readBoolean()
let result = reply.writeBoolean(tmp1)
return true
}
case 8:
{
console.info("case 8 start")
let tmp1 = data.readChar()
let result = reply.writeChar(tmp1)
return true
}
case 9:
{
console.info("case 9 start")
let tmp1 = data.readString()
let result = reply.writeString(tmp1)
return true
}
case 10:
{
console.info("case 10 start")
let tmp1 = data.readByte()
let result = reply.writeByte(tmp1)
return true
}
case 11:
{
console.info("case 11 start")
let tmp1 = data.readInt()
let result = reply.writeInt(tmp1)
return true
}
case 12:
{
console.info("case 12 start")
let tmp1 = data.readFloat()
let result = reply.writeFloat(tmp1)
return true
}
case 13:
{
console.info("case 13 start")
var size = data .readInt();
let tmp1 = data.readRawData(size);
let size1 = reply.writeInt(size);
let result = reply.writeRawData(tmp1, tmp.length)
return true
}
case 14:
{
console.info("case 14 start")
let listener = data.readRemoteObject();
let num = data.readInt()
let str = data.readString()
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
data2.writeInt(num)
data2.writeString(str)
listener.sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("14 send request done, error code: " + result.errCode )
})
.catch(function(e) {
console.error("14 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 14 test done")
})
reply.writeNoException()
return true
}
case 15:
{
console.info("case 15 start")
let s = new MySequenceable(null, null)
var tmp1 = data.readParcelable(s)
let result = reply.writeParcelable(s)
return true
}
case 16:
{
console.info("case 16 start")
data.readException()
var tmp = data.readInt();
reply.writeNoException()
var result = reply.writeInt(tmp);
return true
}
case 17:
{
console.info("case 17 start")
var s = [new MySequenceable(null, null), new MySequenceable(null, null),
new MySequenceable(null, null)];
data.readParcelableArray(s);
let result = reply.writeParcelableArray(s);
return true
}
case 18:
{
console.info("case 18 start")
let listeners = data.readRemoteObjectArray();
for (let i = 0; i < listeners.length; i++) {
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
listeners[i].sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("18 send request done, error code: " + result.errCode + ", index: " + i)
})
.catch(function(e) {
console.error("18 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 18 test done")
})
}
console.info("18 The server's writeRemoteObjectArray result is " + result);
return true
}
case 19:
{
console.info("case 19 start")
let tmp1 = data.readDoubleArray()
let result = reply.writeDoubleArray(tmp1)
return true
}
case 20:
{
console.info("case 20 start")
let tmp1 = data.readByte()
let tmp2 = data.readShort()
let tmp3 = data.readInt()
let tmp4 = data.readLong()
let tmp5 = data.readFloat()
let tmp6 = data.readDouble()
let tmp7 = data.readBoolean()
let tmp8 = data.readChar()
let tmp9 = data.readString()
let s = new MySequenceable(null, null)
let tmp10 = data.readParcelable(s)
let result1 = reply.writeByte(tmp1)
let result2 = reply.writeShort(tmp2)
let result3 = reply.writeInt(tmp3)
let result4 = reply.writeLong(tmp4)
let result5 = reply.writeFloat(tmp5)
let result6 = reply.writeDouble(tmp6)
let result7 = reply.writeBoolean(tmp7)
let result8 = reply.writeChar(tmp8)
let result9 = reply.writeString(tmp9)
let result10 = reply.writeParcelable(s)
return true
}
case 21:
{
console.info("case 21 start")
let tmp1 = data.readByteArray()
let tmp2 = data.readShortArray()
let tmp3 = data.readIntArray()
let tmp4 = data.readLongArray()
let tmp5 = data.readFloatArray()
let tmp6 = data.readDoubleArray()
let tmp7 = data.readBooleanArray()
let tmp8 = data.readCharArray()
let tmp9 = data.readStringArray()
let s = [new MySequenceable(null, null), new MySequenceable(null, null),
new MySequenceable(null, null)]
let tmp10 = data.readParcelableArray(s)
let result1 = reply.writeByteArray(tmp1)
let result2 = reply.writeShortArray(tmp2)
let result3 = reply.writeIntArray(tmp3)
let result4 = reply.writeLongArray(tmp4)
let result5 = reply.writeFloatArray(tmp5)
let result6 = reply.writeDoubleArray(tmp6)
let result7 = reply.writeBooleanArray(tmp7)
let result8 = reply.writeCharArray(tmp8)
let result9 = reply.writeStringArray(tmp9)
let result10 = reply.writeParcelableArray(s)
return true
}
case 22:
{
console.info("case 22 start")
let callingPid = rpc.IPCSkeleton.getCallingPid()
let callingUid = rpc.IPCSkeleton.getCallingUid()
reply.writeNoException()
reply.writeInt(callingPid)
reply.writeInt(callingUid)
reply.writeInt(this.getCallingPid())
reply.writeInt(this.getCallingUid())
let id = rpc.IPCSkeleton.resetCallingIdentity()
rpc.IPCSkeleton.setCallingIdentity(id)
reply.writeInt(rpc.IPCSkeleton.getCallingPid())
reply.writeInt(rpc.IPCSkeleton.getCallingUid())
reply.writeInt(rpc.IPCSkeleton.flushCommands(this))
return true
}
case 23:
{
console.info("case 23 start")
let s = new MySequenceable(null, null);
var tmp1 = data.readParcelable(s);
var result = reply.writeParcelable(s);
return true
}
case 24:
{
console.info("case 24 start")
var tmp1 = data.readShort();
var tmp2 = data.readShort();
var tmp3 = data.readShort();
var tmp4 = data.readShort();
var tmp5 = data.readShort();
var result1 = reply.writeShort(tmp1);
var result2 = reply.writeShort(tmp2);
var result3 = reply.writeShort(tmp3);
var result4 = reply.writeShort(tmp4);
var result5 = reply.writeShort(tmp5);
return true
}
case 25:
{
console.info("case 25 start")
var tmp1 = data.readByte();
var tmp2 = data.readByte();
var tmp3 = data.readByte();
var tmp4 = data.readByte();
var tmp5 = data.readByte();
var result1 = reply.writeByte(tmp1);
var result2 = reply.writeByte(tmp2);
var result3 = reply.writeByte(tmp3);
var result4 = reply.writeByte(tmp4);
var result5 = reply.writeByte(tmp5);
return true
}
case 26:
{
console.info("case 26 start")
var tmp1 = data.readInt();
var tmp2 = data.readInt();
var tmp3 = data.readInt();
var tmp4 = data.readInt();
var tmp5 = data.readInt();
var result1 = reply.writeInt(tmp1);
var result2 = reply.writeInt(tmp2);
var result3 = reply.writeInt(tmp3);
var result4 = reply.writeInt(tmp4);
var result5 = reply.writeInt(tmp5);
return true
}
case 28:
{
console.info("case 28 start")
let callingPid = rpc.IPCSkeleton.getCallingPid()
let callingUid = rpc.IPCSkeleton.getCallingUid()
let callingDeviceID = rpc.IPCSkeleton.getCallingDeviceID()
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID()
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling()
reply.writeNoException()
reply.writeInt(callingPid)
reply.writeInt(callingUid)
reply.writeString(callingDeviceID)
reply.writeString(localDeviceID)
reply.writeBoolean(isLocalCalling)
reply.writeInt(this.getCallingPid())
reply.writeInt(this.getCallingUid())
let id = rpc.IPCSkeleton.resetCallingIdentity()
rpc.IPCSkeleton.setCallingIdentity(id)
reply.writeInt(rpc.IPCSkeleton.getCallingPid())
reply.writeInt(rpc.IPCSkeleton.getCallingUid())
reply.writeInt(rpc.IPCSkeleton.flushCommands(this))
return true
}
case 29:
{
console.info("case 29 starts")
let bytesWr = data.readInt()
let fd = data.readFileDescriptor()
let writeFileResult = fileio.writeSync(fd, "HELLO RPC", {position: bytesWr + 1});
rpc.MessageParcel.closeFileDescriptor(fd)
return true
}
case 30:
{
console.info("case 30 start")
let listeners = data.readRemoteObjectArray();
let num = data.readInt()
let str = data.readString()
for (let i = 0; i < listeners.length; i++) {
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
data2.writeInt(num)
data2.writeString(str)
listeners[i].sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("30 send request done, error code: " + result.errCode + ", index: " + i)
})
.catch(function(e) {
console.error("30 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 30 test done")
})
}
reply.writeNoException()
return true
}
case 31:
{
console.info("case 31 start")
let listeners = data.readRemoteObjectArray();
let num = data.readInt()
let str = data.readString()
console.info("31 num: " + num);
console.info("31 str: " + str);
for (let i = 0; i < listeners.length; i++) {
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
data2.writeInt(num)
data2.writeString(str)
listeners[i].sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("31 send request done, error code: " + result.errCode + ", index: " + i)
})
.catch(function(e) {
console.error("31 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 31 test done")
})
}
reply.writeNoException()
return true
}
case 32:
{
console.info("case 32 start")
let tmp1 = data.readString()
let result = reply.writeString("onRemoteMessageRequest invoking")
return true
}
default:
this.onRemoteRequest(code, data, reply, option)
}
} catch (error) {
console.info("onRemoteMessageRequest: " + error);
}
return false
}
}
class TestAbilityStub extends rpc.RemoteObject { class TestAbilityStub extends rpc.RemoteObject {
constructor(descriptor) { constructor(descriptor) {
super(descriptor) super(descriptor)
...@@ -270,7 +630,6 @@ export default function actsRpcClientJsTest() { ...@@ -270,7 +630,6 @@ export default function actsRpcClientJsTest() {
constructor(descriptor) { constructor(descriptor) {
super(descriptor) super(descriptor)
} }
onRemoteMessageRequest(code, data, reply, option) { onRemoteMessageRequest(code, data, reply, option) {
console.info("TestAbilityMessageStub: onRemoteMessageRequest called, code: " + code) console.info("TestAbilityMessageStub: onRemoteMessageRequest called, code: " + code)
let descriptor = data.readInterfaceToken() let descriptor = data.readInterfaceToken()
...@@ -361,17 +720,6 @@ export default function actsRpcClientJsTest() { ...@@ -361,17 +720,6 @@ export default function actsRpcClientJsTest() {
} }
} }
beforeAll(async function (done) {
console.info('beforeAll called')
await connectAbility().then((remote) => {
console.info("got remote proxy: " + remote)
}).catch((err) => {
console.info("got exception: " + err)
})
done()
console.info("beforeAll done")
})
/* /*
* @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_00100 * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_00100
* @tc.name Call the writeinterfacetoken interface, write the interface descriptor, and read interfacetoken * @tc.name Call the writeinterfacetoken interface, write the interface descriptor, and read interfacetoken
...@@ -5079,7 +5427,7 @@ export default function actsRpcClientJsTest() { ...@@ -5079,7 +5427,7 @@ export default function actsRpcClientJsTest() {
data.reclaim() data.reclaim()
reply.reclaim() reply.reclaim()
console.info("test done") done();
} catch(error) { } catch(error) {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13000: error = " + error); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13000: error = " + error);
} }
...@@ -5105,7 +5453,6 @@ export default function actsRpcClientJsTest() { ...@@ -5105,7 +5453,6 @@ export default function actsRpcClientJsTest() {
done() done()
} }
} }
try{ try{
let option = new rpc.MessageOption() let option = new rpc.MessageOption()
let data = rpc.MessageParcel.create() let data = rpc.MessageParcel.create()
...@@ -5121,17 +5468,17 @@ export default function actsRpcClientJsTest() { ...@@ -5121,17 +5468,17 @@ export default function actsRpcClientJsTest() {
expect(data.writeString("rpcListenerTest")).assertTrue() expect(data.writeString("rpcListenerTest")).assertTrue()
await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECTARRAY_2, data, reply, option) await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECTARRAY_2, data, reply, option)
.then((result)=> { .then((result)=> {
console.info("sendRequest done, error code: " + result.errCode) console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13100 error code: " + result.errCode)
expect(result.errCode).assertEqual(0) expect(result.errCode).assertEqual(0)
result.reply.readException() result.reply.readException()
}) })
data.reclaim() data.reclaim()
reply.reclaim() reply.reclaim()
console.info("test done") console.info("test done")
} catch(error) { } catch(error) {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13100: error = " + error); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13100: error = " + error);
} }
done();
console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_13100---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_13100---------------------------");
}) })
...@@ -5311,7 +5658,7 @@ export default function actsRpcClientJsTest() { ...@@ -5311,7 +5658,7 @@ export default function actsRpcClientJsTest() {
expect(result.errCode == 0).assertTrue(); expect(result.errCode == 0).assertTrue();
let getMePaCapacity = result.reply.getCapacity(); let getMePaCapacity = result.reply.getCapacity();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13600:run getCapacityis is " + getMePaCapacity); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13600:run getCapacityis is " + getMePaCapacity);
expect(getMePaCapacity).assertEqual(("constant".length * 2) + 8); expect(getMePaCapacity).assertEqual("constant".length * 8);
expect(result.reply.readString()).assertEqual("constant"); expect(result.reply.readString()).assertEqual("constant");
}); });
data.reclaim(); data.reclaim();
...@@ -5350,7 +5697,7 @@ export default function actsRpcClientJsTest() { ...@@ -5350,7 +5697,7 @@ export default function actsRpcClientJsTest() {
expect(result.reply.readString()).assertEqual("constant"); expect(result.reply.readString()).assertEqual("constant");
let getMeCa = result.reply.getCapacity(); let getMeCa = result.reply.getCapacity();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13700:run getCapacityis is " + getMeCa); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13700:run getCapacityis is " + getMeCa);
expect(getMeCa).assertEqual(("constant".length * 2) + 8); expect(getMeCa).assertEqual("constant".length * 8);
}); });
data.reclaim(); data.reclaim();
reply.reclaim(); reply.reclaim();
...@@ -5425,7 +5772,7 @@ export default function actsRpcClientJsTest() { ...@@ -5425,7 +5772,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13900:run getSizeis is " + getSizeresult); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13900:run getSizeis is " + getSizeresult);
let setCapacityresult = result.reply.getCapacity(); let setCapacityresult = result.reply.getCapacity();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13900:run getCapacityis is " + setCapacityresult); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13900:run getCapacityis is " + setCapacityresult);
expect(setCapacityresult).assertEqual(("constant".length * 2) + 8); expect(setCapacityresult).assertEqual("constant".length * 8);
}); });
data.reclaim(); data.reclaim();
reply.reclaim(); reply.reclaim();
...@@ -6020,7 +6367,7 @@ export default function actsRpcClientJsTest() { ...@@ -6020,7 +6367,7 @@ export default function actsRpcClientJsTest() {
{ {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15500: gIRemoteObject is undefined"); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15500: gIRemoteObject is undefined");
} }
await gIRemoteObject.sendRequest(CODE_ONREMOTEMESSAGEREQUEST, data, reply, option).then((result) => { await gIRemoteObject.sendRequest(CODE_WRITE_STRING, data, reply, option).then((result) => {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15500: sendRequestis is " + result.errCode); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15500: sendRequestis is " + result.errCode);
var replyReadResult = result.reply.readString(); var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15500: run readString is " + replyReadResult); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15500: run readString is " + replyReadResult);
...@@ -6050,13 +6397,13 @@ export default function actsRpcClientJsTest() { ...@@ -6050,13 +6397,13 @@ export default function actsRpcClientJsTest() {
var reply = rpc.MessageSequence.create(); var reply = rpc.MessageSequence.create();
var option = new rpc.MessageOption(); var option = new rpc.MessageOption();
var token = 'onRemoteMessageRequest invoking'; var token = 'onRemoteMessageRequest invoking';
var result = data.writeString(token); data.writeString(token);
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600:run writeStringis is " + result); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600:run writeStringis is success");
if (gIRemoteObject == undefined) if (gIRemoteObject == undefined)
{ {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: gIRemoteObject is undefined"); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: gIRemoteObject is undefined");
} }
await gIRemoteObject.sendMessageRequest(CODE_ONREMOTEMESSAGEREQUEST, data, reply, option).then((result) => { await gIRemoteObject.sendMessageRequest(CODE_WRITE_STRING, data, reply, option).then((result) => {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: sendRequestis is " + result.errCode); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: sendRequestis is " + result.errCode);
var replyReadResult = result.reply.readString(); var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: run readString is " + replyReadResult); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: run readString is " + replyReadResult);
...@@ -6162,7 +6509,7 @@ export default function actsRpcClientJsTest() { ...@@ -6162,7 +6509,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900:run writeStringis is " + result); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900:run writeStringis is " + result);
data.reclaim(); data.reclaim();
} catch (error) { } catch (error) {
let errCode = ErrorCode.CHECK_PARAM_ERROR let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: errorCode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: errorMessage " + error.message);
...@@ -6189,7 +6536,7 @@ export default function actsRpcClientJsTest() { ...@@ -6189,7 +6536,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000:run writeInterfaceToken result "); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000:run writeInterfaceToken result ");
data.reclaim(); data.reclaim();
} catch (error) { } catch (error) {
let errCode = ErrorCode.PARCEL_MEMORY_ALLOC_ERROR; let errCode = `${rpc.ErrorCode.PARCEL_MEMORY_ALLOC_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorCode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message);
...@@ -6217,7 +6564,7 @@ export default function actsRpcClientJsTest() { ...@@ -6217,7 +6564,7 @@ export default function actsRpcClientJsTest() {
data.reclaim(); data.reclaim();
} catch (error) { } catch (error) {
let errCode = ErrorCode.WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR; let errCode = `${rpc.ErrorCode.WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: errorCode " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: errorMessage " + error.message);
...@@ -6244,7 +6591,7 @@ export default function actsRpcClientJsTest() { ...@@ -6244,7 +6591,7 @@ export default function actsRpcClientJsTest() {
data.readParcelable(ret); data.readParcelable(ret);
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16200: readParcelable is." + ret); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16200: readParcelable is." + ret);
} catch (error) { } catch (error) {
let errCode = ErrorCode.PARCEL_MEMORY_ALLOC_ERROR; let errCode = `${rpc.ErrorCode.PARCEL_MEMORY_ALLOC_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorCode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message);
...@@ -6267,7 +6614,7 @@ export default function actsRpcClientJsTest() { ...@@ -6267,7 +6614,7 @@ export default function actsRpcClientJsTest() {
var token = {} var token = {}
var result = data.writeRemoteObject(token); var result = data.writeRemoteObject(token);
} catch (error) { } catch (error) {
let errCode = ErrorCode.PROXY_OR_REMOTE_OBJECT_INVALID_ERROR; let errCode = `${rpc.ErrorCode.PROXY_OR_REMOTE_OBJECT_INVALID_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: errorCode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: errorMessage " + error.message);
...@@ -6298,7 +6645,7 @@ export default function actsRpcClientJsTest() { ...@@ -6298,7 +6645,7 @@ export default function actsRpcClientJsTest() {
data.readParcelable(ret); data.readParcelable(ret);
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: readParcelable is." + ret); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: readParcelable is." + ret);
} catch (error) { } catch (error) {
let errCode = ErrorCode.CALL_JS_METHOD_ERROR; let errCode = `${rpc.ErrorCode.CALL_JS_METHOD_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400:error = " + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400:error = " + error.message);
expect(error.message != null).assertTrue(); expect(error.message != null).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400:error = " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400:error = " + error.code);
...@@ -6326,7 +6673,7 @@ export default function actsRpcClientJsTest() { ...@@ -6326,7 +6673,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:run readInterfaceToken result is " + resultToken); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:run readInterfaceToken result is " + resultToken);
data.reclaim(); data.reclaim();
} catch (error) { } catch (error) {
let errCode = ErrorCode.READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR; let errCode = `${rpc.ErrorCode.READ_DATA_FROM_MESSAGE_SEQUENCE_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:error = " + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:error = " + error.message);
expect(error.message != null).assertTrue(); expect(error.message != null).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:error = " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:error = " + error.code);
...@@ -6349,7 +6696,7 @@ export default function actsRpcClientJsTest() { ...@@ -6349,7 +6696,7 @@ export default function actsRpcClientJsTest() {
let newFd = rpc.MessageSequence.dupFileDescriptor(fd); let newFd = rpc.MessageSequence.dupFileDescriptor(fd);
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: newFd " +newFd); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: newFd " +newFd);
} catch(error) { } catch(error) {
let errCode = ErrorCode.OS_DUP_ERROR; let errCode = `${rpc.ErrorCode.OS_DUP_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: errorCode " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: errorMessage" + error.message); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: errorMessage" + error.message);
...@@ -6668,7 +7015,7 @@ export default function actsRpcClientJsTest() { ...@@ -6668,7 +7015,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01100: sendRequestis is " + result.errCode); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01100: sendRequestis is " + result.errCode);
var replyReadResult = result.reply.readString(); var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01100: run readString is " + replyReadResult); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01100: run readString is " + replyReadResult);
expect(replyReadResult).assertEqual(""); expect(replyReadResult).assertEqual("option");
expect(option.getFlags()).assertEqual(1); expect(option.getFlags()).assertEqual(1);
}); });
...@@ -6709,7 +7056,7 @@ export default function actsRpcClientJsTest() { ...@@ -6709,7 +7056,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01200: sendRequestis is " + result.errCode); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01200: sendRequestis is " + result.errCode);
var replyReadResult = result.reply.readString(); var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01200: run readString is " + replyReadResult); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01200: run readString is " + replyReadResult);
expect(replyReadResult).assertEqual(""); expect(replyReadResult).assertEqual("option");
expect(option.getFlags()).assertEqual(3); expect(option.getFlags()).assertEqual(3);
}); });
data.reclaim(); data.reclaim();
...@@ -6747,7 +7094,7 @@ export default function actsRpcClientJsTest() { ...@@ -6747,7 +7094,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: sendMessageRequest is " + result.errCode); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: sendMessageRequest is " + result.errCode);
var replyReadResult = result.reply.readString(); var replyReadResult = result.reply.readString();
console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: run readString is " + replyReadResult); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: run readString is " + replyReadResult);
expect(replyReadResult).assertEqual(""); expect(replyReadResult).assertEqual("option");
expect(option.getFlags()).assertEqual(1); expect(option.getFlags()).assertEqual(1);
}); });
...@@ -6826,7 +7173,7 @@ export default function actsRpcClientJsTest() { ...@@ -6826,7 +7173,7 @@ export default function actsRpcClientJsTest() {
let isAsyncData = option.isAsync(); let isAsyncData = option.isAsync();
expect(isAsyncData).assertTrue(); expect(isAsyncData).assertTrue();
var replyReadResult = result.reply.readString(); var replyReadResult = result.reply.readString();
expect(replyReadResult).assertEqual(""); expect(replyReadResult).assertEqual("option");
}); });
data.reclaim(); data.reclaim();
reply.reclaim(); reply.reclaim();
...@@ -7951,7 +8298,7 @@ export default function actsRpcClientJsTest() { ...@@ -7951,7 +8298,7 @@ export default function actsRpcClientJsTest() {
let ashmem = rpc.Ashmem.create("ashmem", (2*G + 1)); let ashmem = rpc.Ashmem.create("ashmem", (2*G + 1));
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: ashmem " + ashmem); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: ashmem " + ashmem);
}catch(error){ }catch(error){
let errCode = ErrorCode.CHECK_PARAM_ERROR; let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: errorCode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: errorMessage " + error.message);
...@@ -7974,7 +8321,7 @@ export default function actsRpcClientJsTest() { ...@@ -7974,7 +8321,7 @@ export default function actsRpcClientJsTest() {
ashmem.mapReadWriteAshmem(); ashmem.mapReadWriteAshmem();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: run mapReadWriteAshmem is success"); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: run mapReadWriteAshmem is success");
}catch(error){ }catch(error){
let errCode = ErrorCode.OS_MMAP_ERROR; let errCode = `${rpc.ErrorCode.OS_MMAP_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: error " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: error " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: error " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: error " + error.message);
...@@ -7995,7 +8342,7 @@ export default function actsRpcClientJsTest() { ...@@ -7995,7 +8342,7 @@ export default function actsRpcClientJsTest() {
let ashmem = rpc.Ashmem.create("ashmem", 0); let ashmem = rpc.Ashmem.create("ashmem", 0);
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: ashmem " + ashmem); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: ashmem " + ashmem);
}catch(error){ }catch(error){
let errCode = ErrorCode.CHECK_PARAM_ERROR; let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: errorCode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: errorMessage " + error.message);
...@@ -8038,7 +8385,7 @@ export default function actsRpcClientJsTest() { ...@@ -8038,7 +8385,7 @@ export default function actsRpcClientJsTest() {
ashmem.setProtectionType(rpc.Ashmem.PROT_WRITE, rpc.Ashmem.PROT_READ); ashmem.setProtectionType(rpc.Ashmem.PROT_WRITE, rpc.Ashmem.PROT_READ);
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: run setProtectionType is success"); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: run setProtectionType is success");
}catch(error){ }catch(error){
let errCode = ErrorCode.CHECK_PARAM_ERROR; let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: errorCode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: errorMessage " + error.message);
...@@ -8061,7 +8408,7 @@ export default function actsRpcClientJsTest() { ...@@ -8061,7 +8408,7 @@ export default function actsRpcClientJsTest() {
ashmem.setProtectionType(null); ashmem.setProtectionType(null);
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: run setProtectionType is success"); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: run setProtectionType is success");
}catch(error){ }catch(error){
let errCode = ErrorCode.OS_IOCTL_ERROR; let errCode = `${rpc.ErrorCode.OS_IOCTL_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: errorCode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: errorCode " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: errorMessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: errorMessage " + error.message);
...@@ -8087,7 +8434,7 @@ export default function actsRpcClientJsTest() { ...@@ -8087,7 +8434,7 @@ export default function actsRpcClientJsTest() {
data.reclaim(); data.reclaim();
data2.reclaim(); data2.reclaim();
}catch(error){ }catch(error){
let errCode = ErrorCode.WRITE_TO_ASHMEM_ERROR; let errCode = `${rpc.ErrorCode.WRITE_TO_ASHMEM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: error " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: error " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: error " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: error " + error.message);
...@@ -8114,7 +8461,7 @@ export default function actsRpcClientJsTest() { ...@@ -8114,7 +8461,7 @@ export default function actsRpcClientJsTest() {
let readResult = ashmem.readAshmem(5, 0); let readResult = ashmem.readAshmem(5, 0);
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: readAshmem is : " + readResult); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: readAshmem is : " + readResult);
}catch(error){ }catch(error){
let errCode = ErrorCode.READ_FROM_ASHMEM_ERROR; let errCode = `${rpc.ErrorCode.READ_FROM_ASHMEM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: error " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: error " + error.code);
expect(error.code != errCode).assertEqual(null); expect(error.code != errCode).assertEqual(null);
} }
...@@ -8138,7 +8485,7 @@ export default function actsRpcClientJsTest() { ...@@ -8138,7 +8485,7 @@ export default function actsRpcClientJsTest() {
expect(size).assertEqual(mapSize); expect(size).assertEqual(mapSize);
ashmem.closeAshmem(); ashmem.closeAshmem();
}catch(error){ }catch(error){
let errCode = ErrorCode.CHECK_PARAM_ERROR; let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: errorcode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: errorcode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: errormessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: errormessage " + error.message);
...@@ -8163,7 +8510,7 @@ export default function actsRpcClientJsTest() { ...@@ -8163,7 +8510,7 @@ export default function actsRpcClientJsTest() {
expect(result).assertEqual(false); expect(result).assertEqual(false);
ashmem.closeAshmem() ashmem.closeAshmem()
}catch(error){ }catch(error){
let errCode = ErrorCode.CHECK_PARAM_ERROR; let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: errorcode " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: errorcode " + error.code);
expect(error.code == errCode).assertTrue(); expect(error.code == errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: errormessage " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: errormessage " + error.message);
...@@ -8187,7 +8534,7 @@ export default function actsRpcClientJsTest() { ...@@ -8187,7 +8534,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: run mapTypedAshmem is success"); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: run mapTypedAshmem is success");
ashmem.closeAshmem() ashmem.closeAshmem()
}catch(error){ }catch(error){
let errCode = ErrorCode.OS_MMAP_ERROR; let errCode = `${rpc.ErrorCode.OS_MMAP_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: error " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: error " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: error " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: error " + error.message);
...@@ -8211,7 +8558,7 @@ export default function actsRpcClientJsTest() { ...@@ -8211,7 +8558,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: run mapTypedAshmem is success"); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: run mapTypedAshmem is success");
ashmem.closeAshmem() ashmem.closeAshmem()
}catch(error){ }catch(error){
let errCode = ErrorCode.CHECK_PARAM_ERROR; let errCode = `${rpc.ErrorCode.CHECK_PARAM_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: error " + error.code); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: error " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: error " + error.message); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: error " + error.message);
...@@ -8583,10 +8930,10 @@ export default function actsRpcClientJsTest() { ...@@ -8583,10 +8930,10 @@ export default function actsRpcClientJsTest() {
data.writeBoolean(true) data.writeBoolean(true)
data.writeChar(96) data.writeChar(96)
data.writeString("HelloWorld") data.writeString("HelloWorld")
data.writeSequenceable(new MySequenceable(1, "aaa")) data.writeParcelable(new MySequenceable(1, "aaa"))
await gIRemoteObject.sendMessageRequest(CODE_ALL_TYPE, data, reply, option, (err, result) => { await gIRemoteObject.sendMessageRequest(CODE_ALL_TYPE, data, reply, option, (err, result) => {
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00900:sendRequest done, error code: " + result.errCode) console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_00900 errorcode: " + result.errCode)
expect(result.errCode).assertEqual(0) expect(result.errCode).assertEqual(0)
expect(result.reply.readByte()).assertEqual(1) expect(result.reply.readByte()).assertEqual(1)
expect(result.reply.readShort()).assertEqual(2) expect(result.reply.readShort()).assertEqual(2)
...@@ -8598,7 +8945,7 @@ export default function actsRpcClientJsTest() { ...@@ -8598,7 +8945,7 @@ export default function actsRpcClientJsTest() {
expect(result.reply.readChar()).assertEqual(96) expect(result.reply.readChar()).assertEqual(96)
expect(result.reply.readString()).assertEqual("HelloWorld") expect(result.reply.readString()).assertEqual("HelloWorld")
let s = new MySequenceable(0, '') let s = new MySequenceable(0, '')
expect(result.reply.readSequenceable(s)).assertTrue() expect(result.reply.readParcelable(s)).assertTrue()
expect(s.num).assertEqual(1) expect(s.num).assertEqual(1)
expect(s.str).assertEqual("aaa") expect(s.str).assertEqual("aaa")
}); });
...@@ -8724,7 +9071,7 @@ export default function actsRpcClientJsTest() { ...@@ -8724,7 +9071,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300:run registerDeathRecipient is done"); console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300:run registerDeathRecipient is done");
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01300---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01300---------------------------");
}); });
...@@ -8745,7 +9092,7 @@ export default function actsRpcClientJsTest() { ...@@ -8745,7 +9092,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:run unregisterDeathRecipient is done"); console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:run unregisterDeathRecipient is done");
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01400---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_IRemoteObject_01400---------------------------");
}); });
...@@ -8761,14 +9108,14 @@ export default function actsRpcClientJsTest() { ...@@ -8761,14 +9108,14 @@ export default function actsRpcClientJsTest() {
try{ try{
let recipient = new MyDeathRecipient(gIRemoteObject, null) let recipient = new MyDeathRecipient(gIRemoteObject, null)
var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0) var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0)
expect(resultAdd1 == true).assertTrue(); expect(resultAdd1 == false).assertTrue();
var resultAdd2 = gIRemoteObject.addDeathRecipient(recipient, 0) var resultAdd2 = gIRemoteObject.addDeathRecipient(recipient, 0)
expect(resultAdd2 == true).assertTrue(); expect(resultAdd2 == false).assertTrue();
var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0) var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0)
expect(resultRemove1 == true).assertTrue(); expect(resultRemove1 == false).assertTrue();
var resultRemove2 = gIRemoteObject.removeDeathRecipient(recipient, 0) var resultRemove2 = gIRemoteObject.removeDeathRecipient(recipient, 0)
expect(resultRemove2 == true).assertTrue(); expect(resultRemove2 == false).assertTrue();
var resultRemove3 = gIRemoteObject.removeDeathRecipient(recipient, 0) var resultRemove3 = gIRemoteObject.removeDeathRecipient(recipient, 0)
expect(resultRemove3 == false).assertTrue(); expect(resultRemove3 == false).assertTrue();
...@@ -8789,9 +9136,9 @@ export default function actsRpcClientJsTest() { ...@@ -8789,9 +9136,9 @@ export default function actsRpcClientJsTest() {
try{ try{
let recipient = new MyDeathRecipient(gIRemoteObject, null); let recipient = new MyDeathRecipient(gIRemoteObject, null);
var resultAdd = gIRemoteObject.addDeathRecipient(recipient, -(2*G)); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, -(2*G));
expect(resultAdd).assertTrue(); expect(resultAdd == false).assertTrue();
var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, -(2*G)); var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, -(2*G));
expect(resultRemove).assertTrue(); expect(resultRemove == false).assertTrue();
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00200:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00200:error = " + error);
} }
...@@ -8809,9 +9156,9 @@ export default function actsRpcClientJsTest() { ...@@ -8809,9 +9156,9 @@ export default function actsRpcClientJsTest() {
try{ try{
let recipient = new MyDeathRecipient(gIRemoteObject, null); let recipient = new MyDeathRecipient(gIRemoteObject, null);
var resultAdd = gIRemoteObject.addDeathRecipient(recipient, (2*G - 1)); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, (2*G - 1));
expect(resultAdd).assertTrue(); expect(resultAdd == false).assertTrue();
var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, (2*G - 1)); var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, (2*G - 1));
expect(resultRemove).assertTrue(); expect(resultRemove == false).assertTrue();
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00300:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00300:error = " + error);
} }
...@@ -8830,10 +9177,10 @@ export default function actsRpcClientJsTest() { ...@@ -8830,10 +9177,10 @@ export default function actsRpcClientJsTest() {
let recipient = new MyDeathRecipient(gIRemoteObject, null); let recipient = new MyDeathRecipient(gIRemoteObject, null);
var resultAdd = gIRemoteObject.addDeathRecipient(recipient, 2*G); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, 2*G);
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:run addDeathRecipient first is " + resultAdd); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:run addDeathRecipient first is " + resultAdd);
expect(resultAdd).assertTrue(); expect(resultAdd == false).assertTrue();
var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, 2*G); var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, 2*G);
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:run removeDeathRecipient1 is " + resultRemove); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:run removeDeathRecipient1 is " + resultRemove);
expect(resultRemove).assertTrue(); expect(resultRemove == false).assertTrue();
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:error = " + error);
} }
...@@ -8852,10 +9199,10 @@ export default function actsRpcClientJsTest() { ...@@ -8852,10 +9199,10 @@ export default function actsRpcClientJsTest() {
let recipient = new MyDeathRecipient(gIRemoteObject, null); let recipient = new MyDeathRecipient(gIRemoteObject, null);
var resultAdd = gIRemoteObject.addDeathRecipient(recipient, -(2*G + 1)); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, -(2*G + 1));
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:run addDeathRecipient first is " + resultAdd); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:run addDeathRecipient first is " + resultAdd);
expect(resultAdd).assertTrue(); expect(resultAdd == false).assertTrue();
var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, -(2*G + 1)); var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, -(2*G + 1));
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:run removeDeathRecipient1 is " + resultRemove); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:run removeDeathRecipient1 is " + resultRemove);
expect(resultRemove).assertTrue(); expect(resultRemove == false).assertTrue();
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:error = " + error);
} }
...@@ -8878,7 +9225,7 @@ export default function actsRpcClientJsTest() { ...@@ -8878,7 +9225,7 @@ export default function actsRpcClientJsTest() {
var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0) var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0)
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run addDeathRecipient first result is " + resultAdd1); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run addDeathRecipient first result is " + resultAdd1);
expect(resultAdd1 == true).assertTrue(); expect(resultAdd1 == false).assertTrue();
var isDead1 = gIRemoteObject.isObjectDead(); var isDead1 = gIRemoteObject.isObjectDead();
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600: run isObjectDead result is " + isDead1); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600: run isObjectDead result is " + isDead1);
...@@ -8886,15 +9233,15 @@ export default function actsRpcClientJsTest() { ...@@ -8886,15 +9233,15 @@ export default function actsRpcClientJsTest() {
var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0) var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0)
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run removeDeathRecipient result is " + resultRemove1); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run removeDeathRecipient result is " + resultRemove1);
expect(resultRemove1 == true).assertTrue(); expect(resultRemove1 == false).assertTrue();
var resultAdd2 = gIRemoteObject.addDeathRecipient(recipient, 0) var resultAdd2 = gIRemoteObject.addDeathRecipient(recipient, 0)
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run addDeathRecipient second result is " + resultAdd2); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run addDeathRecipient second result is " + resultAdd2);
expect(resultAdd2 == true).assertTrue(); expect(resultAdd2 == false).assertTrue();
var resultRemove2 = gIRemoteObject.removeDeathRecipient(recipient, 0) var resultRemove2 = gIRemoteObject.removeDeathRecipient(recipient, 0)
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run removeDeathRecipient1 result is " + resultRemove2); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run removeDeathRecipient1 result is " + resultRemove2);
expect(resultRemove2 == true).assertTrue(); expect(resultRemove2 == false).assertTrue();
var resultRemove3 = gIRemoteObject.removeDeathRecipient(recipient, 0) var resultRemove3 = gIRemoteObject.removeDeathRecipient(recipient, 0)
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run removeDeathRecipient3 result is " + resultRemove3); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run removeDeathRecipient3 result is " + resultRemove3);
...@@ -9015,7 +9362,7 @@ export default function actsRpcClientJsTest() { ...@@ -9015,7 +9362,7 @@ export default function actsRpcClientJsTest() {
expect(isDead2 == false).assertTrue(); expect(isDead2 == false).assertTrue();
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01000:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01000---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01000---------------------------");
}); });
...@@ -9090,7 +9437,7 @@ export default function actsRpcClientJsTest() { ...@@ -9090,7 +9437,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: unregisterDeathRecipient is success"); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: unregisterDeathRecipient is success");
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01300---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01300---------------------------");
}); });
...@@ -9111,7 +9458,7 @@ export default function actsRpcClientJsTest() { ...@@ -9111,7 +9458,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400: unregisterDeathRecipient is success"); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400: unregisterDeathRecipient is success");
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01400---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01400---------------------------");
}); });
...@@ -9132,7 +9479,7 @@ export default function actsRpcClientJsTest() { ...@@ -9132,7 +9479,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500: unregisterDeathRecipient is success"); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500: unregisterDeathRecipient is success");
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01500---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01500---------------------------");
}); });
...@@ -9153,7 +9500,7 @@ export default function actsRpcClientJsTest() { ...@@ -9153,7 +9500,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600: unregisterDeathRecipient is success"); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600: unregisterDeathRecipient is success");
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01600---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01600---------------------------");
}); });
...@@ -9174,7 +9521,7 @@ export default function actsRpcClientJsTest() { ...@@ -9174,7 +9521,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700: unregisterDeathRecipient is success"); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700: unregisterDeathRecipient is success");
} catch (error) { } catch (error) {
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700:error = " + error); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700:error = " + error);
expect(error == null).assertTrue(); expect(error != null).assertTrue();
} }
console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01700---------------------------"); console.info("---------------------end SUB_Softbus_IPC_Compatibility_RemoteProxy_01700---------------------------");
}); });
...@@ -9197,7 +9544,7 @@ export default function actsRpcClientJsTest() { ...@@ -9197,7 +9544,7 @@ export default function actsRpcClientJsTest() {
let res2 = object.getLocalInterface(null); let res2 = object.getLocalInterface(null);
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800: run getLocalInterface success, res2 is " + res2); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800: run getLocalInterface success, res2 is " + res2);
} catch (error) { } catch (error) {
let errCode = ErrorCode.ONLY_PROXY_OBJECT_PERMITTED_ERROR; let errCode = `${rpc.ErrorCode.ONLY_PROXY_OBJECT_PERMITTED_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800:error = " + error.code); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800:error = " + error.code);
expect(error.code != errCode).assertTrue(); expect(error.code != errCode).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800:error = " + error.message); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800:error = " + error.message);
...@@ -9516,6 +9863,7 @@ export default function actsRpcClientJsTest() { ...@@ -9516,6 +9863,7 @@ export default function actsRpcClientJsTest() {
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID(); let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID();
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling(); let isLocalCalling = rpc.IPCSkeleton.isLocalCalling();
let id = rpc.IPCSkeleton.resetCallingIdentity(); let id = rpc.IPCSkeleton.resetCallingIdentity();
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200:" + id)
let ret = rpc.IPCSkeleton.setCallingIdentity(id); let ret = rpc.IPCSkeleton.setCallingIdentity(id);
expect(object.getInterfaceDescriptor()).assertEqual(""); expect(object.getInterfaceDescriptor()).assertEqual("");
expect(callingDeviceID).assertEqual(""); expect(callingDeviceID).assertEqual("");
...@@ -9523,7 +9871,7 @@ export default function actsRpcClientJsTest() { ...@@ -9523,7 +9871,7 @@ export default function actsRpcClientJsTest() {
expect(isLocalCalling).assertTrue(); expect(isLocalCalling).assertTrue();
expect(id).assertEqual(""); expect(id).assertEqual("");
expect(ret).assertTrue(); expect(ret).assertTrue();
expect(rpc.IPCSkeleton.flushCommands(gIRemoteObject)).assertEqual(0); expect(rpc.IPCSkeleton.flushCommands(gIRemoteObject)).assertEqual(101);
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200: callingPid: " + callingPid console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200: callingPid: " + callingPid
+ ", callingUid: " + callingUid + ", callingUid: " + callingUid
+ ", callingDeviceID: " + callingDeviceID + ", localDeviceID: " + localDeviceID + ", callingDeviceID: " + callingDeviceID + ", localDeviceID: " + localDeviceID
...@@ -9649,7 +9997,7 @@ export default function actsRpcClientJsTest() { ...@@ -9649,7 +9997,7 @@ export default function actsRpcClientJsTest() {
object.getDescriptor(); object.getDescriptor();
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600: is success"); console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600: is success");
} catch (error) { } catch (error) {
let errCode = ErrorCode.COMMUNICATION_ERROR; let errCode = `${rpc.ErrorCode.COMMUNICATION_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 error is :" + error.message) console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 error is :" + error.message)
expect(error.message != null).assertTrue(); expect(error.message != null).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 error is :" + error.code) console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 error is :" + error.code)
...@@ -9672,7 +10020,7 @@ export default function actsRpcClientJsTest() { ...@@ -9672,7 +10020,7 @@ export default function actsRpcClientJsTest() {
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 RpcServer: flushCmdBuffer is success"); console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 RpcServer: flushCmdBuffer is success");
} }
catch (error) { catch (error) {
let errCode = ErrorCode.ONLY_REMOTE_OBJECT_PERMITTED_ERROR; let errCode = `${rpc.ErrorCode.ONLY_REMOTE_OBJECT_PERMITTED_ERROR}`;
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 error is :" + error.message) console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 error is :" + error.message)
expect(error.message != null).assertTrue(); expect(error.message != null).assertTrue();
console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 error is :" + error.code) console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 error is :" + error.code)
......
{
"description": "Configuration for rpc Servers",
"driver": {
"type": "JSUnitServer",
"test-timeout": "900000",
"package": "ohos.rpc.test.server",
"abilityName": ".MainAbility",
"shell-timeout": "900000"
},
"kits": [
{
"test-file-name": [
"ActsRpcHapServer.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.rpc.test.server",
"vendor": "rpc",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"target": 8
}
},
"deviceConfig": {},
"module": {
"reqPermissions": [
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
},
{
"name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"package": "ohos.rpc.test.server",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"deviceType": [
"tablet",
"default",
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "js",
"icon": "$media:icon",
"description": "$string:mainability_description",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"srcPath": "ServiceAbility",
"name": ".ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "js",
"description": "$string:serviceability_description",
"type": "service",
"visible": true,
"formsEnabled": false
}
],
"js": [
{
"pages": [
"pages/index/index",
"pages/second/second"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
.btn {
width: 50%;
height: 100px;
font-size: 40px;
}
/*
* 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 rpc from "@ohos.rpc"
import fileio from '@ohos.fileio';
import process from '@ohos.process'
export default {
onStart() {
console.info('RpcServer: onStart')
},
onStop() {
console.info('RpcServer: onStop')
},
onCommand(want, startId) {
console.info('RpcServer: onCommand, want: ' + JSON.stringify(want) +', startId: ' + startId)
},
onConnect(want) {
console.info('RpcServer: service onConnect called.')
return new Stub("rpcTestAbility")
},
onDisconnect(want) {
console.info('RpcServer: service onDisConnect called.')
},
onReconnect(want) {
console.info('RpcServer: service onReConnect called.')
}
}
class MySequenceable {
num = null
str = null
constructor(num, string) {
this.num = num;
this.str = string;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
return true;
}
}
class Stub extends rpc.RemoteObject {
constructor(descriptor) {
super(descriptor);
}
onRemoteRequest(code, data, reply, option) {
try{
console.info("onRemoteRequest: " + code)
if (code === 32){
console.info("case 32 start")
let tmp1 = data.readString()
let result = reply.writeString("onRemoteRequest invoking")
return true
} else if (code === 33){
console.info("case 33 start")
let tmp1 = data.readString()
let result = reply.writeString(tmp1)
return true
}else {
console.error("default case " + code)
return super.onRemoteRequest(code, data, reply, option)
}
} catch (error) {
console.info("onRemoteRequest: " + error);
}
return false
}
onRemoteMessageRequest(code, data, reply, option) {
try{
console.info("onRemoteMessageRequest: " + code)
switch(code) {
case 1:
{
console.info("case 1 start")
let tmp1 = data.readByteArray()
let result = reply.writeByteArray(tmp1)
return true
}
case 2:
{
console.info("case 2 start")
let tmp1 = data.readIntArray()
let result = reply.writeIntArray(tmp1)
return true
}
case 3:
{
console.info("case 3 start")
let tmp1 = data.readFloatArray()
let result = reply.writeFloatArray(tmp1)
return true
}
case 4:
{
console.info("case 4 start")
let tmp1 = data.readShort()
let result = reply.writeShort(tmp1)
return true
}
case 5:
{
console.info("case 5 start")
let tmp1 = data.readLong()
let result = reply.writeLong(tmp1)
return true
}
case 6:
{
console.info("case 6 start")
let tmp1 = data.readDouble()
let result = reply.writeDouble(tmp1)
return true
}
case 7:
{
console.info("case 7 start")
let tmp1 = data.readBoolean()
let result = reply.writeBoolean(tmp1)
return true
}
case 8:
{
console.info("case 8 start")
let tmp1 = data.readChar()
let result = reply.writeChar(tmp1)
return true
}
case 9:
{
console.info("case 9 start")
let tmp1 = data.readString()
let result = reply.writeString(tmp1)
return true
}
case 10:
{
console.info("case 10 start")
let tmp1 = data.readByte()
let result = reply.writeByte(tmp1)
return true
}
case 11:
{
console.info("case 11 start")
let tmp1 = data.readInt()
let result = reply.writeInt(tmp1)
return true
}
case 12:
{
console.info("case 12 start")
let tmp1 = data.readFloat()
let result = reply.writeFloat(tmp1)
return true
}
case 13:
{
console.info("case 13 start")
var size = data .readInt();
let tmp1 = data.readRawData(size);
let size1 = reply.writeInt(size);
let result = reply.writeRawData(tmp1, tmp.length)
return true
}
case 14:
{
console.info("case 14 start")
let listener = data.readRemoteObject();
let num = data.readInt()
let str = data.readString()
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
data2.writeInt(num)
data2.writeString(str)
listener.sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("14 send request done, error code: " + result.errCode )
})
.catch(function(e) {
console.error("14 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 14 test done")
})
reply.writeNoException()
return true
}
case 15:
{
console.info("case 15 start")
let s = new MySequenceable(null, null)
var tmp1 = data.readParcelable(s)
let result = reply.writeParcelable(s)
return true
}
case 16:
{
console.info("case 16 start")
data.readException()
var tmp = data.readInt();
reply.writeNoException()
var result = reply.writeInt(tmp);
return true
}
case 17:
{
console.info("case 17 start")
var s = [new MySequenceable(null, null), new MySequenceable(null, null),
new MySequenceable(null, null)];
data.readParcelableArray(s);
let result = reply.writeParcelableArray(s);
return true
}
case 18:
{
console.info("case 18 start")
let listeners = data.readRemoteObjectArray();
for (let i = 0; i < listeners.length; i++) {
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
listeners[i].sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("18 send request done, error code: " + result.errCode + ", index: " + i)
})
.catch(function(e) {
console.error("18 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 18 test done")
})
}
console.info("18 The server's writeRemoteObjectArray result is " + result);
return true
}
case 19:
{
console.info("case 19 start")
let tmp1 = data.readDoubleArray()
let result = reply.writeDoubleArray(tmp1)
return true
}
case 20:
{
console.info("case 20 start")
let tmp1 = data.readByte()
let tmp2 = data.readShort()
let tmp3 = data.readInt()
let tmp4 = data.readLong()
let tmp5 = data.readFloat()
let tmp6 = data.readDouble()
let tmp7 = data.readBoolean()
let tmp8 = data.readChar()
let tmp9 = data.readString()
let s = new MySequenceable(null, null)
let tmp10 = data.readParcelable(s)
let result1 = reply.writeByte(tmp1)
let result2 = reply.writeShort(tmp2)
let result3 = reply.writeInt(tmp3)
let result4 = reply.writeLong(tmp4)
let result5 = reply.writeFloat(tmp5)
let result6 = reply.writeDouble(tmp6)
let result7 = reply.writeBoolean(tmp7)
let result8 = reply.writeChar(tmp8)
let result9 = reply.writeString(tmp9)
let result10 = reply.writeParcelable(s)
return true
}
case 21:
{
console.info("case 21 start")
let tmp1 = data.readByteArray()
let tmp2 = data.readShortArray()
let tmp3 = data.readIntArray()
let tmp4 = data.readLongArray()
let tmp5 = data.readFloatArray()
let tmp6 = data.readDoubleArray()
let tmp7 = data.readBooleanArray()
let tmp8 = data.readCharArray()
let tmp9 = data.readStringArray()
let s = [new MySequenceable(null, null), new MySequenceable(null, null),
new MySequenceable(null, null)]
let tmp10 = data.readParcelableArray(s)
let result1 = reply.writeByteArray(tmp1)
let result2 = reply.writeShortArray(tmp2)
let result3 = reply.writeIntArray(tmp3)
let result4 = reply.writeLongArray(tmp4)
let result5 = reply.writeFloatArray(tmp5)
let result6 = reply.writeDoubleArray(tmp6)
let result7 = reply.writeBooleanArray(tmp7)
let result8 = reply.writeCharArray(tmp8)
let result9 = reply.writeStringArray(tmp9)
let result10 = reply.writeParcelableArray(s)
return true
}
case 22:
{
console.info("case 22 start")
let callingPid = rpc.IPCSkeleton.getCallingPid()
let callingUid = rpc.IPCSkeleton.getCallingUid()
reply.writeNoException()
reply.writeInt(callingPid)
reply.writeInt(callingUid)
reply.writeInt(this.getCallingPid())
reply.writeInt(this.getCallingUid())
let id = rpc.IPCSkeleton.resetCallingIdentity()
rpc.IPCSkeleton.setCallingIdentity(id)
reply.writeInt(rpc.IPCSkeleton.getCallingPid())
reply.writeInt(rpc.IPCSkeleton.getCallingUid())
reply.writeInt(rpc.IPCSkeleton.flushCommands(this))
return true
}
case 23:
{
console.info("case 23 start")
let s = new MySequenceable(null, null);
var tmp1 = data.readParcelable(s);
var result = reply.writeParcelable(s);
return true
}
case 24:
{
console.info("case 24 start")
var tmp1 = data.readShort();
var tmp2 = data.readShort();
var tmp3 = data.readShort();
var tmp4 = data.readShort();
var tmp5 = data.readShort();
var result1 = reply.writeShort(tmp1);
var result2 = reply.writeShort(tmp2);
var result3 = reply.writeShort(tmp3);
var result4 = reply.writeShort(tmp4);
var result5 = reply.writeShort(tmp5);
return true
}
case 25:
{
console.info("case 25 start")
var tmp1 = data.readByte();
var tmp2 = data.readByte();
var tmp3 = data.readByte();
var tmp4 = data.readByte();
var tmp5 = data.readByte();
var result1 = reply.writeByte(tmp1);
var result2 = reply.writeByte(tmp2);
var result3 = reply.writeByte(tmp3);
var result4 = reply.writeByte(tmp4);
var result5 = reply.writeByte(tmp5);
return true
}
case 26:
{
console.info("case 26 start")
var tmp1 = data.readInt();
var tmp2 = data.readInt();
var tmp3 = data.readInt();
var tmp4 = data.readInt();
var tmp5 = data.readInt();
var result1 = reply.writeInt(tmp1);
var result2 = reply.writeInt(tmp2);
var result3 = reply.writeInt(tmp3);
var result4 = reply.writeInt(tmp4);
var result5 = reply.writeInt(tmp5);
return true
}
case 28:
{
console.info("case 28 start")
let callingPid = rpc.IPCSkeleton.getCallingPid()
let callingUid = rpc.IPCSkeleton.getCallingUid()
let callingDeviceID = rpc.IPCSkeleton.getCallingDeviceID()
let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID()
let isLocalCalling = rpc.IPCSkeleton.isLocalCalling()
reply.writeNoException()
reply.writeInt(callingPid)
reply.writeInt(callingUid)
reply.writeString(callingDeviceID)
reply.writeString(localDeviceID)
reply.writeBoolean(isLocalCalling)
reply.writeInt(this.getCallingPid())
reply.writeInt(this.getCallingUid())
let id = rpc.IPCSkeleton.resetCallingIdentity()
rpc.IPCSkeleton.setCallingIdentity(id)
reply.writeInt(rpc.IPCSkeleton.getCallingPid())
reply.writeInt(rpc.IPCSkeleton.getCallingUid())
reply.writeInt(rpc.IPCSkeleton.flushCommands(this))
return true
}
case 29:
{
console.info("case 29 starts")
let bytesWr = data.readInt()
let fd = data.readFileDescriptor()
let writeFileResult = fileio.writeSync(fd, "HELLO RPC", {position: bytesWr + 1});
rpc.MessageParcel.closeFileDescriptor(fd)
return true
}
case 30:
{
console.info("case 30 start")
let listeners = data.readRemoteObjectArray();
let num = data.readInt()
let str = data.readString()
for (let i = 0; i < listeners.length; i++) {
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
data2.writeInt(num)
data2.writeString(str)
listeners[i].sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("30 send request done, error code: " + result.errCode + ", index: " + i)
})
.catch(function(e) {
console.error("30 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 30 test done")
})
}
reply.writeNoException()
return true
}
case 31:
{
console.info("case 31 start")
let listeners = new Array(3)
data.readRemoteObjectArray(listeners)
let num = data.readInt()
let str = data.readString()
for (let i = 0; i < listeners.length; i++) {
let option2 = new rpc.MessageOption()
let data2 = rpc.MessageParcel.create()
let reply2 = rpc.MessageParcel.create()
data2.writeInt(num)
data2.writeString(str)
listeners[i].sendRequest(1, data2, reply2, option2)
.then(function(result) {
console.info("31 send request done, error code: " + result.errCode + ", index: " + i)
})
.catch(function(e) {
console.error("31 send request got exception: " + e)
})
.finally(() => {
data2.reclaim()
reply2.reclaim()
console.info("case 31 test done")
})
}
reply.writeNoException()
return true
}
case 32:
{
console.info("case 32 start")
let tmp1 = data.readString()
let result = reply.writeString("onRemoteMessageRequest invoking")
return true
}
default:
this.onRemoteRequest(code, data, reply, option)
}
} catch (error) {
console.info("onRemoteMessageRequest: " + error);
}
return false
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "RpcServer"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
},
{
"name": "serviceability_description",
"value": "hap sample empty service"
}
]
}
\ No newline at end of file
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; import colorSpaceManager from '@ohos.graphics.colorSpaceManager';
export default function colorSpaceManagerTest(context, windowStage, abilityStorage) { export default function colorSpaceManagerTest(context, windowStage, abilityStorage) {
...@@ -93,7 +91,7 @@ export default function colorSpaceManagerTest(context, windowStage, abilityStora ...@@ -93,7 +91,7 @@ export default function colorSpaceManagerTest(context, windowStage, abilityStora
done(); done();
} catch (err) { } catch (err) {
console.log('test enum value of ColorSpace Manager not support error ' + JSON.stringify(err)); console.log('test enum value of ColorSpace Manager not support error ' + JSON.stringify(err));
expect(err.code == 18600001).assertTrue(); expect(err.code).assertEqual(18600001);
done(); done();
} }
}) })
......
...@@ -973,6 +973,9 @@ describe('webgl1Test_webgl14', function() { ...@@ -973,6 +973,9 @@ describe('webgl1Test_webgl14', function() {
var x13 = gl2.ANY_SAMPLES_PASSED_CONSERVATIVE; var x13 = gl2.ANY_SAMPLES_PASSED_CONSERVATIVE;
expect(x13).assertEqual(36202); expect(x13).assertEqual(36202);
var x14 = gl2.RGB10_A2;
expect(x14).assertEqual(32857);
var y1 = gl.LUMINANCE_ALPHA; var y1 = gl.LUMINANCE_ALPHA;
expect(y1).assertEqual(6410); expect(y1).assertEqual(6410);
...@@ -994,6 +997,9 @@ describe('webgl1Test_webgl14', function() { ...@@ -994,6 +997,9 @@ describe('webgl1Test_webgl14', function() {
var y7 = gl.CONTEXT_LOST_WEBGL; var y7 = gl.CONTEXT_LOST_WEBGL;
expect(y7).assertEqual(37442); expect(y7).assertEqual(37442);
var y8 = gl.ACTIVE_ATTRIBUTES;
expect(y8).assertEqual(35721);
done(); done();
}); });
}) })
...@@ -2955,6 +2955,15 @@ describe('window_test', function () { ...@@ -2955,6 +2955,15 @@ describe('window_test', function () {
expect(0).assertEqual(window.Orientation.UNSPECIFIED); expect(0).assertEqual(window.Orientation.UNSPECIFIED);
expect(1).assertEqual(window.Orientation.PORTRAIT); expect(1).assertEqual(window.Orientation.PORTRAIT);
expect(2).assertEqual(window.Orientation.LANDSCAPE); expect(2).assertEqual(window.Orientation.LANDSCAPE);
expect(3).assertEqual(window.Orientation.PORTRAIT_INVERTED);
expect(4).assertEqual(window.Orientation.LANDSCAPE_INVERTED);
expect(5).assertEqual(window.Orientation.AUTO_ROTATION);
expect(6).assertEqual(window.Orientation.AUTO_ROTATION_PORTRAIT);
expect(7).assertEqual(window.Orientation.AUTO_ROTATION_LANDSCAPE);
expect(8).assertEqual(window.Orientation.AUTO_ROTATION_RESTRICTED);
expect(9).assertEqual(window.Orientation.AUTO_ROTATION_PORTRAIT_RESTRICTED);
expect(10).assertEqual(window.Orientation.AUTO_ROTATION_LANDSCAPE_RESTRICTED);
expect(11).assertEqual(window.Orientation.LOCKED);
done(); done();
} catch (err) { } catch (err) {
console.info('test enum value of windowStageEventType error ' + JSON.stringify(err)); console.info('test enum value of windowStageEventType error ' + JSON.stringify(err));
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"bundle-name": "com.acts.imeability.test", "bundle-name": "com.acts.imeability.test",
"module-name": "phone", "module-name": "phone",
"shell-timeout": "600000", "shell-timeout": "600000",
"testcase-timeout": 70000 "testcase-timeout": 10000
}, },
"kits": [{ "kits": [{
"test-file-name": [ "test-file-name": [
......
...@@ -29,7 +29,7 @@ export default function imeAbilityTest(abilityContext) { ...@@ -29,7 +29,7 @@ export default function imeAbilityTest(abilityContext) {
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/ */
beforeEach(function () { beforeEach(function () {
console.info('beforeEach: switchInputMethod to kikakeyboard.'); console.info('====>beforeEach: switchInputMethod to kikakeyboard.');
let serviceAbilityProperty = { let serviceAbilityProperty = {
packageName: "com.example.kikakeyboard", packageName: "com.example.kikakeyboard",
methodId: "ServiceExtAbility", methodId: "ServiceExtAbility",
...@@ -39,7 +39,7 @@ export default function imeAbilityTest(abilityContext) { ...@@ -39,7 +39,7 @@ export default function imeAbilityTest(abilityContext) {
} }
inputMethod.switchInputMethod(serviceAbilityProperty).then((data)=>{ inputMethod.switchInputMethod(serviceAbilityProperty).then((data)=>{
console.info('SUB_InputMethod_IMEAbility_0001 switchInputMethod to Kika :' + data); console.info('====>SUB_InputMethod_IMEAbility_0001 switchInputMethod to Kika :' + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}) })
...@@ -49,7 +49,7 @@ export default function imeAbilityTest(abilityContext) { ...@@ -49,7 +49,7 @@ export default function imeAbilityTest(abilityContext) {
* afterEach: Test case-level clearance conditions, which are executed after each test case is executed. * afterEach: Test case-level clearance conditions, which are executed after each test case is executed.
*/ */
afterEach(function () { afterEach(function () {
console.info('afterEach: Test case-level clearance conditions is executed.'); console.info('====>afterEach: Test case-level clearance conditions is executed.');
}); });
/** /**
...@@ -60,7 +60,7 @@ export default function imeAbilityTest(abilityContext) { ...@@ -60,7 +60,7 @@ export default function imeAbilityTest(abilityContext) {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('SUB_InputMethod_IMEAbility_0001', 0, async function (done) { it('SUB_InputMethod_IMEAbility_0001', 0, async function (done) {
console.info('----------SUB_InputMethod_IMEAbility_0001 start-------------'); console.info('====>----------SUB_InputMethod_IMEAbility_0001 start-------------');
let imExtAbilityProperty = { let imExtAbilityProperty = {
packageName : "com.acts.imeability.test", packageName : "com.acts.imeability.test",
methodId : "com.acts.imeability.test.ImExtAbility", methodId : "com.acts.imeability.test.ImExtAbility",
...@@ -70,11 +70,11 @@ export default function imeAbilityTest(abilityContext) { ...@@ -70,11 +70,11 @@ export default function imeAbilityTest(abilityContext) {
} }
inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{ inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{
console.info('SUB_InputMethod_IMEAbility_0004 switchInputMethod to IME :' + data); console.info('====>SUB_InputMethod_IMEAbility_0004 switchInputMethod to IME :' + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(Date.now(), 3000); sleep(Date.now(), 3000);
console.info('----------SUB_InputMethod_IMEAbility_0001 end-------------'); console.info('====>----------SUB_InputMethod_IMEAbility_0001 end-------------');
done(); done();
}) })
...@@ -87,7 +87,7 @@ export default function imeAbilityTest(abilityContext) { ...@@ -87,7 +87,7 @@ export default function imeAbilityTest(abilityContext) {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('SUB_InputMethod_IMEAbility_0002', 0, async function (done) { it('SUB_InputMethod_IMEAbility_0002', 0, async function (done) {
console.info('-----------SUB_InputMethod_IMEAbility_0002 start-------------'); console.info('====>-----------SUB_InputMethod_IMEAbility_0002 start-------------');
let imExtAbilityProperty = { let imExtAbilityProperty = {
packageName : "com.acts.imeability.test", packageName : "com.acts.imeability.test",
...@@ -98,11 +98,11 @@ export default function imeAbilityTest(abilityContext) { ...@@ -98,11 +98,11 @@ export default function imeAbilityTest(abilityContext) {
} }
inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{ inputMethod.switchInputMethod(imExtAbilityProperty).then((data)=>{
console.info('SUB_InputMethod_IMEAbility_0004 switchInputMethod to IME :' + data); console.info('====>SUB_InputMethod_IMEAbility_0004 switchInputMethod to IME :' + data);
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
sleep(Date.now(), 2500); sleep(Date.now(), 2500);
console.info('-----------SUB_InputMethod_IMEAbility_0002 end-------------'); console.info('====>-----------SUB_InputMethod_IMEAbility_0002 end-------------');
done(); done();
}) })
}) })
......
...@@ -18,7 +18,7 @@ import subtype from '@ohos.inputMethodSubtype'; ...@@ -18,7 +18,7 @@ import subtype from '@ohos.inputMethodSubtype';
export default function inputMethodStageJSUnit() { export default function inputMethodStageJSUnit() {
describe('inputMethodTest', function () { describe('inputMethodTest', function () {
console.info("************* settings Test start*************"); console.info("====>************* settings Test start*************");
/* /*
* @tc.number inputMethod_test_getController_001 * @tc.number inputMethod_test_getController_001
* @tc.name get inputMethod controller * @tc.name get inputMethod controller
...@@ -26,23 +26,23 @@ export default function inputMethodStageJSUnit() { ...@@ -26,23 +26,23 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_getController_001', 0, async function (done) { it('inputMethod_test_getController_001', 0, async function (done) {
console.info("-----------------inputMethod_test_getController_001 start---------------------"); console.info("====>-----------------inputMethod_test_getController_001 start---------------------");
try{ try{
let inputMethodControl = inputMethod.getController(); let inputMethodControl = inputMethod.getController();
console.info("inputMethod_test_getController_001 result:" + typeof inputMethodControl); console.info("====>inputMethod_test_getController_001 result:" + typeof inputMethodControl);
if(typeof inputMethodControl == "object" ){ if(typeof inputMethodControl == "object" ){
console.info("inputMethod_test_getController_001 getController success"); console.info("====>inputMethod_test_getController_001 getController success");
expect(true).assertTrue(); expect(true).assertTrue();
}else{ }else{
console.info("inputMethod_test_getController_001 getController failed"); console.info("====>inputMethod_test_getController_001 getController failed");
expect().assertFail(); expect().assertFail();
}; };
}catch(error){ }catch(error){
console.info("inputMethod_test_getController_001 getController error" + JSON.stringify(error)); console.info("====>inputMethod_test_getController_001 getController error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
}; };
console.info("-----------------inputMethod_test_getController_001 end---------------------"); console.info("====>-----------------inputMethod_test_getController_001 end---------------------");
done(); done();
}); });
...@@ -53,7 +53,7 @@ export default function inputMethodStageJSUnit() { ...@@ -53,7 +53,7 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_listInputMethodSubtype_001', 0, async function (done) { it('inputMethod_test_listInputMethodSubtype_001', 0, async function (done) {
console.info("-----------------inputMethod_test_listInputMethodSubtype_001 start---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_001 start---------------------");
let inputMethodProperty = { let inputMethodProperty = {
packageName:"com.example.kikakeyboard", packageName:"com.example.kikakeyboard",
methodId:"ServiceExtAbility", methodId:"ServiceExtAbility",
...@@ -67,23 +67,23 @@ export default function inputMethodStageJSUnit() { ...@@ -67,23 +67,23 @@ export default function inputMethodStageJSUnit() {
try{ try{
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
console.info("inputMethod_test_listInputMethodSubtype_001 getSetting result:" + inputMethodSetting); console.info("====>inputMethod_test_listInputMethodSubtype_001 getSetting result:" + inputMethodSetting);
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => {
if(err){ if(err){
console.info("inputMethod_test_listInputMethodSubtype_001 failed" + JSON.stringify(err)); console.info("====>inputMethod_test_listInputMethodSubtype_001 failed" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
} }
console.info("inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype: " + JSON.stringify(data)); console.info("====>inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}); });
}catch(error){ }catch(error){
console.info("inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype catch error" + JSON.stringify(error)); console.info("====>inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype catch error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_listInputMethodSubtype_001 end---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_001 end---------------------");
}); });
/* /*
...@@ -93,7 +93,7 @@ export default function inputMethodStageJSUnit() { ...@@ -93,7 +93,7 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_listInputMethodSubtype_002', 0, async function (done) { it('inputMethod_test_listInputMethodSubtype_002', 0, async function (done) {
console.info("-----------------inputMethod_test_listInputMethodSubtype_002 start---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_002 start---------------------");
let inputMethodProperty = { let inputMethodProperty = {
packageName:"com.example.kikakeyboard", packageName:"com.example.kikakeyboard",
methodId:"ServiceExtAbility", methodId:"ServiceExtAbility",
...@@ -107,32 +107,32 @@ export default function inputMethodStageJSUnit() { ...@@ -107,32 +107,32 @@ export default function inputMethodStageJSUnit() {
try{ try{
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
console.info("inputMethod_test_listInputMethodSubtype_002 getSetting result:" + inputMethodSetting); console.info("====>inputMethod_test_listInputMethodSubtype_002 getSetting result:" + inputMethodSetting);
inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => {
if(err){ if(err){
console.info("inputMethod_test_listInputMethodSubtype_002 failed" + JSON.stringify(err)); console.info("====>inputMethod_test_listInputMethodSubtype_002 failed" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done() done()
}; };
console.info("inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype:" + JSON.stringify(data)); console.info("====>inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype:" + JSON.stringify(data));
if(data.length >= 1){ if(data.length >= 1){
let inputMethodSubtype = data[0] let inputMethodSubtype = data[0]
console.info("inputMethod_test_listInputMethodSubtype_002 inputMethodSubtype" + JSON.stringify(inputMethodSubtype)); console.info("====>inputMethod_test_listInputMethodSubtype_002 inputMethodSubtype" + JSON.stringify(inputMethodSubtype));
expect(inputMethodSubtype.id != null).assertTrue(); expect(inputMethodSubtype.id != null).assertTrue();
expect(inputMethodSubtype.label != null).assertTrue(); expect(inputMethodSubtype.label != null).assertTrue();
done(); done();
}else{ }else{
console.info("inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype length less 1"); console.info("====>inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype length less 1");
expect().assertFail(); expect().assertFail();
done(); done();
}; };
}); });
}catch(error){ }catch(error){
console.info("inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype catch error" + JSON.stringify(error)); console.info("====>inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype catch error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_listInputMethodSubtype_002 end---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_002 end---------------------");
}); });
/* /*
...@@ -141,8 +141,9 @@ export default function inputMethodStageJSUnit() { ...@@ -141,8 +141,9 @@ export default function inputMethodStageJSUnit() {
* @tc.desc Function test * @tc.desc Function test
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_listInputMethodSubtype_003', 0, async function (done) { it('inputMethod_test_listInputMethodSubtype_003', 0, async function (done) {
console.info("-----------------inputMethod_test_listInputMethodSubtype_003 start---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_003 start---------------------");
let inputMethodProperty = { let inputMethodProperty = {
packageName:"com.example.kikakeyboard", packageName:"com.example.kikakeyboard",
methodId:"ServiceExtAbility", methodId:"ServiceExtAbility",
...@@ -156,22 +157,22 @@ export default function inputMethodStageJSUnit() { ...@@ -156,22 +157,22 @@ export default function inputMethodStageJSUnit() {
try{ try{
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
console.info("inputMethod_test_listInputMethodSubtype_003 getSetting result:" + inputMethodSetting); console.info("====>inputMethod_test_listInputMethodSubtype_003 getSetting result:" + inputMethodSetting);
inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
console.info("inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype: " + JSON.stringify(data)); console.info("====>inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info("inputMethod_test_listInputMethodSubtype_003 failed" + JSON.stringify(err)); console.info("====>inputMethod_test_listInputMethodSubtype_003 failed" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
}catch(error){ }catch(error){
console.info("inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype catch error" + JSON.stringify(error)); console.info("====>inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype catch error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_listInputMethodSubtype_003 end---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_003 end---------------------");
}); });
/* /*
...@@ -181,7 +182,7 @@ export default function inputMethodStageJSUnit() { ...@@ -181,7 +182,7 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_listInputMethodSubtype_004', 0, async function (done) { it('inputMethod_test_listInputMethodSubtype_004', 0, async function (done) {
console.info("-----------------inputMethod_test_listInputMethodSubtype_004 start---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_004 start---------------------");
let inputMethodProperty = { let inputMethodProperty = {
packageName:"com.example.kikakeyboard", packageName:"com.example.kikakeyboard",
methodId:"ServiceExtAbility", methodId:"ServiceExtAbility",
...@@ -195,31 +196,31 @@ export default function inputMethodStageJSUnit() { ...@@ -195,31 +196,31 @@ export default function inputMethodStageJSUnit() {
try{ try{
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
console.info("inputMethod_test_listInputMethodSubtype_004 getSetting result:" + inputMethodSetting); console.info("====>inputMethod_test_listInputMethodSubtype_004 getSetting result:" + inputMethodSetting);
inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => {
console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype:" + JSON.stringify(data)); console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype:" + JSON.stringify(data));
if(data.length >= 1){ if(data.length >= 1){
let inputMethodSubtype = data[0] let inputMethodSubtype = data[0]
console.info("inputMethod_test_listInputMethodSubtype_004 inputMethodSubtype" + JSON.stringify(inputMethodSubtype)); console.info("====>inputMethod_test_listInputMethodSubtype_004 inputMethodSubtype" + JSON.stringify(inputMethodSubtype));
expect(inputMethodSubtype.id != null).assertTrue(); expect(inputMethodSubtype.id != null).assertTrue();
expect(inputMethodSubtype.label != null).assertTrue(); expect(inputMethodSubtype.label != null).assertTrue();
done(); done();
}else{ }else{
console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype length less 1"); console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype length less 1");
expect().assertFail(); expect().assertFail();
done(); done();
} }
}).catch(err => { }).catch(err => {
console.info("inputMethod_test_listInputMethodSubtype_004 failed" + JSON.stringify(err)); console.info("====>inputMethod_test_listInputMethodSubtype_004 failed" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
}catch(error){ }catch(error){
console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype catch error" + JSON.stringify(error)); console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype catch error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
} }
console.info("-----------------inputMethod_test_listInputMethodSubtype_004 end---------------------"); console.info("====>-----------------inputMethod_test_listInputMethodSubtype_004 end---------------------");
}); });
/* /*
...@@ -229,26 +230,26 @@ export default function inputMethodStageJSUnit() { ...@@ -229,26 +230,26 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_listCurrentInputMethodSubtype_001', 0, async function (done) { it('inputMethod_test_listCurrentInputMethodSubtype_001', 0, async function (done) {
console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_001 start---------------------"); console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_001 start---------------------");
try{ try{
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
console.info("inputMethod_test_listCurrentInputMethodSubtype_001 getSetting result:" + inputMethodSetting); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 getSetting result:" + inputMethodSetting);
inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { inputMethodSetting.listCurrentInputMethodSubtype((err, data) => {
if(err){ if(err){
console.info("inputMethod_test_listCurrentInputMethodSubtype_001 failed" + JSON.stringify(err)); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 failed" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype: " + JSON.stringify(data)); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}); });
}catch(error){ }catch(error){
console.info("inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype catch error" + JSON.stringify(error)); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype catch error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_001 end---------------------"); console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_001 end---------------------");
}); });
/* /*
...@@ -258,25 +259,25 @@ export default function inputMethodStageJSUnit() { ...@@ -258,25 +259,25 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_listCurrentInputMethodSubtype_002', 0, async function (done) { it('inputMethod_test_listCurrentInputMethodSubtype_002', 0, async function (done) {
console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_002 start---------------------"); console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_002 start---------------------");
try{ try{
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
console.info("inputMethod_test_listCurrentInputMethodSubtype_002 getSetting result:" + inputMethodSetting); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 getSetting result:" + inputMethodSetting);
inputMethodSetting.listCurrentInputMethodSubtype().then((data) => { inputMethodSetting.listCurrentInputMethodSubtype().then((data) => {
console.info("inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype: " + JSON.stringify(data)); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info("inputMethod_test_listCurrentInputMethodSubtype_002 failed" + JSON.stringify(err)); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 failed" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
}catch(error){ }catch(error){
console.info("inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype catch error" + JSON.stringify(error)); console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype catch error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_002 end---------------------"); console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_002 end---------------------");
}); });
/* /*
...@@ -286,22 +287,22 @@ export default function inputMethodStageJSUnit() { ...@@ -286,22 +287,22 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_getCurrentInputMethodSubtype_001', 0, async function (done) { it('inputMethod_test_getCurrentInputMethodSubtype_001', 0, async function (done) {
console.info("-----------------inputMethod_test_getCurrentInputMethodSubtype_001 start---------------------"); console.info("====>-----------------inputMethod_test_getCurrentInputMethodSubtype_001 start---------------------");
try{ try{
let inputMethodSubtype = inputMethod.getCurrentInputMethodSubtype(); let inputMethodSubtype = inputMethod.getCurrentInputMethodSubtype();
console.info("inputMethod_test_getCurrentInputMethodSubtype_001 result:" + typeof inputMethodSubtype); console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 result:" + typeof inputMethodSubtype);
if(typeof inputMethodSubtype == "object" ){ if(typeof inputMethodSubtype == "object" ){
console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype success"); console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype success");
expect(true).assertTrue(); expect(true).assertTrue();
}else{ }else{
console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype failed"); console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype failed");
expect().assertFail(); expect().assertFail();
}; };
}catch(error){ }catch(error){
console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------inputMethod_test_getCurrentInputMethodSubtype_001 end---------------------"); console.info("====>-----------------inputMethod_test_getCurrentInputMethodSubtype_001 end---------------------");
done(); done();
}); });
...@@ -312,7 +313,7 @@ export default function inputMethodStageJSUnit() { ...@@ -312,7 +313,7 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) { it('inputMethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) {
console.info("************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test start*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test start*************");
let inputMethodProperty = { let inputMethodProperty = {
packageName: "com.example.kikakeyboard", packageName: "com.example.kikakeyboard",
methodId: "ServiceExtAbility", methodId: "ServiceExtAbility",
...@@ -338,7 +339,7 @@ export default function inputMethodStageJSUnit() { ...@@ -338,7 +339,7 @@ export default function inputMethodStageJSUnit() {
expect( err.code == 12800008 ).assertTrue(); expect( err.code == 12800008 ).assertTrue();
done(); done();
} }
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_001 data: " + JSON.stringify(data)); console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_001 data: " + JSON.stringify(data));
expect(data != null).assertTrue(); expect(data != null).assertTrue();
done(); done();
}); });
...@@ -347,7 +348,7 @@ export default function inputMethodStageJSUnit() { ...@@ -347,7 +348,7 @@ export default function inputMethodStageJSUnit() {
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test end*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test end*************");
}); });
/* /*
...@@ -357,7 +358,7 @@ export default function inputMethodStageJSUnit() { ...@@ -357,7 +358,7 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) { it('inputMethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) {
console.info("************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test start*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test start*************");
let inputMethodProperty = { let inputMethodProperty = {
packageName: "com.example.kikakeyboard", packageName: "com.example.kikakeyboard",
methodId: "ServiceExtAbility", methodId: "ServiceExtAbility",
...@@ -378,7 +379,7 @@ export default function inputMethodStageJSUnit() { ...@@ -378,7 +379,7 @@ export default function inputMethodStageJSUnit() {
}; };
try { try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((data) => { inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((data) => {
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_002 data: " + JSON.stringify(data)); console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_002 data: " + JSON.stringify(data));
expect(data != null).assertTrue(); expect(data != null).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
...@@ -391,7 +392,7 @@ export default function inputMethodStageJSUnit() { ...@@ -391,7 +392,7 @@ export default function inputMethodStageJSUnit() {
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test end*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test end*************");
}); });
/* /*
...@@ -401,7 +402,7 @@ export default function inputMethodStageJSUnit() { ...@@ -401,7 +402,7 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_switchCurrentInputMethodSubtype_001', 0, async function (done) { it('inputMethod_test_switchCurrentInputMethodSubtype_001', 0, async function (done) {
console.info("************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test start*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test start*************");
let inputMethodSubProperty : subtype = { let inputMethodSubProperty : subtype = {
id: "com.example.kikakeyboard", id: "com.example.kikakeyboard",
label: "ServiceExtAbility", label: "ServiceExtAbility",
...@@ -420,7 +421,7 @@ export default function inputMethodStageJSUnit() { ...@@ -420,7 +421,7 @@ export default function inputMethodStageJSUnit() {
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("inputMethod_test_switchCurrentInputMethodSubtype_001 data: " + JSON.stringify(data)); console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_001 data: " + JSON.stringify(data));
expect(data != null).assertTrue(); expect(data != null).assertTrue();
done(); done();
}); });
...@@ -429,7 +430,7 @@ export default function inputMethodStageJSUnit() { ...@@ -429,7 +430,7 @@ export default function inputMethodStageJSUnit() {
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test end*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test end*************");
}); });
/* /*
...@@ -439,7 +440,7 @@ export default function inputMethodStageJSUnit() { ...@@ -439,7 +440,7 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_switchCurrentInputMethodSubtype_002', 0, async function (done) { it('inputMethod_test_switchCurrentInputMethodSubtype_002', 0, async function (done) {
console.info("************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test start*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test start*************");
let inputMethodSubProperty : subtype = { let inputMethodSubProperty : subtype = {
id: "com.example.kikakeyboard", id: "com.example.kikakeyboard",
label: "ServiceExtAbility", label: "ServiceExtAbility",
...@@ -453,7 +454,7 @@ export default function inputMethodStageJSUnit() { ...@@ -453,7 +454,7 @@ export default function inputMethodStageJSUnit() {
}; };
try { try {
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty).then((data) => { inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty).then((data) => {
console.info("inputMethod_test_switchCurrentInputMethodSubtype_002 data: " + JSON.stringify(data)); console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_002 data: " + JSON.stringify(data));
expect(data != null).assertTrue(); expect(data != null).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
...@@ -466,7 +467,7 @@ export default function inputMethodStageJSUnit() { ...@@ -466,7 +467,7 @@ export default function inputMethodStageJSUnit() {
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test end*************"); console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test end*************");
done(); done();
}); });
...@@ -477,28 +478,28 @@ export default function inputMethodStageJSUnit() { ...@@ -477,28 +478,28 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_showOptionalInputMethods_001', 0, async function (done) { it('inputMethod_test_showOptionalInputMethods_001', 0, async function (done) {
console.info("-----------------inputMethod_test_showOptionalInputMethods_001 start---------------------"); console.info("====>-----------------inputMethod_test_showOptionalInputMethods_001 start---------------------");
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
try{ try{
console.info("inputMethod_test_showOptionalInputMethods_001 result:" + inputMethodSetting); console.info("====>inputMethod_test_showOptionalInputMethods_001 result:" + inputMethodSetting);
inputMethodSetting.showOptionalInputMethods((err, data) => { inputMethodSetting.showOptionalInputMethods((err, data) => {
if(err){ if(err){
console.info("inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods faild: " + JSON.stringify(err)); console.info("====>inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods faild: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods success data is : " + data); console.info("====>inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods success data is : " + data);
expect(true).assertTrue(); expect(true).assertTrue();
setTimeout(() => { setTimeout(() => {
done(); done();
}, 1000); }, 1000);
}); });
}catch(error){ }catch(error){
console.info("inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods catch error: " + JSON.stringify(error)); console.info("====>inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods catch error: " + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_showOptionalInputMethods_001 end---------------------"); console.info("====>-----------------inputMethod_test_showOptionalInputMethods_001 end---------------------");
}); });
/* /*
...@@ -508,25 +509,25 @@ export default function inputMethodStageJSUnit() { ...@@ -508,25 +509,25 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_showOptionalInputMethods_002', 0, async function (done) { it('inputMethod_test_showOptionalInputMethods_002', 0, async function (done) {
console.info("-----------------inputMethod_test_showOptionalInputMethods_002 start---------------------"); console.info("====>-----------------inputMethod_test_showOptionalInputMethods_002 start---------------------");
let inputMethodSetting = inputMethod.getSetting(); let inputMethodSetting = inputMethod.getSetting();
try { try {
console.info("inputMethod_test_showOptionalInputMethods_002 result:" + JSON.stringify(inputMethodSetting)); console.info("====>inputMethod_test_showOptionalInputMethods_002 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.showOptionalInputMethods().then((data) => { inputMethodSetting.showOptionalInputMethods().then((data) => {
console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods success data is: " + JSON.stringify(data)); console.info("====>inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods success data is: " + JSON.stringify(data));
expect(true).assertTrue(); expect(true).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods faild: " + JSON.stringify(err)); console.info("====>inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods faild: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); });
} catch (error) { } catch (error) {
console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods catch error: " + JSON.stringify(error)); console.info("====>inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods catch error: " + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_showOptionalInputMethods_002 end---------------------"); console.info("====>-----------------inputMethod_test_showOptionalInputMethods_002 end---------------------");
}); });
/* /*
...@@ -536,25 +537,24 @@ export default function inputMethodStageJSUnit() { ...@@ -536,25 +537,24 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_stopInputSession_002', 0, async function (done) { it('inputMethod_test_stopInputSession_002', 0, async function (done) {
console.info("-----------------inputMethod_test_stopInputSession_002 start---------------------"); console.info("====>-----------------inputMethod_test_stopInputSession_002 start---------------------");
try{ try{
let inputMethodCtrl = inputMethod.getController(); let inputMethodCtrl = inputMethod.getController();
console.info("inputMethod_test_stopInputSession_002 result:" + typeof inputMethodCtrl); console.info("====>inputMethod_test_stopInputSession_002 result:" + typeof inputMethodCtrl);
inputMethodCtrl.stopInputSession().then((data) => { inputMethodCtrl.stopInputSession().then((data) => {
console.info("inputMethod_test_stopInputSession_002 stopInputSession data: " + data);
expect(data == true).assertTrue();
done();
}).catch(err => {
console.info("inputMethod_test_stopInputSession_002 faild: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
done(); done();
}); }).catch((err) => {
console.debug("inputMethod_test_stopInputSession_002 faild: " + JSON.stringify(err));
expect(err.code).assertEqual('12800003')
done();
})
}catch(error){ }catch(error){
console.info("inputMethod_test_stopInputSession_002 catch error" + JSON.stringify(error)); console.info("====>inputMethod_test_stopInputSession_002 catch error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
done(); done();
}; };
console.info("-----------------inputMethod_test_stopInputSession_002 end---------------------"); console.info("====>-----------------inputMethod_test_stopInputSession_002 end---------------------");
}); });
/* /*
...@@ -564,26 +564,24 @@ export default function inputMethodStageJSUnit() { ...@@ -564,26 +564,24 @@ export default function inputMethodStageJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethod_test_stopInputSession_001', 0, async function (done) { it('inputMethod_test_stopInputSession_001', 0, async function (done) {
console.info("-----------------inputMethod_test_stopInputSession_001 start---------------------"); console.info("====>-----------------inputMethod_test_stopInputSession_001 start---------------------");
try{
let inputMethodCtrl = inputMethod.getController(); let inputMethodCtrl = inputMethod.getController();
console.info("inputMethod_test_stopInputSession_001 result: " + typeof inputMethodCtrl); console.debug("inputMethod_test_stopInputSession_001 result: " + typeof inputMethodCtrl);
inputMethodCtrl.stopInputSession((err, data) => { try{
inputMethodCtrl.stopInputSession((err)=>{
if(err){ if(err){
console.info("inputMethod_test_stopInputSession_001 faild: " + JSON.stringify(err)); console.info("====>inputMethod_test_stopInputSession_001 faild: " + JSON.stringify(err));
expect().assertFail(); expect(err.code).assertEqual('12800003');
done(); done();
}; }else{
console.info("inputMethod_test_stopInputSession_001 stopInputSession data: " + data); expect().assertFail();
expect(data == true).assertTrue();
done(); done();
}); }
}catch(error){ })
console.info("inputMethod_test_stopInputSession_001 catch error" + JSON.stringify(error)); }catch(err){
expect().assertFail(); expect().assertFail();
done(); done();
}; }
console.info("-----------------inputMethod_test_stopInputSession_001 end---------------------");
}); });
/* /*
...@@ -594,7 +592,7 @@ export default function inputMethodStageJSUnit() { ...@@ -594,7 +592,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_PERMISSION_001', 0, async function (done) { it('inputMethod_test_EXCEPTION_PERMISSION_001', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_PERMISSION; let keyType = inputMethod.EXCEPTION_PERMISSION;
console.info("inputMethod_test_EXCEPTION_PERMISSION_001 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_PERMISSION_001 result:" + keyType);
expect(keyType).assertEqual(201); expect(keyType).assertEqual(201);
done(); done();
}); });
...@@ -607,7 +605,7 @@ export default function inputMethodStageJSUnit() { ...@@ -607,7 +605,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_PARAMCHECK_002', 0, async function (done) { it('inputMethod_test_EXCEPTION_PARAMCHECK_002', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_PARAMCHECK; let keyType = inputMethod.EXCEPTION_PARAMCHECK;
console.info("inputMethod_test_EXCEPTION_PARAMCHECK_002 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_PARAMCHECK_002 result:" + keyType);
expect(keyType).assertEqual(401); expect(keyType).assertEqual(401);
done(); done();
}); });
...@@ -620,7 +618,7 @@ export default function inputMethodStageJSUnit() { ...@@ -620,7 +618,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_UNSUPPORTED_003', 0, async function (done) { it('inputMethod_test_EXCEPTION_UNSUPPORTED_003', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_UNSUPPORTED; let keyType = inputMethod.EXCEPTION_UNSUPPORTED;
console.info("inputMethod_test_EXCEPTION_UNSUPPORTED_003 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_UNSUPPORTED_003 result:" + keyType);
expect(keyType).assertEqual(801); expect(keyType).assertEqual(801);
done(); done();
}); });
...@@ -633,7 +631,7 @@ export default function inputMethodStageJSUnit() { ...@@ -633,7 +631,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_PACKAGEMANAGER_004', 0, async function (done) { it('inputMethod_test_EXCEPTION_PACKAGEMANAGER_004', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_PACKAGEMANAGER; let keyType = inputMethod.EXCEPTION_PACKAGEMANAGER;
console.info("inputMethod_test_EXCEPTION_PACKAGEMANAGER_004 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_PACKAGEMANAGER_004 result:" + keyType);
expect(keyType).assertEqual(12800001); expect(keyType).assertEqual(12800001);
done(); done();
}); });
...@@ -646,7 +644,7 @@ export default function inputMethodStageJSUnit() { ...@@ -646,7 +644,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_IMENGINE_005', 0, async function (done) { it('inputMethod_test_EXCEPTION_IMENGINE_005', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_IMENGINE; let keyType = inputMethod.EXCEPTION_IMENGINE;
console.info("inputMethod_test_EXCEPTION_IMENGINE_005 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_IMENGINE_005 result:" + keyType);
expect(keyType).assertEqual(12800002); expect(keyType).assertEqual(12800002);
done(); done();
}); });
...@@ -659,7 +657,7 @@ export default function inputMethodStageJSUnit() { ...@@ -659,7 +657,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_IMCLIENT_006', 0, async function (done) { it('inputMethod_test_EXCEPTION_IMCLIENT_006', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_IMCLIENT; let keyType = inputMethod.EXCEPTION_IMCLIENT;
console.info("inputMethod_test_EXCEPTION_IMCLIENT_006 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_IMCLIENT_006 result:" + keyType);
expect(keyType).assertEqual(12800003); expect(keyType).assertEqual(12800003);
done(); done();
}); });
...@@ -672,7 +670,7 @@ export default function inputMethodStageJSUnit() { ...@@ -672,7 +670,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_KEYEVENT_007', 0, async function (done) { it('inputMethod_test_EXCEPTION_KEYEVENT_007', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_KEYEVENT; let keyType = inputMethod.EXCEPTION_KEYEVENT;
console.info("inputMethod_test_EXCEPTION_KEYEVENT_007 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_KEYEVENT_007 result:" + keyType);
expect(keyType).assertEqual(12800004); expect(keyType).assertEqual(12800004);
done(); done();
}); });
...@@ -685,7 +683,7 @@ export default function inputMethodStageJSUnit() { ...@@ -685,7 +683,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_CONFPERSIST_008', 0, async function (done) { it('inputMethod_test_EXCEPTION_CONFPERSIST_008', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_CONFPERSIST; let keyType = inputMethod.EXCEPTION_CONFPERSIST;
console.info("inputMethod_test_EXCEPTION_CONFPERSIST_008 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_CONFPERSIST_008 result:" + keyType);
expect(keyType).assertEqual(12800005); expect(keyType).assertEqual(12800005);
done(); done();
}); });
...@@ -698,7 +696,7 @@ export default function inputMethodStageJSUnit() { ...@@ -698,7 +696,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_CONTROLLER_009', 0, async function (done) { it('inputMethod_test_EXCEPTION_CONTROLLER_009', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_CONTROLLER; let keyType = inputMethod.EXCEPTION_CONTROLLER;
console.info("inputMethod_test_EXCEPTION_CONTROLLER_009 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_CONTROLLER_009 result:" + keyType);
expect(keyType).assertEqual(12800006); expect(keyType).assertEqual(12800006);
done(); done();
}); });
...@@ -711,7 +709,7 @@ export default function inputMethodStageJSUnit() { ...@@ -711,7 +709,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_SETTINGS_010', 0, async function (done) { it('inputMethod_test_EXCEPTION_SETTINGS_010', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_SETTINGS; let keyType = inputMethod.EXCEPTION_SETTINGS;
console.info("inputMethod_test_EXCEPTION_SETTINGS_010 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_SETTINGS_010 result:" + keyType);
expect(keyType).assertEqual(12800007); expect(keyType).assertEqual(12800007);
done(); done();
}); });
...@@ -724,7 +722,7 @@ export default function inputMethodStageJSUnit() { ...@@ -724,7 +722,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_IMMS_011', 0, async function (done) { it('inputMethod_test_EXCEPTION_IMMS_011', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_IMMS; let keyType = inputMethod.EXCEPTION_IMMS;
console.info("inputMethod_test_EXCEPTION_IMMS_011 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_IMMS_011 result:" + keyType);
expect(keyType).assertEqual(12800008); expect(keyType).assertEqual(12800008);
done(); done();
}); });
...@@ -737,7 +735,7 @@ export default function inputMethodStageJSUnit() { ...@@ -737,7 +735,7 @@ export default function inputMethodStageJSUnit() {
*/ */
it('inputMethod_test_EXCEPTION_OTHERS_012', 0, async function (done) { it('inputMethod_test_EXCEPTION_OTHERS_012', 0, async function (done) {
let keyType = inputMethod.EXCEPTION_OTHERS; let keyType = inputMethod.EXCEPTION_OTHERS;
console.info("inputMethod_test_EXCEPTION_OTHERS_012 result:" + keyType); console.info("====>inputMethod_test_EXCEPTION_OTHERS_012 result:" + keyType);
expect(keyType).assertEqual(12899999); expect(keyType).assertEqual(12899999);
done(); done();
}); });
......
...@@ -34,9 +34,9 @@ export default class Utils { ...@@ -34,9 +34,9 @@ export default class Utils {
static getComponentRect(key) { static getComponentRect(key) {
let strJson = getInspectorByKey(key); let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); console.info("====>[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']') let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo); console.info("====>[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
...@@ -47,12 +47,12 @@ export default class Utils { ...@@ -47,12 +47,12 @@ export default class Utils {
} }
static async swipe(downX, downY, upX, upY, steps) { static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe') console.info('====>start to swipe')
this.drags(downX, downY, upX, upY, steps, false) this.drags(downX, downY, upX, upY, steps, false)
} }
static async drag(downX, downY, upX, upY, steps) { static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag') console.info('====>start to drag')
this.drags(downX, downY, upX, upY, steps, true) this.drags(downX, downY, upX, upY, steps, true)
} }
...@@ -70,16 +70,16 @@ export default class Utils { ...@@ -70,16 +70,16 @@ export default class Utils {
} }
xStep = (upX - downX) / swipeSteps; xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps; yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) console.info('====>move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
let downPonit: TouchObject = { let downPonit: TouchObject = {
id: 1, id: 1,
x: downX, x: downX,
y: downY, y: downY,
type: TouchType.Down, type: TouchType.Down,
} }
console.info('down touch started: ' + JSON.stringify(downPonit)) console.info('====>down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit); sendTouchEvent(downPonit);
console.info('start to move') console.info('====>start to move')
if (drag) { if (drag) {
await this.sleep(500) await this.sleep(500)
} }
...@@ -90,14 +90,14 @@ export default class Utils { ...@@ -90,14 +90,14 @@ export default class Utils {
y: downY + (yStep * i), y: downY + (yStep * i),
type: TouchType.Move type: TouchType.Move
} }
console.info('move touch started: ' + JSON.stringify(movePoint)) console.info('====>move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint) ret = sendTouchEvent(movePoint)
if (ret == false) { if (ret == false) {
break; break;
} }
await this.sleep(5) await this.sleep(5)
} }
console.info('start to up') console.info('====>start to up')
if (drag) { if (drag) {
await this.sleep(100) await this.sleep(100)
} }
...@@ -107,7 +107,7 @@ export default class Utils { ...@@ -107,7 +107,7 @@ export default class Utils {
y: upY, y: upY,
type: TouchType.Up, type: TouchType.Up,
} }
console.info('up touch started: ' + JSON.stringify(upPoint)) console.info('====>up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint) sendTouchEvent(upPoint)
await this.sleep(500) await this.sleep(500)
} }
......
...@@ -26,7 +26,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -26,7 +26,7 @@ export default function inputMethodEngineJSUnit() {
let kbController = null; let kbController = null;
let KeyboardDelegate = null; let KeyboardDelegate = null;
console.info("************* inputMethodEngine Test start*************"); console.info("====>************* inputMethodEngine Test start*************");
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/input', uri: 'pages/input',
...@@ -45,279 +45,279 @@ export default function inputMethodEngineJSUnit() { ...@@ -45,279 +45,279 @@ export default function inputMethodEngineJSUnit() {
}); });
afterEach(async function () { afterEach(async function () {
console.info("inputMethodEngine afterEach start:" + inputMethodEngineObject); console.info("====>inputMethodEngine afterEach start:" + inputMethodEngineObject);
await Utils.sleep(1000); await Utils.sleep(1000);
}); });
it('inputMethodEngine_testOff_000', 0 , async function (done) { it('inputMethodEngine_testOff_000', 0 , async function (done) {
inputMethodEngineObject.off('inputStart', (kbController, textInputClient) => { inputMethodEngineObject.off('inputStart', (kbController, textInputClient) => {
console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController));
console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient));
}); });
inputMethodEngineObject.off('keyboardShow', () => { inputMethodEngineObject.off('keyboardShow', () => {
console.info("inputMethodEngine beforeEach keyboardShow:"); console.info("====>inputMethodEngine beforeEach keyboardShow:");
}); });
inputMethodEngineObject.off('keyboardHide', () => { inputMethodEngineObject.off('keyboardHide', () => {
console.info("inputMethodEngine beforeEach keyboardHide:"); console.info("====>inputMethodEngine beforeEach keyboardHide:");
}); });
KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
KeyboardDelegate.off('keyDown', (keyEvent) => { KeyboardDelegate.off('keyDown', (keyEvent) => {
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1'); expect(keyEvent.keyCode).assertEqual('1');
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('1'); expect(keyEvent.keyAction).assertEqual('1');
}); });
KeyboardDelegate.off('keyUp', (keyEvent) => { KeyboardDelegate.off('keyUp', (keyEvent) => {
console.info("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1'); expect(keyEvent.keyCode).assertEqual('1');
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('0'); expect(keyEvent.keyAction).assertEqual('0');
}); });
KeyboardDelegate.off('cursorContextChange', (x, y, height) => { KeyboardDelegate.off('cursorContextChange', (x, y, height) => {
console.info("inputMethodEngine beforeEach cursorContextChange x:" + x); console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x);
console.info("inputMethodEngine beforeEach cursorContextChange y:" + y); console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y);
console.info("inputMethodEngine beforeEach cursorContextChange height:" + height); console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height);
}); });
KeyboardDelegate.off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { KeyboardDelegate.off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info("inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin);
console.info("inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd);
console.info("inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin);
console.info("inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd);
}); });
KeyboardDelegate.off('textChange', (text) => { KeyboardDelegate.off('textChange', (text) => {
console.info("inputMethodEngine beforeEach textChange:" + text); console.info("====>inputMethodEngine beforeEach textChange:" + text);
}); });
done(); done();
}); });
it('inputMethodEngine_test_000', 0, async function (done) { it('inputMethodEngine_test_000', 0, async function (done) {
inputMethodEngineObject.on('inputStart', (kbController, textInputClient) => { inputMethodEngineObject.on('inputStart', (kbController, textInputClient) => {
console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController));
console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient));
textInputClient = textInputClient; textInputClient = textInputClient;
kbController = kbController; kbController = kbController;
}); });
inputMethodEngineObject.on('keyboardShow', () => { inputMethodEngineObject.on('keyboardShow', () => {
console.info("inputMethodEngine beforeEach keyboardShow:"); console.info("====>inputMethodEngine beforeEach keyboardShow:");
}); });
inputMethodEngineObject.on('keyboardHide', () => { inputMethodEngineObject.on('keyboardHide', () => {
console.info("inputMethodEngine beforeEach keyboardHide:"); console.info("====>inputMethodEngine beforeEach keyboardHide:");
}); });
mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
mKeyboardDelegate.on('keyDown', (keyEvent) => { mKeyboardDelegate.on('keyDown', (keyEvent) => {
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1'); expect(keyEvent.keyCode).assertEqual('1');
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('1'); expect(keyEvent.keyAction).assertEqual('1');
}); });
mKeyboardDelegate.on('keyUp', (keyEvent) => { mKeyboardDelegate.on('keyUp', (keyEvent) => {
console.info("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1'); expect(keyEvent.keyCode).assertEqual('1');
console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction);
expect(keyEvent.keyAction).assertEqual('0'); expect(keyEvent.keyAction).assertEqual('0');
}); });
mKeyboardDelegate.on('cursorContextChange', (x, y, height) => { mKeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.info("inputMethodEngine beforeEach cursorContextChange x:" + x); console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x);
console.info("inputMethodEngine beforeEach cursorContextChange y:" + y); console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y);
console.info("inputMethodEngine beforeEach cursorContextChange height:" + height); console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height);
}); });
mKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { mKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info("inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin);
console.info("inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd);
console.info("inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin);
console.info("inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd);
}); });
mKeyboardDelegate.on('textChange', (text) => { mKeyboardDelegate.on('textChange', (text) => {
console.info("inputMethodEngine beforeEach textChange:" + text); console.info("====>inputMethodEngine beforeEach textChange:" + text);
}); });
done(); done();
}); });
it('inputMethodEngine_test_001', 0, async function (done) { it('inputMethodEngine_test_001', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED; let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED;
console.info("inputMethodEngine_test_001 result:" + keyType); console.info("====>inputMethodEngine_test_001 result:" + keyType);
expect(keyType).assertEqual(0); expect(keyType).assertEqual(0);
done(); done();
}); });
it('inputMethodEngine_test_002', 0, async function (done) { it('inputMethodEngine_test_002', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_GO; let keyType = inputMethodEngine.ENTER_KEY_TYPE_GO;
console.info("inputMethodEngine_test_002 result:" + keyType); console.info("====>inputMethodEngine_test_002 result:" + keyType);
expect(keyType).assertEqual(2); expect(keyType).assertEqual(2);
done(); done();
}); });
it('inputMethodEngine_test_003', 0, async function (done) { it('inputMethodEngine_test_003', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEARCH; let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEARCH;
console.info("inputMethodEngine_test_003 result:" + keyType); console.info("====>inputMethodEngine_test_003 result:" + keyType);
expect(keyType).assertEqual(3); expect(keyType).assertEqual(3);
done(); done();
}); });
it('inputMethodEngine_test_004', 0, async function (done) { it('inputMethodEngine_test_004', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEND; let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEND;
console.info("inputMethodEngine_test_004 result:" + keyType); console.info("====>inputMethodEngine_test_004 result:" + keyType);
expect(keyType).assertEqual(4); expect(keyType).assertEqual(4);
done(); done();
}); });
it('inputMethodEngine_test_005', 0, async function (done) { it('inputMethodEngine_test_005', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_NEXT; let keyType = inputMethodEngine.ENTER_KEY_TYPE_NEXT;
console.info("inputMethodEngine_test_005 result:" + keyType); console.info("====>inputMethodEngine_test_005 result:" + keyType);
expect(keyType).assertEqual(5); expect(keyType).assertEqual(5);
done(); done();
}); });
it('inputMethodEngine_test_006', 0, async function (done) { it('inputMethodEngine_test_006', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_DONE; let keyType = inputMethodEngine.ENTER_KEY_TYPE_DONE;
console.info("inputMethodEngine_test_006 result:" + keyType); console.info("====>inputMethodEngine_test_006 result:" + keyType);
expect(keyType).assertEqual(6); expect(keyType).assertEqual(6);
done(); done();
}); });
it('inputMethodEngine_test_007', 0, async function (done) { it('inputMethodEngine_test_007', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS; let keyType = inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS;
console.info("inputMethodEngine_test_007 result:" + keyType); console.info("====>inputMethodEngine_test_007 result:" + keyType);
expect(keyType).assertEqual(7); expect(keyType).assertEqual(7);
done(); done();
}); });
it('inputMethodEngine_test_008', 0, async function (done) { it('inputMethodEngine_test_008', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_NULL; let keyType = inputMethodEngine.PATTERN_NULL;
console.info("inputMethodEngine_test_008 result:" + keyType); console.info("====>inputMethodEngine_test_008 result:" + keyType);
expect(keyType).assertEqual(-1); expect(keyType).assertEqual(-1);
done(); done();
}); });
it('inputMethodEngine_test_009', 0, async function (done) { it('inputMethodEngine_test_009', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_TEXT; let keyType = inputMethodEngine.PATTERN_TEXT;
console.info("inputMethodEngine_test_009 result:" + keyType); console.info("====>inputMethodEngine_test_009 result:" + keyType);
expect(keyType).assertEqual(0); expect(keyType).assertEqual(0);
done(); done();
}); });
it('inputMethodEngine_test_010', 0, async function (done) { it('inputMethodEngine_test_010', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_NUMBER; let keyType = inputMethodEngine.PATTERN_NUMBER;
console.info("inputMethodEngine_test_010 result:" + keyType); console.info("====>inputMethodEngine_test_010 result:" + keyType);
expect(keyType).assertEqual(2); expect(keyType).assertEqual(2);
done(); done();
}); });
it('inputMethodEngine_test_011', 0, async function (done) { it('inputMethodEngine_test_011', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_PHONE; let keyType = inputMethodEngine.PATTERN_PHONE;
console.info("inputMethodEngine_test_011 result:" + keyType); console.info("====>inputMethodEngine_test_011 result:" + keyType);
expect(keyType).assertEqual(3); expect(keyType).assertEqual(3);
done(); done();
}); });
it('inputMethodEngine_test_012', 0, async function (done) { it('inputMethodEngine_test_012', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_DATETIME; let keyType = inputMethodEngine.PATTERN_DATETIME;
console.info("inputMethodEngine_test_012 result:" + keyType); console.info("====>inputMethodEngine_test_012 result:" + keyType);
expect(keyType).assertEqual(4); expect(keyType).assertEqual(4);
done(); done();
}); });
it('inputMethodEngine_test_013', 0, async function (done) { it('inputMethodEngine_test_013', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_EMAIL; let keyType = inputMethodEngine.PATTERN_EMAIL;
console.info("inputMethodEngine_test_013 result:" + keyType); console.info("====>inputMethodEngine_test_013 result:" + keyType);
expect(keyType).assertEqual(5); expect(keyType).assertEqual(5);
done(); done();
}); });
it('inputMethodEngine_test_014', 0, async function (done) { it('inputMethodEngine_test_014', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_URI; let keyType = inputMethodEngine.PATTERN_URI;
console.info("inputMethodEngine_test_014 result:" + keyType); console.info("====>inputMethodEngine_test_014 result:" + keyType);
expect(keyType).assertEqual(6); expect(keyType).assertEqual(6);
done(); done();
}); });
it('inputMethodEngine_test_015', 0, async function (done) { it('inputMethodEngine_test_015', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_PASSWORD; let keyType = inputMethodEngine.PATTERN_PASSWORD;
console.info("inputMethodEngine_test_015 result:" + keyType); console.info("====>inputMethodEngine_test_015 result:" + keyType);
expect(keyType).assertEqual(7); expect(keyType).assertEqual(7);
done(); done();
}); });
it('inputMethodEngine_test_016', 0, async function (done) { it('inputMethodEngine_test_016', 0, async function (done) {
let keyType = inputMethodEngine.FLAG_SELECTING; let keyType = inputMethodEngine.FLAG_SELECTING;
console.info("inputMethodEngine_test_016 result:" + keyType); console.info("====>inputMethodEngine_test_016 result:" + keyType);
expect(keyType).assertEqual(2); expect(keyType).assertEqual(2);
done(); done();
}); });
it('inputMethodEngine_test_017', 0, async function (done) { it('inputMethodEngine_test_017', 0, async function (done) {
let keyType = inputMethodEngine.FLAG_SINGLE_LINE; let keyType = inputMethodEngine.FLAG_SINGLE_LINE;
console.info("inputMethodEngine_test_017 result:" + keyType); console.info("====>inputMethodEngine_test_017 result:" + keyType);
expect(keyType).assertEqual(1); expect(keyType).assertEqual(1);
done(); done();
}); });
it('inputMethodEngine_test_018', 0, async function (done) { it('inputMethodEngine_test_018', 0, async function (done) {
let keyType = inputMethodEngine.DISPLAY_MODE_PART; let keyType = inputMethodEngine.DISPLAY_MODE_PART;
console.info("inputMethodEngine_test_018 result:" + keyType); console.info("====>inputMethodEngine_test_018 result:" + keyType);
expect(keyType).assertEqual(0); expect(keyType).assertEqual(0);
done(); done();
}); });
it('inputMethodEngine_test_019', 0, async function (done) { it('inputMethodEngine_test_019', 0, async function (done) {
let keyType = inputMethodEngine.DISPLAY_MODE_FULL; let keyType = inputMethodEngine.DISPLAY_MODE_FULL;
console.info("inputMethodEngine_test_019 result:" + keyType); console.info("====>inputMethodEngine_test_019 result:" + keyType);
expect(keyType).assertEqual(1); expect(keyType).assertEqual(1);
done(); done();
}); });
it('inputMethodEngine_test_020', 0, async function (done) { it('inputMethodEngine_test_020', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_ASCII; let keyType = inputMethodEngine.OPTION_ASCII;
console.info("inputMethodEngine_test_020 result:" + keyType); console.info("====>inputMethodEngine_test_020 result:" + keyType);
expect(keyType).assertEqual(20); expect(keyType).assertEqual(20);
done(); done();
}); });
it('inputMethodEngine_test_021', 0, async function (done) { it('inputMethodEngine_test_021', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_NONE; let keyType = inputMethodEngine.OPTION_NONE;
console.info("inputMethodEngine_test_021 result:" + keyType); console.info("====>inputMethodEngine_test_021 result:" + keyType);
expect(keyType).assertEqual(0); expect(keyType).assertEqual(0);
done(); done();
}); });
it('inputMethodEngine_test_022', 0, async function (done) { it('inputMethodEngine_test_022', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_CAP_CHARACTERS; let keyType = inputMethodEngine.OPTION_AUTO_CAP_CHARACTERS;
console.info("inputMethodEngine_test_022 result:" + keyType); console.info("====>inputMethodEngine_test_022 result:" + keyType);
expect(keyType).assertEqual(2); expect(keyType).assertEqual(2);
done(); done();
}); });
it('inputMethodEngine_test_023', 0, async function (done) { it('inputMethodEngine_test_023', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_CAP_SENTENCES; let keyType = inputMethodEngine.OPTION_AUTO_CAP_SENTENCES;
console.info("inputMethodEngine_test_023 result:" + keyType); console.info("====>inputMethodEngine_test_023 result:" + keyType);
expect(keyType).assertEqual(8); expect(keyType).assertEqual(8);
done(); done();
}); });
it('inputMethodEngine_test_024', 0, async function (done) { it('inputMethodEngine_test_024', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_WORDS; let keyType = inputMethodEngine.OPTION_AUTO_WORDS;
console.info("inputMethodEngine_test_024 result:" + keyType); console.info("====>inputMethodEngine_test_024 result:" + keyType);
expect(keyType).assertEqual(4); expect(keyType).assertEqual(4);
done(); done();
}); });
it('inputMethodEngine_test_025', 0, async function (done) { it('inputMethodEngine_test_025', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_MULTI_LINE; let keyType = inputMethodEngine.OPTION_MULTI_LINE;
console.info("inputMethodEngine_test_025 result:" + keyType); console.info("====>inputMethodEngine_test_025 result:" + keyType);
expect(keyType).assertEqual(1); expect(keyType).assertEqual(1);
done(); done();
}); });
it('inputMethodEngine_test_026', 0, async function (done) { it('inputMethodEngine_test_026', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_NO_FULLSCREEN; let keyType = inputMethodEngine.OPTION_NO_FULLSCREEN;
console.info("inputMethodEngine_test_026 result:" + keyType); console.info("====>inputMethodEngine_test_026 result:" + keyType);
expect(keyType).assertEqual(10); expect(keyType).assertEqual(10);
done(); done();
}); });
...@@ -325,12 +325,12 @@ export default function inputMethodEngineJSUnit() { ...@@ -325,12 +325,12 @@ export default function inputMethodEngineJSUnit() {
it('inputMethodEngine_test_027', 0, async function (done) { it('inputMethodEngine_test_027', 0, async function (done) {
let rect = await Utils.getComponentRect('TextInput') let rect = await Utils.getComponentRect('TextInput')
console.info("[inputMethodEngine_test_027] rectInfo is " + rect); console.info("====>[inputMethodEngine_test_027] rectInfo is " + rect);
console.info("[inputMethodEngine_test_027] rectInfo is " + JSON.stringify(rect)); console.info("====>[inputMethodEngine_test_027] rectInfo is " + JSON.stringify(rect));
let x_value = rect.left + (rect.right - rect.left) / 10 let x_value = rect.left + (rect.right - rect.left) / 10
let y_value = rect.top + (rect.bottom - rect.top) / 10 let y_value = rect.top + (rect.bottom - rect.top) / 10
console.info("[inputMethodEngine_test_027] onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); console.info("====>[inputMethodEngine_test_027] onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value);
let point: TouchObject = { let point: TouchObject = {
id: 1, id: 1,
x: x_value, x: x_value,
...@@ -339,9 +339,9 @@ export default function inputMethodEngineJSUnit() { ...@@ -339,9 +339,9 @@ export default function inputMethodEngineJSUnit() {
screenX: rect.left + (rect.right - rect.left) / 10, screenX: rect.left + (rect.right - rect.left) / 10,
screenY: rect.left + (rect.right - rect.left) / 10, screenY: rect.left + (rect.right - rect.left) / 10,
} }
console.info('[inputMethodEngine_test_027] testSendTouchEvent ' + sendTouchEvent(point)); console.info('====>[inputMethodEngine_test_027] testSendTouchEvent ' + sendTouchEvent(point));
await Utils.sleep(1000) await Utils.sleep(1000)
console.info('[inputMethodEngine_test_027] END'); console.info('====>[inputMethodEngine_test_027] END');
done(); done();
}); });
...@@ -350,7 +350,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -350,7 +350,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.sendKeyFunction(0, (value) => { textInputClient.sendKeyFunction(0, (value) => {
console.info("inputMethodEngine_test_028 textInputClient sendKeyFunction:" + value); console.info("====>inputMethodEngine_test_028 textInputClient sendKeyFunction:" + value);
expect(value).assertEqual(true); expect(value).assertEqual(true);
}); });
} }
...@@ -363,10 +363,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -363,10 +363,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = textInputClient.sendKeyFunction(0); let promise = textInputClient.sendKeyFunction(0);
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_029 listInputMethod promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_029 listInputMethod promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true); expect(res).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_029 listInputMethod promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_029 listInputMethod promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -378,7 +378,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -378,7 +378,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.deleteForward(1, (value) => { textInputClient.deleteForward(1, (value) => {
console.info("inputMethodEngine_test_030 deleteForward:" + value); console.info("====>inputMethodEngine_test_030 deleteForward:" + value);
expect(value).assertEqual(true); expect(value).assertEqual(true);
}); });
} }
...@@ -391,10 +391,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -391,10 +391,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = textInputClient.deleteForward(1); let promise = textInputClient.deleteForward(1);
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_031 deleteForward promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_031 deleteForward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true); expect(res).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_031 deleteForward promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_031 deleteForward promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -406,7 +406,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -406,7 +406,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.deleteBackward(1, (value) => { textInputClient.deleteBackward(1, (value) => {
console.info("inputMethodEngine_test_032 deleteBackward:" + value); console.info("====>inputMethodEngine_test_032 deleteBackward:" + value);
expect(value).assertEqual(true); expect(value).assertEqual(true);
}); });
} }
...@@ -419,10 +419,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -419,10 +419,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = textInputClient.deleteBackward(1); let promise = textInputClient.deleteBackward(1);
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_033 deleteBackward promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_033 deleteBackward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true); expect(res).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_033 deleteBackward promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_033 deleteBackward promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -434,7 +434,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -434,7 +434,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.InsertText('test', (value) => { textInputClient.InsertText('test', (value) => {
console.info("inputMethodEngine_test_034 InsertText:" + value); console.info("====>inputMethodEngine_test_034 InsertText:" + value);
expect(value).assertEqual(true); expect(value).assertEqual(true);
}); });
} }
...@@ -447,10 +447,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -447,10 +447,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = textInputClient.InsertText('test'); let promise = textInputClient.InsertText('test');
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_035 InsertText promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_035 InsertText promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true); expect(res).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_035 InsertText promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_035 InsertText promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -462,7 +462,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -462,7 +462,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.getForward(1, (value) => { textInputClient.getForward(1, (value) => {
console.info("inputMethodEngine_test_036 getForward:" + value); console.info("====>inputMethodEngine_test_036 getForward:" + value);
expect(value).assertEqual(true); expect(value).assertEqual(true);
}); });
} }
...@@ -475,10 +475,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -475,10 +475,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = textInputClient.getForward(1); let promise = textInputClient.getForward(1);
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_037 getForward promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_037 getForward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true); expect(res).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_037 getForward promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_037 getForward promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -490,7 +490,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -490,7 +490,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.getEditorAttribute(1, (editorAttribute) => { textInputClient.getEditorAttribute(1, (editorAttribute) => {
console.info("inputMethodEngine_test_038 getEditorAttribute:" + editorAttribute); console.info("====>inputMethodEngine_test_038 getEditorAttribute:" + editorAttribute);
expect(editorAttribute.inputPattern).assertEqual(1); expect(editorAttribute.inputPattern).assertEqual(1);
expect(editorAttribute.enterKeyType).assertEqual(1); expect(editorAttribute.enterKeyType).assertEqual(1);
}); });
...@@ -504,11 +504,11 @@ export default function inputMethodEngineJSUnit() { ...@@ -504,11 +504,11 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = textInputClient.getEditorAttribute(); let promise = textInputClient.getEditorAttribute();
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_039 getEditorAttribute promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_039 getEditorAttribute promise result-----" + JSON.stringify(res));
expect(res.inputPattern).assertEqual(1); expect(res.inputPattern).assertEqual(1);
expect(res.enterKeyType).assertEqual(1); expect(res.enterKeyType).assertEqual(1);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_039 getEditorAttribute promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_039 getEditorAttribute promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -520,7 +520,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -520,7 +520,7 @@ export default function inputMethodEngineJSUnit() {
expect(kbController == null).assertEqual(true); expect(kbController == null).assertEqual(true);
} else { } else {
kbController.hideKeyboard(() => { kbController.hideKeyboard(() => {
console.info("inputMethodEngine_test_040 hideKeyboard"); console.info("====>inputMethodEngine_test_040 hideKeyboard");
expect(1 == 1).assertTrue(); expect(1 == 1).assertTrue();
}); });
} }
...@@ -533,10 +533,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -533,10 +533,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = kbController.hideKeyboard(); let promise = kbController.hideKeyboard();
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_041 hideKeyboard promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_041 hideKeyboard promise result-----" + JSON.stringify(res));
expect(1 == 1).assertTrue(); expect(1 == 1).assertTrue();
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_041 hideKeyboard promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_041 hideKeyboard promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -548,7 +548,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -548,7 +548,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.getBackward(1, (value) => { textInputClient.getBackward(1, (value) => {
console.info("inputMethodEngine_test_042 getBackward:" + value); console.info("====>inputMethodEngine_test_042 getBackward:" + value);
expect(value).assertEqual(true); expect(value).assertEqual(true);
}); });
} }
...@@ -561,10 +561,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -561,10 +561,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = textInputClient.getBackward(1); let promise = textInputClient.getBackward(1);
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_043 getBackward promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_043 getBackward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true); expect(res).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_043 getBackward promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_043 getBackward promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -583,7 +583,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -583,7 +583,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_UP, (value) => { textInputClient.moveCursor(inputMethodEngine.CURSOR_UP, (value) => {
console.info("inputMethodEngine_test_045 moveCursor:" + value); console.info("====>inputMethodEngine_test_045 moveCursor:" + value);
expect(value == null).assertEqual(true); expect(value == null).assertEqual(true);
}); });
} }
...@@ -595,7 +595,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -595,7 +595,7 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (value) => { textInputClient.moveCursor(inputMethodEngine.CURSOR_DOWN, (value) => {
console.info("inputMethodEngine_test_046 moveCursor:" + value); console.info("====>inputMethodEngine_test_046 moveCursor:" + value);
expect(value == null).assertEqual(true); expect(value == null).assertEqual(true);
}); });
} }
...@@ -607,10 +607,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -607,10 +607,10 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_LEFT).then(res => { textInputClient.moveCursor(inputMethodEngine.CURSOR_LEFT).then(res => {
console.info("inputMethodEngine_test_047 moveCursor promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_047 moveCursor promise result-----" + JSON.stringify(res));
expect(res == null).assertEqual(true); expect(res == null).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_047 moveCursor promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_047 moveCursor promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -622,10 +622,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -622,10 +622,10 @@ export default function inputMethodEngineJSUnit() {
expect(textInputClient == null).assertEqual(true); expect(textInputClient == null).assertEqual(true);
} else { } else {
textInputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT).then(res => { textInputClient.moveCursor(inputMethodEngine.CURSOR_RIGHT).then(res => {
console.info("inputMethodEngine_test_048 moveCursor promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_048 moveCursor promise result-----" + JSON.stringify(res));
expect(res == null).assertEqual(true); expect(res == null).assertEqual(true);
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_048 moveCursor promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_048 moveCursor promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -637,7 +637,7 @@ export default function inputMethodEngineJSUnit() { ...@@ -637,7 +637,7 @@ export default function inputMethodEngineJSUnit() {
expect(kbController == null).assertEqual(true); expect(kbController == null).assertEqual(true);
} else { } else {
kbController.hide(() => { kbController.hide(() => {
console.info("inputMethodEngine_test_049 hideKeyboard:"); console.info("====>inputMethodEngine_test_049 hideKeyboard:");
expect(1 == 1).assertTrue(); expect(1 == 1).assertTrue();
}); });
} }
...@@ -650,10 +650,10 @@ export default function inputMethodEngineJSUnit() { ...@@ -650,10 +650,10 @@ export default function inputMethodEngineJSUnit() {
} else { } else {
let promise = kbController.hide(); let promise = kbController.hide();
promise.then(res => { promise.then(res => {
console.info("inputMethodEngine_test_050 hideKeyboard promise result-----" + JSON.stringify(res)); console.info("====>inputMethodEngine_test_050 hideKeyboard promise result-----" + JSON.stringify(res));
expect(1 == 1).assertTrue(); expect(1 == 1).assertTrue();
}).catch(err => { }).catch(err => {
console.info("inputMethodEngine_test_050 hideKeyboard promise error----" + JSON.stringify(err)); console.info("====>inputMethodEngine_test_050 hideKeyboard promise error----" + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}); });
} }
...@@ -667,22 +667,22 @@ export default function inputMethodEngineJSUnit() { ...@@ -667,22 +667,22 @@ export default function inputMethodEngineJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethodEngine_test_getInputMethodAbility_001', 0, async function (done) { it('inputMethodEngine_test_getInputMethodAbility_001', 0, async function (done) {
console.info("-----------------inputMethodEngine_test_getInputMethodAbility_001 start---------------------"); console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 start---------------------");
try{ try{
let inputMethodAbility = inputMethodEngine.getInputMethodAbility(); let inputMethodAbility = inputMethodEngine.getInputMethodAbility();
console.info("inputMethodEngine_test_getInputMethodAbility_001 result:" + typeof inputMethodAbility); console.info("====>inputMethodEngine_test_getInputMethodAbility_001 result:" + typeof inputMethodAbility);
if(typeof inputMethodAbility == "object" ){ if(typeof inputMethodAbility == "object" ){
console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype success"); console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype success");
expect(true).assertTrue(); expect(true).assertTrue();
}else{ }else{
console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype failed"); console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype failed");
expect().assertFail(); expect().assertFail();
}; };
}catch(error){ }catch(error){
console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------inputMethodEngine_test_getInputMethodAbility_001 end---------------------"); console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 end---------------------");
done(); done();
}); });
...@@ -693,22 +693,22 @@ export default function inputMethodEngineJSUnit() { ...@@ -693,22 +693,22 @@ export default function inputMethodEngineJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputMethodEngine_test_getKeyboardDelegate_001', 0, async function (done) { it('inputMethodEngine_test_getKeyboardDelegate_001', 0, async function (done) {
console.info("-----------------inputMethodEngine_test_getKeyboardDelegate_001 start---------------------"); console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 start---------------------");
try{ try{
let inputMethodAbility = inputMethodEngine.getKeyboardDelegate(); let inputMethodAbility = inputMethodEngine.getKeyboardDelegate();
console.info("inputMethodEngine_test_getKeyboardDelegate_001 result:" + typeof inputMethodAbility); console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 result:" + typeof inputMethodAbility);
if(typeof inputMethodAbility == "object" ){ if(typeof inputMethodAbility == "object" ){
console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype success"); console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype success");
expect(true).assertTrue(); expect(true).assertTrue();
}else{ }else{
console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype failed"); console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype failed");
expect().assertFail(); expect().assertFail();
}; };
}catch(error){ }catch(error){
console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype error" + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------inputMethodEngine_test_getKeyboardDelegate_001 end---------------------"); console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 end---------------------");
done(); done();
}); });
......
...@@ -17,12 +17,12 @@ import inputMethod from '@ohos.inputmethod'; ...@@ -17,12 +17,12 @@ import inputMethod from '@ohos.inputmethod';
export default function inputMethodJSUnit() { export default function inputMethodJSUnit() {
describe('appInfoTest_input_2', function () { describe('appInfoTest_input_2', function () {
console.info("************* settings Test start*************"); console.info("====>************* settings Test start*************");
it('inputmethoh_test_001', 0, async function (done) { it('inputmethoh_test_001', 0, async function (done) {
let inputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
console.info("inputmethoh_test_001 result:" + JSON.stringify(inputMethodSetting)); console.info("====>inputmethoh_test_001 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.listInputMethod((arr) => { inputMethodSetting.listInputMethod((arr) => {
console.info("appInfoTest_input_2 listInputMethod result---" + JSON.stringify(arr)); console.info("====>appInfoTest_input_2 listInputMethod result---" + JSON.stringify(arr));
expect(1==1).assertTrue(); expect(1==1).assertTrue();
}); });
done(); done();
...@@ -30,40 +30,40 @@ export default function inputMethodJSUnit() { ...@@ -30,40 +30,40 @@ export default function inputMethodJSUnit() {
it('inputmethoh_test_002', 0, async function (done) { it('inputmethoh_test_002', 0, async function (done) {
let inputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
console.info("inputmethoh_test_002 result:" + JSON.stringify(inputMethodSetting)); console.info("====>inputmethoh_test_002 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.listInputMethod().then(inputMethodProperty => { inputMethodSetting.listInputMethod().then(inputMethodProperty => {
if (inputMethodProperty.length > 0){ if (inputMethodProperty.length > 0){
let obj = inputMethodProperty[0] let obj = inputMethodProperty[0]
console.info("inputmethoh_test_002 listInputMethod obj---" + JSON.stringify(obj)); console.info("====>inputmethoh_test_002 listInputMethod obj---" + JSON.stringify(obj));
expect(obj.packageName != null).assertTrue(); expect(obj.packageName != null).assertTrue();
expect(obj.methodId != null).assertTrue(); expect(obj.methodId != null).assertTrue();
}else{ }else{
console.info("inputmethoh_test_002 listInputMethod is null"); console.info("====>inputmethoh_test_002 listInputMethod is null");
expect().assertFail() expect().assertFail()
} }
}).catch(err => { }).catch(err => {
console.info("inputmethoh_test_002 listInputMethod is err: " + JSON.stringify(err)); console.info("====>inputmethoh_test_002 listInputMethod is err: " + JSON.stringify(err));
}); });
done(); done();
}); });
it('inputmethoh_test_003', 0, async function (done) { it('inputmethoh_test_003', 0, async function (done) {
let inputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
console.info("inputmethoh_test_003 result:" + JSON.stringify(inputMethodSetting)); console.info("====>inputmethoh_test_003 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.displayOptionalInputMethod(() => { inputMethodSetting.displayOptionalInputMethod(() => {
console.info("inputmethoh_test_003 displayOptionalInputMethod---"); console.info("====>inputmethoh_test_003 displayOptionalInputMethod---");
}); });
done(); done();
}); });
it('inputmethoh_test_004', 0, async function (done) { it('inputmethoh_test_004', 0, async function (done) {
let inputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
console.info("inputmethoh_test_004 result:" + JSON.stringify(inputMethodSetting)); console.info("====>inputmethoh_test_004 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.displayOptionalInputMethod().then(() => { inputMethodSetting.displayOptionalInputMethod().then(() => {
console.info("inputmethoh_test_004 displayOptionalInputMethod is called"); console.info("====>inputmethoh_test_004 displayOptionalInputMethod is called");
expect(true).assertTrue() expect(true).assertTrue()
}).catch(err => { }).catch(err => {
console.info("inputmethoh_test_004 displayOptionalInputMethod is err: " + JSON.stringify(err)); console.info("====>inputmethoh_test_004 displayOptionalInputMethod is err: " + JSON.stringify(err));
expect().assertFail() expect().assertFail()
}); });
done(); done();
...@@ -71,24 +71,24 @@ export default function inputMethodJSUnit() { ...@@ -71,24 +71,24 @@ export default function inputMethodJSUnit() {
it('inputmethoh_test_005', 0, async function (done) { it('inputmethoh_test_005', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController(); let inputMethodCtrl = inputMethod.getInputMethodController();
console.info("inputmethoh_test_005 result:" + JSON.stringify(inputMethodCtrl)); console.info("====>inputmethoh_test_005 result:" + JSON.stringify(inputMethodCtrl));
inputMethodCtrl.stopInput((res) => { inputMethodCtrl.stopInput((res) => {
console.info("inputmethoh_test_005 stopInput result----" + res); console.info("====>inputmethoh_test_005 stopInput result----" + res);
}); });
done(); done();
}); });
it('inputmethoh_test_006', 0, async function (done) { it('inputmethoh_test_006', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController(); let inputMethodCtrl = inputMethod.getInputMethodController();
console.info("inputmethoh_test_006 result:" + JSON.stringify(inputMethodCtrl)); console.info("====>inputmethoh_test_006 result:" + JSON.stringify(inputMethodCtrl));
inputMethodCtrl.stopInput().then(data => { inputMethodCtrl.stopInput().then(() => {
console.info("inputmethoh_test_006 stopInput result----" + data);
expect(data == true).assertTrue();
}).catch(err => {
console.info("inputmethoh_test_006 stopInput is err: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
});
done(); done();
}).catch((err) => {
console.info("====>inputmethoh_test_006 stopInput is err: " + JSON.stringify(err));
expect().assertEqual();
done();
});
}); });
/* /*
...@@ -97,11 +97,11 @@ export default function inputMethodJSUnit() { ...@@ -97,11 +97,11 @@ export default function inputMethodJSUnit() {
* @tc.desc: Verify Max_ TYPE_ NUM * @tc.desc: Verify Max_ TYPE_ NUM
*/ */
it('inputmethod_test_MAX_TYPE_NUM_001', 0, async function (done) { it('inputmethod_test_MAX_TYPE_NUM_001', 0, async function (done) {
console.info("************* inputmethod_test_MAX_TYPE_NUM_001 Test start*************"); console.info("====>************* inputmethod_test_MAX_TYPE_NUM_001 Test start*************");
let inputMethodSetting = inputMethod.MAX_TYPE_NUM; let inputMethodSetting = inputMethod.MAX_TYPE_NUM;
console.info("inputmethod_test_001 result:" + inputMethodSetting); console.info("====>inputmethod_test_001 result:" + inputMethodSetting);
expect(inputMethodSetting != null).assertTrue(); expect(inputMethodSetting !== null).assertTrue();
console.info("************* inputmethod_test_MAX_TYPE_NUM_001 Test end*************"); console.info("====>************* inputmethod_test_MAX_TYPE_NUM_001 Test end*************");
done(); done();
}); });
...@@ -112,7 +112,7 @@ export default function inputMethodJSUnit() { ...@@ -112,7 +112,7 @@ export default function inputMethodJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputmethod_test_switchInputMethod_001', 0, async function (done) { it('inputmethod_test_switchInputMethod_001', 0, async function (done) {
console.info("************* inputmethod_test_switchInputMethod_001 Test start*************"); console.info("====>************* inputmethod_test_switchInputMethod_001 Test start*************");
let inputMethodProperty = { let inputMethodProperty = {
packageName: "com.example.kikakeyboard", packageName: "com.example.kikakeyboard",
methodId: "ServiceExtAbility", methodId: "ServiceExtAbility",
...@@ -121,13 +121,13 @@ export default function inputMethodJSUnit() { ...@@ -121,13 +121,13 @@ export default function inputMethodJSUnit() {
extra:{} extra:{}
} }
inputMethod.switchInputMethod(inputMethodProperty).then(data => { inputMethod.switchInputMethod(inputMethodProperty).then(data => {
console.info("inputmethod_test_switchInputMethod_001 data:" + data) console.info("====>inputmethod_test_switchInputMethod_001 data:" + data)
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}).catch( err=> { }).catch( err=> {
console.info("inputmethod_test_switchInputMethod_001 err:" + err) console.info("====>inputmethod_test_switchInputMethod_001 err:" + err)
expect().assertFail(); expect().assertFail();
}) })
console.info("************* inputmethod_test_switchInputMethod_001 Test end*************"); console.info("====>************* inputmethod_test_switchInputMethod_001 Test end*************");
done(); done();
}); });
...@@ -138,7 +138,7 @@ export default function inputMethodJSUnit() { ...@@ -138,7 +138,7 @@ export default function inputMethodJSUnit() {
* @tc.level 2 * @tc.level 2
*/ */
it('inputmethod_test_switchInputMethod_002', 0, async function (done) { it('inputmethod_test_switchInputMethod_002', 0, async function (done) {
console.info("************* inputmethod_test_switchInputMethod_002 Test start*************"); console.info("====>************* inputmethod_test_switchInputMethod_002 Test start*************");
let inputMethodProperty = { let inputMethodProperty = {
packageName: "com.example.kikakeyboard", packageName: "com.example.kikakeyboard",
methodId: "ServiceExtAbility", methodId: "ServiceExtAbility",
...@@ -148,13 +148,13 @@ export default function inputMethodJSUnit() { ...@@ -148,13 +148,13 @@ export default function inputMethodJSUnit() {
} }
inputMethod.switchInputMethod(inputMethodProperty, (err, data)=>{ inputMethod.switchInputMethod(inputMethodProperty, (err, data)=>{
if(err){ if(err){
console.info("inputmethod_test_switchInputMethod_002 error:" + err); console.info("====>inputmethod_test_switchInputMethod_002 error:" + err);
expect().assertFail(); expect().assertFail();
} }
console.info("inputmethod_test_switchInputMethod_002 data:" + data) console.info("====>inputmethod_test_switchInputMethod_002 data:" + data)
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
console.info("************* inputmethod_test_switchInputMethod_002 Test end*************"); console.info("====>************* inputmethod_test_switchInputMethod_002 Test end*************");
done(); done();
}); });
...@@ -166,17 +166,16 @@ export default function inputMethodJSUnit() { ...@@ -166,17 +166,16 @@ export default function inputMethodJSUnit() {
*/ */
it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) { it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard((err, data)=>{ try{
if(data == undefined){ inputMethodCtrl.showSoftKeyboard((err)=>{
console.info("showSoftKeyboard callbace success" ); expect(err.code).assertEqual('12800003')
expect(true).assertTrue(); console.info("====>************* inputmethod_test_showSoftKeyboard_001 Test end*************");
}else{ done();
console.info('showSoftKeyboard callbace failed : ' + JSON.stringify(err))
expect().assertFail();
}
}); });
console.info("************* inputmethod_test_showSoftKeyboard_001 Test end*************"); }catch(err){
expect().assertFail()
done(); done();
}
}); });
/* /*
...@@ -187,15 +186,15 @@ export default function inputMethodJSUnit() { ...@@ -187,15 +186,15 @@ export default function inputMethodJSUnit() {
*/ */
it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) { it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard().then((data) =>{ inputMethodCtrl.showSoftKeyboard().then(() =>{
console.info("showSoftKeyboard promise success" ); expect().assertFail()
expect(true).assertTrue(); done();
}).catch((err) => { }).catch((err) => {
console.info('showSoftKeyboard promise failed : ' + JSON.stringify(err)) console.info('====>showSoftKeyboard promise failed : ' + JSON.stringify(err))
expect().assertFail(); expect(err.code).assertEqual('12800003')
}) console.info("====>************* inputmethod_test_showSoftKeyboard_002 Test end*************");
console.info("************* inputmethod_test_showSoftKeyboard_002 Test end*************");
done(); done();
})
}); });
/* /*
...@@ -206,17 +205,17 @@ export default function inputMethodJSUnit() { ...@@ -206,17 +205,17 @@ export default function inputMethodJSUnit() {
*/ */
it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) { it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard((err, data)=>{ try{
if(data == undefined){ inputMethodCtrl.hideSoftKeyboard((err)=>{
console.info("hideSoftKeyboard callbace success" ); console.info('====>hideSoftKeyboard callbacek failed : ' + JSON.stringify(err))
expect(true).assertTrue(); expect(err.code).assertEqual('12800003')
}else{ console.info("====>************* inputmethod_test_hideSoftKeyboard_001 Test end*************");
console.info('hideSoftKeyboard callbace failed : ' + JSON.stringify(err)) done();
})
}catch(err){
expect().assertFail(); expect().assertFail();
}
});
console.info("************* inputmethod_test_hideSoftKeyboard_001 Test end*************");
done(); done();
}
}); });
/* /*
...@@ -227,15 +226,15 @@ export default function inputMethodJSUnit() { ...@@ -227,15 +226,15 @@ export default function inputMethodJSUnit() {
*/ */
it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) { it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController() let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard().then((data) =>{ inputMethodCtrl.hideSoftKeyboard().then(() =>{
console.info("hideSoftKeyboard promise success" );
expect(true).assertTrue();
}).catch((err) => {
console.info('hideSoftKeyboard promise failed : ' + JSON.stringify(err))
expect().assertFail(); expect().assertFail();
})
console.info("************* inputmethod_test_hideSoftKeyboard_002 Test end*************");
done(); done();
}).catch((err) => {
console.info('====>hideSoftKeyboard promise failed : ' + JSON.stringify(err))
expect(err.code).assertEqual('12800003');
console.info("====>************* inputmethod_test_hideSoftKeyboard_002 Test end*************");
done();
})
}); });
/* /*
...@@ -246,12 +245,12 @@ export default function inputMethodJSUnit() { ...@@ -246,12 +245,12 @@ export default function inputMethodJSUnit() {
*/ */
it('inputmethod_test_getCurrentInputMethod_001', 0, async function (done) { it('inputmethod_test_getCurrentInputMethod_001', 0, async function (done) {
let currentIme = inputMethod.getCurrentInputMethod(); let currentIme = inputMethod.getCurrentInputMethod();
console.info("inputmethod_test_getCurrentInputMethod_001 currentIme---" + JSON.stringify(currentIme)); console.info("====>inputmethod_test_getCurrentInputMethod_001 currentIme---" + JSON.stringify(currentIme));
console.info(currentIme.packageName); console.info(currentIme.packageName);
console.info(currentIme.methodId); console.info(currentIme.methodId);
expect(currentIme.packageName != null).assertTrue(); expect(currentIme.packageName !== null).assertTrue();
expect(currentIme.methodId != null).assertTrue(); expect(currentIme.methodId !== null).assertTrue();
console.info("************* inputmethod_test_getCurrentInputMethod_001 Test end*************"); console.info("====>************* inputmethod_test_getCurrentInputMethod_001 Test end*************");
done(); done();
}); });
...@@ -264,13 +263,13 @@ export default function inputMethodJSUnit() { ...@@ -264,13 +263,13 @@ export default function inputMethodJSUnit() {
*/ */
it('inputmethod_test_getInputMethods_001', 0, async function (done) { it('inputmethod_test_getInputMethods_001', 0, async function (done) {
let inputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
console.info("inputmethod_test_getInputMethods_001 result:" + JSON.stringify(inputMethodSetting)); console.info("====>inputmethod_test_getInputMethods_001 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.getInputMethods(true, (err, arr) => { inputMethodSetting.getInputMethods(true, (err, arr) => {
if (err) { if (err) {
console.error("inputmethod_test_getInputMethods_001 failed because: " + JSON.stringify(err)); console.error("inputmethod_test_getInputMethods_001 failed because: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}; };
console.info("inputmethod_test_getInputMethods_001 listInputMethod result---" + JSON.stringify(arr)); console.info("====>inputmethod_test_getInputMethods_001 listInputMethod result---" + JSON.stringify(arr));
expect(arr != null).assertTrue(); expect(arr != null).assertTrue();
}); });
done(); done();
...@@ -285,13 +284,13 @@ export default function inputMethodJSUnit() { ...@@ -285,13 +284,13 @@ export default function inputMethodJSUnit() {
*/ */
it('inputmethod_test_getInputMethods_002', 0, async function (done) { it('inputmethod_test_getInputMethods_002', 0, async function (done) {
let inputMethodSetting = inputMethod.getInputMethodSetting(); let inputMethodSetting = inputMethod.getInputMethodSetting();
console.info("inputmethod_test_getInputMethods_002 result:" + JSON.stringify(inputMethodSetting)); console.info("====>inputmethod_test_getInputMethods_002 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.getInputMethods(false, (err, arr) => { inputMethodSetting.getInputMethods(false, (err, arr) => {
if (err) { if (err) {
console.error("inputmethod_test_getInputMethods_002 failed because: " + JSON.stringify(err)); console.error("inputmethod_test_getInputMethods_002 failed because: " + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}; };
console.info("inputmethod_test_getInputMethods_002 listInputMethod result---" + JSON.stringify(arr)); console.info("====>inputmethod_test_getInputMethods_002 listInputMethod result---" + JSON.stringify(arr));
expect(arr != null).assertTrue(); expect(arr != null).assertTrue();
}); });
done(); done();
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 brightness from '@system.brightness'; import brightness from '@system.brightness';
import { describe, it, expect } from '@ohos/hypium'; import { describe, it, expect } from '@ohos/hypium';
...@@ -20,44 +19,25 @@ const INPUT_ERROR_CODE_CODE = 202; ...@@ -20,44 +19,25 @@ const INPUT_ERROR_CODE_CODE = 202;
const SET_VALUE_MSG = "value is not an available number"; const SET_VALUE_MSG = "value is not an available number";
const SET_MODE_MSG = "value is not an available number"; const SET_MODE_MSG = "value is not an available number";
export default function SystemDisplayTest() { export default async function SystemDisplayTest() {
describe('SystemDisplayTest', function () { describe('SystemDisplayTest', async function () {
console.log("*************System SystemDisplay Unit Test Begin*************"); console.log("System SystemDisplay Unit Test Begin");
/** /**
* @tc.number system_display_js_0100 * @tc.number system_display_js_0100
* @tc.name get_value_success * @tc.name get_value_success
* @tc.desc Get brightness success * @tc.desc Get brightness success
*/ */
it('get_value_success', 0, function () { it('get_value_success', 0, async function (done) {
let currValue = 100; let currValue = 100;
let setValue = 120;
brightness.getValue({ brightness.getValue({
success: (data) => { success: (data) => {
currValue = data.value; currValue = data.value;
let value = (data.value > 0) && (data.value <= 255); let value = (data.value > 0) && (data.value <= 255);
expect(value).assertTrue(); expect(value).assertTrue();
done();
} }
}); });
brightness.setValue({
value: setValue
});
brightness.getValue({
success: (data) => {
expect(setValue === data.value).assertTrue();
},
fail: (data, code) => {
console.log("get_value_success, data: " + data + ", code: " + code);
expect().assertFail();
},
complete: () => {
console.log("The device information is obtained successfully. Procedure");
}
});
brightness.setValue({
value: currValue
});
}); });
/** /**
...@@ -65,14 +45,16 @@ describe('SystemDisplayTest', function () { ...@@ -65,14 +45,16 @@ describe('SystemDisplayTest', function () {
* @tc.name get_value_success_not_must_test * @tc.name get_value_success_not_must_test
* @tc.desc Get brightness * @tc.desc Get brightness
*/ */
it('get_status_test_success_not_must', 0, function () { it('get_status_test_success_not_must', 0, async function (done) {
brightness.getValue({ brightness.getValue({
fail: (data, code) => { fail: (data, code) => {
console.log("get_status_test_success_not_must, data: " + data + ", code: " + code); console.log("get_status_test_success_not_must, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
done();
}, },
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
}) })
...@@ -82,10 +64,11 @@ describe('SystemDisplayTest', function () { ...@@ -82,10 +64,11 @@ describe('SystemDisplayTest', function () {
* @tc.name get_value_fail_not_must_test * @tc.name get_value_fail_not_must_test
* @tc.desc Get brightness * @tc.desc Get brightness
*/ */
it('get_value_fail_not_must_test', 0, function () { it('get_value_fail_not_must_test', 0, async function (done) {
brightness.getValue({ brightness.getValue({
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
}); });
...@@ -95,9 +78,10 @@ describe('SystemDisplayTest', function () { ...@@ -95,9 +78,10 @@ describe('SystemDisplayTest', function () {
* @tc.name get_value_null_test * @tc.name get_value_null_test
* @tc.desc Get brightness * @tc.desc Get brightness
*/ */
it('get_status_test_fail_not_must', 0, function () { it('get_status_test_fail_not_must', 0, async function (done) {
brightness.getValue(); brightness.getValue();
expect(true).assertTrue(); expect(true).assertTrue();
done();
}) })
/** /**
...@@ -105,7 +89,7 @@ describe('SystemDisplayTest', function () { ...@@ -105,7 +89,7 @@ describe('SystemDisplayTest', function () {
* @tc.name set_value_success_all * @tc.name set_value_success_all
* @tc.desc Set brightness success * @tc.desc Set brightness success
*/ */
it('set_value_success_all', 0, function () { it('set_value_success_all', 0, async function (done) {
let setValue = 200; let setValue = 200;
let currValue = 100; let currValue = 100;
brightness.getValue({ brightness.getValue({
...@@ -120,21 +104,25 @@ describe('SystemDisplayTest', function () { ...@@ -120,21 +104,25 @@ describe('SystemDisplayTest', function () {
brightness.getValue({ brightness.getValue({
success: (data) => { success: (data) => {
expect(data.value === setValue).assertTrue(); expect(data.value === setValue).assertTrue();
brightness.setValue({
value: currValue,
success: function () {
done();
},
});
} }
}); });
}, },
fail: (data, code) => { fail: (data, code) => {
console.log("set_value_success_all, data: " + data + ", code: " + code); console.log("set_value_success_all, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
done();
}, },
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
brightness.setValue({
value: currValue
});
}); });
/** /**
...@@ -142,31 +130,35 @@ describe('SystemDisplayTest', function () { ...@@ -142,31 +130,35 @@ describe('SystemDisplayTest', function () {
* @tc.name set_value_success_value * @tc.name set_value_success_value
* @tc.desc Set brightness success * @tc.desc Set brightness success
*/ */
it('set_value_success_value', 0, function () { it('set_value_success_value', 0, async function (done) {
let setValue = 50;
let currValue = 100;
brightness.getValue({
success: (data) => {
currValue = data.value;
}
});
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: true, keepScreenOn: true,
success: function () { success: function () {
console.log('handling set keep screen on success.'); console.log('handling set keep screen on success.');
brightness.setValue({ value: setValue }); brightness.setValue({
}, value: 50,
fail: function (data, code) { success: function () {
console.error('handling set keep screen on fail, code:' + code + ', data: ' + data); setTimeout(() => {
}
});
brightness.getValue({ brightness.getValue({
success: (data) => { success: (data) => {
console.log("set_value_success_value, brightness: " + data.value); console.log("set_value_success_value, brightness: " + data.value);
expect(data.value === setValue).assertTrue(); expect(data.value === 50).assertTrue();
done();
} }
}); });
brightness.setValue({ value: currValue }); }, 1000);
},
});
},
fail: function (data, code) {
console.error('handling set keep screen on fail, code:' + code + ', data: ' + data);
done();
},
complete: function () {
console.error('handling set keep screen on complete.');
done();
},
});
}); });
/** /**
...@@ -174,18 +166,20 @@ describe('SystemDisplayTest', function () { ...@@ -174,18 +166,20 @@ describe('SystemDisplayTest', function () {
* @tc.name set_value_fail * @tc.name set_value_fail
* @tc.desc Set brightness fail * @tc.desc Set brightness fail
*/ */
it('set_value_fail', 0, function () { it('set_value_fail', 0, async function (done) {
let setValue = "50"; let setValue = "50";
brightness.setValue({ brightness.setValue({
value: setValue, value: setValue,
success: () => { success: () => {
console.log("set_value_fail success"); console.log("set_value_fail success");
expect().assertFail(); expect().assertFail();
done();
}, },
fail: (data, code) => { fail: (data, code) => {
console.log("set_value_fail, data: " + data + ", code: " + code); console.log("set_value_fail, data: " + data + ", code: " + code);
expect(code === NPUT_ERROR_CODE).assertTrue(); expect(code === INPUT_ERROR_CODE_CODE).assertTrue();
expect(data === SET_VALUE_MSG).assertTrue(); expect(data === SET_VALUE_MSG).assertTrue();
done();
} }
}); });
}); });
...@@ -195,39 +189,14 @@ describe('SystemDisplayTest', function () { ...@@ -195,39 +189,14 @@ describe('SystemDisplayTest', function () {
* @tc.name get_mode_success * @tc.name get_mode_success
* @tc.desc Get mode success * @tc.desc Get mode success
*/ */
it('get_mode_success', 0, function () { it('get_mode_success', 0, async function (done) {
let modeVal = 0;
let exec = true;
brightness.getMode({ brightness.getMode({
success: (data) => { success: (data) => {
console.log("get_mode_success: get mode: " + data.mode); console.log("get_mode_success: get mode: " + data.mode);
modeVal = data.mode; expect(data.mode === 0 || data.mode === 1).assertTrue();
} done();
});
brightness.setMode({
mode: modeVal ? 0 : 1,
fail: (data, code) => {
console.log("get_mode_success, data: " + data + ", code: " + code);
exec = false;
}
})
if (!exec) {
return;
}
brightness.getMode({
success: (data) => {
expect(data.mode === (modeVal ? 0 : 1)).assertTrue();
},
fail: (data, code) => {
console.log("get_mode_success, data: " + data + ", code: " + code);
expect().assertFail();
},
complete: () => {
console.log("The device information is obtained successfully. Procedure");
} }
}); });
brightness.setMode({ mode: modeVal });
}) })
/** /**
...@@ -235,14 +204,16 @@ describe('SystemDisplayTest', function () { ...@@ -235,14 +204,16 @@ describe('SystemDisplayTest', function () {
* @tc.name get_mode_success_null * @tc.name get_mode_success_null
* @tc.desc Get mode success is null * @tc.desc Get mode success is null
*/ */
it('get_mode_success_null', 0, function () { it('get_mode_success_null', 0, async function (done) {
brightness.getMode({ brightness.getMode({
fail: (data, code) => { fail: (data, code) => {
console.log("get_mode_success_null, data: " + data + ", code: " + code); console.log("get_mode_success_null, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
done();
}, },
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
}); });
...@@ -252,31 +223,24 @@ describe('SystemDisplayTest', function () { ...@@ -252,31 +223,24 @@ describe('SystemDisplayTest', function () {
* @tc.name set_mode_success * @tc.name set_mode_success
* @tc.desc set mode success * @tc.desc set mode success
*/ */
it('set_mode_success', 0, function () { it('set_mode_success', 0, async function (done) {
let modeVal = 0;
brightness.getMode({
success: (data) => {
modeVal = data.mode;
}
});
brightness.setMode({ brightness.setMode({
mode: modeVal ? 0 : 1, mode: 0,
success: () => { success: () => {
console.log("set_mode_success success"); console.log("set_mode_success success");
brightness.getMode({ brightness.getMode({
success: (data) => { success: (data) => {
console.log("set_mode_success, data: " + data.mode); console.log("set_mode_success, data: " + data.mode);
expect(data.mode === (modeVal ? 0 : 1)).assertTrue(); expect(data.mode === 0).assertTrue();
done();
} }
}); });
}, },
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
brightness.setMode({ mode: modeVal });
}); });
/** /**
...@@ -284,19 +248,22 @@ describe('SystemDisplayTest', function () { ...@@ -284,19 +248,22 @@ describe('SystemDisplayTest', function () {
* @tc.name set_mode_fail * @tc.name set_mode_fail
* @tc.desc set mode fail * @tc.desc set mode fail
*/ */
it('set_mode_fail', 0, function () { it('set_mode_fail', 0, async function (done) {
brightness.setMode({ brightness.setMode({
mode: "0", mode: "0",
success: () => { success: () => {
expect().assertFail(); expect().assertFail();
done();
}, },
fail: (data, code) => { fail: (data, code) => {
console.log("set_mode_fail, data: " + data + ", code: " + code); console.log("set_mode_fail, data: " + data + ", code: " + code);
expect(code === INPUT_ERROR_CODE_CODE).assertTrue(); expect(code === INPUT_ERROR_CODE_CODE).assertTrue();
expect(data === SET_MODE_MSG).assertTrue(); expect(data === SET_MODE_MSG).assertTrue();
done();
}, },
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
}); });
...@@ -306,18 +273,21 @@ describe('SystemDisplayTest', function () { ...@@ -306,18 +273,21 @@ describe('SystemDisplayTest', function () {
* @tc.name set_keep_screen_on_true * @tc.name set_keep_screen_on_true
* @tc.desc set keep screen on true * @tc.desc set keep screen on true
*/ */
it('set_keep_screen_on_true', 0, async function () { it('set_keep_screen_on_true', 0, async function (done) {
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: true, keepScreenOn: true,
success: () => { success: () => {
expect().assertTrue(); expect(true).assertTrue();
done();
}, },
fail: (data, code) => { fail: (data, code) => {
console.log("set_keep_screen_on, data: " + data + ", code: " + code); console.log("set_keep_screen_on, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
done();
}, },
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
}); });
...@@ -327,20 +297,23 @@ describe('SystemDisplayTest', function () { ...@@ -327,20 +297,23 @@ describe('SystemDisplayTest', function () {
* @tc.name set_keep_screen_on_false * @tc.name set_keep_screen_on_false
* @tc.desc set keep screen on false * @tc.desc set keep screen on false
*/ */
it('set_keep_screen_on_false', 0, async function () { it('set_keep_screen_on_false', 0, async function (done) {
brightness.setKeepScreenOn({ brightness.setKeepScreenOn({
keepScreenOn: false, keepScreenOn: false,
success: () => { success: () => {
expect().assertTrue(); expect(true).assertTrue();
done();
}, },
fail: (data, code) => { fail: (data, code) => {
console.log("set_keep_screen_on_false, data: " + data + ", code: " + code); console.log("set_keep_screen_on_false, data: " + data + ", code: " + code);
expect().assertFail(); expect().assertFail();
done();
}, },
complete: () => { complete: () => {
console.log("The device information is obtained successfully. Procedure"); console.log("The device information is obtained successfully. Procedure");
done();
} }
}); });
}); });
}) })
} }
\ No newline at end of file
...@@ -19,34 +19,34 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " ...@@ -19,34 +19,34 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "
export default function requestDownloadJSUnit() { export default function requestDownloadJSUnit() {
describe('requestDownloadTest', function () { describe('requestDownloadTest', 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: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/ */
beforeAll(function () { 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: Prerequisites at the test case level, which are executed before each test case is executed.
*/ */
beforeEach(function () { 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: Test case-level clearance conditions, which are executed after each test case is executed.
*/ */
afterEach(function () { 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: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/ */
afterAll(function () { afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition is executed'); console.info('====>afterAll: Test suite-level cleanup condition is executed');
}); });
let downloadTask; let downloadTask;
...@@ -72,18 +72,18 @@ export default function requestDownloadJSUnit() { ...@@ -72,18 +72,18 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 is starting-----------------------");
try { try {
request.download(downloadConfig, (data)=>{ request.download(downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
}); });
} catch (err) { } catch (err) {
console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 error: " + err);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 end-----------------------");
done(); done();
}); });
...@@ -95,16 +95,16 @@ export default function requestDownloadJSUnit() { ...@@ -95,16 +95,16 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_PROMISE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_PROMISE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 is starting-----------------------");
request.download(downloadConfig).then(data => { request.download(downloadConfig).then(data => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
}).catch(err => { }).catch(err => {
console.error("SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err);
expect().assertFail(); expect().assertFail();
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 end-----------------------");
done(); done();
}); });
...@@ -116,20 +116,20 @@ export default function requestDownloadJSUnit() { ...@@ -116,20 +116,20 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 downloadTask: " + downloadTask);
expect(true).assertEqual(downloadTask != undefined); expect(true).assertEqual(downloadTask != undefined);
downloadTask.on('progress', (data1, data2) => { downloadTask.on('progress', (data1, data2) => {
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1);
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2);
expect(true).assertEqual(data1 != undefined); expect(true).assertEqual(data1 != undefined);
expect(true).assertEqual(data2 != undefined); expect(true).assertEqual(data2 != undefined);
}); });
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 end-----------------------");
done(); done();
}); });
...@@ -141,21 +141,21 @@ export default function requestDownloadJSUnit() { ...@@ -141,21 +141,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask);
expect(true).assertEqual(downloadTask != undefined);
try{ try{
expect(true).assertEqual(downloadTask != undefined);
downloadTask.on('complete', () => { downloadTask.on('complete', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_CALLBACK_0002 task completed.') console.info('====>SUB_REQUEST_DOWNLOAD_API_CALLBACK_0002 task completed.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0002 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0002 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 end-----------------------");
done(); done();
}); });
...@@ -167,21 +167,21 @@ export default function requestDownloadJSUnit() { ...@@ -167,21 +167,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask);
expect(true).assertEqual(downloadTask != undefined);
try{ try{
expect(true).assertEqual(downloadTask != undefined);
downloadTask.on('pause', () => { downloadTask.on('pause', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 task pause.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 task pause.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 end-----------------------");
done(); done();
}); });
...@@ -193,21 +193,22 @@ export default function requestDownloadJSUnit() { ...@@ -193,21 +193,22 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true);
try{ try{
expect(downloadTask != undefined).assertEqual(true);
downloadTask.on('remove', () => { downloadTask.on('remove', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 task remove.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 task remove.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 end-----------------------");
done(); done();
}); });
...@@ -219,21 +220,21 @@ export default function requestDownloadJSUnit() { ...@@ -219,21 +220,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.on('remove', () => { downloadTask.on('remove', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 task remove.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 task remove.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 end-----------------------");
done(); done();
}); });
...@@ -245,19 +246,19 @@ export default function requestDownloadJSUnit() { ...@@ -245,19 +246,19 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.off('progress', (data1, data2) => { downloadTask.off('progress', (data1, data2) => {
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data1 =" + data1); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data1 =" + data1);
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data2 =" + data2); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data2 =" + data2);
expect(data1 != undefined).assertEqual(true); expect(data1 != undefined).assertEqual(true);
expect(data2 != undefined).assertEqual(true); expect(data2 != undefined).assertEqual(true);
}); });
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 end-----------------------");
done(); done();
}); });
...@@ -269,21 +270,21 @@ export default function requestDownloadJSUnit() { ...@@ -269,21 +270,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.off('complete', () => { downloadTask.off('complete', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 task complete.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------");
done(); done();
}); });
...@@ -295,21 +296,21 @@ export default function requestDownloadJSUnit() { ...@@ -295,21 +296,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.off('pause', () => { downloadTask.off('pause', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task pause.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 task pause.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------");
done(); done();
}); });
...@@ -321,21 +322,21 @@ export default function requestDownloadJSUnit() { ...@@ -321,21 +322,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.off('remove', () => { downloadTask.off('remove', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 task remove.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 task remove.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 end-----------------------");
done(); done();
}); });
...@@ -347,21 +348,21 @@ export default function requestDownloadJSUnit() { ...@@ -347,21 +348,21 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.off('pause', () => { downloadTask.off('pause', () => {
console.info('SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 task complete.') console.info('====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 task complete.')
}); });
}catch(err){ }catch(err){
console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err); console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err);
expect().assertFail(); expect().assertFail();
} }
}); });
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------");
done(); done();
}); });
...@@ -373,10 +374,10 @@ export default function requestDownloadJSUnit() { ...@@ -373,10 +374,10 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.remove((err, data)=>{ downloadTask.remove((err, data)=>{
if(err) { if(err) {
...@@ -384,7 +385,7 @@ export default function requestDownloadJSUnit() { ...@@ -384,7 +385,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
} }
if (data) { if (data) {
console.info('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Download task removed.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Download task removed.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
} else { } else {
console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.');
...@@ -392,7 +393,7 @@ export default function requestDownloadJSUnit() { ...@@ -392,7 +393,7 @@ export default function requestDownloadJSUnit() {
} }
}); });
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 end-----------------------");
done(); done();
}); });
...@@ -404,14 +405,14 @@ export default function requestDownloadJSUnit() { ...@@ -404,14 +405,14 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.remove().then(data => { downloadTask.remove().then(data => {
if (data) { if (data) {
console.info('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Download task removed.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Download task removed.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
} else { } else {
console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.');
...@@ -422,7 +423,7 @@ export default function requestDownloadJSUnit() { ...@@ -422,7 +423,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
}) })
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 end-----------------------");
done(); done();
}); });
...@@ -434,14 +435,14 @@ export default function requestDownloadJSUnit() { ...@@ -434,14 +435,14 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.pause(()=>{ downloadTask.pause(()=>{
console.info('SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 Download task pause success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 Download task pause success.');
expect(true).assertTrue(); expect(true).assertTrue();
}) })
}catch(err){ }catch(err){
...@@ -449,7 +450,7 @@ export default function requestDownloadJSUnit() { ...@@ -449,7 +450,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
} }
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 end-----------------------");
done(); done();
}); });
...@@ -461,20 +462,20 @@ export default function requestDownloadJSUnit() { ...@@ -461,20 +462,20 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_PAUSE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.pause().then(() => { downloadTask.pause().then(() => {
console.info('SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 Download task pause success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 Download task pause success.');
expect(true).assertTrue(); expect(true).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('Failed to pause the download task pause. because: ' + JSON.stringify(err)); console.error('Failed to pause the download task pause. because: ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}) })
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 end-----------------------");
done(); done();
}); });
...@@ -486,14 +487,14 @@ export default function requestDownloadJSUnit() { ...@@ -486,14 +487,14 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.resume(()=>{ downloadTask.resume(()=>{
console.info('SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 Download task resume success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 Download task resume success.');
expect(true).assertTrue(); expect(true).assertTrue();
}) })
}catch(err){ }catch(err){
...@@ -501,7 +502,7 @@ export default function requestDownloadJSUnit() { ...@@ -501,7 +502,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
} }
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 end-----------------------");
done(); done();
}); });
...@@ -513,20 +514,20 @@ export default function requestDownloadJSUnit() { ...@@ -513,20 +514,20 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_REMUSE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.resume().then(() => { downloadTask.resume().then(() => {
console.info('SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 Download task resume success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 Download task resume success.');
expect(true).assertTrue(); expect(true).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('Failed to pause the download task resume. because: ' + JSON.stringify(err)); console.error('Failed to pause the download task resume. because: ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
}) })
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 end-----------------------");
done(); done();
}); });
...@@ -538,10 +539,10 @@ export default function requestDownloadJSUnit() { ...@@ -538,10 +539,10 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERY_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERY_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
try{ try{
downloadTask.query((err, downloadInfo)=>{ downloadTask.query((err, downloadInfo)=>{
...@@ -549,17 +550,17 @@ export default function requestDownloadJSUnit() { ...@@ -549,17 +550,17 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 Failed to query: ' + JSON.stringify(err)); console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 Failed to query: ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
} else { } else {
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes);
expect(true).assertTrue(); expect(true).assertTrue();
} }
}) })
...@@ -568,7 +569,7 @@ export default function requestDownloadJSUnit() { ...@@ -568,7 +569,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
} }
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 end-----------------------");
done(); done();
}); });
...@@ -580,27 +581,27 @@ export default function requestDownloadJSUnit() { ...@@ -580,27 +581,27 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERY_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERY_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 is starting-----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.query().then((err, downloadInfo)=>{ downloadTask.query().then((err, downloadInfo)=>{
if(err) { if(err) {
console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0002 Failed to query: ' + JSON.stringify(err)); console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0002 Failed to query: ' + JSON.stringify(err));
expect().assertFail(); expect().assertFail();
} else { } else {
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.description);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadedBytes);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadId);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.failedReason);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.fileName);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.filePath);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.pausedReason);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.status);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.targetURI);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTitle);
console.info('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes);
expect(true).assertTrue(); expect(true).assertTrue();
} }
}).catch(err => { }).catch(err => {
...@@ -608,7 +609,7 @@ export default function requestDownloadJSUnit() { ...@@ -608,7 +609,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
}) })
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 end-----------------------");
done(); done();
}); });
...@@ -620,10 +621,10 @@ export default function requestDownloadJSUnit() { ...@@ -620,10 +621,10 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001', 0, async function (done) {
console.info("---------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 is starting---------------------"); console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 is starting---------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.queryMimeType((err, data)=>{ downloadTask.queryMimeType((err, data)=>{
if(err) { if(err) {
...@@ -631,7 +632,7 @@ export default function requestDownloadJSUnit() { ...@@ -631,7 +632,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
} }
if (data) { if (data) {
console.info('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Download task queryMimeType.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Download task queryMimeType.');
expect(typeof data == "string").assertTrue(); expect(typeof data == "string").assertTrue();
} else { } else {
console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Failed to queryMimeType the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Failed to queryMimeType the download task.');
...@@ -639,7 +640,7 @@ export default function requestDownloadJSUnit() { ...@@ -639,7 +640,7 @@ export default function requestDownloadJSUnit() {
} }
}); });
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 end-----------------------");
done(); done();
}); });
...@@ -651,14 +652,14 @@ export default function requestDownloadJSUnit() { ...@@ -651,14 +652,14 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002', 0, async function (done) {
console.info("-------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 is starting----------------------"); console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 is starting----------------------");
request.download( downloadConfig, (data)=>{ request.download( downloadConfig, (data)=>{
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.queryMimeType().then(data => { downloadTask.queryMimeType().then(data => {
if (data) { if (data) {
console.info('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Download task queryMimeType.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Download task queryMimeType.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
} else { } else {
console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Failed to queryMimeType the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Failed to queryMimeType the download task.');
...@@ -669,7 +670,7 @@ export default function requestDownloadJSUnit() { ...@@ -669,7 +670,7 @@ export default function requestDownloadJSUnit() {
expect().assertFail(); expect().assertFail();
}) })
}) })
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 end-----------------------");
done(); done();
}); });
...@@ -681,18 +682,18 @@ export default function requestDownloadJSUnit() { ...@@ -681,18 +682,18 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DELETE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DELETE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_delete_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_delete_0001 is starting-----------------------");
try { try {
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.delete((err, data) => { downloadTask.delete((err, data) => {
if (err) { if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.');
expect().assertFail(); expect().assertFail();
} }
console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.');
expect(typeof data == "boolean").assertTrue(); expect(typeof data == "boolean").assertTrue();
}); });
}) })
...@@ -700,7 +701,7 @@ export default function requestDownloadJSUnit() { ...@@ -700,7 +701,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0001 end-----------------------");
done(); done();
}); });
...@@ -712,17 +713,17 @@ export default function requestDownloadJSUnit() { ...@@ -712,17 +713,17 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_DELETE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_DELETE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 is starting-----------------------");
try { try {
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.delete().then(data => { downloadTask.delete().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}).catch((err) => { }).catch((err) => {
console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.');
expect().assertFail(); expect().assertFail();
}) })
}) })
...@@ -730,7 +731,7 @@ export default function requestDownloadJSUnit() { ...@@ -730,7 +731,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error'); console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error');
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------");
done(); done();
}); });
...@@ -742,18 +743,18 @@ export default function requestDownloadJSUnit() { ...@@ -742,18 +743,18 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 is starting-----------------------");
try { try {
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.suspend((err, data) => { downloadTask.suspend((err, data) => {
if (err) { if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.');
expect().assertFail(); expect().assertFail();
} }
console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
}) })
...@@ -762,7 +763,7 @@ export default function requestDownloadJSUnit() { ...@@ -762,7 +763,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 end-----------------------");
done(); done();
}); });
...@@ -774,17 +775,17 @@ export default function requestDownloadJSUnit() { ...@@ -774,17 +775,17 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 is starting-----------------------");
try { try {
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.suspend().then(data => { downloadTask.suspend().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}).catch((err) => { }).catch((err) => {
console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Failed to suspend the download task.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Failed to suspend the download task.');
expect().assertFail(); expect().assertFail();
}) })
}) })
...@@ -793,7 +794,7 @@ export default function requestDownloadJSUnit() { ...@@ -793,7 +794,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 end-----------------------");
done(); done();
}); });
...@@ -805,18 +806,18 @@ export default function requestDownloadJSUnit() { ...@@ -805,18 +806,18 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 is starting-----------------------");
try{ try{
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.restore((err, data) => { downloadTask.restore((err, data) => {
if (err) { if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.');
expect().assertFail(); expect().assertFail();
} }
console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Download restore success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Download restore success.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}); });
}); });
...@@ -824,7 +825,7 @@ export default function requestDownloadJSUnit() { ...@@ -824,7 +825,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 end-----------------------");
done(); done();
}); });
...@@ -836,17 +837,17 @@ export default function requestDownloadJSUnit() { ...@@ -836,17 +837,17 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 is starting-----------------------");
try{ try{
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.restore().then(data => { downloadTask.restore().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}).catch((err) => { }).catch((err) => {
console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.');
expect().assertFail(); expect().assertFail();
}); });
}); });
...@@ -854,7 +855,7 @@ export default function requestDownloadJSUnit() { ...@@ -854,7 +855,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 end-----------------------");
done(); done();
}); });
...@@ -866,18 +867,18 @@ export default function requestDownloadJSUnit() { ...@@ -866,18 +867,18 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001', 0, async function (done) {
console.info("---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 is starting---------------------"); console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 is starting---------------------");
try{ try{
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskInfo((err, data) => { downloadTask.getTaskInfo((err, data) => {
if (err) { if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.');
expect().assertFail(); expect().assertFail();
} }
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Download getTaskInfo success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Download getTaskInfo success.');
expect(typeof data == "object").assertTrue(); expect(typeof data == "object").assertTrue();
}); });
}); });
...@@ -885,7 +886,7 @@ export default function requestDownloadJSUnit() { ...@@ -885,7 +886,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 end-----------------------");
done(); done();
}); });
...@@ -897,14 +898,14 @@ export default function requestDownloadJSUnit() { ...@@ -897,14 +898,14 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002', 0, async function (done) {
console.info("-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 is starting----------------------"); console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 is starting----------------------");
try{ try{
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskInfo().then(data => { downloadTask.getTaskInfo().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.');
expect(typeof data == "object").assertTrue(); expect(typeof data == "object").assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.');
...@@ -915,7 +916,7 @@ export default function requestDownloadJSUnit() { ...@@ -915,7 +916,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 end-----------------------");
done(); done();
}); });
...@@ -927,18 +928,18 @@ export default function requestDownloadJSUnit() { ...@@ -927,18 +928,18 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001', 0, async function (done) {
console.info("---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 is starting---------------------"); console.info("====>---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 is starting---------------------");
try{ try{
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskMimeType((err, data) => { downloadTask.getTaskMimeType((err, data) => {
if (err) { if (err) {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Failed to getTaskMimeType the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Failed to getTaskMimeType the download task.');
expect().assertFail(); expect().assertFail();
} }
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Download task getTaskMimeType success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Download task getTaskMimeType success.');
expect(typeof data == "string").assertTrue(); expect(typeof data == "string").assertTrue();
}); });
}); });
...@@ -946,7 +947,7 @@ export default function requestDownloadJSUnit() { ...@@ -946,7 +947,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 end-----------------------");
done(); done();
}); });
...@@ -958,14 +959,14 @@ export default function requestDownloadJSUnit() { ...@@ -958,14 +959,14 @@ export default function requestDownloadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002', 0, async function (done) { it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002', 0, async function (done) {
console.info("-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 is starting----------------------"); console.info("====>-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 is starting----------------------");
try{ try{
request.download(downloadConfig, (data) => { request.download(downloadConfig, (data) => {
downloadTask = data; downloadTask = data;
console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask); console.info("====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask);
expect(downloadTask != undefined).assertEqual(true); expect(downloadTask != undefined).assertEqual(true);
downloadTask.getTaskMimeType().then(data => { downloadTask.getTaskMimeType().then(data => {
console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Download getTaskMimeType success.'); console.info('====>SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Download getTaskMimeType success.');
expect(typeof data == "string").assertTrue(); expect(typeof data == "string").assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Failed to getTaskMimeType the download task.'); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Failed to getTaskMimeType the download task.');
...@@ -976,7 +977,7 @@ export default function requestDownloadJSUnit() { ...@@ -976,7 +977,7 @@ export default function requestDownloadJSUnit() {
console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 end-----------------------");
done(); done();
}); });
......
...@@ -18,7 +18,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " ...@@ -18,7 +18,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "
export default function requestSystemJSUnit() { export default function requestSystemJSUnit() {
describe('requestSystemJSUnit', function () { describe('requestSystemJSUnit', function () {
console.info('****************start requestSystemTest*****************') console.info('====>****************start requestSystemTest*****************')
/** /**
* @tc.name: ohos.SUB_REQUESTSYSTEM_UPLOAD_API_0001 * @tc.name: ohos.SUB_REQUESTSYSTEM_UPLOAD_API_0001
...@@ -28,7 +28,7 @@ export default function requestSystemJSUnit() { ...@@ -28,7 +28,7 @@ export default function requestSystemJSUnit() {
* @tc.level: Level 1 * @tc.level: Level 1
*/ */
it('SUB_REQUESTSYSTEM_UPLOAD_API_0001', 0, async function (done) { it('SUB_REQUESTSYSTEM_UPLOAD_API_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUESTSYSTEM_UPLOAD_API_0001 start-----------------------"); console.info("====>-----------------------SUB_REQUESTSYSTEM_UPLOAD_API_0001 start-----------------------");
let UploadResponse = { let UploadResponse = {
code: 200, code: 200,
data: '', data: '',
...@@ -52,23 +52,23 @@ export default function requestSystemJSUnit() { ...@@ -52,23 +52,23 @@ export default function requestSystemJSUnit() {
}, },
], ],
success: function(UploadResponse) { success: function(UploadResponse) {
console.info('SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload success, code:' + UploadResponse.code); console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload success, code:' + UploadResponse.code);
}, },
fail: function(data, code) { fail: function(data, code) {
console.info('SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload fail'); console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload fail');
}, },
complete: function (){ complete: function (){
console.info('SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload complete'); console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload complete');
} }
} }
try{ try{
let result = request.upload(UploadRequestOptions); let result = request.upload(UploadRequestOptions);
console.info('SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload err:' + result); console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload err:' + result);
expect(true).assertEqual(true); expect(true).assertEqual(true);
}catch(err){ }catch(err){
console.info('SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload err:' + err); console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload err:' + err);
} }
console.info("-----------------------SUB_REQUESTSYSTEM_UPLOAD_API_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUESTSYSTEM_UPLOAD_API_0001 end-----------------------");
done(); done();
}); });
...@@ -80,7 +80,7 @@ export default function requestSystemJSUnit() { ...@@ -80,7 +80,7 @@ export default function requestSystemJSUnit() {
* @tc.level: Level 1 * @tc.level: Level 1
*/ */
it('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001', 0, async function (done) { it('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 start-----------------------"); console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 start-----------------------");
let DownloadResponse = { let DownloadResponse = {
token: "Hm_lpvt_1d6c34c1bc067f5746a5fca18d1c24ab" token: "Hm_lpvt_1d6c34c1bc067f5746a5fca18d1c24ab"
} }
...@@ -91,23 +91,23 @@ export default function requestSystemJSUnit() { ...@@ -91,23 +91,23 @@ export default function requestSystemJSUnit() {
header: '', header: '',
description: 'this is requeSystem download response', description: 'this is requeSystem download response',
success: function(DownloadResponse) { success: function(DownloadResponse) {
console.info('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001call success callback success: ' + DownloadResponse.token); console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001call success callback success: ' + DownloadResponse.token);
}, },
fail: function(data, code) { fail: function(data, code) {
console.info('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 handling fail'); console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 handling fail');
}, },
complete: function (){ complete: function (){
console.info('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete'); console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete');
} }
} }
try{ try{
let result = request.download(DownloadRequestOptions); let result = request.download(DownloadRequestOptions);
console.info('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 upload err:' + result); console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 upload err:' + result);
expect(result == null).assertEqual(true); expect(result == null).assertEqual(true);
}catch(err){ }catch(err){
console.info('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete' + err); console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete' + err);
} }
console.info("-----------------------SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 end-----------------------");
done(); done();
}); });
...@@ -119,27 +119,27 @@ export default function requestSystemJSUnit() { ...@@ -119,27 +119,27 @@ export default function requestSystemJSUnit() {
* @tc.level: Level 1 * @tc.level: Level 1
*/ */
it('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001', 0, async function (done) { it('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 start-----------------------"); console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 start-----------------------");
let OnDownloadCompleteResponse = { let OnDownloadCompleteResponse = {
uri: "http://www.path.com" uri: "http://www.path.com"
} }
let OnDownloadCompleteOptions = { let OnDownloadCompleteOptions = {
token: 'token-index', token: 'token-index',
success: function(OnDownloadCompleteResponse) { success: function(OnDownloadCompleteResponse) {
console.info('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download success,uri:' console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download success,uri:'
+ OnDownloadCompleteResponse.uri); + OnDownloadCompleteResponse.uri);
}, },
fail: function(data, code) { fail: function(data, code) {
console.info('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download fail'); console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download fail');
}, },
complete: function (){ complete: function (){
console.info('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download complete'); console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download complete');
} }
} }
let result = request.onDownloadComplete(OnDownloadCompleteOptions); let result = request.onDownloadComplete(OnDownloadCompleteOptions);
console.info('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 upload err:' + result); console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 upload err:' + result);
expect(result == null).assertEqual(true); expect(result == null).assertEqual(true);
console.info("-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 end-----------------------");
done(); done();
}); });
}) })
......
...@@ -19,34 +19,34 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " ...@@ -19,34 +19,34 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "
export default function requestUploadJSUnit() { export default function requestUploadJSUnit() {
describe('requestUploadTest', function () { describe('requestUploadTest', 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: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/ */
beforeAll(function () { 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: Prerequisites at the test case level, which are executed before each test case is executed.
*/ */
beforeEach(function () { 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: Test case-level clearance conditions, which are executed after each test case is executed.
*/ */
afterEach(function () { 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: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/ */
afterAll(function () { afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition is executed'); console.info('====>afterAll: Test suite-level cleanup condition is executed');
}); });
/** /**
...@@ -88,21 +88,21 @@ export default function requestUploadJSUnit() { ...@@ -88,21 +88,21 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_REQUEST_UPLOAD_API_0001', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0001 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_0001 request.NETWORK_MOBILE:" + request.NETWORK_MOBILE); console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.NETWORK_MOBILE:" + request.NETWORK_MOBILE);
expect(request.NETWORK_MOBILE).assertEqual(1); expect(request.NETWORK_MOBILE).assertEqual(1);
console.info("SUB_REQUEST_UPLOAD_API_0001 request.NETWORK_WIFI:" + request.NETWORK_WIFI); console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.NETWORK_WIFI:" + request.NETWORK_WIFI);
expect(request.NETWORK_WIFI).assertEqual(65536); expect(request.NETWORK_WIFI).assertEqual(65536);
console.info("SUB_REQUEST_UPLOAD_API_0001 request.ERROR_CANNOT_RESUME:" + request.ERROR_CANNOT_RESUME); console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.ERROR_CANNOT_RESUME:" + request.ERROR_CANNOT_RESUME);
expect(request.ERROR_CANNOT_RESUME).assertEqual(0); expect(request.ERROR_CANNOT_RESUME).assertEqual(0);
console.info("SUB_REQUEST_UPLOAD_API_0001 request.ERROR_DEVICE_NOT_FOUND:" + request.ERROR_DEVICE_NOT_FOUND); console.info("====>SUB_REQUEST_UPLOAD_API_0001 request.ERROR_DEVICE_NOT_FOUND:" + request.ERROR_DEVICE_NOT_FOUND);
expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(1); expect(request.ERROR_DEVICE_NOT_FOUND).assertEqual(1);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("SUB_REQUEST_UPLOAD_API_0001 error: " + err); console.error("SUB_REQUEST_UPLOAD_API_0001 error: " + err);
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0001 end-----------------------");
done(); done();
}); });
...@@ -115,21 +115,21 @@ export default function requestUploadJSUnit() { ...@@ -115,21 +115,21 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_REQUEST_UPLOAD_API_0002', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0002 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_0002 request.ERROR_FILE_ALREADY_EXISTS:" + request.ERROR_FILE_ALREADY_EXISTS); console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_FILE_ALREADY_EXISTS:" + request.ERROR_FILE_ALREADY_EXISTS);
expect(request.ERROR_FILE_ALREADY_EXISTS).assertEqual(2); expect(request.ERROR_FILE_ALREADY_EXISTS).assertEqual(2);
console.info("SUB_REQUEST_UPLOAD_API_0002 request.ERROR_FILE_ERROR:" + request.ERROR_FILE_ERROR); console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_FILE_ERROR:" + request.ERROR_FILE_ERROR);
expect(request.ERROR_FILE_ERROR).assertEqual(3); expect(request.ERROR_FILE_ERROR).assertEqual(3);
console.info("SUB_REQUEST_UPLOAD_API_0002 request.ERROR_HTTP_DATA_ERROR:" + request.ERROR_HTTP_DATA_ERROR); console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_HTTP_DATA_ERROR:" + request.ERROR_HTTP_DATA_ERROR);
expect(request.ERROR_HTTP_DATA_ERROR).assertEqual(4); expect(request.ERROR_HTTP_DATA_ERROR).assertEqual(4);
console.info("SUB_REQUEST_UPLOAD_API_0002 request.ERROR_INSUFFICIENT_SPACE:" + request.ERROR_INSUFFICIENT_SPACE); console.info("====>SUB_REQUEST_UPLOAD_API_0002 request.ERROR_INSUFFICIENT_SPACE:" + request.ERROR_INSUFFICIENT_SPACE);
expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(5); expect(request.ERROR_INSUFFICIENT_SPACE).assertEqual(5);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("SUB_REQUEST_UPLOAD_API_0002 error: " + err); console.error("SUB_REQUEST_UPLOAD_API_0002 error: " + err);
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0002 end-----------------------");
done(); done();
}); });
...@@ -142,21 +142,21 @@ export default function requestUploadJSUnit() { ...@@ -142,21 +142,21 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_REQUEST_UPLOAD_API_0003', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_0003', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0003 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0003 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_0003 request.ERROR_TOO_MANY_REDIRECTS:" + request.ERROR_TOO_MANY_REDIRECTS); console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.ERROR_TOO_MANY_REDIRECTS:" + request.ERROR_TOO_MANY_REDIRECTS);
expect(request.ERROR_TOO_MANY_REDIRECTS).assertEqual(6); expect(request.ERROR_TOO_MANY_REDIRECTS).assertEqual(6);
console.info("SUB_REQUEST_UPLOAD_API_0003 request.ERROR_UNHANDLED_HTTP_CODE:" + request.ERROR_UNHANDLED_HTTP_CODE); console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.ERROR_UNHANDLED_HTTP_CODE:" + request.ERROR_UNHANDLED_HTTP_CODE);
expect(request.ERROR_UNHANDLED_HTTP_CODE).assertEqual(7); expect(request.ERROR_UNHANDLED_HTTP_CODE).assertEqual(7);
console.info("SUB_REQUEST_UPLOAD_API_0003 request.ERROR_UNKNOWN:" + request.ERROR_UNKNOWN); console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.ERROR_UNKNOWN:" + request.ERROR_UNKNOWN);
expect(request.ERROR_UNKNOWN).assertEqual(8); expect(request.ERROR_UNKNOWN).assertEqual(8);
console.info("SUB_REQUEST_UPLOAD_API_0003 request.PAUSED_QUEUED_FOR_WIFI:" + request.PAUSED_QUEUED_FOR_WIFI); console.info("====>SUB_REQUEST_UPLOAD_API_0003 request.PAUSED_QUEUED_FOR_WIFI:" + request.PAUSED_QUEUED_FOR_WIFI);
expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(0); expect(request.PAUSED_QUEUED_FOR_WIFI).assertEqual(0);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("SUB_REQUEST_UPLOAD_API_0003 error: " + err); console.error("SUB_REQUEST_UPLOAD_API_0003 error: " + err);
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0003 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0003 end-----------------------");
done(); done();
}); });
...@@ -169,21 +169,21 @@ export default function requestUploadJSUnit() { ...@@ -169,21 +169,21 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_REQUEST_UPLOAD_API_0004', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_0004', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0004 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0004 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_UNKNOWN:" + request.PAUSED_UNKNOWN); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_UNKNOWN:" + request.PAUSED_UNKNOWN);
expect(request.PAUSED_UNKNOWN).assertEqual(4); expect(request.PAUSED_UNKNOWN).assertEqual(4);
console.info("SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_WAITING_FOR_NETWORK:" + request.PAUSED_WAITING_FOR_NETWORK); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_WAITING_FOR_NETWORK:" + request.PAUSED_WAITING_FOR_NETWORK);
expect(request.PAUSED_WAITING_FOR_NETWORK).assertEqual(1); expect(request.PAUSED_WAITING_FOR_NETWORK).assertEqual(1);
console.info("SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_WAITING_TO_RETRY:" + request.PAUSED_WAITING_TO_RETRY); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.PAUSED_WAITING_TO_RETRY:" + request.PAUSED_WAITING_TO_RETRY);
expect(request.PAUSED_WAITING_TO_RETRY).assertEqual(2); expect(request.PAUSED_WAITING_TO_RETRY).assertEqual(2);
console.info("SUB_REQUEST_UPLOAD_API_0004 request.SESSION_FAILED:" + request.SESSION_FAILED); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.SESSION_FAILED:" + request.SESSION_FAILED);
expect(request.SESSION_FAILED).assertEqual(4); expect(request.SESSION_FAILED).assertEqual(4);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("SUB_REQUEST_UPLOAD_API_0004 error: " + err); console.error("SUB_REQUEST_UPLOAD_API_0004 error: " + err);
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0004 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0004 end-----------------------");
done(); done();
}); });
...@@ -196,21 +196,21 @@ export default function requestUploadJSUnit() { ...@@ -196,21 +196,21 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_REQUEST_UPLOAD_API_0005', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_0005', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0005 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0005 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_0004 request.SESSION_PAUSED:" + request.SESSION_PAUSED); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.SESSION_PAUSED:" + request.SESSION_PAUSED);
expect(request.SESSION_PAUSED).assertEqual(3); expect(request.SESSION_PAUSED).assertEqual(3);
console.info("SUB_REQUEST_UPLOAD_API_0004 request.SESSION_PENDING:" + request.SESSION_PENDING); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.SESSION_PENDING:" + request.SESSION_PENDING);
expect(request.SESSION_PENDING).assertEqual(2); expect(request.SESSION_PENDING).assertEqual(2);
console.info("SUB_REQUEST_UPLOAD_API_0004 request.SESSION_RUNNING:" + request.SESSION_RUNNING); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.SESSION_RUNNING:" + request.SESSION_RUNNING);
expect(request.SESSION_RUNNING).assertEqual(1); expect(request.SESSION_RUNNING).assertEqual(1);
console.info("SUB_REQUEST_UPLOAD_API_0004 request.SESSION_SUCCESSFUL:" + request.SESSION_SUCCESSFUL); console.info("====>SUB_REQUEST_UPLOAD_API_0004 request.SESSION_SUCCESSFUL:" + request.SESSION_SUCCESSFUL);
expect(request.SESSION_SUCCESSFUL).assertEqual(0); expect(request.SESSION_SUCCESSFUL).assertEqual(0);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("SUB_REQUEST_UPLOAD_API_0005 error: " + err); console.error("SUB_REQUEST_UPLOAD_API_0005 error: " + err);
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0005 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0005 end-----------------------");
done(); done();
}); });
...@@ -223,31 +223,31 @@ export default function requestUploadJSUnit() { ...@@ -223,31 +223,31 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_REQUEST_UPLOAD_API_0006', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_0006', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0006 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0006 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_PERMISSION:" + request.EXCEPTION_PERMISSION); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_PERMISSION:" + request.EXCEPTION_PERMISSION);
expect(request.EXCEPTION_PERMISSION).assertEqual(201); expect(request.EXCEPTION_PERMISSION).assertEqual(201);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_PARAMCHECK:" + request.EXCEPTION_PARAMCHECK); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_PARAMCHECK:" + request.EXCEPTION_PARAMCHECK);
expect(request.EXCEPTION_PARAMCHECK).assertEqual(401); expect(request.EXCEPTION_PARAMCHECK).assertEqual(401);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_UNSUPPORTED:" + request.EXCEPTION_UNSUPPORTED); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_UNSUPPORTED:" + request.EXCEPTION_UNSUPPORTED);
expect(request.EXCEPTION_UNSUPPORTED).assertEqual(801); expect(request.EXCEPTION_UNSUPPORTED).assertEqual(801);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_FILEIO:" + request.EXCEPTION_FILEIO); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_FILEIO:" + request.EXCEPTION_FILEIO);
expect(request.EXCEPTION_FILEIO).assertEqual(13400001); expect(request.EXCEPTION_FILEIO).assertEqual(13400001);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_FILEPATH:" + request.EXCEPTION_FILEPATH); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_FILEPATH:" + request.EXCEPTION_FILEPATH);
expect(request.EXCEPTION_FILEPATH).assertEqual(13400002); expect(request.EXCEPTION_FILEPATH).assertEqual(13400002);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_SERVICE:" + request.EXCEPTION_SERVICE); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_SERVICE:" + request.EXCEPTION_SERVICE);
expect(request.EXCEPTION_SERVICE).assertEqual(13400003); expect(request.EXCEPTION_SERVICE).assertEqual(13400003);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_OTHERS:" + request.EXCEPTION_OTHERS); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.EXCEPTION_OTHERS:" + request.EXCEPTION_OTHERS);
expect(request.EXCEPTION_OTHERS).assertEqual(13499999); expect(request.EXCEPTION_OTHERS).assertEqual(13499999);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.ERROR_OFFLINE:" + request.ERROR_OFFLINE); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.ERROR_OFFLINE:" + request.ERROR_OFFLINE);
expect(request.ERROR_OFFLINE).assertEqual(9); expect(request.ERROR_OFFLINE).assertEqual(9);
console.info("SUB_REQUEST_UPLOAD_API_0006 request.ERROR_UNSUPPORTED_NETWORK_TYPE:" + request.ERROR_UNSUPPORTED_NETWORK_TYPE); console.info("====>SUB_REQUEST_UPLOAD_API_0006 request.ERROR_UNSUPPORTED_NETWORK_TYPE:" + request.ERROR_UNSUPPORTED_NETWORK_TYPE);
expect(request.ERROR_UNSUPPORTED_NETWORK_TYPE).assertEqual(10); expect(request.ERROR_UNSUPPORTED_NETWORK_TYPE).assertEqual(10);
} catch (err) { } catch (err) {
expect(true).assertEqual(true); expect(true).assertEqual(true);
console.error("SUB_REQUEST_UPLOAD_API_0006 error: " + err); console.error("SUB_REQUEST_UPLOAD_API_0006 error: " + err);
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_0006 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_0006 end-----------------------");
done(); done();
}); });
...@@ -260,26 +260,26 @@ export default function requestUploadJSUnit() { ...@@ -260,26 +260,26 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('SUB_REQUEST_UPLOAD_API_CALLBACK_0001', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_CALLBACK_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig)); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 uploadConfig = " + JSON.stringify(uploadConfig));
request.upload(uploadConfig, (data) => { request.upload(uploadConfig, (data) => {
uploadTask = data; uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask)); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 progress uploadTask =" + JSON.stringify(uploadTask));
expect(uploadTask != undefined).assertEqual(true); expect(uploadTask != undefined).assertEqual(true);
uploadTask.on('progress', function (data1, data2) { uploadTask.on('progress', function (data1, data2) {
console.info("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data1 =" + data1); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data1 =" + data1);
console.info("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data2 =" + data2); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data2 =" + data2);
}); });
uploadTask.off('progress', function (data1, data2) { uploadTask.off('progress', function (data1, data2) {
console.info("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data1 =" + data1); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data1 =" + data1);
console.info("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data2 =" + data2); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data2 =" + data2);
}); });
uploadTask.remove((err, data) => { uploadTask.remove((err, data) => {
console.info("SUB_REQUEST_UPLOAD_API_CALLBACK_0001 remove =" + data); console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 remove =" + data);
}); });
}); });
} catch (err) { } catch (err) {
...@@ -287,7 +287,7 @@ export default function requestUploadJSUnit() { ...@@ -287,7 +287,7 @@ export default function requestUploadJSUnit() {
expect().assertFail(); expect().assertFail();
} }
sleep(Date.now(), 20000); sleep(Date.now(), 20000);
console.info("-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 end-----------------------");
done(); done();
}); });
...@@ -300,26 +300,26 @@ export default function requestUploadJSUnit() { ...@@ -300,26 +300,26 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it('SUB_REQUEST_UPLOAD_API_PROMISE_0001', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_PROMISE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 is starting-----------------------");
try { try {
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig)); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 UploadConfig = " + JSON.stringify(uploadConfig));
request.upload(uploadConfig).then((data) => { request.upload(uploadConfig).then((data) => {
uploadTask = data; uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0001 uploadTask = " + uploadTask); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 uploadTask = " + uploadTask);
expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {})); expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {}));
uploadTask.on('headerReceive', (header) => { uploadTask.on('headerReceive', (header) => {
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header);
expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); expect(true).assertEqual((header != undefined) || (header != "") || (header != {}));
}); });
uploadTask.off('headerReceive', (header) => { uploadTask.off('headerReceive', (header) => {
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 header = " + header);
expect(true).assertEqual((header != undefined) || (header != "") || (header != {})); expect(true).assertEqual((header != undefined) || (header != "") || (header != {}));
}); });
uploadTask.remove().then((result)=>{ uploadTask.remove().then((result)=>{
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0001 remove result = " + result); console.info("====>SUB_REQUEST_UPLOAD_API_PROMISE_0001 remove result = " + result);
expect(result).assertEqual(true); expect(result).assertEqual(true);
}); });
}); });
...@@ -328,90 +328,11 @@ export default function requestUploadJSUnit() { ...@@ -328,90 +328,11 @@ export default function requestUploadJSUnit() {
expect(true).assertFail(true); expect(true).assertFail(true);
} }
sleep(Date.now(), 20000); sleep(Date.now(), 20000);
console.info("-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------");
done(); done();
}); });
/**
* @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(uploadConfig).then((data) => {
uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0002 uploadTask = " + uploadTask);
expect(true).assertEqual((uploadTask != undefined) || (uploadTask != "") || (uploadTask != {}));
uploadTask.on('complete', (TaskState) => {
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0002 TaskState.path = " + TaskState.path);
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0002 TaskState.responseCode" + TaskState.responseCode);
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0002 TaskState.TaskState.message" + TaskState.message);
expect(typeof(TaskState.path) == "string").assertEqual(true);
expect(typeof(TaskState.responseCode) == "number").assertEqual(true);
expect(typeof(TaskState.message) == "string").assertEqual(true);
});
uploadTask.on('fail', (TaskState) => {
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0002 TaskState.path = " + TaskState.path);
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0002 TaskState.responseCode" + TaskState.responseCode);
console.info("SUB_REQUEST_UPLOAD_API_PROMISE_0002 TaskState.TaskState.message" + TaskState.message);
expect(typeof(TaskState.path) == "string").assertEqual(true);
expect(typeof(TaskState.responseCode) == "number").assertEqual(true);
expect(typeof(TaskState.message) == "string").assertEqual(true);
expect(true).assertEqual(true);
});
});
} catch (e) {
console.error("SUB_REQUEST_UPLOAD_API_PROMISE_0001 error: " + JSON.stringify(e));
expect(true).assertFail(true);
}
sleep(Date.now(), 20000);
console.info("-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------");
done();
});
/**
* @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(uploadConfig).then((data) => {
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 (e) {
console.error("SUB_REQUEST_UPLOAD_API_PROMISE_0003 error: " + JSON.stringify(e));
expect(true).assertFail(true);
}
sleep(Date.now(), 20000);
console.info("-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0003 end-----------------------");
done();
});
/** /**
* @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0001 * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0001
...@@ -421,18 +342,18 @@ export default function requestUploadJSUnit() { ...@@ -421,18 +342,18 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------");
try { try {
request.upload(uploadConfig, (data) => { request.upload(uploadConfig, (data) => {
uploadTask = data; uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask); console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask);
expect(uploadTask != undefined).assertEqual(true); expect(uploadTask != undefined).assertEqual(true);
uploadTask.delete((err, data) => { uploadTask.delete((err, data) => {
if (err) { if (err) {
console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.'); console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.');
expect().assertFail(); expect().assertFail();
} }
console.info('SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask task delete success.'); console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask task delete success.');
expect(typeof data == "boolean").assertTrue(); expect(typeof data == "boolean").assertTrue();
}); });
}) })
...@@ -440,7 +361,7 @@ export default function requestUploadJSUnit() { ...@@ -440,7 +361,7 @@ export default function requestUploadJSUnit() {
console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error); console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error);
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------");
done(); done();
}); });
...@@ -452,17 +373,17 @@ export default function requestUploadJSUnit() { ...@@ -452,17 +373,17 @@ export default function requestUploadJSUnit() {
* @tc.level : Level 2 * @tc.level : Level 2
*/ */
it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) { it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) {
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------");
try { try {
request.upload(uploadConfig, (data) => { request.upload(uploadConfig, (data) => {
uploadTask = data; uploadTask = data;
console.info("SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask); console.info("====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask);
expect(uploadTask != undefined).assertEqual(true); expect(uploadTask != undefined).assertEqual(true);
uploadTask.delete().then(data => { uploadTask.delete().then(data => {
console.info('SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask task delete success.'); console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask task delete success.');
expect(data == true).assertTrue(); expect(data == true).assertTrue();
}).catch((err) => { }).catch((err) => {
console.info('SUB_REQUEST_UPLOAD_API_DELETE_0002 Failed to delete the uploadTask task.'); console.info('====>SUB_REQUEST_UPLOAD_API_DELETE_0002 Failed to delete the uploadTask task.');
expect().assertFail(); expect().assertFail();
}) })
}) })
...@@ -470,7 +391,7 @@ export default function requestUploadJSUnit() { ...@@ -470,7 +391,7 @@ export default function requestUploadJSUnit() {
console.error('SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch error'); console.error('SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch error');
expect().assertFail(); expect().assertFail();
} }
console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 end-----------------------"); console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 end-----------------------");
done(); done();
}); });
......
...@@ -18,6 +18,7 @@ group("storage") { ...@@ -18,6 +18,7 @@ group("storage") {
deps = [ deps = [
"storagefileioerrorjstest:storagefileioerror_js_test", "storagefileioerrorjstest:storagefileioerror_js_test",
"storagefileiojstest:storagefileio_js_test", "storagefileiojstest:storagefileio_js_test",
"storagefileiov9jstest:storagefileiov9_js_test",
"storagefilejstest:storagefile_js_test", "storagefilejstest:storagefile_js_test",
"storagesecuritylabeljstest:storagesecuritylabel_js_test", "storagesecuritylabeljstest:storagesecuritylabel_js_test",
"storagestatfsjstest:storagestatfs_js_test", "storagestatfsjstest:storagestatfs_js_test",
......
# Copyright (C) 2021 Huawei Device Co., Ltd. # Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
...@@ -10,25 +10,26 @@ ...@@ -10,25 +10,26 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsRpcJsServer") { ohos_js_hap_suite("storagefileiov9_js_test") {
hap_profile = "./src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":rpc_js_assets", ":storagefileiov9_js_assets",
":rpc_js_resources", ":storagefileiov9_js_resources",
] ]
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsRpcHapServer" hap_name = "ActsStorageFileIoV9JSTest"
subsystem_name = "communication" subsystem_name = "filemanagement"
part_name = "ipc" part_name = "file_api"
} }
ohos_js_assets("rpc_js_assets") { ohos_js_assets("storagefileiov9_js_assets") {
source_dir = "./src/main/js" js2abc = true
hap_profile = "./src/main/config.json" hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("rpc_js_resources") { ohos_resources("storagefileiov9_js_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json" hap_profile = "./src/main/config.json"
} }
{
"description": "Configuration for storage filefs Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.storage.fileiov9",
"package-name": "ohos.acts.storage.fileiov9"
},
"kits": [
{
"test-file-name": ["ActsStorageFileIoV9JSTest.hap"],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.storage.fileiov9",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.storage.fileiov9",
"name": ".entry",
"deviceType": [
"default",
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
export default { export default {
onCreate() { onCreate() {
console.info("Application onCreate"); console.info('ohos.acts.storage.fileio onCreate');
}, },
onDestroy() { onDestroy() {
console.info("Application onDestroy"); console.info('ohos.acts.storage.fileio onDestroy');
} }
}; };
{
"strings": {
"hello": "Hello",
"world": "Test"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "测试"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container" onswipe="touchMove"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
<input class="btn" type="button" value="{{ $t('strings.next') }}" onclick="onclick"></input>
</div> </div>
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,15 +13,21 @@ ...@@ -13,15 +13,21 @@
* limitations under the License. * limitations under the License.
*/ */
import router from '@system.router' import app from '@system.app'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default { export default {
data: { data: {
title: 'World' title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
}, },
onclick: function () {
router.replace({
uri: "pages/index/index"
})
}
} }
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{ {
"strings": { "strings": {
"hello": "Hello", "hello": "Hello",
"world": "World", "world": "World"
"page": "Second Page",
"next": "Next Page",
"back": "Back"
}, },
"Files": { "Files": {
} }
......
{ {
"strings": { "strings": {
"hello": "您好", "hello": "您好",
"world": "世界", "world": "世界"
"page": "第二页",
"next": "下一页",
"back": "返回"
}, },
"Files": { "Files": {
} }
......
...@@ -17,8 +17,14 @@ ...@@ -17,8 +17,14 @@
margin: 10px; margin: 10px;
} }
.btn { @media screen and (device-type: phone) and (orientation: landscape) {
width: 50%; .title {
height: 100px; font-size: 60px;
font-size: 40px; }
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
} }
\ No newline at end of file
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.page') }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
<input class="btn" type="button" value="{{ $t('strings.back') }}" onclick="onclick"></input>
</div> </div>
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,20 +13,11 @@ ...@@ -13,20 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import router from '@system.router'
export default { export default {
data: { data: {
title: "" title: ""
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.$t('strings.world');
},
onclick: function () {
router.replace({
uri: "pages/second/second"
})
} }
} }
/*
* Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2022 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 fileio from '@ohos.fileio';
import fileIO from '@ohos.file.fs';
import featureAbility from '@ohos.ability.featureAbility';
export const FILE_CONTENT = 'hello world';
import {
describe, it, expect
}
from '@ohos/hypium'
export function prepareFile(fpath, content) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileIO.truncateSync(file.fd)
fileIO.writeSync(file.fd, content)
fileio.fsyncSync(file.fd)
fileio.closeSync(file.fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function prepareEmptyFile(fpath) {
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE)
fileio.closeSync(file.fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function fileToReadOnly(fpath) {
try {
let file = fileio.openSync(fpath, fileIO.OpenMode.CREATE)
fileio.fchmodSync(file.fd, 0o444)
fileio.fsyncSync(file.fd)
fileio.closeSync(file.fd)
return true
}
catch (e) {
console.log('Failed to fileToReadOnly for ' + e);
return false
}
}
export function fileToWriteOnly(fpath) {
try {
let file = fileio.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.WRITE_ONLY)
fileio.fchmodSync(file.fd, 0o222)
fileio.fsyncSync(file.fd)
fileio.closeSync(file.fd)
return true
}
catch (e) {
console.log('Failed to fileToWriteOnly ' + e)
return false
}
}
export async function nextFileName(testName) {
let context = featureAbility.getContext();
let data = await context.getCacheDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export async function fileName(testName) {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export function randomString(num) {
let len= num;
var $chars = 'aaaabbbbcccc';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
export function forceRemoveDir(path, num) {
for (let i = num; i >= 0; i--) {
if (i < num) {
path = path.replace(`/d${i}`, "");
}
fileio.rmdirSync(path);
}
}
function isIntNum(val) {
return typeof val === 'number' && val % 1 === 0;
}
function isString(str) {
return (typeof str == 'string') && str.constructor == String;
}
function isBoolean(val) {
return typeof val == 'boolean';
}
function isInclude(error, message) {
return error.toString().indexOf(message) != -1;
}
export {
fileio,
fileIO,
isIntNum,
isString,
isBoolean,
isInclude,
describe,
it,
expect
};
\ No newline at end of file
/*
* Copyright (C) 2022 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 fileIOOpen from './members/open.test.js'
import fileIORead from './members/read.test.js'
import fileIOStat from './members/stat.test.js'
import fileIOTruncate from './members/truncate.test.js'
import fileIOWrite from './members/write.test.js'
export default function testsuite() {
fileIOOpen()
fileIORead()
fileIOStat()
fileIOTruncate()
fileIOWrite()
}
/*
* Copyright (C) 2022 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 {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
describe, it, expect,
} from '../Common';
export default function fileIOOpen() {
describe('fileIO_fs_open', function () {
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0000
* @tc.name fileIO_test_open_sync_000
* @tc.desc Test openSync() interfaces. mode=0o0.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0100
* @tc.name fileIO_test_open_sync_001
* @tc.desc Test openSync() interfaces. mode=0o1.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let length = 20;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0200
* @tc.name fileIO_test_open_sync_002
* @tc.desc Test openSync() interfaces. mode=0o2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
let length = 20;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0300
* @tc.name fileIO_test_open_sync_003
* @tc.desc Test openSync() interfaces. Missing Parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_003', 0, function () {
try {
fileIO.openSync();
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_open_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue;
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0400
* @tc.name fileIO_test_open_sync_004
* @tc.desc Test openSync() interfaces. mode=0o102.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_004', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_004');
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0500
* @tc.name fileIO_test_open_sync_005
* @tc.desc Test openSync() interfaces. mode=0o1002.
* If the file exists and the file is opened for write-only or read-write, trim its length to zero.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_005', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let number = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(number == 0).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0600
* @tc.name fileIO_test_open_sync_006
* @tc.desc Test openSync() interfaces. mode=0o2002.
* Open as append, subsequent writes will append to the end of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let length = 100;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue();
let number = fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 0 });
expect(number == length + FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0700
* @tc.name fileIO_test_open_sync_007
* @tc.desc Test openSync() interfaces. mode=0o4002.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_007', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0800
* @tc.name fileIO_test_open_sync_008
* @tc.desc Test openSync() interfaces. mode=0o200000.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_008', 0, async function () {
let dpath = await nextFileName('fileIO_test_open_sync_008');
fileio.mkdirSync(dpath);
try {
let file = fileIO.openSync(dpath, fileIO.OpenMode.DIR);
expect(isIntNum(file.fd)).assertTrue();
fileio.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_test_open_sync_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_0900
* @tc.name fileIO_test_open_sync_009
* @tc.desc Test openSync() interfaces. mode=0o200000. Not a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_009', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_009');
expect(prepareFile(fpath, '')).assertTrue();
try {
fileIO.openSync(fpath, fileIO.OpenMode.DIR);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_open_sync_009 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue;
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_1000
* @tc.name fileIO_test_open_sync_010
* @tc.desc Test openSync() interfaces. mode=0o400002.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_010', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_010');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_010 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_1100
* @tc.name fileIO_test_open_sync_011
* @tc.desc Test openSync() interfaces. mode=0o400002. Shouldn't be Symbolic link.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_011', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_011');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
fileIO.openSync(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_open_sync_011 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue;
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_SYNC_1200
* @tc.name fileIO_test_open_sync_012
* @tc.desc Test openSync() interfaces. mode=0o4010002.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_sync_012', 0, async function () {
let fpath = await nextFileName('fileIO_test_open_sync_012');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_sync_012 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0000
* @tc.name fileIO_test_open_async_000
* @tc.desc Test open() interfaces. mode=0o0.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.open(fpath, fileIO.OpenMode.READ_ONLY, function (err, file) {
fileIO.read(file.fd, new ArrayBuffer(4096))
.then(function (res) {
expect(res == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
});
} catch (e) {
console.log('fileIO_test_open_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0100
* @tc.name fileIO_test_open_async_001
* @tc.desc Test open() interfaces. mode=0o2. No such file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_001');
try {
await fileIO.open(fpath, fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_open_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue;
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0200
* @tc.name fileIO_test_open_async_002
* @tc.desc Test open() interfaces. Invalid fp.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_002', 0, async function (done) {
try {
await fileIO.open(-1, fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_open_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0300
* @tc.name fileIO_test_open_async_003
* @tc.desc Test open() interfaces. mode=0o1.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let length = 20;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0400
* @tc.name fileIO_test_open_async_004
* @tc.desc Test open() interfaces. mode=0o2.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let readlen = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
let length = 20;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0500
* @tc.name fileIO_test_open_async_005
* @tc.desc Test open() interfaces. mode=0o102. Promise.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_005', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_005');
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0600
* @tc.name fileIO_test_open_async_006
* @tc.desc Test open() interfaces. mode=0o102. Callback.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.open(fpath, fileIO.OpenMode.CREATE | fileIO.OpenMode.READ_WRITE, function (err, file) {
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_open_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0700
* @tc.name fileIO_test_open_async_007
* @tc.desc Test open() interfaces. mode=0o1002.
* If the file exists and the file is opened for write-only or read-write, trim its length to zero.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.TRUNC | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let number = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(number == 0).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0800
* @tc.name fileIO_test_open_async_008
* @tc.desc Test open() interfaces. mode=0o2002.
* Open as append, subsequent writes will append to the end of the file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_008', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let length = 100;
let num = fileIO.writeSync(file.fd, new ArrayBuffer(length));
expect(num == length).assertTrue();
let number = fileIO.readSync(file.fd, new ArrayBuffer(4096), { offset: 0 });
expect(number == length + FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_008 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_0900
* @tc.name fileIO_test_open_async_009
* @tc.desc Test open() interfaces. mode=0o4002.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_009', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_009');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.NONBLOCK | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_009 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1000
* @tc.name fileIO_test_open_async_010
* @tc.desc Test open() interfaces. mode=0o200000.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_010', 0, async function (done) {
let dpath = await nextFileName('fileIO_test_open_async_010');
fileio.mkdirSync(dpath);
try {
let file = await fileIO.open(dpath, fileIO.OpenMode.DIR);
expect(isIntNum(file.fd)).assertTrue();
fileio.rmdirSync(dpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_010 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1100
* @tc.name fileIO_test_open_async_011
* @tc.desc Test open() interfaces. mode=0o200000. Not a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_011', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_011');
expect(prepareFile(fpath, '')).assertTrue();
try {
await fileIO.open(fpath, fileIO.OpenMode.DIR | fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
console.log('fileIO_test_open_async_011 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue;
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1200
* @tc.name fileIO_test_open_async_012
* @tc.desc Test open() interfaces. mode=0o400002.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_012', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_012');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = await fileIO.open(fpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_open_async_012 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1300
* @tc.name fileIO_test_open_async_013
* @tc.desc Test open() interfaces. mode=0o400002. Shouldn't be Symbolic link.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_013', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_013');
let ffpath = fpath + 'aaaa';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileio.symlinkSync(fpath, ffpath);
await fileIO.open(ffpath, fileIO.OpenMode.NOFOLLOW | fileIO.OpenMode.READ_WRITE);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_open_async_013 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900033 && e.message == 'Too many symbolic links encountered').assertTrue;
fileio.unlinkSync(fpath);
fileio.unlinkSync(ffpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_OPEN_ASYNC_1400
* @tc.name fileIO_test_open_async_014
* @tc.desc Test open() interfaces. mode=0o4010002.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_async_014', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_open_async_014');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.open(fpath, fileIO.OpenMode.SYNC | fileIO.OpenMode.READ_WRITE, function(err, file) {
expect(isIntNum(file.fd)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (err) {
console.log('fileIO_test_open_async_014 has failed for ' + err.message + ', code: ' + err.code);
expect(false).assertTrue();
}
});
});
}
/*
* Copyright (C) 2022 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 {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
describe, it, expect,
} from '../Common';
export default function fileIORead() {
describe('fileIO_fs_read', function () {
/**
* @tc.number SUB_DF_FILEIO_READ_SYNC_0000
* @tc.name fileIO_test_read_sync_000
* @tc.desc Test readSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_read_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_read_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_SYNC_0100
* @tc.name fileIO_test_read_sync_001
* @tc.desc Test readSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_read_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
length: 1,
});
expect(len == 1).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_read_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_SYNC_0200
* @tc.name fileIO_test_read_sync_002
* @tc.desc Test readSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_read_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
offset: 1,
});
expect(len == FILE_CONTENT.length - 1).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_read_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_SYNC_0300
* @tc.name fileIO_test_read_sync_003
* @tc.desc Test readSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_sync_003', 0, async function () {
let fpath = await nextFileName('fileIO_test_read_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
const invalidLength = 9999;
try {
file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
fileIO.readSync(file.fd, new ArrayBuffer(4096), {length: invalidLength});
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_read_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_SYNC_0400
* @tc.name fileIO_test_read_sync_004
* @tc.desc Test readSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_sync_004', 0, async function () {
try {
fileIO.readSync(-1, new ArrayBuffer(4096));
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_read_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_SYNC_0500
* @tc.name fileIO_test_read_sync_005
* @tc.desc Test readSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_sync_005', 0, async function () {
let fpath = await nextFileName('fileIO_test_read_sync_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let invalidPos = FILE_CONTENT.length + 1;
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096), {
offset: invalidPos,
});
expect(len == 0).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_read_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_ASYNC_0000
* @tc.name fileIO_test_read_async_000
* @tc.desc Test read() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_read_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let res = await fileIO.read(file.fd, new ArrayBuffer(4096));
expect(res == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_read_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_ASYNC_0100
* @tc.name fileIO_test_read_async_001
* @tc.desc Test read() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_read_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
fileIO.read(file.fd, new ArrayBuffer(4096), async function (err, readlen) {
expect(readlen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_test_read_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_ASYNC_0200
* @tc.name fileIO_test_read_async_002
* @tc.desc Test read() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_read_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let readlen = await fileIO.read(file.fd, new ArrayBuffer(4096));
expect(readlen == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_read_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_ASYNC_0300
* @tc.name fileIO_test_read_async_003
* @tc.desc Test read() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_read_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let readlen = await fileIO.read(file.fd, new ArrayBuffer(4096), {
offset: 1,
});
expect(readlen == FILE_CONTENT.length - 1).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_read_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_ASYNC_0400
* @tc.name fileIO_test_read_async_004
* @tc.desc Test read() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_read_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let readlen = await fileIO.read(file.fd, new ArrayBuffer(4096), {
length: 3,
});
expect(readlen == 3).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_read_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_ASYNC_0500
* @tc.name fileIO_test_read_async_005
* @tc.desc Test read() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_async_005', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_read_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let len = await fileIO.read(file.fd, new ArrayBuffer(4096), {
offset: FILE_CONTENT.length + 1,
});
expect(isIntNum(len)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_read_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_READ_ASYNC_0600
* @tc.name fileIO_test_read_async_006
* @tc.desc Test read() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_read_async_006', 0, async function (done) {
try {
await fileIO.read(-1, new ArrayBuffer(4096));
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_read_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
done();
}
});
});
}
/*
* Copyright (C) 2022 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 {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum, isBoolean,
describe, it, expect,
} from '../Common';
export default function fileIOStat() {
describe('fileIO_fs_stat', function () {
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_0000
* @tc.name fileIO_stat_sync_000
* @tc.desc Test Stat.statSync() interfaces.
* This interface shall work properly in normal case.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat !== null).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_0100
* @tc.name fileIO_stat_sync_001
* @tc.desc Test Stat.statSync() interfaces.
* This interface shall throw an exception when the file isnt's exist.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_001');
try {
fileIO.statSync(fpath);
expect(false).assertTrue();
} catch (e) {
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
console.log('fileIO_stat_sync_001 has failed for ' + e.message + ', code: ' + e.code);
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_0200
* @tc.name fileIO_stat_sync_002
* @tc.desc Test Stat.statSync() interfaces.
* This interface shall throw an exception when the file isnt's exist.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_002');
try {
fileIO.statSync();
expect(false).assertTrue();
} catch (e) {
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
console.log('fileIO_stat_sync_002 has failed for ' + e.message + ', code: ' + e.code);
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_INO_0000
* @tc.name fileIO_stat_sync_ino_000
* @tc.desc Test Stat.statSync_Ino() interfaces.
* @tc.desc Test the ino member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_ino_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_ino_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.ino)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.ino)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.info('fileIO_stat_sync_ino_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_MODE_0000
* @tc.name fileIO_stat_sync_mode_000
* @tc.desc Test Stat.statSync_Mode() interfaces.
* @tc.desc Test the mode member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_mode_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_mode_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.mode)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.mode)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.info('fileIO_stat_sync_mode_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_UID_0000
* @tc.name fileIO_stat_sync_uid_000
* @tc.desc Test Stat.statSync_Uid() interfaces.
* @tc.desc Test the uid member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_uid_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_uid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.uid)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.uid)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_uid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_GID_0000
* @tc.name fileIO_stat_sync_gid_000
* @tc.desc Test Stat.statSync_Gid() interfaces.
* @tc.desc Test the gid member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_gid_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_gid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.gid)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.gid)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_gid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_SIZE_0000
* @tc.name fileIO_stat_sync_size_000
* @tc.desc Test Stat.statSync_Size() interfaces.
* @tc.desc Test the size member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_size_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_size_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.size)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.size)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_size_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_BLKSIZE_0000
* @tc.name fileIO_stat_sync_blksize_000
* @tc.desc Test Stat.statSync_Blksize() interfaces.
* @tc.desc Test the blksize member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_blksize_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_blksize_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.blksize)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.blksize)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_blksize_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ATIME_0000
* @tc.name fileIO_stat_sync_atime_000
* @tc.desc Test Stat.statSync_Atime() interfaces.
* @tc.desc Test the atime member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_atime_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_atime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.atime)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.atime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_atime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_MTIME_0000
* @tc.name fileIO_stat_sync_mtime_000
* @tc.desc Test Stat.statSync_Mtime() interfaces.
* @tc.desc Test the mtime member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_mtime_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_mtime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.mtime)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.mtime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_CTIME_0000
* @tc.name fileIO_stat_sync_ctime_000
* @tc.desc Test Stat.statSync_Ctime() interfaces.
* @tc.desc Test the ctime member of class Stat
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_ctime_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_ctime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.ctime)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isIntNum(stat2.ctime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0000
* @tc.name fileIO_stat_sync_is_block_device_000
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_block_device_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_block_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isBlockDevice())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isBlockDevice())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0100
* @tc.name fileIO_stat_sync_is_block_device_001
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* This interface shall not treat a normal file as a block special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_block_device_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_block_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isBlockDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0200
* @tc.name fileIO_stat_sync_is_block_device_002
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_block_device_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_block_device_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isBlockDevice(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
console.info('fileIO_stat_sync_is_block_device_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISBLOCKDEVICE_0300
* @tc.name fileIO_stat_sync_is_block_device_003
* @tc.desc Test Stat.statSync_IsBlockDevice() interfaces.
* @tc.desc Test the isBlockDevice() method of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_block_device_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_block_device_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isBlockDevice(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
console.info('fileIO_stat_sync_is_block_device_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0000
* @tc.name fileIO_stat_sync_is_character_device_000
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_character_device_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_character_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isCharacterDevice())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isCharacterDevice())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0100
* @tc.name fileIO_stat_sync_is_character_device_001
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* This interface shall not treat a normal file as a character special device.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_character_device_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_character_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isCharacterDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0200
* @tc.name fileIO_stat_sync_is_character_device_002
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_character_device_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_character_device_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isCharacterDevice(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISCHARACTER_DEVICE_0300
* @tc.name fileIO_stat_sync_is_character_device_003
* @tc.desc Test Stat.statsync_IsCharacterDevice() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_character_device_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_character_device_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isCharacterDevice(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0000
* @tc.name fileIO_stat_sync_is_directory_000
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_directory_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isDirectory())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isDirectory())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_directory_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0100
* @tc.name fileIO_stat_sync_is_directory_001
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* This interface shall not treat a normal file as a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_directory_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isDirectory() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0200
* @tc.name fileIO_stat_sync_is_directory_002
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* This interface shall treat a directory as a directory.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_002', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_002');
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isDirectory()).assertTrue();
let file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory()).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_stat_sync_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0300
* @tc.name fileIO_stat_sync_is_directory_003
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_003', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_003') + 'd';
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isDirectory(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.rmdirSync(dpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISDIRECTORY_0400
* @tc.name fileIO_stat_sync_is_directory_004
* @tc.desc Test Stat.statsync_isDirectory() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_directory_004', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_directory_004') + 'd';
let file;
try {
fileio.mkdirSync(dpath);
file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isDirectory(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0000
* @tc.name fileIO_stat_sync_is_fifo_000
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_fifo_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_fifo_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isFIFO())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isFIFO())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0100
* @tc.name fileIO_stat_sync_is_fifo_001
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* This interface shall not treat a normal file as a FIFO.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_fifo_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_fifo_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isFIFO() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0200
* @tc.name fileIO_stat_sync_is_fifo_002
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_fifo_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_fifo_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isFile(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFIFO_0300
* @tc.name fileIO_stat_sync_is_fifo_003
* @tc.desc Test Stat.statsync_isFIFO() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_fifo_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_fifo_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile(-1) === false).assertTrue();
fileio.closeSync(file.fd);
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0000
* @tc.name fileIO_stat_sync_is_file_000
* @tc.desc Test Stat.statsync_isFile() interfaces.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_file_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_file_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isFile())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isFile())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_file_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0100
* @tc.name fileIO_stat_sync_is_file_001
* @tc.desc Test Stat.statsync_isFile() interfaces.
* This interface shall treat a normal file as a normal file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_file_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_file_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isFile()).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile()).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0200
* @tc.name fileIO_stat_sync_is_file_002
* @tc.desc Test Stat.statsync_isFile() interfaces.
* This interface shall not treat a directory as a normal file.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_file_002', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_002');
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isFile() === false).assertTrue();
let file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
} catch (e) {
console.log('fileIO_stat_sync_is_file_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0300
* @tc.name fileIO_stat_sync_is_file_003
* @tc.desc Test Stat.statsync_isFile() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_file_003', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_003');
try {
fileio.mkdirSync(dpath);
let stat = fileIO.statSync(dpath);
expect(stat.isFile(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.rmdirSync(dpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISFILE_0400
* @tc.name fileIO_stat_sync_is_file_004
* @tc.desc Test Stat.statsync_isFile() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_file_004', 0, async function () {
let dpath = await nextFileName('fileIO_stat_sync_is_file_004');
let file;
try {
fileio.mkdirSync(dpath);
file = fileIO.openSync(dpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isFile(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0000
* @tc.name fileIO_stat_sync_is_socket_000
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_socket_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_socket_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isSocket())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isSocket())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0100
* @tc.name fileIO_stat_sync_is_socket_001
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* This interface shall not treat a file as a socket.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_socket_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_socket_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSocket() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0200
* @tc.name fileIO_stat_sync_is_socket_002
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_socket_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_socket_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSocket(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSOCKET_0300
* @tc.name fileIO_stat_sync_is_socket_003
* @tc.desc Test Stat.statsync_isSocket() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_socket_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_socket_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSocket(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0000
* @tc.name fileIO_stat_sync_is_symbolic_link_000
* @tc.desc Test Stat.statasync_isSymbolicLink() interfaces.
* This interface shall return a boolean variable.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_symbolic_link_000', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isBoolean(stat.isSymbolicLink())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(isBoolean(stat2.isSymbolicLink())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0100
* @tc.name fileIO_stat_sync_is_symbolic_link_001
* @tc.desc Test Stat.statasync_isSymbolicLink() interfaces.
* This interface shall not treat a normal file as a symbolic link.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_symbolic_link_001', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSymbolicLink() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_stat_sync_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0200
* @tc.name fileIO_stat_sync_is_symbolic_link_002
* @tc.desc Test Stat.isSymbolicLink() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_symbolic_link_002', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(stat.isSymbolicLink(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_ISSYMBOLICLINK_0300
* @tc.name fileIO_stat_sync_is_symbolic_link_003
* @tc.desc Test Stat.isSymbolicLink() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_sync_is_symbolic_link_003', 0, async function () {
let fpath = await nextFileName('fileIO_stat_sync_is_symbolic_link_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
try {
file = fileIO.openSync(fpath);
let stat2 = fileIO.statSync(file.fd);
expect(stat2.isSymbolicLink(-1) === false).assertTrue();
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0000
* @tc.name fileIO_stat_async_000
* @tc.desc Test Stat.statAsync() interface.
* This interface shall work properly in normal case when providing the promise async model.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath).then((stat) => {
expect(stat !== null).assertTrue();
});
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd).then((stat2) => {
expect(stat2 !== null).assertTrue();
fileio.closeSync(file.fd);
});
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0100
* @tc.name fileIO_stat_async_001
* @tc.desc Test Stat.statAsync() interface.
* This interface shall work properly in normal case when providing the callback async model.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.stat(fpath, function (error) {
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_0200
* @tc.name fileIO_stat_async_002
* @tc.desc Test Stat.statAsync() interface.
* This interface shall work properly in normal case when providing the callback async model.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath);
fileIO.stat(file.fd, function (error) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
});
} catch (e) {
console.log('fileIO_stat_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_INO_0000
* @tc.name fileIO_stat_async_ino_000
* @tc.desc Test the ino member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_ino_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_ino_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.ino)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.ino)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_ino_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_MODE_0000
* @tc.name fileIO_stat_async_mode_000
* @tc.desc Test the mode member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_mode_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_mode_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.mode)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.mode)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_mode_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_UID_0000
* @tc.name fileIO_stat_async_uid_000
* @tc.desc Test the uid member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_uid_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_uid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.uid)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.uid)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_uid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_GID_0000
* @tc.name fileIO_stat_async_gid_000
* @tc.desc Test the gid member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_gid_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_gid_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.gid)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.gid)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_gid_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_SIZE_0000
* @tc.name fileIO_stat_async_size_000
* @tc.desc Test the size member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_size_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_size_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.size)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.size)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_size_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ATIME_0000
* @tc.name fileIO_stat_async_atime_000
* @tc.desc Test Stat.atime() interface.
* @tc.desc Test the atime member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_atime_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_atime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.atime)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.atime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_atime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_MTIME_0000
* @tc.name fileIO_stat_async_mtime_000
* @tc.desc Test Stat.mtime() interface.
* @tc.desc Test the mtime member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_mtime_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_mtime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.mtime)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.mtime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_mtime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_CTIME_0000
* @tc.name fileIO_stat_async_ctime_000
* @tc.desc Test the ctime member of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_ctime_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_ctime_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isIntNum(stat.ctime)).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isIntNum(stat2.ctime)).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_ctime_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISBLOCKDEVICE_0000
* @tc.name fileIO_stat_async_is_block_device_000
* @tc.desc Test the isBlockDevice method of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_block_device_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_block_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isBlockDevice())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isBlockDevice())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_block_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISBLOCKDEVICE_0100
* @tc.name fileIO_stat_async_is_block_device_001
* @tc.desc Test the isBlockDevice method of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_block_device_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_block_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isBlockDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isBlockDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_block_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISCHARACTERDEVICE_0000
* @tc.name fileIO_stat_async_is_character_device_000
* @tc.desc Test the isCharacterDevice method of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_character_device_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_character_device_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isCharacterDevice())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isCharacterDevice())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_character_device_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISCHARACTERDEVICE_0100
* @tc.name fileIO_stat_async_is_character_device_001
* @tc.desc Test the isCharacterDevice method of class Stat.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_character_device_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_character_device_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isCharacterDevice() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isCharacterDevice() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_character_device_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0000
* @tc.name fileIO_stat_async_is_directory_000
* @tc.desc Test Stat.isDirectory() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_directory_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_directory_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isDirectory())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isDirectory())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_directory_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0100
* @tc.name fileIO_stat_async_is_directory_001
* @tc.desc Test Stat.isDirectory() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_directory_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_directory_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isDirectory() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isDirectory() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_directory_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISDIRECTORY_0200
* @tc.name fileIO_stat_async_is_directory_002
* @tc.desc Test Stat.isDirectory() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_directory_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_stat_async_is_directory_002') + 'd';
try {
fileio.mkdirSync(dpath);
let stat = await fileIO.stat(dpath);
expect(stat.isDirectory()).assertTrue();
let file = fileIO.openSync(dpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isDirectory()).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_directory_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFIFO_0000
* @tc.name fileIO_stat_async_is_fifo_000
* @tc.desc Test Stat.isFIFO() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_fifo_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_fifo_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isFIFO())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isFIFO())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_fifo_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFIFO_0100
* @tc.name fileIO_stat_async_is_fifo_001
* @tc.desc Test Stat.isFIFO() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_fifo_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_fifo_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isFIFO() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFIFO() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_fifo_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0000
* @tc.name fileIO_stat_async_is_file_000
* @tc.desc Test Stat.isFile() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_file_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_file_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isFile())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isFile())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_file_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0100
* @tc.name fileIO_stat_async_is_file_001
* @tc.desc Test Stat.isFile() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_file_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_file_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isFile()).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFile()).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISFILE_0200
* @tc.name fileIO_stat_async_is_file_002
* @tc.desc Test Stat.isFile() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_file_002', 0, async function (done) {
let dpath = await nextFileName('fileIO_stat_async_is_file_002');
try {
fileio.mkdirSync(dpath);
let stat = await fileIO.stat(dpath);
expect(stat.isFile() === false).assertTrue();
let file = fileIO.openSync(dpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isFile() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.rmdirSync(dpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_file_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSOCKET_0000
* @tc.name fileIO_stat_async_is_socket_000
* @tc.desc Test Stat.isSocket() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_socket_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_socket_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isSocket())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isSocket())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_socket_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSOCKET_0100
* @tc.name fileIO_stat_async_is_socket_001
* @tc.desc Test Stat.isSocket() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_socket_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_socket_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isSocket() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isSocket() === false).assertTrue();
fileio.closeSync(file.fd);
done();
} catch (e) {
console.log('fileIO_stat_async_is_socket_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSYMBOLICLINK_0000
* @tc.name fileIO_stat_async_is_symbolic_link_000
* @tc.desc Test Stat.isSymbolicLink() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_symbolic_link_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_symbolic_link_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(isBoolean(stat.isSymbolicLink())).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(isBoolean(stat2.isSymbolicLink())).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_symbolic_link_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_ASYNC_ISSYMBOLICLINK_0100
* @tc.name fileIO_stat_async_is_symbolic_link_001
* @tc.desc Test Stat.isSymbolicLink() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_stat_async_is_symbolic_link_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_stat_async_is_symbolic_link_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = await fileIO.stat(fpath);
expect(stat.isSymbolicLink() === false).assertTrue();
let file = fileIO.openSync(fpath);
let stat2 = await fileIO.stat(file.fd);
expect(stat2.isSymbolicLink() === false).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_stat_async_is_symbolic_link_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_APPEND_FILE_SYNC_0000
* @tc.name fileIO_stat_sync_append_file_sync_000
* @tc.desc Test Stat.statSync() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_append_file_sync_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_append_file_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let stat = fileIO.statSync(fpath);
expect(isIntNum(stat.size)).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
stat = fileIO.statSync(fpath);
expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_append_file_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
done();
});
/**
* @tc.number SUB_DF_FILEIO_STAT_SYNC_APPEND_FILE_SYNC_0100
* @tc.name fileIO_stat_sync_append_file_sync_001
* @tc.desc Test Stat.statSync() interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_append_file_sync_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_append_file_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.APPEND | fileIO.OpenMode.READ_WRITE);
let stat = fileIO.statSync(file.fd);
expect(isIntNum(stat.size)).assertTrue();
expect(isIntNum(file.fd)).assertTrue();
expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
let file2 = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
stat = fileIO.statSync(file2.fd);
expect(stat.size == FILE_CONTENT.length * 2).assertTrue();
fileio.closeSync(file2.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_append_file_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
done();
});
});
}
/*
* Copyright (C) 2022 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 {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
describe, it, expect,
} from '../Common';
export default function fileIOTruncate() {
describe('fileIO_fs_truncate', function () {
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0000
* @tc.name fileIO_truncate_async_000
* @tc.desc Test the truncate() interface that receives the fpath parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_truncate_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_truncate_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let truncateLen = 5;
try {
await fileIO.truncate(fpath, truncateLen);
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.info('fileIO_truncate_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0100
* @tc.name fileIO_truncate_async_001
* @tc.desc Test the truncate() interface that receives the fd parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_truncate_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_truncate_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
let truncateLen = 5;
try {
file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileIO.truncate(file.fd, truncateLen, function (err) {
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
})
} catch (e) {
console.log('fileIO_truncate_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0200
* @tc.name fileIO_truncate_async_002
* @tc.desc Test the truncate() interface that receives the fpath parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_truncate_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_truncate_async_002');
expect(prepareFile(fpath, 'truncate')).assertTrue();
let truncateLen = 2;
try {
fileIO
.truncate(fpath, truncateLen)
.then(function (err) {
expect(err == null).assertTrue();
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
})
.catch(function (e) {
console.log('catch ' + e.message + ', code: ' + e.code);
});
} catch(e) {
console.log('fileIO_truncate_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0300
* @tc.name fileIO_truncate_async_003
* @tc.desc Test the truncate() interface that receives the fd parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_truncate_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_truncate_async_003');
expect(prepareFile(fpath, 'truncate')).assertTrue();
let file;
let truncateLen = 2;
try {
file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileIO.truncate(file.fd, truncateLen)
.then(function (err) {
expect(err == null).assertTrue();
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
})
.catch(function (e) {
console.log('catch ' + e.message + ', code: ' + e.code);
})
} catch(e) {
console.log('fileIO_truncate_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_ASYNC_0400
* @tc.name fileIO_truncate_async_004
* @tc.desc Test the truncate() interface that receives the fpath parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_truncate_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_truncate_async_004');
let truncateLen = 2;
try {
fileIO.truncate(fpath, truncateLen, function (err) {
done();
});
} catch (e) {
console.log('fileIO_truncate_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(!!e).assertTrue();
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0000
* @tc.name fileIO_test_truncate_sync_000
* @tc.desc Test the truncateSync() interface that receives the fpath parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_truncate_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_truncate_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
fileIO.truncateSync(fpath);
expect(fileIO.statSync(fpath).size == 0).assertTrue();
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_truncate_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0100
* @tc.name fileIO_test_truncate_sync_001
* @tc.desc Test the truncateSync() interface that receives the fd parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_truncate_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_truncate_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let file;
let truncateLen = 5;
try {
file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileIO.truncateSync(file.fd, truncateLen);
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_truncate_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0200
* @tc.name fileIO_test_truncate_sync_002
* @tc.desc Test the truncateSync() interface that receives the fpath parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_truncate_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_truncate_sync_002');
try {
let stat = fileIO.truncateSync(fpath);
console.info('fileIO_test_truncate_sync_002 = ' + stat);
expect(false).assertTrue();
} catch (e) {
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0300
* @tc.name fileIO_test_truncate_sync_003
* @tc.desc Test the truncateSync() interface that receives the fd parameter.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_truncate_sync_003', 0, async function () {
let fpath = await nextFileName('fileIO_test_truncate_sync_003');
expect(prepareFile(fpath, 'truncate')).assertTrue();
let file;
let truncateLen = 2;
try {
file = fileIO.openSync(fpath, fileIO.OpenMode.READ_WRITE);
expect(isIntNum(file.fd)).assertTrue();
fileIO.truncateSync(file.fd, truncateLen);
let len = fileIO.readSync(file.fd, new ArrayBuffer(4096));
expect(len == truncateLen).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_truncate_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0400
* @tc.name fileIO_test_truncate_sync_004
* @tc.desc Test truncateSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_truncate_sync_004', 0, function () {
try {
let stat = fileIO.truncateSync();
console.info('fileIO_test_truncate_sync_004 = ' + stat);
expect(false).assertTrue();
} catch (e) {
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_TRUNCATE_SYNC_0500
* @tc.name fileIO_test_truncate_sync_005
* @tc.desc Test truncateSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_truncate_sync_005', 0, async function () {
let fpath = await nextFileName('fileIO_test_truncate_sync_005');
let truncateLen = 2;
try {
fileIO.truncateSync(fpath, truncateLen);
} catch (e) {
console.log('fileIO_test_truncate_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(!!e).assertTrue();
}
});
});
}
/*
* Copyright (C) 2022 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 {
fileio, fileIO, FILE_CONTENT, prepareFile, nextFileName, isIntNum,
describe, it, expect,
} from '../Common';
export default function fileIOWrite() {
describe('fileIO_fs_write', function () {
/**
* @tc.number SUB_DF_FILEIO_WRITE_SYNC_0000
* @tc.name fileIO_test_write_sync_000
* @tc.desc Test writeSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_sync_000', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
expect(fileIO.writeSync(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_write_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_SYNC_0100
* @tc.name fileIO_test_write_sync_001
* @tc.desc Test writeSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_sync_001', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
expect(
fileIO.writeSync(file.fd, FILE_CONTENT, {
encoding: 'utf-8',
})
== FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_write_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_SYNC_0200
* @tc.name fileIO_test_write_sync_002
* @tc.desc Test writeSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_sync_002', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
expect(
fileIO.writeSync(file.fd, FILE_CONTENT, {
length: FILE_CONTENT.length - 1,
})
== FILE_CONTENT.length - 1).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_write_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_SYNC_0300
* @tc.name fileIO_test_write_sync_003
* @tc.desc Test writeSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_sync_003', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
expect(
fileIO.writeSync(file.fd, FILE_CONTENT, {
length: 1,
})
== 1).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_write_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_SYNC_0400
* @tc.name fileIO_test_write_sync_004
* @tc.desc Test writeSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_sync_004', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
const invalidLength = 9999;
let file;
try {
file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
fileIO.writeSync(file.fd, FILE_CONTENT, {
length: invalidLength,
})
expect(false).assertTrue();
} catch (e) {
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
console.info('fileIO_test_write_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == 'Invalid argument').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_SYNC_0500
* @tc.name fileIO_test_write_sync_005
* @tc.desc Test writeSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_sync_005', 0, function () {
try {
fileIO.writeSync(-1, FILE_CONTENT);
expect(false).assertTrue();
} catch (e) {
console.log('fileIO_test_write_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900008 && e.message == 'Bad file descriptor').assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_SYNC_0600
* @tc.name fileIO_test_write_sync_006
* @tc.desc Test writeSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_sync_006', 0, async function () {
let fpath = await nextFileName('fileIO_test_write_sync_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let writeNum = fileIO.writeSync(file.fd, new ArrayBuffer(4096));
expect(writeNum == 4096).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_write_sync_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0000
* @tc.name fileIO_test_write_async_000
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_write_async_000', 0, async function (done) {
let fpath = await nextFileName('fileIO_write_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
expect(await fileIO.write(file.fd, FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_write_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0100
* @tc.name fileIO_test_write_async_001
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_async_001', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let writeNum = await fileIO.write(file.fd, FILE_CONTENT, {
length: 3,
});
expect(writeNum == 3).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_write_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0200
* @tc.name fileIO_test_write_async_002
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_async_002', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let writeNum = await fileIO.write(file.fd, FILE_CONTENT, {
length: 3,
offset: 5,
});
expect(writeNum == 3).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_write_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0300
* @tc.name fileIO_test_write_async_003
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_async_003', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
let writeNum = await fileIO.write(file.fd, FILE_CONTENT, {
length: 4,
offset: 5,
encoding: 'utf-8',
});
expect(writeNum == 4).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileIO_test_write_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0400
* @tc.name fileIO_test_write_async_004
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_async_004', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
await fileIO.write(file.fd, new ArrayBuffer(4096), function (
error,
bytesWritten
) {
expect(bytesWritten == 4096).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
}
);
done();
} catch (e) {
console.log('fileIO_test_write_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0500
* @tc.name fileIO_test_write_async_005
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_async_005', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
await fileIO.write(
file.fd,
FILE_CONTENT,
{
length: 5,
}, function (error, bytesWritten) {
expect(bytesWritten == 5).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
}
);
} catch (e) {
console.log('fileIO_test_write_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0600
* @tc.name fileIO_test_write_async_006
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_async_006', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
await fileIO.write(
file.fd,
FILE_CONTENT,
{
length: 5,
offset: 5,
}, function (error, bytesWritten) {
expect(bytesWritten == 5).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
}
);
} catch (e) {
console.log('fileIO_test_write_async_006 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_WRITE_ASYNC_0700
* @tc.name fileIO_test_write_async_007
* @tc.desc Test write() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_write_async_007', 0, async function (done) {
let fpath = await nextFileName('fileIO_test_write_async_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.WRITE_ONLY);
expect(isIntNum(file.fd)).assertTrue();
await fileIO.write(
file.fd,
FILE_CONTENT,
{
length: 5,
offset: 5,
encoding: 'utf-8',
}, function (error, bytesWritten) {
expect(bytesWritten == 5).assertTrue();
fileio.closeSync(file.fd);
fileio.unlinkSync(fpath);
done();
}
);
} catch (e) {
console.log('fileIO_test_write_async_007 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
{
"string": [
{
"name": "app_name",
"value": "storagefilefsjstest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
...@@ -19,7 +19,7 @@ import systemTime from "@ohos.systemTime"; ...@@ -19,7 +19,7 @@ import systemTime from "@ohos.systemTime";
export default function systemTimeJsunit() { export default function systemTimeJsunit() {
describe('systemTimeTest', function () { describe('systemTimeTest', function () {
console.info('--------------------systemTimeTest start-----------------------'); console.info('====>---------------systemTimeTest start-----------------------');
/** /**
* @tc.number SUB_systemTime_getCurrentTime_JS_API_0001 * @tc.number SUB_systemTime_getCurrentTime_JS_API_0001
* @tc.name Test systemTime.getCurrentTime * @tc.name Test systemTime.getCurrentTime
...@@ -29,7 +29,7 @@ export default function systemTimeJsunit() { ...@@ -29,7 +29,7 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) { it("SUB_systemTime_getCurrentTime_JS_API_0001", 0, async function (done) {
console.info("---------------UB_systemTime_getCurrentTime_JS_API_0001 start----------------"); console.info("====>----------UB_systemTime_getCurrentTime_JS_API_0001 start----------------");
systemTime.getCurrentTime(true, (error, data) => { systemTime.getCurrentTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
...@@ -39,7 +39,7 @@ export default function systemTimeJsunit() { ...@@ -39,7 +39,7 @@ export default function systemTimeJsunit() {
expect(data != null).assertEqual(true); expect(data != null).assertEqual(true);
}); });
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------"); console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------");
done(); done();
}); });
...@@ -52,15 +52,15 @@ export default function systemTimeJsunit() { ...@@ -52,15 +52,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) { it("SUB_systemTime_getCurrentTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 start----------------"); console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 start----------------");
systemTime.getCurrentTime(true).then((data) => { systemTime.getCurrentTime(true).then((data) => {
console.info(`systemTime.getCurrentTime promise success data : ` + JSON.stringify(data)); console.info(`SUB_systemTime_getCurrentTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true); expect(data != null).assertEqual(true);
}).catch(err => { }).catch(err => {
console.error(`failed to systemTime.getCurrentTime promise because ` + JSON.stringify(error)); console.error(`SUB_systemTime_getCurrentTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail() expect().assertFail()
}); });
console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 end------------"); console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 end------------");
done(); done();
}); });
...@@ -73,17 +73,17 @@ export default function systemTimeJsunit() { ...@@ -73,17 +73,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) { it("SUB_systemTime_getRealActiveTime_JS_API_0001", 0, async function (done) {
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------"); console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 start----------------");
systemTime.getRealActiveTime(true, (error, data) => { systemTime.getRealActiveTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error)); console.error(`SUB_systemTime_getRealActiveTime_JS_API_0001 err: ` + JSON.stringify(error));
expect().assertFail() expect().assertFail()
}; };
console.info(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.info(`SUB_systemTime_getRealActiveTime_JS_API_0001 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true); expect(data != null).assertEqual(true);
}); });
console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------"); console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------");
done(); done();
}); });
...@@ -96,15 +96,15 @@ export default function systemTimeJsunit() { ...@@ -96,15 +96,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) { it("SUB_systemTime_getRealActiveTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------"); console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 start----------------");
systemTime.getRealActiveTime(true).then((data) => { systemTime.getRealActiveTime(true).then((data) => {
onsole.log(`systemTime.getRealActiveTime promise success data : ` + JSON.stringify(data)); onsole.log(`SUB_systemTime_getRealActiveTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true); expect(data != null).assertEqual(true);
}).catch(err => { }).catch(err => {
console.error(`failed to systemTime.getRealActiveTime promise because ` + JSON.stringify(error)); console.error(`SUB_systemTime_getRealActiveTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail() expect().assertFail()
}); });
console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 end------------"); console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 end------------");
done(); done();
}); });
...@@ -117,17 +117,17 @@ export default function systemTimeJsunit() { ...@@ -117,17 +117,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) { it("SUB_systemTime_getRealTime_JS_API_0001", 0, async function (done) {
console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 start----------------"); console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 start----------------");
systemTime.getRealTime(true, (error, data) => { systemTime.getRealTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`SUB_systemTime_getRealTime_JS_API_0001 err: ` + JSON.stringify(error));
expect().assertFail() expect().assertFail()
}; };
console.info(`systemTime.getRealTime success data : ` + JSON.stringify(data)); console.info(`SUB_systemTime_getRealTime_JS_API_0001 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true); expect(data != null).assertEqual(true);
}); });
console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 end-----------------"); console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 end-----------------");
done(); done();
}); });
...@@ -140,15 +140,15 @@ export default function systemTimeJsunit() { ...@@ -140,15 +140,15 @@ export default function systemTimeJsunit() {
* @tc.level : Level 1 * @tc.level : Level 1
*/ */
it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) { it("SUB_systemTime_getRealTime_JS_API_0002", 0, async function (done) {
console.info("----------SUB_systemTime_getRealTime_JS_API_0002 start----------------"); console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 start----------------");
systemTime.getRealTime(true).then((data) => { systemTime.getRealTime(true).then((data) => {
console.info(`systemTime.getRealTime promise success data : ` + JSON.stringify(data)); console.info(`SUB_systemTime_getRealTime_JS_API_0002 data : ` + JSON.stringify(data));
expect(data != null).assertEqual(true); expect(data != null).assertEqual(true);
}).catch(err => { }).catch(err => {
console.error(`failed to systemTime.getRealTime promise because ` + JSON.stringify(error)); console.error(`SUB_systemTime_getRealTime_JS_API_0002 err: ` + JSON.stringify(error));
expect().assertFail(); expect().assertFail();
}); });
console.info("----------SUB_systemTime_getRealTime_JS_API_0002 end------------"); console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 end------------");
done(); done();
}); });
...@@ -161,17 +161,17 @@ export default function systemTimeJsunit() { ...@@ -161,17 +161,17 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) { it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0100 start"); console.info("====>SUB_systemTime_setTime_JS_API_0100 start");
systemTime.setTime(1526003846000) let currentTime = new Date().getTime() + 2000
.then(data =>{ try{
console.info("setTime ===data " + data); await systemTime.setTime(currentTime)
expect(data).assertEqual(true) expect(true).assertTrue();
}).catch(error => { done();
console.info("setTime ===error " + error); }catch(err){
expect(0).assertLarger(1) console.info("====>SUB_systemTime_setTime_JS_API_0100 error " + err);
}); expect().assertFail();
console.info('SUB_systemTime_setTime_JS_API_0100 end');
done(); done();
}
}); });
/** /**
...@@ -183,17 +183,23 @@ export default function systemTimeJsunit() { ...@@ -183,17 +183,23 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) { it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0200 start"); console.info("====>SUB_systemTime_setTime_JS_API_0200 start");
systemTime.setTime(15222) try{
.then(data => { systemTime.setTime(15222).then(() => {
console.info("setTime ===data " + data); console.debug('SUB_systemTime_setTime_JS_API_0200 setTime fail')
expect().assertFail();
done();
}).catch((err)=>{
console.debug('SUB_systemTime_setTime_JS_API_0200 setTime err:' + JSON.stringify(err))
expect(true).assertTrue(); expect(true).assertTrue();
}).catch(error => { console.debug('SUB_systemTime_setTime_JS_API_0200 end');
console.info("setTime ===error " + error);
expect(0).assertLarger(1)
});
console.info('SUB_systemTime_setTime_JS_API_0200 end');
done(); done();
})
}catch(err){
console.debug('SUB_systemTime_setTime_JS_API_0200 setTime throw_err' + JSON.stringify(err))
expect(err.code).assertEqual('401');
done();
}
}); });
/** /**
...@@ -205,18 +211,19 @@ export default function systemTimeJsunit() { ...@@ -205,18 +211,19 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) { it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0300 start"); console.info("====>SUB_systemTime_setTime_JS_API_0300 start");
systemTime.setTime(1597156246000, (err, data) => { let currentTime = new Date().getTime() + 2000
if (err) { systemTime.setTime(currentTime, (err) => {
console.info("setTime ===error: " + err); try{
expect().assertFail()
}else{
console.info("setTime ===data: " + data);
expect(true).assertTrue(); expect(true).assertTrue();
};
});
console.info('SUB_systemTime_setTime_JS_API_0300 end'); console.info('SUB_systemTime_setTime_JS_API_0300 end');
done(); done();
}catch(err){
console.info("====>SUB_systemTime_setTime_JS_API_0300 error: " + err);
expect().assertFail();
done();
}
});
}); });
/** /**
...@@ -228,11 +235,11 @@ export default function systemTimeJsunit() { ...@@ -228,11 +235,11 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setTime_JS_API_0400', 0, async function (done) { it('SUB_systemTime_setTime_JS_API_0400', 0, async function (done) {
console.info("SUB_systemTime_setTime_JS_API_0400 start"); console.info("====>SUB_systemTime_setTime_JS_API_0400 start");
try{ try{
systemTime.setTime(18, (err, data) => { systemTime.setTime(18, (err, data) => {
console.info("setTime ===data: " + data); console.info("====>SUB_systemTime_setTime_JS_API_0400 data: " + data);
console.info("setTime ===error: " + err); console.info("====>SUB_systemTime_setTime_JS_API_0400 error: " + err);
expect(true).assertTrue(); expect(true).assertTrue();
})}catch(error) {error => { })}catch(error) {error => {
expect(1).assertLarger(0); expect(1).assertLarger(0);
...@@ -251,13 +258,13 @@ export default function systemTimeJsunit() { ...@@ -251,13 +258,13 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) { it('SUB_systemTime_setDate_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0100 start"); console.info("====>SUB_systemTime_setDate_JS_API_0100 start");
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(1).then(data => { systemTime.setDate(1).then(data => {
console.info("setTime ===data " + data); console.info("====>SUB_systemTime_setDate_JS_API_0100 data " + data);
expect(true).assertTrue(); expect(true).assertTrue();
}).catch(error => { }).catch(error => {
console.info("setTime ===error " + error); console.info("====>SUB_systemTime_setDate_JS_API_0100 error " + error);
expect().assertFail(); expect().assertFail();
}); });
done(); done();
...@@ -272,12 +279,12 @@ export default function systemTimeJsunit() { ...@@ -272,12 +279,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setDate_JS_API_0200', 0, async function (done) { it('SUB_systemTime_setDate_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0200 start"); console.info("====>SUB_systemTime_setDate_JS_API_0200 start");
systemTime.setDate(0).then(data => { systemTime.setDate(0).then(data => {
console.info("setTime ===data " + data); console.info("====>SUB_systemTime_setDate_JS_API_0200 data " + data);
expect(true).assertTrue(); expect(true).assertTrue();
}).catch(error => { }).catch(error => {
console.info("setTime ===error " + error); console.info("====>SUB_systemTime_setDate_JS_API_0200 error " + error);
expect().assertFail(); expect().assertFail();
}); });
done(); done();
...@@ -292,14 +299,14 @@ export default function systemTimeJsunit() { ...@@ -292,14 +299,14 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) { it('SUB_systemTime_setDate_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setDate_JS_API_0300 start"); console.info("====>SUB_systemTime_setDate_JS_API_0300 start");
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data, (error, data) => { systemTime.setDate(data, (error, data) => {
if(error){ if(error){
console.info("setTime ===error " + error); console.info("====>SUB_systemTime_setDate_JS_API_0300 error " + error);
expect().assertFail(); expect().assertFail();
}else{ }else{
console.info("setTime ===data " + data); console.info("====>SUB_systemTime_setDate_JS_API_0300 data " + data);
expect(true).assertTrue(); expect(true).assertTrue();
}; };
}); });
...@@ -315,12 +322,12 @@ export default function systemTimeJsunit() { ...@@ -315,12 +322,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setTimezone_JS_API_0100', 0, async function (done) { it('SUB_systemTime_setTimezone_JS_API_0100', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0100 start"); console.info("====>SUB_systemTime_setTimezone_JS_API_0100 start");
systemTime.setTimezone('Asia, Shanghai').then(data => { systemTime.setTimezone('Asia, Shanghai').then(data => {
console.info("setTime ===data " + data); console.info("====>SUB_systemTime_setTimezone_JS_API_0100 data " + data);
expect().assertFail(); expect().assertFail();
}).catch(error => { }).catch(error => {
console.info("setTime ===error " + error); console.info("====>SUB_systemTime_setTimezone_JS_API_0100 error " + error);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
done(); done();
...@@ -335,12 +342,12 @@ export default function systemTimeJsunit() { ...@@ -335,12 +342,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setTimezone_JS_API_0200', 0, async function (done) { it('SUB_systemTime_setTimezone_JS_API_0200', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0200 start"); console.info("====>SUB_systemTime_setTimezone_JS_API_0200 start");
systemTime.setTimezone('Beijing,China').then(data => { systemTime.setTimezone('Beijing,China').then(data => {
console.info("setTime ===data " + data); console.info("====>SUB_systemTime_setTimezone_JS_API_0200 data " + data);
expect().assertFail(); expect().assertFail();
}).catch(error => { }).catch(error => {
console.info("setTime ===error " + error); console.info("====>SUB_systemTime_setTimezone_JS_API_0200 error " + error);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
done(); done();
...@@ -355,12 +362,12 @@ export default function systemTimeJsunit() { ...@@ -355,12 +362,12 @@ export default function systemTimeJsunit() {
* @tc.level : Level 0 * @tc.level : Level 0
*/ */
it('SUB_systemTime_setTimezone_JS_API_0300', 0, async function (done) { it('SUB_systemTime_setTimezone_JS_API_0300', 0, async function (done) {
console.info("SUB_systemTime_setTimezone_JS_API_0300 start"); console.info("====>SUB_systemTime_setTimezone_JS_API_0300 start");
systemTime.setTimezone('Baker Island, U.S.A.').then(data => { systemTime.setTimezone('Baker Island, U.S.A.').then(data => {
console.info("setTime ===data " + data); console.info("====>SUB_systemTime_setTimezone_JS_API_0300 data " + data);
expect().assertFail(); expect().assertFail();
}).catch(error => { }).catch(error => {
console.info("setTime ===error " + error); console.info("====>SUB_systemTime_setTimezone_JS_API_0300 error " + error);
expect(true).assertTrue(); expect(true).assertTrue();
}); });
done(); done();
......
...@@ -19,7 +19,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -19,7 +19,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export default function systemTimerTest() { export default function systemTimerTest() {
describe('systemTimerTest', function () { describe('systemTimerTest', function () {
console.info('systemTimer Test start'); console.info('====>systemTimer Test start');
//wantAgent对象 //wantAgent对象
var wantAgent; var wantAgent;
...@@ -43,11 +43,11 @@ export default function systemTimerTest() { ...@@ -43,11 +43,11 @@ export default function systemTimerTest() {
* beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed. * beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.
*/ */
beforeAll(function () { beforeAll(function () {
console.info('beforeAll: Prerequisites are executed.'); console.info('====>beforeAll: Prerequisites are executed.');
WantAgent.getWantAgent(wantAgentInfo) WantAgent.getWantAgent(wantAgentInfo)
.then((data) => { .then((data) => {
if ( data != undefined || data != null) { if ( data != undefined || data != null) {
console.info('beforeAll: success to get wantAgent: ' + typeof(data)); console.info('====>beforeAll: success to get wantAgent: ' + typeof(data));
wantAgent = data; wantAgent = data;
} }
}) })
...@@ -60,21 +60,21 @@ export default function systemTimerTest() { ...@@ -60,21 +60,21 @@ export default function systemTimerTest() {
* beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.
*/ */
beforeEach(function () { 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: Test case-level clearance conditions, which are executed after each test case is executed.
*/ */
afterEach(function () { 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: Test suite-level cleanup condition, which is executed after the test suite is executed.
*/ */
afterAll(function () { afterAll(function () {
console.info('afterAll: Test suite-level cleanup condition is executed.'); console.info('====>afterAll: Test suite-level cleanup condition is executed.');
}); });
/** /**
...@@ -86,27 +86,27 @@ export default function systemTimerTest() { ...@@ -86,27 +86,27 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_createTimer_0000', 0, async function (done) { it('SUB_time_systemTimer_createTimer_0000', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0000 start.'); console.info('====>SUB_time_systemTimer_createTimer_0000 start.');
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false repeat: false
}; };
try { try {
console.info('SUB_time_systemTimer_createTimer_0000 create timer.'); console.info('====>SUB_time_systemTimer_createTimer_0000 create timer.');
systemTimer.createTimer(options, function (err, timerID) { systemTimer.createTimer(options, function (err, timerID) {
if (err) { if (err) {
// 处理业务逻辑错误 // 处理业务逻辑错误
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
console.info('SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID); console.info('====>SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID);
globalTimerID = timerID; globalTimerID = timerID;
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
// 捕获参数错误 // 捕获参数错误
console.info('SUB_time_systemTimer_createTimer_0000 has failed for ' + err); console.info('====>SUB_time_systemTimer_createTimer_0000 has failed for ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -121,7 +121,7 @@ export default function systemTimerTest() { ...@@ -121,7 +121,7 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_createTimer_0001', 0, async function (done) { it('SUB_time_systemTimer_createTimer_0001', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0001 start.'); console.info('====>SUB_time_systemTimer_createTimer_0001 start.');
let options = { let options = {
type: systemTimer.TIMER_TYPE_IDLE, type: systemTimer.TIMER_TYPE_IDLE,
repeat: false repeat: false
...@@ -129,16 +129,16 @@ export default function systemTimerTest() { ...@@ -129,16 +129,16 @@ export default function systemTimerTest() {
try { try {
systemTimer.createTimer(options, function (err, timerID) { systemTimer.createTimer(options, function (err, timerID) {
if (err) { if (err) {
console.info('SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code); console.info('====>SUB_time_systemTimer_createTimer_0001 wrong since ' + err.code);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
console.info('SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID); console.info('====>SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code); console.info('====>SUB_time_systemTimer_createTimer_0001 arv wrong since ' + e.code);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -153,9 +153,9 @@ export default function systemTimerTest() { ...@@ -153,9 +153,9 @@ export default function systemTimerTest() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_time_systemTimer_createTimer_0002', 2, async function (done) { it('SUB_time_systemTimer_createTimer_0002', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0002 start"); console.info("====>SUB_time_systemTimer_createTimer_0002 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{ WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info('SUB_time_systemTimer_createTimer_0002 BundleName: ' + data); console.info('====>SUB_time_systemTimer_createTimer_0002 BundleName: ' + data);
}) })
let options = { let options = {
type: systemTimer.TIMER_TYPE_WAKEUP, type: systemTimer.TIMER_TYPE_WAKEUP,
...@@ -164,19 +164,19 @@ export default function systemTimerTest() { ...@@ -164,19 +164,19 @@ export default function systemTimerTest() {
interval: interval_time interval: interval_time
}; };
try { try {
console.info("SUB_time_systemTimer_createTimer_0002 create timer") console.info("====>SUB_time_systemTimer_createTimer_0002 create timer")
systemTimer.createTimer(options, function (err, timerID) { systemTimer.createTimer(options, function (err, timerID) {
if (err) { if (err) {
console.info('SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code); console.info('====>SUB_time_systemTimer_createTimer_0002 wrong since ' + err.code);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
console.info('SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID); console.info('====>SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e); console.info('====>SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -191,16 +191,16 @@ export default function systemTimerTest() { ...@@ -191,16 +191,16 @@ export default function systemTimerTest() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_time_systemTimer_createTimer_0003', 2, async function (done) { it('SUB_time_systemTimer_createTimer_0003', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0003 start"); console.info("====>SUB_time_systemTimer_createTimer_0003 start");
let options = { let options = {
type: systemTimer.TIMER_TYPE_EXACT, type: systemTimer.TIMER_TYPE_EXACT,
repeat: false repeat: false
}; };
try { try {
console.info("SUB_time_systemTimer_createTimer_0003 create timer") console.info("====>SUB_time_systemTimer_createTimer_0003 create timer")
systemTimer.createTimer(options, function (err, timerID) { systemTimer.createTimer(options, function (err, timerID) {
if (err) { if (err) {
console.info('SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code); console.info('====>SUB_time_systemTimer_createTimer_0003 wrong since ' + err.code);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
...@@ -208,7 +208,7 @@ export default function systemTimerTest() { ...@@ -208,7 +208,7 @@ export default function systemTimerTest() {
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e); console.info('====>SUB_time_systemTimer_createTimer_0002 arv wrong since ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -223,9 +223,9 @@ export default function systemTimerTest() { ...@@ -223,9 +223,9 @@ export default function systemTimerTest() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_time_systemTimer_createTimer_0004', 2, async function (done) { it('SUB_time_systemTimer_createTimer_0004', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0004 start"); console.info("====>SUB_time_systemTimer_createTimer_0004 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{ WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info("SUB_time_systemTimer_createTimer_0004 BundleName: " + data); console.info("====>SUB_time_systemTimer_createTimer_0004 BundleName: " + data);
}); });
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
...@@ -234,7 +234,7 @@ export default function systemTimerTest() { ...@@ -234,7 +234,7 @@ export default function systemTimerTest() {
interval: interval_time interval: interval_time
}; };
try { try {
console.info("SUB_time_systemTimer_createTimer_0004 create timer") console.info("====>SUB_time_systemTimer_createTimer_0004 create timer")
systemTimer.createTimer(options, function (err, timerID) { systemTimer.createTimer(options, function (err, timerID) {
if (err) { if (err) {
expect().assertTrue(); expect().assertTrue();
...@@ -244,7 +244,7 @@ export default function systemTimerTest() { ...@@ -244,7 +244,7 @@ export default function systemTimerTest() {
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0004 has failed for ' + e); console.info('====>SUB_time_systemTimer_createTimer_0004 has failed for ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -260,24 +260,24 @@ export default function systemTimerTest() { ...@@ -260,24 +260,24 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_createTimer_0005', 0, async function (done) { it('SUB_time_systemTimer_createTimer_0005', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0005 start.'); console.info('====>SUB_time_systemTimer_createTimer_0005 start.');
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false repeat: false
}; };
try { try {
console.info('SUB_time_systemTimer_createTimer_0005 create timer.'); console.info('====>SUB_time_systemTimer_createTimer_0005 create timer.');
systemTimer.createTimer(options).then((timerID) =>{ systemTimer.createTimer(options).then((timerID) =>{
console.info('SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID); console.info('====>SUB_time_systemTimer_createTimer_0005 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0005 promise failed ' + err); console.info('====>SUB_time_systemTimer_createTimer_0005 promise failed ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
console.info('SUB_time_systemTimer_createTimer_0005 has failed for ' + err); console.info('====>SUB_time_systemTimer_createTimer_0005 has failed for ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -292,23 +292,23 @@ export default function systemTimerTest() { ...@@ -292,23 +292,23 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) { it('SUB_time_systemTimer_createTimer_0006', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0006 start.'); console.info('====>SUB_time_systemTimer_createTimer_0006 start.');
let options = { let options = {
type: systemTimer.TIMER_TYPE_IDLE, type: systemTimer.TIMER_TYPE_IDLE,
repeat: false repeat: false
}; };
try { try {
systemTimer.createTimer(options).then((timerID) => { systemTimer.createTimer(options).then((timerID) => {
console.info('SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID); console.info('====>SUB_time_systemTimer_createTimer_0006 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0006 promise failed ' + err); console.info('====>SUB_time_systemTimer_createTimer_0006 promise failed ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code); console.info('====>SUB_time_systemTimer_createTimer_0006 arv wrong since ' + e.code);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -323,9 +323,9 @@ export default function systemTimerTest() { ...@@ -323,9 +323,9 @@ export default function systemTimerTest() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_time_systemTimer_createTimer_0007', 2, async function (done) { it('SUB_time_systemTimer_createTimer_0007', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0007 start"); console.info("====>SUB_time_systemTimer_createTimer_0007 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{ WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info('SUB_time_systemTimer_createTimer_0007 BundleName: ' + data); console.info('====>SUB_time_systemTimer_createTimer_0007 BundleName: ' + data);
}) })
let options = { let options = {
type: systemTimer.TIMER_TYPE_WAKEUP, type: systemTimer.TIMER_TYPE_WAKEUP,
...@@ -334,18 +334,18 @@ export default function systemTimerTest() { ...@@ -334,18 +334,18 @@ export default function systemTimerTest() {
interval: interval_time interval: interval_time
}; };
try { try {
console.info("SUB_time_systemTimer_createTimer_0007 create timer"); console.info("====>SUB_time_systemTimer_createTimer_0007 create timer");
systemTimer.createTimer(options).then((timerID) => { systemTimer.createTimer(options).then((timerID) => {
console.info('SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID); console.info('====>SUB_time_systemTimer_createTimer_0007 timerID: ' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0007 promise failed ' + err); console.info('====>SUB_time_systemTimer_createTimer_0007 promise failed ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e); console.info('====>SUB_time_systemTimer_createTimer_0007 arv wrong since ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -360,23 +360,23 @@ export default function systemTimerTest() { ...@@ -360,23 +360,23 @@ export default function systemTimerTest() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_time_systemTimer_createTimer_0008', 2, async function (done) { it('SUB_time_systemTimer_createTimer_0008', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0008 start"); console.info("====>SUB_time_systemTimer_createTimer_0008 start");
let options = { let options = {
type: systemTimer.TIMER_TYPE_EXACT, type: systemTimer.TIMER_TYPE_EXACT,
repeat: false repeat: false
}; };
try { try {
console.info("SUB_time_systemTimer_createTimer_0008 create timer") console.info("====>SUB_time_systemTimer_createTimer_0008 create timer")
systemTimer.createTimer(options).then((timerID) => { systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0008 promise failed ' + err); console.info('====>SUB_time_systemTimer_createTimer_0008 promise failed ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e); console.info('====>SUB_time_systemTimer_createTimer_0008 arv wrong since ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -391,9 +391,9 @@ export default function systemTimerTest() { ...@@ -391,9 +391,9 @@ export default function systemTimerTest() {
* @tc.level Level 2 * @tc.level Level 2
*/ */
it('SUB_time_systemTimer_createTimer_0009', 2, async function (done) { it('SUB_time_systemTimer_createTimer_0009', 2, async function (done) {
console.info("SUB_time_systemTimer_createTimer_0009 start"); console.info("====>SUB_time_systemTimer_createTimer_0009 start");
WantAgent.getBundleName(wantAgent, (err, data)=>{ WantAgent.getBundleName(wantAgent, (err, data)=>{
console.info("SUB_time_systemTimer_createTimer_0009 BundleName: " + data); console.info("====>SUB_time_systemTimer_createTimer_0009 BundleName: " + data);
}); });
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
...@@ -402,17 +402,17 @@ export default function systemTimerTest() { ...@@ -402,17 +402,17 @@ export default function systemTimerTest() {
interval: interval_time interval: interval_time
}; };
try { try {
console.info("SUB_time_systemTimer_createTimer_0009 create timer") console.info("====>SUB_time_systemTimer_createTimer_0009 create timer")
systemTimer.createTimer(options).then((timerID) => { systemTimer.createTimer(options).then((timerID) => {
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
done(); done();
}).catch(err => { }).catch(err => {
console.info('SUB_time_systemTimer_createTimer_0009 promise failed ' + err); console.info('====>SUB_time_systemTimer_createTimer_0009 promise failed ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_createTimer_0009 has failed for ' + e); console.info('====>SUB_time_systemTimer_createTimer_0009 has failed for ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -427,21 +427,21 @@ export default function systemTimerTest() { ...@@ -427,21 +427,21 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_startTimer_0001', 0, async function (done) { it('SUB_time_systemTimer_startTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_startTimer_0001 start"); console.info("====>SUB_time_systemTimer_startTimer_0001 start");
try { try {
console.info("SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID) console.info("====>SUB_time_systemTimer_startTimer_0001 start timer, timerID: " + globalTimerID)
let triggerTime = new Date().getTime() + interval_time * 1.2; let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) { systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) {
if (err) { if (err) {
console.info('SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code); console.info('====>SUB_time_systemTimer_startTimer_0001 wrong since ' + err.code);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
console.info("SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID); console.info("====>SUB_time_systemTimer_startTimer_0001 success to start timerID: " + globalTimerID);
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_startTimer_0001 has failed for ' + e); console.info('====>SUB_time_systemTimer_startTimer_0001 has failed for ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -456,19 +456,19 @@ export default function systemTimerTest() { ...@@ -456,19 +456,19 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_stopTimer_0001', 0, async function (done) { it('SUB_time_systemTimer_stopTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_stopTimer_0001 start"); console.info("====>SUB_time_systemTimer_stopTimer_0001 start");
try { try {
console.info("SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID) console.info("====>SUB_time_systemTimer_stopTimer_0001 stop timer, timerID: " + globalTimerID)
systemTimer.stopTimer(globalTimerID, function (err, data) { systemTimer.stopTimer(globalTimerID, function (err, data) {
if (err) { if (err) {
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
console.info("SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID); console.info("====>SUB_time_systemTimer_stopTimer_0001 success to stop timerID: " + globalTimerID);
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_stopTimer_0001 has failed for ' + e); console.info('====>SUB_time_systemTimer_stopTimer_0001 has failed for ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -483,19 +483,19 @@ export default function systemTimerTest() { ...@@ -483,19 +483,19 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_destroyTimer_0001', 0, async function (done) { it('SUB_time_systemTimer_destroyTimer_0001', 0, async function (done) {
console.info("SUB_time_systemTimer_destroyTimer_0001 start"); console.info("====>SUB_time_systemTimer_destroyTimer_0001 start");
try { try {
console.info("SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID) console.info("====>SUB_time_systemTimer_destroyTimer_0001 destroy timer, timerID: " + globalTimerID)
systemTimer.destroyTimer(globalTimerID, function (err, data) { systemTimer.destroyTimer(globalTimerID, function (err, data) {
if (err) { if (err) {
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
console.info("SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID); console.info("====>SUB_time_systemTimer_destroyTimer_0001 success to destroy timerID: " + globalTimerID);
done(); done();
}); });
} catch (e) { } catch (e) {
console.info('SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e); console.info('====>SUB_time_systemTimer_destroyTimer_0001 has failed for ' + e);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -510,27 +510,27 @@ export default function systemTimerTest() { ...@@ -510,27 +510,27 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_createTimer_0002', 0, async function (done) { it('SUB_time_systemTimer_createTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_createTimer_0002 start.'); console.info('====>SUB_time_systemTimer_createTimer_0002 start.');
let options = { let options = {
type: systemTimer.TIMER_TYPE_REALTIME, type: systemTimer.TIMER_TYPE_REALTIME,
repeat: false repeat: false
}; };
try { try {
console.info('SUB_time_systemTimer_createTimer_0002 create timer.'); console.info('====>SUB_time_systemTimer_createTimer_0002 create timer.');
systemTimer.createTimer(options).then((timerID)=>{ systemTimer.createTimer(options).then((timerID)=>{
console.info('SUB_time_systemTimer_createTimer_0002 timerID:' + timerID); console.info('====>SUB_time_systemTimer_createTimer_0002 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
globalTimerID = timerID; globalTimerID = timerID;
done(); done();
}).catch( error => { }).catch( error => {
// 捕获业务逻辑错误 // 捕获业务逻辑错误
console.info('SUB_time_systemTimer_createTimer_0002 failed to create timer.'); console.info('====>SUB_time_systemTimer_createTimer_0002 failed to create timer.');
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
// 捕获参数错误 // 捕获参数错误
console.info('SUB_time_systemTimer_createTimer_0002 has failed for ' + err); console.info('====>SUB_time_systemTimer_createTimer_0002 has failed for ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -545,23 +545,23 @@ export default function systemTimerTest() { ...@@ -545,23 +545,23 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_startTimer_0002', 0, async function (done) { it('SUB_time_systemTimer_startTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_startTimer_0002 start.'); console.info('====>SUB_time_systemTimer_startTimer_0002 start.');
try { try {
console.info('SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID); console.info('====>SUB_time_systemTimer_startTimer_0002 start timer, timerID: ' + globalTimerID);
let triggerTime = new Date().getTime() + interval_time * 2; let triggerTime = new Date().getTime() + interval_time * 2;
systemTimer.startTimer(globalTimerID, triggerTime) systemTimer.startTimer(globalTimerID, triggerTime)
.then(()=>{ .then(()=>{
console.info('SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID); console.info('====>SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID);
done(); done();
}).catch(()=>{ }).catch(()=>{
// 捕获业务逻辑错误 // 捕获业务逻辑错误
console.info('SUB_time_systemTimer_startTimer_0002 failed to start timer.'); console.info('====>SUB_time_systemTimer_startTimer_0002 failed to start timer.');
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
// 捕获参数错误 // 捕获参数错误
console.info('SUB_time_systemTimer_startTimer_0002 has failed for ' + err); console.info('====>SUB_time_systemTimer_startTimer_0002 has failed for ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
...@@ -576,22 +576,22 @@ export default function systemTimerTest() { ...@@ -576,22 +576,22 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_stopTimer_0002', 0, async function (done) { it('SUB_time_systemTimer_stopTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_stopTimer_0002 start.'); console.info('====>SUB_time_systemTimer_stopTimer_0002 start.');
try { try {
console.info('SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID); console.info('====>SUB_time_systemTimer_stopTimer_0002 stop timer, timerID: ' + globalTimerID);
systemTimer.stopTimer(globalTimerID) systemTimer.stopTimer(globalTimerID)
.then(()=>{ .then(()=>{
console.info('SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID); console.info('====>SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID);
done(); done();
}).catch(()=>{ }).catch(()=>{
// 捕获业务逻辑错误 // 捕获业务逻辑错误
console.info('SUB_time_systemTimer_stopTimer_0002 failed to stop timer.'); console.info('====>SUB_time_systemTimer_stopTimer_0002 failed to stop timer.');
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
// 捕获参数错误 // 捕获参数错误
console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err); console.info('====>SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -606,22 +606,22 @@ export default function systemTimerTest() { ...@@ -606,22 +606,22 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_destroyTimer_0002', 0, async function (done) { it('SUB_time_systemTimer_destroyTimer_0002', 0, async function (done) {
console.info('SUB_time_systemTimer_destroyTimer_0002 start.'); console.info('====>SUB_time_systemTimer_destroyTimer_0002 start.');
try { try {
console.info('SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID); console.info('====>SUB_time_systemTimer_destroyTimer_0002 destroy timer, timerID: ' + globalTimerID);
systemTimer.destroyTimer(globalTimerID) systemTimer.destroyTimer(globalTimerID)
.then(()=>{ .then(()=>{
console.info('SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID); console.info('====>SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID);
done(); done();
}).catch(()=>{ }).catch(()=>{
// 捕获业务逻辑错误 // 捕获业务逻辑错误
console.info('SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.'); console.info('====>SUB_time_systemTimer_destroyTimer_0002 failed to destroy timer.');
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
// 捕获参数错误 // 捕获参数错误
console.info('SUB_time_systemTimer_stopTimer_0002 has failed for ' + err); console.info('====>SUB_time_systemTimer_stopTimer_0002 has failed for ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
}; };
...@@ -636,65 +636,65 @@ export default function systemTimerTest() { ...@@ -636,65 +636,65 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_ALL_Promise_0008', 0, async function (done) { it('SUB_time_systemTimer_ALL_Promise_0008', 0, async function (done) {
console.info('SUB_time_systemTimer_ALL_Promise_0008 start.'); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start.');
let options = { let options = {
type: systemTimer.TIMER_TYPE_WAKEUP, type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false repeat: false
}; };
try { try {
console.info('SUB_time_systemTimer_ALL_Promise_0008 create timer.'); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 create timer.');
systemTimer.createTimer(options) systemTimer.createTimer(options)
.then((timerID)=>{ .then((timerID)=>{
console.info('SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
try { try {
let triggerTime = new Date().getTime() + interval_time * 1.2; let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime) systemTimer.startTimer(timerID, triggerTime)
.then(()=>{ .then(()=>{
console.info('SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID);
try { try {
systemTimer.stopTimer(timerID) systemTimer.stopTimer(timerID)
.then(()=>{ .then(()=>{
systemTimer.destroyTimer(timerID, function (err, data) { systemTimer.destroyTimer(timerID, function (err, data) {
console.info('SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 destroyTimer: ' + timerID);
done(); done();
}); });
}) })
.catch(()=>{ .catch(()=>{
// 捕获stopTimer业务逻辑错误 // 捕获stopTimer业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.'); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue(); expect().assertTrue();
done(); done();
}) })
} catch (err) { } catch (err) {
// 捕获stopTimer参数错误 // 捕获stopTimer参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 stopTimer with wrong arg: ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
}) })
.catch(()=>{ .catch(()=>{
// 捕获startTimer业务逻辑错误 // 捕获startTimer业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.'); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to stop timer.');
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
// 捕获参数错误 // 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 startTimer with wrong arg: ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
}) })
.catch(()=>{ .catch(()=>{
// 捕获业务逻辑错误 // 捕获业务逻辑错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.'); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 failed to create timer.');
expect().assertTrue(); expect().assertTrue();
done(); done();
}); });
} catch (err) { } catch (err) {
// 捕获参数错误 // 捕获参数错误
console.info('SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err); console.info('====>SUB_time_systemTimer_ALL_Promise_0008 createTimer with wrong arg: ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
...@@ -709,42 +709,42 @@ export default function systemTimerTest() { ...@@ -709,42 +709,42 @@ export default function systemTimerTest() {
* @tc.level Level 0 * @tc.level Level 0
*/ */
it('SUB_time_systemTimer_ALL_Callback_0009', 0, async function (done) { it('SUB_time_systemTimer_ALL_Callback_0009', 0, async function (done) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 start.'); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start.');
let options = { let options = {
type: systemTimer.TIMER_TYPE_WAKEUP, type: systemTimer.TIMER_TYPE_WAKEUP,
repeat: false repeat: false
}; };
try { try {
console.info('SUB_time_systemTimer_ALL_Callback_0009 create timer.'); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 create timer.');
systemTimer.createTimer(options) systemTimer.createTimer(options)
.then((timerID)=>{ .then((timerID)=>{
console.info('SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 timerID:' + timerID);
expect(Number.isInteger(timerID)).assertTrue(); expect(Number.isInteger(timerID)).assertTrue();
try { try {
let triggerTime = new Date().getTime() + interval_time * 1.2; let triggerTime = new Date().getTime() + interval_time * 1.2;
systemTimer.startTimer(timerID, triggerTime, ()=>{ systemTimer.startTimer(timerID, triggerTime, ()=>{
console.info('SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 start timerID: ' + timerID);
try { try {
systemTimer.stopTimer(timerID, ()=>{ systemTimer.stopTimer(timerID, ()=>{
systemTimer.destroyTimer(timerID, function (err, data) { systemTimer.destroyTimer(timerID, function (err, data) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 destroyTimer: ' + timerID);
done(); done();
}); });
}) })
} catch (err) { } catch (err) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 stopTimer with wrong arg: ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
}) })
} catch (err) { } catch (err) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 startTimer with wrong arg: ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
}) })
} catch (err) { } catch (err) {
console.info('SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err); console.info('====>SUB_time_systemTimer_ALL_Callback_0009 createTimer with wrong arg: ' + err);
expect().assertTrue(); expect().assertTrue();
done(); done();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册