diff --git a/communication/BUILD.gn b/communication/BUILD.gn index 3f600974f5776f2fee1f65ae37a4c042b508c423..08aed112359ceafb33ebf26a836965a22be30eec 100644 --- a/communication/BUILD.gn +++ b/communication/BUILD.gn @@ -21,7 +21,6 @@ group("communication") { "bluetooth_profile:ActsBluetoothProFileJsTest", "bluetooth_standard:ActsBluetoothJsTest", "dsoftbus/rpc:ActsRpcJsTest", - "dsoftbus/rpc_server:ActsRpcJsServer", "nfc_Controller:ActsNFCJSTest", "wifi_p2p:ActsP2PJSTest", "wifi_standard:ActsWifiJSTest", diff --git a/communication/dsoftbus/rpc/Test.json b/communication/dsoftbus/rpc/Test.json index 64b24131994477ff3cec9dd94382111ae24f2e17..486d5ae51be5373f210d6a0f1ee37a5bd80cfd38 100644 --- a/communication/dsoftbus/rpc/Test.json +++ b/communication/dsoftbus/rpc/Test.json @@ -12,8 +12,7 @@ "kits": [ { "test-file-name": [ - "ActsRpcHapTest.hap", - "ActsRpcHapServer.hap" + "ActsRpcHapTest.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js b/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js index 375844d6520ccec66edb88d47775a0e6d769412d..f8f4f2fe07e3ce7c91838ba5fcec57a770924726 100755 --- a/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js +++ b/communication/dsoftbus/rpc/src/main/js/test/RpcClientJsunit.test.js @@ -17,12 +17,15 @@ import rpc from '@ohos.rpc' import fileio from '@ohos.fileio'; import FA from '@ohos.ability.featureAbility' import {describe, expect, beforeAll, it} from 'deccjsunit/index' +var gIRemoteObject = null; export default function actsRpcClientJsTest() { - - var gIRemoteObject = undefined; - describe('ActsRpcClientJsTest', function(){ 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 (){ console.info('beforeEach called'); @@ -73,87 +76,6 @@ export default function actsRpcClientJsTest() { const CODE_ONREMOTEMESSAGE_OR_ONREMOTE = 32; 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) { var now = new Date(); @@ -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 { constructor(descriptor) { super(descriptor) @@ -270,7 +630,6 @@ export default function actsRpcClientJsTest() { constructor(descriptor) { super(descriptor) } - onRemoteMessageRequest(code, data, reply, option) { console.info("TestAbilityMessageStub: onRemoteMessageRequest called, code: " + code) let descriptor = data.readInterfaceToken() @@ -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.name Call the writeinterfacetoken interface, write the interface descriptor, and read interfacetoken @@ -5079,7 +5427,7 @@ export default function actsRpcClientJsTest() { data.reclaim() reply.reclaim() - console.info("test done") + done(); } catch(error) { console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13000: error = " + error); } @@ -5105,7 +5453,6 @@ export default function actsRpcClientJsTest() { done() } } - try{ let option = new rpc.MessageOption() let data = rpc.MessageParcel.create() @@ -5121,26 +5468,26 @@ export default function actsRpcClientJsTest() { expect(data.writeString("rpcListenerTest")).assertTrue() await gIRemoteObject.sendRequest(CODE_WRITE_REMOTEOBJECTARRAY_2, data, reply, option) .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) result.reply.readException() }) - data.reclaim() reply.reclaim() console.info("test done") } catch(error) { console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13100: error = " + error); } + done(); console.info("---------------------end SUB_Softbus_IPC_Compatibility_MessageParcel_13100---------------------------"); }) /* - * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_13200 - * @tc.name Invoke the rewindRead interface, write the POS, and read the offset value - * @tc.desc Function test - * @tc.level 0 - */ + * @tc.number SUB_Softbus_IPC_Compatibility_MessageParcel_13200 + * @tc.name Invoke the rewindRead interface, write the POS, and read the offset value + * @tc.desc Function test + * @tc.level 0 + */ it("SUB_Softbus_IPC_Compatibility_MessageParcel_13200", 0, async function(done){ console.info("---------------------start SUB_Softbus_IPC_Compatibility_MessageParcel_13200---------------------------"); try{ @@ -5311,7 +5658,7 @@ export default function actsRpcClientJsTest() { expect(result.errCode == 0).assertTrue(); let getMePaCapacity = result.reply.getCapacity(); 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"); }); data.reclaim(); @@ -5350,7 +5697,7 @@ export default function actsRpcClientJsTest() { expect(result.reply.readString()).assertEqual("constant"); let getMeCa = result.reply.getCapacity(); 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(); reply.reclaim(); @@ -5425,7 +5772,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_13900:run getSizeis is " + getSizeresult); let setCapacityresult = result.reply.getCapacity(); 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(); reply.reclaim(); @@ -6020,7 +6367,7 @@ export default function actsRpcClientJsTest() { { 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); var replyReadResult = result.reply.readString(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15500: run readString is " + replyReadResult); @@ -6050,13 +6397,13 @@ export default function actsRpcClientJsTest() { var reply = rpc.MessageSequence.create(); var option = new rpc.MessageOption(); var token = 'onRemoteMessageRequest invoking'; - var result = data.writeString(token); - console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600:run writeStringis is " + result); + data.writeString(token); + console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600:run writeStringis is success"); if (gIRemoteObject == 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); var replyReadResult = result.reply.readString(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15600: run readString is " + replyReadResult); @@ -6162,7 +6509,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900:run writeStringis is " + result); data.reclaim(); } 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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_15900: errorMessage " + error.message); @@ -6189,7 +6536,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000:run writeInterfaceToken result "); data.reclaim(); } 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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message); @@ -6217,7 +6564,7 @@ export default function actsRpcClientJsTest() { data.reclaim(); } 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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: errorMessage " + error.message); @@ -6244,7 +6591,7 @@ export default function actsRpcClientJsTest() { data.readParcelable(ret); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16200: readParcelable is." + ret); } 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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16000: errorMessage " + error.message); @@ -6267,7 +6614,7 @@ export default function actsRpcClientJsTest() { var token = {} var result = data.writeRemoteObject(token); } 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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16300: errorMessage " + error.message); @@ -6298,7 +6645,7 @@ export default function actsRpcClientJsTest() { data.readParcelable(ret); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16100: readParcelable is." + ret); } 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); expect(error.message != null).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16400:error = " + error.code); @@ -6326,7 +6673,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:run readInterfaceToken result is " + resultToken); data.reclaim(); } 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); expect(error.message != null).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16500:error = " + error.code); @@ -6349,7 +6696,7 @@ export default function actsRpcClientJsTest() { let newFd = rpc.MessageSequence.dupFileDescriptor(fd); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: newFd " +newFd); } 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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_MessageParcel_16600: errorMessage" + error.message); @@ -6668,7 +7015,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01100: sendRequestis is " + result.errCode); var replyReadResult = result.reply.readString(); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01100: run readString is " + replyReadResult); - expect(replyReadResult).assertEqual(""); + expect(replyReadResult).assertEqual("option"); expect(option.getFlags()).assertEqual(1); }); @@ -6709,7 +7056,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01200: sendRequestis is " + result.errCode); var replyReadResult = result.reply.readString(); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01200: run readString is " + replyReadResult); - expect(replyReadResult).assertEqual(""); + expect(replyReadResult).assertEqual("option"); expect(option.getFlags()).assertEqual(3); }); data.reclaim(); @@ -6747,7 +7094,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: sendMessageRequest is " + result.errCode); var replyReadResult = result.reply.readString(); console.info("SUB_Softbus_IPC_Compatibility_MessageOption_01300: run readString is " + replyReadResult); - expect(replyReadResult).assertEqual(""); + expect(replyReadResult).assertEqual("option"); expect(option.getFlags()).assertEqual(1); }); @@ -6826,7 +7173,7 @@ export default function actsRpcClientJsTest() { let isAsyncData = option.isAsync(); expect(isAsyncData).assertTrue(); var replyReadResult = result.reply.readString(); - expect(replyReadResult).assertEqual(""); + expect(replyReadResult).assertEqual("option"); }); data.reclaim(); reply.reclaim(); @@ -7951,7 +8298,7 @@ export default function actsRpcClientJsTest() { let ashmem = rpc.Ashmem.create("ashmem", (2*G + 1)); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: ashmem " + ashmem); }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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04100: errorMessage " + error.message); @@ -7974,7 +8321,7 @@ export default function actsRpcClientJsTest() { ashmem.mapReadWriteAshmem(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: run mapReadWriteAshmem is success"); }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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04200: error " + error.message); @@ -7995,7 +8342,7 @@ export default function actsRpcClientJsTest() { let ashmem = rpc.Ashmem.create("ashmem", 0); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: ashmem " + ashmem); }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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04300: errorMessage " + error.message); @@ -8038,7 +8385,7 @@ export default function actsRpcClientJsTest() { ashmem.setProtectionType(rpc.Ashmem.PROT_WRITE, rpc.Ashmem.PROT_READ); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: run setProtectionType is success"); }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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04500: errorMessage " + error.message); @@ -8061,7 +8408,7 @@ export default function actsRpcClientJsTest() { ashmem.setProtectionType(null); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: run setProtectionType is success"); }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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04600: errorMessage " + error.message); @@ -8087,7 +8434,7 @@ export default function actsRpcClientJsTest() { data.reclaim(); data2.reclaim(); }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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04700: error " + error.message); @@ -8114,7 +8461,7 @@ export default function actsRpcClientJsTest() { let readResult = ashmem.readAshmem(5, 0); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04800: readAshmem is : " + readResult); }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); expect(error.code != errCode).assertEqual(null); } @@ -8138,7 +8485,7 @@ export default function actsRpcClientJsTest() { expect(size).assertEqual(mapSize); ashmem.closeAshmem(); }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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_04900: errormessage " + error.message); @@ -8163,7 +8510,7 @@ export default function actsRpcClientJsTest() { expect(result).assertEqual(false); ashmem.closeAshmem() }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); expect(error.code == errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05000: errormessage " + error.message); @@ -8187,7 +8534,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: run mapTypedAshmem is success"); ashmem.closeAshmem() }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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05100: error " + error.message); @@ -8211,7 +8558,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: run mapTypedAshmem is success"); ashmem.closeAshmem() }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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_Ashmem_05200: error " + error.message); @@ -8583,10 +8930,10 @@ export default function actsRpcClientJsTest() { data.writeBoolean(true) data.writeChar(96) 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) => { - 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.reply.readByte()).assertEqual(1) expect(result.reply.readShort()).assertEqual(2) @@ -8598,7 +8945,7 @@ export default function actsRpcClientJsTest() { expect(result.reply.readChar()).assertEqual(96) expect(result.reply.readString()).assertEqual("HelloWorld") let s = new MySequenceable(0, '') - expect(result.reply.readSequenceable(s)).assertTrue() + expect(result.reply.readParcelable(s)).assertTrue() expect(s.num).assertEqual(1) expect(s.str).assertEqual("aaa") }); @@ -8724,7 +9071,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01300:run registerDeathRecipient is done"); } catch (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---------------------------"); }); @@ -8745,7 +9092,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_IRemoteObject_01400:run unregisterDeathRecipient is done"); } catch (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---------------------------"); }); @@ -8761,14 +9108,14 @@ export default function actsRpcClientJsTest() { try{ let recipient = new MyDeathRecipient(gIRemoteObject, null) var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0) - expect(resultAdd1 == true).assertTrue(); + expect(resultAdd1 == false).assertTrue(); var resultAdd2 = gIRemoteObject.addDeathRecipient(recipient, 0) - expect(resultAdd2 == true).assertTrue(); + expect(resultAdd2 == false).assertTrue(); var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0) - expect(resultRemove1 == true).assertTrue(); + expect(resultRemove1 == false).assertTrue(); var resultRemove2 = gIRemoteObject.removeDeathRecipient(recipient, 0) - expect(resultRemove2 == true).assertTrue(); + expect(resultRemove2 == false).assertTrue(); var resultRemove3 = gIRemoteObject.removeDeathRecipient(recipient, 0) expect(resultRemove3 == false).assertTrue(); @@ -8789,9 +9136,9 @@ export default function actsRpcClientJsTest() { try{ let recipient = new MyDeathRecipient(gIRemoteObject, null); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, -(2*G)); - expect(resultAdd).assertTrue(); + expect(resultAdd == false).assertTrue(); var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, -(2*G)); - expect(resultRemove).assertTrue(); + expect(resultRemove == false).assertTrue(); } catch (error) { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00200:error = " + error); } @@ -8809,9 +9156,9 @@ export default function actsRpcClientJsTest() { try{ let recipient = new MyDeathRecipient(gIRemoteObject, null); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, (2*G - 1)); - expect(resultAdd).assertTrue(); + expect(resultAdd == false).assertTrue(); var resultRemove = gIRemoteObject.removeDeathRecipient(recipient, (2*G - 1)); - expect(resultRemove).assertTrue(); + expect(resultRemove == false).assertTrue(); } catch (error) { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00300:error = " + error); } @@ -8830,10 +9177,10 @@ export default function actsRpcClientJsTest() { let recipient = new MyDeathRecipient(gIRemoteObject, null); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, 2*G); 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); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:run removeDeathRecipient1 is " + resultRemove); - expect(resultRemove).assertTrue(); + expect(resultRemove == false).assertTrue(); } catch (error) { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00400:error = " + error); } @@ -8852,10 +9199,10 @@ export default function actsRpcClientJsTest() { let recipient = new MyDeathRecipient(gIRemoteObject, null); var resultAdd = gIRemoteObject.addDeathRecipient(recipient, -(2*G + 1)); 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)); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:run removeDeathRecipient1 is " + resultRemove); - expect(resultRemove).assertTrue(); + expect(resultRemove == false).assertTrue(); } catch (error) { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00500:error = " + error); } @@ -8878,7 +9225,7 @@ export default function actsRpcClientJsTest() { var resultAdd1 = gIRemoteObject.addDeathRecipient(recipient, 0) 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(); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600: run isObjectDead result is " + isDead1); @@ -8886,15 +9233,15 @@ export default function actsRpcClientJsTest() { var resultRemove1 = gIRemoteObject.removeDeathRecipient(recipient, 0) 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) 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) 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) console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_00600:run removeDeathRecipient3 result is " + resultRemove3); @@ -9015,7 +9362,7 @@ export default function actsRpcClientJsTest() { expect(isDead2 == false).assertTrue(); } catch (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---------------------------"); }); @@ -9090,7 +9437,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01300: unregisterDeathRecipient is success"); } catch (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---------------------------"); }); @@ -9111,7 +9458,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01400: unregisterDeathRecipient is success"); } catch (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---------------------------"); }); @@ -9132,7 +9479,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01500: unregisterDeathRecipient is success"); } catch (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---------------------------"); }); @@ -9153,7 +9500,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01600: unregisterDeathRecipient is success"); } catch (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---------------------------"); }); @@ -9174,7 +9521,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01700: unregisterDeathRecipient is success"); } catch (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---------------------------"); }); @@ -9197,7 +9544,7 @@ export default function actsRpcClientJsTest() { let res2 = object.getLocalInterface(null); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800: run getLocalInterface success, res2 is " + res2); } 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); expect(error.code != errCode).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_RemoteProxy_01800:error = " + error.message); @@ -9516,6 +9863,7 @@ export default function actsRpcClientJsTest() { let localDeviceID = rpc.IPCSkeleton.getLocalDeviceID(); let isLocalCalling = rpc.IPCSkeleton.isLocalCalling(); let id = rpc.IPCSkeleton.resetCallingIdentity(); + console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01200:" + id) let ret = rpc.IPCSkeleton.setCallingIdentity(id); expect(object.getInterfaceDescriptor()).assertEqual(""); expect(callingDeviceID).assertEqual(""); @@ -9523,7 +9871,7 @@ export default function actsRpcClientJsTest() { expect(isLocalCalling).assertTrue(); expect(id).assertEqual(""); 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 + ", callingUid: " + callingUid + ", callingDeviceID: " + callingDeviceID + ", localDeviceID: " + localDeviceID @@ -9649,7 +9997,7 @@ export default function actsRpcClientJsTest() { object.getDescriptor(); console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600: is success"); } 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) expect(error.message != null).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01600 error is :" + error.code) @@ -9672,7 +10020,7 @@ export default function actsRpcClientJsTest() { console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 RpcServer: flushCmdBuffer is success"); } 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) expect(error.message != null).assertTrue(); console.info("SUB_Softbus_IPC_Compatibility_IPCSkeleton_01700 error is :" + error.code) diff --git a/communication/dsoftbus/rpc_server/Test.json b/communication/dsoftbus/rpc_server/Test.json deleted file mode 100644 index 1cf442933fd02ebd2be6d0fc3fcac778edc6ebee..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/Test.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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 - } - ] - -} diff --git a/communication/dsoftbus/rpc_server/src/main/config.json b/communication/dsoftbus/rpc_server/src/main/config.json deleted file mode 100644 index 9c69f13592d2534107cc925bd56756b1391176a4..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/config.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "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 diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/i18n/en-US.json b/communication/dsoftbus/rpc_server/src/main/js/MainAbility/i18n/en-US.json deleted file mode 100644 index 8feb7199333a82bab6f9e29341246e466c7dfd55..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/i18n/en-US.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World", - "page": "Second Page", - "next": "Next Page", - "back": "Back" - }, - "Files": { - } -} \ No newline at end of file diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/i18n/zh-CN.json b/communication/dsoftbus/rpc_server/src/main/js/MainAbility/i18n/zh-CN.json deleted file mode 100644 index 6551d160806d9089707897124655bcba11a83932..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/i18n/zh-CN.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界", - "page": "第二页", - "next": "下一页", - "back": "返回" - }, - "Files": { - } -} \ No newline at end of file diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.hml b/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.hml deleted file mode 100644 index ee2e929407a27df6cccf2d5bd36ded974215b209..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.hml +++ /dev/null @@ -1,6 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - - -
diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.css b/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.css deleted file mode 100644 index 87b92cb0fa66fabbd552fc73804aab915f79c22e..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.css +++ /dev/null @@ -1,24 +0,0 @@ -.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; -} diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.hml b/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.hml deleted file mode 100644 index 5d50c7448ea9304c23c6d9a2e0d8790aab310d3d..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.hml +++ /dev/null @@ -1,6 +0,0 @@ -
- - {{ $t('strings.page') }} - - -
diff --git a/communication/dsoftbus/rpc_server/src/main/js/ServiceAbility/service.js b/communication/dsoftbus/rpc_server/src/main/js/ServiceAbility/service.js deleted file mode 100644 index 815d1a4bec0a0f03f7e9f40be55b3366d56c0e74..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/js/ServiceAbility/service.js +++ /dev/null @@ -1,498 +0,0 @@ -/* - * 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 diff --git a/communication/dsoftbus/rpc_server/src/main/resources/base/element/string.json b/communication/dsoftbus/rpc_server/src/main/resources/base/element/string.json deleted file mode 100644 index 16e3bbc3f7c9ec1caf47bc5dcd117beadc774f53..0000000000000000000000000000000000000000 --- a/communication/dsoftbus/rpc_server/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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 diff --git a/graphic/graphicColorSpace/entry/src/main/ets/test/colorSpaceManager.test.ets b/graphic/graphicColorSpace/entry/src/main/ets/test/colorSpaceManager.test.ets index f8fc1d1d6eec45a506dbe1901879706a5e5a6660..a0e97fb28a7442f06e89b00c7a02d2476720973b 100644 --- a/graphic/graphicColorSpace/entry/src/main/ets/test/colorSpaceManager.test.ets +++ b/graphic/graphicColorSpace/entry/src/main/ets/test/colorSpaceManager.test.ets @@ -12,9 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -// @ts-nocheck -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; export default function colorSpaceManagerTest(context, windowStage, abilityStorage) { @@ -93,7 +91,7 @@ export default function colorSpaceManagerTest(context, windowStage, abilityStora done(); } catch (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(); } }) diff --git a/graphic/webGL/src/main/js/default/test/WebGL.test14.js b/graphic/webGL/src/main/js/default/test/WebGL.test14.js index 79c3758faec6a01ac8a51496abf61b50aaf53bb9..04507ee1452dd5ff4089c672617cfe568c60dda6 100644 --- a/graphic/webGL/src/main/js/default/test/WebGL.test14.js +++ b/graphic/webGL/src/main/js/default/test/WebGL.test14.js @@ -973,6 +973,9 @@ describe('webgl1Test_webgl14', function() { var x13 = gl2.ANY_SAMPLES_PASSED_CONSERVATIVE; expect(x13).assertEqual(36202); + var x14 = gl2.RGB10_A2; + expect(x14).assertEqual(32857); + var y1 = gl.LUMINANCE_ALPHA; expect(y1).assertEqual(6410); @@ -994,6 +997,9 @@ describe('webgl1Test_webgl14', function() { var y7 = gl.CONTEXT_LOST_WEBGL; expect(y7).assertEqual(37442); + var y8 = gl.ACTIVE_ATTRIBUTES; + expect(y8).assertEqual(35721); + done(); }); }) diff --git a/graphic/windowstandard/src/main/js/test/window.test.js b/graphic/windowstandard/src/main/js/test/window.test.js index 3d14082f3f74c010ce0b9bd532c7c8448ae38a6b..0ed5232b93060512b017b6daa06bb0e7b65d6167 100644 --- a/graphic/windowstandard/src/main/js/test/window.test.js +++ b/graphic/windowstandard/src/main/js/test/window.test.js @@ -2955,6 +2955,15 @@ describe('window_test', function () { expect(0).assertEqual(window.Orientation.UNSPECIFIED); expect(1).assertEqual(window.Orientation.PORTRAIT); 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(); } catch (err) { console.info('test enum value of windowStageEventType error ' + JSON.stringify(err)); diff --git a/inputmethod/InputMethodTest_Stage/Test.json b/inputmethod/InputMethodTest_Stage/Test.json index e8d752ab0812ca9d28ef0f4b8a07a50384955e46..5d2e5fb56b32cae8e4525e610f4bbe7b8980861a 100644 --- a/inputmethod/InputMethodTest_Stage/Test.json +++ b/inputmethod/InputMethodTest_Stage/Test.json @@ -6,7 +6,7 @@ "bundle-name": "com.acts.imeability.test", "module-name": "phone", "shell-timeout": "600000", - "testcase-timeout": 70000 + "testcase-timeout": 10000 }, "kits": [{ "test-file-name": [ diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets index 99afcb79523be7ad14669082e10f0dfcb25f9834..e3ed8ac0d7766703f2c4582984385584d6416d20 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/imeAbilityTest.test.ets @@ -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(function () { - console.info('beforeEach: switchInputMethod to kikakeyboard.'); + console.info('====>beforeEach: switchInputMethod to kikakeyboard.'); let serviceAbilityProperty = { packageName: "com.example.kikakeyboard", methodId: "ServiceExtAbility", @@ -39,7 +39,7 @@ export default function imeAbilityTest(abilityContext) { } 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(); }) @@ -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(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) { * @tc.level : Level 1 */ 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 = { packageName : "com.acts.imeability.test", methodId : "com.acts.imeability.test.ImExtAbility", @@ -70,11 +70,11 @@ export default function imeAbilityTest(abilityContext) { } 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(); }); sleep(Date.now(), 3000); - console.info('----------SUB_InputMethod_IMEAbility_0001 end-------------'); + console.info('====>----------SUB_InputMethod_IMEAbility_0001 end-------------'); done(); }) @@ -87,7 +87,7 @@ export default function imeAbilityTest(abilityContext) { * @tc.level : Level 1 */ 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 = { packageName : "com.acts.imeability.test", @@ -98,11 +98,11 @@ export default function imeAbilityTest(abilityContext) { } 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(); }); sleep(Date.now(), 2500); - console.info('-----------SUB_InputMethod_IMEAbility_0002 end-------------'); + console.info('====>-----------SUB_InputMethod_IMEAbility_0002 end-------------'); done(); }) }) diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets index 98a7b39924e66025df7429082a3a844ed9599075..d0f5a7b96292864ff648aeb028f3df29e9f31aef 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets @@ -18,7 +18,7 @@ import subtype from '@ohos.inputMethodSubtype'; export default function inputMethodStageJSUnit() { describe('inputMethodTest', function () { - console.info("************* settings Test start*************"); + console.info("====>************* settings Test start*************"); /* * @tc.number inputMethod_test_getController_001 * @tc.name get inputMethod controller @@ -26,23 +26,23 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ it('inputMethod_test_getController_001', 0, async function (done) { - console.info("-----------------inputMethod_test_getController_001 start---------------------"); + console.info("====>-----------------inputMethod_test_getController_001 start---------------------"); try{ 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" ){ - console.info("inputMethod_test_getController_001 getController success"); + console.info("====>inputMethod_test_getController_001 getController success"); expect(true).assertTrue(); }else{ - console.info("inputMethod_test_getController_001 getController failed"); + console.info("====>inputMethod_test_getController_001 getController failed"); expect().assertFail(); }; }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(); }; - console.info("-----------------inputMethod_test_getController_001 end---------------------"); + console.info("====>-----------------inputMethod_test_getController_001 end---------------------"); done(); }); @@ -53,7 +53,7 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ 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 = { packageName:"com.example.kikakeyboard", methodId:"ServiceExtAbility", @@ -67,23 +67,23 @@ export default function inputMethodStageJSUnit() { try{ 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) => { if(err){ - console.info("inputMethod_test_listInputMethodSubtype_001 failed" + JSON.stringify(err)); + console.info("====>inputMethod_test_listInputMethodSubtype_001 failed" + JSON.stringify(err)); expect().assertFail(); done(); } - console.info("inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype: " + JSON.stringify(data)); + console.info("====>inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype: " + JSON.stringify(data)); expect(true).assertTrue(); done(); }); }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(); done(); }; - console.info("-----------------inputMethod_test_listInputMethodSubtype_001 end---------------------"); + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_001 end---------------------"); }); /* @@ -93,7 +93,7 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ 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 = { packageName:"com.example.kikakeyboard", methodId:"ServiceExtAbility", @@ -107,32 +107,32 @@ export default function inputMethodStageJSUnit() { try{ 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) => { if(err){ - console.info("inputMethod_test_listInputMethodSubtype_002 failed" + JSON.stringify(err)); + console.info("====>inputMethod_test_listInputMethodSubtype_002 failed" + JSON.stringify(err)); expect().assertFail(); 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){ 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.label != null).assertTrue(); done(); }else{ - console.info("inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype length less 1"); + console.info("====>inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype length less 1"); expect().assertFail(); done(); }; }); }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(); done(); }; - console.info("-----------------inputMethod_test_listInputMethodSubtype_002 end---------------------"); + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_002 end---------------------"); }); /* @@ -141,8 +141,9 @@ export default function inputMethodStageJSUnit() { * @tc.desc Function test * @tc.level 2 */ + 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 = { packageName:"com.example.kikakeyboard", methodId:"ServiceExtAbility", @@ -156,22 +157,22 @@ export default function inputMethodStageJSUnit() { try{ 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) => { - console.info("inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype: " + JSON.stringify(data)); + console.info("====>inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype: " + JSON.stringify(data)); expect(true).assertTrue(); done(); }).catch(err => { - console.info("inputMethod_test_listInputMethodSubtype_003 failed" + JSON.stringify(err)); + console.info("====>inputMethod_test_listInputMethodSubtype_003 failed" + JSON.stringify(err)); expect().assertFail(); done(); }); }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(); done(); }; - console.info("-----------------inputMethod_test_listInputMethodSubtype_003 end---------------------"); + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_003 end---------------------"); }); /* @@ -181,7 +182,7 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ 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 = { packageName:"com.example.kikakeyboard", methodId:"ServiceExtAbility", @@ -195,31 +196,31 @@ export default function inputMethodStageJSUnit() { try{ 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) => { - console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype:" + JSON.stringify(data)); + console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype:" + JSON.stringify(data)); if(data.length >= 1){ 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.label != null).assertTrue(); done(); }else{ - console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype length less 1"); + console.info("====>inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype length less 1"); expect().assertFail(); done(); } }).catch(err => { - console.info("inputMethod_test_listInputMethodSubtype_004 failed" + JSON.stringify(err)); + console.info("====>inputMethod_test_listInputMethodSubtype_004 failed" + JSON.stringify(err)); expect().assertFail(); done(); }); }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(); done(); } - console.info("-----------------inputMethod_test_listInputMethodSubtype_004 end---------------------"); + console.info("====>-----------------inputMethod_test_listInputMethodSubtype_004 end---------------------"); }); /* @@ -229,26 +230,26 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ it('inputMethod_test_listCurrentInputMethodSubtype_001', 0, async function (done) { - console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_001 start---------------------"); + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_001 start---------------------"); try{ 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) => { if(err){ - console.info("inputMethod_test_listCurrentInputMethodSubtype_001 failed" + JSON.stringify(err)); + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 failed" + JSON.stringify(err)); expect().assertFail(); done(); }; - console.info("inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype: " + JSON.stringify(data)); + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype: " + JSON.stringify(data)); expect(true).assertTrue(); done(); }); }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(); done(); }; - console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_001 end---------------------"); + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_001 end---------------------"); }); /* @@ -258,25 +259,25 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ it('inputMethod_test_listCurrentInputMethodSubtype_002', 0, async function (done) { - console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_002 start---------------------"); + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_002 start---------------------"); try{ 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) => { - console.info("inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype: " + JSON.stringify(data)); + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype: " + JSON.stringify(data)); expect(true).assertTrue(); done(); }).catch(err => { - console.info("inputMethod_test_listCurrentInputMethodSubtype_002 failed" + JSON.stringify(err)); + console.info("====>inputMethod_test_listCurrentInputMethodSubtype_002 failed" + JSON.stringify(err)); expect().assertFail(); done(); }); }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(); done(); }; - console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_002 end---------------------"); + console.info("====>-----------------inputMethod_test_listCurrentInputMethodSubtype_002 end---------------------"); }); /* @@ -286,22 +287,22 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ it('inputMethod_test_getCurrentInputMethodSubtype_001', 0, async function (done) { - console.info("-----------------inputMethod_test_getCurrentInputMethodSubtype_001 start---------------------"); + console.info("====>-----------------inputMethod_test_getCurrentInputMethodSubtype_001 start---------------------"); try{ 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" ){ - console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype success"); + console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype success"); expect(true).assertTrue(); }else{ - console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype failed"); + console.info("====>inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype failed"); expect().assertFail(); }; }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(); } - console.info("-----------------inputMethod_test_getCurrentInputMethodSubtype_001 end---------------------"); + console.info("====>-----------------inputMethod_test_getCurrentInputMethodSubtype_001 end---------------------"); done(); }); @@ -312,7 +313,7 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ 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 = { packageName: "com.example.kikakeyboard", methodId: "ServiceExtAbility", @@ -338,7 +339,7 @@ export default function inputMethodStageJSUnit() { expect( err.code == 12800008 ).assertTrue(); 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(); done(); }); @@ -347,7 +348,7 @@ export default function inputMethodStageJSUnit() { expect().assertFail(); 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() { * @tc.level 2 */ 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 = { packageName: "com.example.kikakeyboard", methodId: "ServiceExtAbility", @@ -378,7 +379,7 @@ export default function inputMethodStageJSUnit() { }; try { 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(); done(); }).catch(err => { @@ -391,7 +392,7 @@ export default function inputMethodStageJSUnit() { expect().assertFail(); 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() { * @tc.level 2 */ 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 = { id: "com.example.kikakeyboard", label: "ServiceExtAbility", @@ -420,7 +421,7 @@ export default function inputMethodStageJSUnit() { expect().assertFail(); 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(); done(); }); @@ -429,7 +430,7 @@ export default function inputMethodStageJSUnit() { expect().assertFail(); 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() { * @tc.level 2 */ 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 = { id: "com.example.kikakeyboard", label: "ServiceExtAbility", @@ -453,7 +454,7 @@ export default function inputMethodStageJSUnit() { }; try { 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(); done(); }).catch(err => { @@ -466,7 +467,7 @@ export default function inputMethodStageJSUnit() { expect().assertFail(); done(); }; - console.info("************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test end*************"); + console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test end*************"); done(); }); @@ -477,28 +478,28 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ 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(); try{ - console.info("inputMethod_test_showOptionalInputMethods_001 result:" + inputMethodSetting); + console.info("====>inputMethod_test_showOptionalInputMethods_001 result:" + inputMethodSetting); inputMethodSetting.showOptionalInputMethods((err, data) => { 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(); 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(); setTimeout(() => { done(); }, 1000); }); }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(); done(); }; - console.info("-----------------inputMethod_test_showOptionalInputMethods_001 end---------------------"); + console.info("====>-----------------inputMethod_test_showOptionalInputMethods_001 end---------------------"); }); /* @@ -508,25 +509,25 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ 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(); 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) => { - 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(); done(); }).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(); done(); }); } 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(); done(); }; - console.info("-----------------inputMethod_test_showOptionalInputMethods_002 end---------------------"); + console.info("====>-----------------inputMethod_test_showOptionalInputMethods_002 end---------------------"); }); /* @@ -536,25 +537,24 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ it('inputMethod_test_stopInputSession_002', 0, async function (done) { - console.info("-----------------inputMethod_test_stopInputSession_002 start---------------------"); + console.info("====>-----------------inputMethod_test_stopInputSession_002 start---------------------"); try{ 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) => { - 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(); done(); - }); + }).catch((err) => { + console.debug("inputMethod_test_stopInputSession_002 faild: " + JSON.stringify(err)); + expect(err.code).assertEqual('12800003') + done(); + }) }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(); done(); }; - console.info("-----------------inputMethod_test_stopInputSession_002 end---------------------"); + console.info("====>-----------------inputMethod_test_stopInputSession_002 end---------------------"); }); /* @@ -564,26 +564,24 @@ export default function inputMethodStageJSUnit() { * @tc.level 2 */ it('inputMethod_test_stopInputSession_001', 0, async function (done) { - console.info("-----------------inputMethod_test_stopInputSession_001 start---------------------"); + console.info("====>-----------------inputMethod_test_stopInputSession_001 start---------------------"); + let inputMethodCtrl = inputMethod.getController(); + console.debug("inputMethod_test_stopInputSession_001 result: " + typeof inputMethodCtrl); try{ - let inputMethodCtrl = inputMethod.getController(); - console.info("inputMethod_test_stopInputSession_001 result: " + typeof inputMethodCtrl); - inputMethodCtrl.stopInputSession((err, data) => { - if(err){ - console.info("inputMethod_test_stopInputSession_001 faild: " + JSON.stringify(err)); - expect().assertFail(); - done(); - }; - console.info("inputMethod_test_stopInputSession_001 stopInputSession data: " + data); - expect(data == true).assertTrue(); + inputMethodCtrl.stopInputSession((err)=>{ + if(err){ + console.info("====>inputMethod_test_stopInputSession_001 faild: " + JSON.stringify(err)); + expect(err.code).assertEqual('12800003'); + done(); + }else{ + expect().assertFail(); + done(); + } + }) + }catch(err){ + expect().assertFail(); done(); - }); - }catch(error){ - console.info("inputMethod_test_stopInputSession_001 catch error" + JSON.stringify(error)); - expect().assertFail(); - done(); - }; - console.info("-----------------inputMethod_test_stopInputSession_001 end---------------------"); + } }); /* @@ -594,7 +592,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_PERMISSION_001', 0, async function (done) { 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); done(); }); @@ -607,7 +605,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_PARAMCHECK_002', 0, async function (done) { 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); done(); }); @@ -620,7 +618,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_UNSUPPORTED_003', 0, async function (done) { 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); done(); }); @@ -633,7 +631,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_PACKAGEMANAGER_004', 0, async function (done) { 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); done(); }); @@ -646,7 +644,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_IMENGINE_005', 0, async function (done) { 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); done(); }); @@ -659,7 +657,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_IMCLIENT_006', 0, async function (done) { 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); done(); }); @@ -672,7 +670,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_KEYEVENT_007', 0, async function (done) { 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); done(); }); @@ -685,7 +683,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_CONFPERSIST_008', 0, async function (done) { 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); done(); }); @@ -698,7 +696,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_CONTROLLER_009', 0, async function (done) { 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); done(); }); @@ -711,7 +709,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_SETTINGS_010', 0, async function (done) { 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); done(); }); @@ -724,7 +722,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_IMMS_011', 0, async function (done) { 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); done(); }); @@ -737,7 +735,7 @@ export default function inputMethodStageJSUnit() { */ it('inputMethod_test_EXCEPTION_OTHERS_012', 0, async function (done) { 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); done(); }); diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets index b778f82cd5e117995895687c82220083942c6728..4d27274069336154724453066b05559e3bbb3ea1 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/Utils.ets @@ -34,9 +34,9 @@ export default class Utils { static getComponentRect(key) { let strJson = getInspectorByKey(key); 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 + ']') - console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + console.info("====>[getInspectorByKey] rectInfo is: " + rectInfo); this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] @@ -47,12 +47,12 @@ export default class Utils { } 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) } 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) } @@ -70,16 +70,16 @@ export default class Utils { } xStep = (upX - downX) / 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 = { id: 1, x: downX, y: downY, type: TouchType.Down, } - console.info('down touch started: ' + JSON.stringify(downPonit)) + console.info('====>down touch started: ' + JSON.stringify(downPonit)) sendTouchEvent(downPonit); - console.info('start to move') + console.info('====>start to move') if (drag) { await this.sleep(500) } @@ -90,14 +90,14 @@ export default class Utils { y: downY + (yStep * i), type: TouchType.Move } - console.info('move touch started: ' + JSON.stringify(movePoint)) + console.info('====>move touch started: ' + JSON.stringify(movePoint)) ret = sendTouchEvent(movePoint) if (ret == false) { break; } await this.sleep(5) } - console.info('start to up') + console.info('====>start to up') if (drag) { await this.sleep(100) } @@ -107,7 +107,7 @@ export default class Utils { y: upY, type: TouchType.Up, } - console.info('up touch started: ' + JSON.stringify(upPoint)) + console.info('====>up touch started: ' + JSON.stringify(upPoint)) sendTouchEvent(upPoint) await this.sleep(500) } diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets index bc05859a4fb8c5ef31619597220558eea2e127cd..2847cf0bca46d7b1c2f6f4ad3cebb0f9eb794c41 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets @@ -26,7 +26,7 @@ export default function inputMethodEngineJSUnit() { let kbController = null; let KeyboardDelegate = null; - console.info("************* inputMethodEngine Test start*************"); + console.info("====>************* inputMethodEngine Test start*************"); beforeEach(async function (done) { let options = { uri: 'pages/input', @@ -45,279 +45,279 @@ export default function inputMethodEngineJSUnit() { }); afterEach(async function () { - console.info("inputMethodEngine afterEach start:" + inputMethodEngineObject); + console.info("====>inputMethodEngine afterEach start:" + inputMethodEngineObject); await Utils.sleep(1000); }); it('inputMethodEngine_testOff_000', 0 , async function (done) { inputMethodEngineObject.off('inputStart', (kbController, textInputClient) => { - console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); - console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); }); inputMethodEngineObject.off('keyboardShow', () => { - console.info("inputMethodEngine beforeEach keyboardShow:"); + console.info("====>inputMethodEngine beforeEach keyboardShow:"); }); inputMethodEngineObject.off('keyboardHide', () => { - console.info("inputMethodEngine beforeEach keyboardHide:"); + console.info("====>inputMethodEngine beforeEach keyboardHide:"); }); KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); KeyboardDelegate.off('keyDown', (keyEvent) => { - console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); expect(keyEvent.keyCode).assertEqual('1'); - console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); expect(keyEvent.keyAction).assertEqual('1'); }); KeyboardDelegate.off('keyUp', (keyEvent) => { - console.info("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); + console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); expect(keyEvent.keyCode).assertEqual('1'); - console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); expect(keyEvent.keyAction).assertEqual('0'); }); KeyboardDelegate.off('cursorContextChange', (x, y, height) => { - console.info("inputMethodEngine beforeEach cursorContextChange x:" + x); - console.info("inputMethodEngine beforeEach cursorContextChange y:" + y); - console.info("inputMethodEngine beforeEach cursorContextChange height:" + height); + console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x); + console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y); + console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height); }); KeyboardDelegate.off('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { - console.info("inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); - console.info("inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); - console.info("inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); - console.info("inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); + console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); + console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); + console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); + console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); }); KeyboardDelegate.off('textChange', (text) => { - console.info("inputMethodEngine beforeEach textChange:" + text); + console.info("====>inputMethodEngine beforeEach textChange:" + text); }); done(); }); it('inputMethodEngine_test_000', 0, async function (done) { inputMethodEngineObject.on('inputStart', (kbController, textInputClient) => { - console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); - console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); + console.info("====>inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); textInputClient = textInputClient; kbController = kbController; }); inputMethodEngineObject.on('keyboardShow', () => { - console.info("inputMethodEngine beforeEach keyboardShow:"); + console.info("====>inputMethodEngine beforeEach keyboardShow:"); }); inputMethodEngineObject.on('keyboardHide', () => { - console.info("inputMethodEngine beforeEach keyboardHide:"); + console.info("====>inputMethodEngine beforeEach keyboardHide:"); }); mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); mKeyboardDelegate.on('keyDown', (keyEvent) => { - console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyCode); expect(keyEvent.keyCode).assertEqual('1'); - console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); expect(keyEvent.keyAction).assertEqual('1'); }); mKeyboardDelegate.on('keyUp', (keyEvent) => { - console.info("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); + console.info("====>inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode); expect(keyEvent.keyCode).assertEqual('1'); - console.info("inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); + console.info("====>inputMethodEngine beforeEach keyDown:" + keyEvent.keyAction); expect(keyEvent.keyAction).assertEqual('0'); }); mKeyboardDelegate.on('cursorContextChange', (x, y, height) => { - console.info("inputMethodEngine beforeEach cursorContextChange x:" + x); - console.info("inputMethodEngine beforeEach cursorContextChange y:" + y); - console.info("inputMethodEngine beforeEach cursorContextChange height:" + height); + console.info("====>inputMethodEngine beforeEach cursorContextChange x:" + x); + console.info("====>inputMethodEngine beforeEach cursorContextChange y:" + y); + console.info("====>inputMethodEngine beforeEach cursorContextChange height:" + height); }); mKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { - console.info("inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); - console.info("inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); - console.info("inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); - console.info("inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); + console.info("====>inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin); + console.info("====>inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd); + console.info("====>inputMethodEngine beforeEach selectionChange newBegin:" + newBegin); + console.info("====>inputMethodEngine beforeEach selectionChange newEnd:" + newEnd); }); mKeyboardDelegate.on('textChange', (text) => { - console.info("inputMethodEngine beforeEach textChange:" + text); + console.info("====>inputMethodEngine beforeEach textChange:" + text); }); done(); }); it('inputMethodEngine_test_001', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_002', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_003', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_004', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_005', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_006', 0, async function (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); done(); }); it('inputMethodEngine_test_007', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_008', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_NULL; - console.info("inputMethodEngine_test_008 result:" + keyType); + console.info("====>inputMethodEngine_test_008 result:" + keyType); expect(keyType).assertEqual(-1); done(); }); it('inputMethodEngine_test_009', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_TEXT; - console.info("inputMethodEngine_test_009 result:" + keyType); + console.info("====>inputMethodEngine_test_009 result:" + keyType); expect(keyType).assertEqual(0); done(); }); it('inputMethodEngine_test_010', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_NUMBER; - console.info("inputMethodEngine_test_010 result:" + keyType); + console.info("====>inputMethodEngine_test_010 result:" + keyType); expect(keyType).assertEqual(2); done(); }); it('inputMethodEngine_test_011', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_PHONE; - console.info("inputMethodEngine_test_011 result:" + keyType); + console.info("====>inputMethodEngine_test_011 result:" + keyType); expect(keyType).assertEqual(3); done(); }); it('inputMethodEngine_test_012', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_DATETIME; - console.info("inputMethodEngine_test_012 result:" + keyType); + console.info("====>inputMethodEngine_test_012 result:" + keyType); expect(keyType).assertEqual(4); done(); }); it('inputMethodEngine_test_013', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_EMAIL; - console.info("inputMethodEngine_test_013 result:" + keyType); + console.info("====>inputMethodEngine_test_013 result:" + keyType); expect(keyType).assertEqual(5); done(); }); it('inputMethodEngine_test_014', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_URI; - console.info("inputMethodEngine_test_014 result:" + keyType); + console.info("====>inputMethodEngine_test_014 result:" + keyType); expect(keyType).assertEqual(6); done(); }); it('inputMethodEngine_test_015', 0, async function (done) { let keyType = inputMethodEngine.PATTERN_PASSWORD; - console.info("inputMethodEngine_test_015 result:" + keyType); + console.info("====>inputMethodEngine_test_015 result:" + keyType); expect(keyType).assertEqual(7); done(); }); it('inputMethodEngine_test_016', 0, async function (done) { let keyType = inputMethodEngine.FLAG_SELECTING; - console.info("inputMethodEngine_test_016 result:" + keyType); + console.info("====>inputMethodEngine_test_016 result:" + keyType); expect(keyType).assertEqual(2); done(); }); it('inputMethodEngine_test_017', 0, async function (done) { let keyType = inputMethodEngine.FLAG_SINGLE_LINE; - console.info("inputMethodEngine_test_017 result:" + keyType); + console.info("====>inputMethodEngine_test_017 result:" + keyType); expect(keyType).assertEqual(1); done(); }); it('inputMethodEngine_test_018', 0, async function (done) { let keyType = inputMethodEngine.DISPLAY_MODE_PART; - console.info("inputMethodEngine_test_018 result:" + keyType); + console.info("====>inputMethodEngine_test_018 result:" + keyType); expect(keyType).assertEqual(0); done(); }); it('inputMethodEngine_test_019', 0, async function (done) { let keyType = inputMethodEngine.DISPLAY_MODE_FULL; - console.info("inputMethodEngine_test_019 result:" + keyType); + console.info("====>inputMethodEngine_test_019 result:" + keyType); expect(keyType).assertEqual(1); done(); }); it('inputMethodEngine_test_020', 0, async function (done) { let keyType = inputMethodEngine.OPTION_ASCII; - console.info("inputMethodEngine_test_020 result:" + keyType); + console.info("====>inputMethodEngine_test_020 result:" + keyType); expect(keyType).assertEqual(20); done(); }); it('inputMethodEngine_test_021', 0, async function (done) { let keyType = inputMethodEngine.OPTION_NONE; - console.info("inputMethodEngine_test_021 result:" + keyType); + console.info("====>inputMethodEngine_test_021 result:" + keyType); expect(keyType).assertEqual(0); done(); }); it('inputMethodEngine_test_022', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_023', 0, async function (done) { 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); done(); }); it('inputMethodEngine_test_024', 0, async function (done) { let keyType = inputMethodEngine.OPTION_AUTO_WORDS; - console.info("inputMethodEngine_test_024 result:" + keyType); + console.info("====>inputMethodEngine_test_024 result:" + keyType); expect(keyType).assertEqual(4); done(); }); it('inputMethodEngine_test_025', 0, async function (done) { let keyType = inputMethodEngine.OPTION_MULTI_LINE; - console.info("inputMethodEngine_test_025 result:" + keyType); + console.info("====>inputMethodEngine_test_025 result:" + keyType); expect(keyType).assertEqual(1); done(); }); it('inputMethodEngine_test_026', 0, async function (done) { let keyType = inputMethodEngine.OPTION_NO_FULLSCREEN; - console.info("inputMethodEngine_test_026 result:" + keyType); + console.info("====>inputMethodEngine_test_026 result:" + keyType); expect(keyType).assertEqual(10); done(); }); @@ -325,12 +325,12 @@ export default function inputMethodEngineJSUnit() { it('inputMethodEngine_test_027', 0, async function (done) { let rect = await Utils.getComponentRect('TextInput') - 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 " + rect); + console.info("====>[inputMethodEngine_test_027] rectInfo is " + JSON.stringify(rect)); let x_value = rect.left + (rect.right - rect.left) / 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 = { id: 1, x: x_value, @@ -339,9 +339,9 @@ export default function inputMethodEngineJSUnit() { screenX: 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) - console.info('[inputMethodEngine_test_027] END'); + console.info('====>[inputMethodEngine_test_027] END'); done(); }); @@ -350,7 +350,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { textInputClient.sendKeyFunction(0, (value) => { - console.info("inputMethodEngine_test_028 textInputClient sendKeyFunction:" + value); + console.info("====>inputMethodEngine_test_028 textInputClient sendKeyFunction:" + value); expect(value).assertEqual(true); }); } @@ -363,10 +363,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = textInputClient.sendKeyFunction(0); 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); }).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(); }); } @@ -378,7 +378,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { textInputClient.deleteForward(1, (value) => { - console.info("inputMethodEngine_test_030 deleteForward:" + value); + console.info("====>inputMethodEngine_test_030 deleteForward:" + value); expect(value).assertEqual(true); }); } @@ -391,10 +391,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = textInputClient.deleteForward(1); 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); }).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(); }); } @@ -406,7 +406,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { textInputClient.deleteBackward(1, (value) => { - console.info("inputMethodEngine_test_032 deleteBackward:" + value); + console.info("====>inputMethodEngine_test_032 deleteBackward:" + value); expect(value).assertEqual(true); }); } @@ -419,10 +419,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = textInputClient.deleteBackward(1); 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); }).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(); }); } @@ -434,7 +434,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { textInputClient.InsertText('test', (value) => { - console.info("inputMethodEngine_test_034 InsertText:" + value); + console.info("====>inputMethodEngine_test_034 InsertText:" + value); expect(value).assertEqual(true); }); } @@ -447,10 +447,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = textInputClient.InsertText('test'); 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); }).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(); }); } @@ -462,7 +462,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { textInputClient.getForward(1, (value) => { - console.info("inputMethodEngine_test_036 getForward:" + value); + console.info("====>inputMethodEngine_test_036 getForward:" + value); expect(value).assertEqual(true); }); } @@ -475,10 +475,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = textInputClient.getForward(1); 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); }).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(); }); } @@ -490,7 +490,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { 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.enterKeyType).assertEqual(1); }); @@ -504,11 +504,11 @@ export default function inputMethodEngineJSUnit() { } else { let promise = textInputClient.getEditorAttribute(); 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.enterKeyType).assertEqual(1); }).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(); }); } @@ -520,7 +520,7 @@ export default function inputMethodEngineJSUnit() { expect(kbController == null).assertEqual(true); } else { kbController.hideKeyboard(() => { - console.info("inputMethodEngine_test_040 hideKeyboard"); + console.info("====>inputMethodEngine_test_040 hideKeyboard"); expect(1 == 1).assertTrue(); }); } @@ -533,10 +533,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = kbController.hideKeyboard(); 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(); }).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(); }); } @@ -548,7 +548,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { textInputClient.getBackward(1, (value) => { - console.info("inputMethodEngine_test_042 getBackward:" + value); + console.info("====>inputMethodEngine_test_042 getBackward:" + value); expect(value).assertEqual(true); }); } @@ -561,10 +561,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = textInputClient.getBackward(1); 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); }).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(); }); } @@ -583,7 +583,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { 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); }); } @@ -595,7 +595,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { 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); }); } @@ -607,10 +607,10 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { 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); }).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(); }); } @@ -622,10 +622,10 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { 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); }).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(); }); } @@ -637,7 +637,7 @@ export default function inputMethodEngineJSUnit() { expect(kbController == null).assertEqual(true); } else { kbController.hide(() => { - console.info("inputMethodEngine_test_049 hideKeyboard:"); + console.info("====>inputMethodEngine_test_049 hideKeyboard:"); expect(1 == 1).assertTrue(); }); } @@ -650,10 +650,10 @@ export default function inputMethodEngineJSUnit() { } else { let promise = kbController.hide(); 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(); }).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(); }); } @@ -667,22 +667,22 @@ export default function inputMethodEngineJSUnit() { * @tc.level 2 */ it('inputMethodEngine_test_getInputMethodAbility_001', 0, async function (done) { - console.info("-----------------inputMethodEngine_test_getInputMethodAbility_001 start---------------------"); + console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 start---------------------"); try{ 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" ){ - console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype success"); + console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype success"); expect(true).assertTrue(); }else{ - console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype failed"); + console.info("====>inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype failed"); expect().assertFail(); }; }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(); } - console.info("-----------------inputMethodEngine_test_getInputMethodAbility_001 end---------------------"); + console.info("====>-----------------inputMethodEngine_test_getInputMethodAbility_001 end---------------------"); done(); }); @@ -693,22 +693,22 @@ export default function inputMethodEngineJSUnit() { * @tc.level 2 */ it('inputMethodEngine_test_getKeyboardDelegate_001', 0, async function (done) { - console.info("-----------------inputMethodEngine_test_getKeyboardDelegate_001 start---------------------"); + console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 start---------------------"); try{ 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" ){ - console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype success"); + console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype success"); expect(true).assertTrue(); }else{ - console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype failed"); + console.info("====>inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype failed"); expect().assertFail(); }; }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(); } - console.info("-----------------inputMethodEngine_test_getKeyboardDelegate_001 end---------------------"); + console.info("====>-----------------inputMethodEngine_test_getKeyboardDelegate_001 end---------------------"); done(); }); diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets index 8660b7290ab01da6ecf6a2b4e69aa030518135af..9322d71418117f9e30e8b25abf38937d4df455fe 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets @@ -17,12 +17,12 @@ import inputMethod from '@ohos.inputmethod'; export default function inputMethodJSUnit() { describe('appInfoTest_input_2', function () { - console.info("************* settings Test start*************"); + console.info("====>************* settings Test start*************"); it('inputmethoh_test_001', 0, async function (done) { 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) => { - console.info("appInfoTest_input_2 listInputMethod result---" + JSON.stringify(arr)); + console.info("====>appInfoTest_input_2 listInputMethod result---" + JSON.stringify(arr)); expect(1==1).assertTrue(); }); done(); @@ -30,40 +30,40 @@ export default function inputMethodJSUnit() { it('inputmethoh_test_002', 0, async function (done) { 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 => { if (inputMethodProperty.length > 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.methodId != null).assertTrue(); }else{ - console.info("inputmethoh_test_002 listInputMethod is null"); + console.info("====>inputmethoh_test_002 listInputMethod is null"); expect().assertFail() } }).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(); }); it('inputmethoh_test_003', 0, async function (done) { let inputMethodSetting = inputMethod.getInputMethodSetting(); - console.info("inputmethoh_test_003 result:" + JSON.stringify(inputMethodSetting)); + console.info("====>inputmethoh_test_003 result:" + JSON.stringify(inputMethodSetting)); inputMethodSetting.displayOptionalInputMethod(() => { - console.info("inputmethoh_test_003 displayOptionalInputMethod---"); + console.info("====>inputmethoh_test_003 displayOptionalInputMethod---"); }); done(); }); it('inputmethoh_test_004', 0, async function (done) { 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(() => { - console.info("inputmethoh_test_004 displayOptionalInputMethod is called"); + console.info("====>inputmethoh_test_004 displayOptionalInputMethod is called"); expect(true).assertTrue() }).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() }); done(); @@ -71,24 +71,24 @@ export default function inputMethodJSUnit() { it('inputmethoh_test_005', 0, async function (done) { 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) => { - console.info("inputmethoh_test_005 stopInput result----" + res); + console.info("====>inputmethoh_test_005 stopInput result----" + res); }); done(); }); it('inputmethoh_test_006', 0, async function (done) { let inputMethodCtrl = inputMethod.getInputMethodController(); - console.info("inputmethoh_test_006 result:" + JSON.stringify(inputMethodCtrl)); - inputMethodCtrl.stopInput().then(data => { - 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)); + console.info("====>inputmethoh_test_006 result:" + JSON.stringify(inputMethodCtrl)); + inputMethodCtrl.stopInput().then(() => { expect().assertFail(); + done(); + }).catch((err) => { + console.info("====>inputmethoh_test_006 stopInput is err: " + JSON.stringify(err)); + expect().assertEqual(); + done(); }); - done(); }); /* @@ -97,11 +97,11 @@ export default function inputMethodJSUnit() { * @tc.desc: Verify Max_ TYPE_ NUM */ 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; - console.info("inputmethod_test_001 result:" + inputMethodSetting); - expect(inputMethodSetting != null).assertTrue(); - console.info("************* inputmethod_test_MAX_TYPE_NUM_001 Test end*************"); + console.info("====>inputmethod_test_001 result:" + inputMethodSetting); + expect(inputMethodSetting !== null).assertTrue(); + console.info("====>************* inputmethod_test_MAX_TYPE_NUM_001 Test end*************"); done(); }); @@ -112,7 +112,7 @@ export default function inputMethodJSUnit() { * @tc.level 2 */ 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 = { packageName: "com.example.kikakeyboard", methodId: "ServiceExtAbility", @@ -121,13 +121,13 @@ export default function inputMethodJSUnit() { extra:{} } 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(); }).catch( err=> { - console.info("inputmethod_test_switchInputMethod_001 err:" + err) + console.info("====>inputmethod_test_switchInputMethod_001 err:" + err) expect().assertFail(); }) - console.info("************* inputmethod_test_switchInputMethod_001 Test end*************"); + console.info("====>************* inputmethod_test_switchInputMethod_001 Test end*************"); done(); }); @@ -138,7 +138,7 @@ export default function inputMethodJSUnit() { * @tc.level 2 */ 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 = { packageName: "com.example.kikakeyboard", methodId: "ServiceExtAbility", @@ -148,13 +148,13 @@ export default function inputMethodJSUnit() { } inputMethod.switchInputMethod(inputMethodProperty, (err, data)=>{ if(err){ - console.info("inputmethod_test_switchInputMethod_002 error:" + err); + console.info("====>inputmethod_test_switchInputMethod_002 error:" + err); expect().assertFail(); } - console.info("inputmethod_test_switchInputMethod_002 data:" + data) + console.info("====>inputmethod_test_switchInputMethod_002 data:" + data) expect(data == true).assertTrue(); }); - console.info("************* inputmethod_test_switchInputMethod_002 Test end*************"); + console.info("====>************* inputmethod_test_switchInputMethod_002 Test end*************"); done(); }); @@ -166,17 +166,16 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) { let inputMethodCtrl = inputMethod.getInputMethodController() - inputMethodCtrl.showSoftKeyboard((err, data)=>{ - if(data == undefined){ - console.info("showSoftKeyboard callbace success" ); - expect(true).assertTrue(); - }else{ - console.info('showSoftKeyboard callbace failed : ' + JSON.stringify(err)) - expect().assertFail(); - } - }); - console.info("************* inputmethod_test_showSoftKeyboard_001 Test end*************"); - done(); + try{ + inputMethodCtrl.showSoftKeyboard((err)=>{ + expect(err.code).assertEqual('12800003') + console.info("====>************* inputmethod_test_showSoftKeyboard_001 Test end*************"); + done(); + }); + }catch(err){ + expect().assertFail() + done(); + } }); /* @@ -187,15 +186,15 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) { let inputMethodCtrl = inputMethod.getInputMethodController() - inputMethodCtrl.showSoftKeyboard().then((data) =>{ - console.info("showSoftKeyboard promise success" ); - expect(true).assertTrue(); + inputMethodCtrl.showSoftKeyboard().then(() =>{ + expect().assertFail() + done(); }).catch((err) => { - console.info('showSoftKeyboard promise failed : ' + JSON.stringify(err)) - expect().assertFail(); + console.info('====>showSoftKeyboard promise failed : ' + JSON.stringify(err)) + expect(err.code).assertEqual('12800003') + console.info("====>************* inputmethod_test_showSoftKeyboard_002 Test end*************"); + done(); }) - console.info("************* inputmethod_test_showSoftKeyboard_002 Test end*************"); - done(); }); /* @@ -206,17 +205,17 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) { let inputMethodCtrl = inputMethod.getInputMethodController() - inputMethodCtrl.hideSoftKeyboard((err, data)=>{ - if(data == undefined){ - console.info("hideSoftKeyboard callbace success" ); - expect(true).assertTrue(); - }else{ - console.info('hideSoftKeyboard callbace failed : ' + JSON.stringify(err)) - expect().assertFail(); - } - }); - console.info("************* inputmethod_test_hideSoftKeyboard_001 Test end*************"); - done(); + try{ + inputMethodCtrl.hideSoftKeyboard((err)=>{ + console.info('====>hideSoftKeyboard callbacek failed : ' + JSON.stringify(err)) + expect(err.code).assertEqual('12800003') + console.info("====>************* inputmethod_test_hideSoftKeyboard_001 Test end*************"); + done(); + }) + }catch(err){ + expect().assertFail(); + done(); + } }); /* @@ -227,15 +226,15 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) { let inputMethodCtrl = inputMethod.getInputMethodController() - inputMethodCtrl.hideSoftKeyboard().then((data) =>{ - console.info("hideSoftKeyboard promise success" ); - expect(true).assertTrue(); - }).catch((err) => { - console.info('hideSoftKeyboard promise failed : ' + JSON.stringify(err)) + inputMethodCtrl.hideSoftKeyboard().then(() =>{ expect().assertFail(); + 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(); }) - console.info("************* inputmethod_test_hideSoftKeyboard_002 Test end*************"); - done(); }); /* @@ -246,12 +245,12 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_getCurrentInputMethod_001', 0, async function (done) { 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.methodId); - expect(currentIme.packageName != null).assertTrue(); - expect(currentIme.methodId != null).assertTrue(); - console.info("************* inputmethod_test_getCurrentInputMethod_001 Test end*************"); + expect(currentIme.packageName !== null).assertTrue(); + expect(currentIme.methodId !== null).assertTrue(); + console.info("====>************* inputmethod_test_getCurrentInputMethod_001 Test end*************"); done(); }); @@ -264,13 +263,13 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_getInputMethods_001', 0, async function (done) { 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) => { if (err) { console.error("inputmethod_test_getInputMethods_001 failed because: " + JSON.stringify(err)); 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(); }); done(); @@ -285,13 +284,13 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_getInputMethods_002', 0, async function (done) { 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) => { if (err) { console.error("inputmethod_test_getInputMethods_002 failed because: " + JSON.stringify(err)); 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(); }); done(); diff --git a/powermgr/display_manager/src/main/js/test/system_display.test.js b/powermgr/display_manager/src/main/js/test/system_display.test.js index 09f1e49adad035f3223656218831e094eab48c20..43ff8825fb12c4df8c9baa960d6e3e3a6e183b04 100644 --- a/powermgr/display_manager/src/main/js/test/system_display.test.js +++ b/powermgr/display_manager/src/main/js/test/system_display.test.js @@ -3,16 +3,15 @@ * 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 - * + * + * 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 brightness from '@system.brightness'; import { describe, it, expect } from '@ohos/hypium'; @@ -20,327 +19,301 @@ const INPUT_ERROR_CODE_CODE = 202; const SET_VALUE_MSG = "value is not an available number"; const SET_MODE_MSG = "value is not an available number"; -export default function SystemDisplayTest() { -describe('SystemDisplayTest', function () { - console.log("*************System SystemDisplay Unit Test Begin*************"); +export default async function SystemDisplayTest() { + describe('SystemDisplayTest', async function () { + console.log("System SystemDisplay Unit Test Begin"); - /** - * @tc.number system_display_js_0100 - * @tc.name get_value_success - * @tc.desc Get brightness success - */ - it('get_value_success', 0, function () { - let currValue = 100; - let setValue = 120; - brightness.getValue({ - success: (data) => { - currValue = data.value; - let value = (data.value > 0) && (data.value <= 255); - expect(value).assertTrue(); - } - }); - 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"); - } + /** + * @tc.number system_display_js_0100 + * @tc.name get_value_success + * @tc.desc Get brightness success + */ + it('get_value_success', 0, async function (done) { + let currValue = 100; + brightness.getValue({ + success: (data) => { + currValue = data.value; + let value = (data.value > 0) && (data.value <= 255); + expect(value).assertTrue(); + done(); + } + }); }); - brightness.setValue({ - value: currValue - }); - }); + /** + * @tc.number system_display_js_0101 + * @tc.name get_value_success_not_must_test + * @tc.desc Get brightness + */ + it('get_status_test_success_not_must', 0, async function (done) { + brightness.getValue({ + fail: (data, code) => { + console.log("get_status_test_success_not_must, data: " + data + ", code: " + code); + expect().assertFail(); + done(); + }, + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); + }) - /** - * @tc.number system_display_js_0101 - * @tc.name get_value_success_not_must_test - * @tc.desc Get brightness - */ - it('get_status_test_success_not_must', 0, function () { - brightness.getValue({ - fail: (data, code) => { - console.log("get_status_test_success_not_must, data: " + data + ", code: " + code); - expect().assertFail(); - }, - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } + /** + * @tc.number system_display_js_0102 + * @tc.name get_value_fail_not_must_test + * @tc.desc Get brightness + */ + it('get_value_fail_not_must_test', 0, async function (done) { + brightness.getValue({ + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); }); - }) - /** - * @tc.number system_display_js_0102 - * @tc.name get_value_fail_not_must_test - * @tc.desc Get brightness - */ - it('get_value_fail_not_must_test', 0, function () { - brightness.getValue({ - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } - }); - }); + /** + * @tc.number system_display_js_0103 + * @tc.name get_value_null_test + * @tc.desc Get brightness + */ + it('get_status_test_fail_not_must', 0, async function (done) { + brightness.getValue(); + expect(true).assertTrue(); + done(); + }) - /** - * @tc.number system_display_js_0103 - * @tc.name get_value_null_test - * @tc.desc Get brightness - */ - it('get_status_test_fail_not_must', 0, function () { - brightness.getValue(); - expect(true).assertTrue(); - }) + /** + * @tc.number system_display_js_0200 + * @tc.name set_value_success_all + * @tc.desc Set brightness success + */ + it('set_value_success_all', 0, async function (done) { + let setValue = 200; + let currValue = 100; + brightness.getValue({ + success: (data) => { + currValue = data.value; + } + }); - /** - * @tc.number system_display_js_0200 - * @tc.name set_value_success_all - * @tc.desc Set brightness success - */ - it('set_value_success_all', 0, function () { - let setValue = 200; - let currValue = 100; - brightness.getValue({ - success: (data) => { - currValue = data.value; - } + brightness.setValue({ + value: setValue, + success: () => { + brightness.getValue({ + success: (data) => { + expect(data.value === setValue).assertTrue(); + brightness.setValue({ + value: currValue, + success: function () { + done(); + }, + }); + } + }); + }, + fail: (data, code) => { + console.log("set_value_success_all, data: " + data + ", code: " + code); + expect().assertFail(); + done(); + }, + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); }); - brightness.setValue({ - value: setValue, - success: () => { - brightness.getValue({ - success: (data) => { - expect(data.value === setValue).assertTrue(); - } - }); - }, - fail: (data, code) => { - console.log("set_value_success_all, data: " + data + ", code: " + code); - expect().assertFail(); - }, - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } + /** + * @tc.number system_display_js_0201 + * @tc.name set_value_success_value + * @tc.desc Set brightness success + */ + it('set_value_success_value', 0, async function (done) { + brightness.setKeepScreenOn({ + keepScreenOn: true, + success: function () { + console.log('handling set keep screen on success.'); + brightness.setValue({ + value: 50, + success: function () { + setTimeout(() => { + brightness.getValue({ + success: (data) => { + console.log("set_value_success_value, brightness: " + data.value); + expect(data.value === 50).assertTrue(); + done(); + } + }); + }, 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(); + }, + }); }); - brightness.setValue({ - value: currValue + /** + * @tc.number system_display_js_0202 + * @tc.name set_value_fail + * @tc.desc Set brightness fail + */ + it('set_value_fail', 0, async function (done) { + let setValue = "50"; + brightness.setValue({ + value: setValue, + success: () => { + console.log("set_value_fail success"); + expect().assertFail(); + done(); + }, + fail: (data, code) => { + console.log("set_value_fail, data: " + data + ", code: " + code); + expect(code === INPUT_ERROR_CODE_CODE).assertTrue(); + expect(data === SET_VALUE_MSG).assertTrue(); + done(); + } + }); }); - }); - /** - * @tc.number system_display_js_0201 - * @tc.name set_value_success_value - * @tc.desc Set brightness success - */ - it('set_value_success_value', 0, function () { - let setValue = 50; - let currValue = 100; - brightness.getValue({ - success: (data) => { - currValue = data.value; - } - }); - brightness.setKeepScreenOn({ - keepScreenOn: true, - success: function () { - console.log('handling set keep screen on success.'); - brightness.setValue({ value: setValue }); - }, - fail: function (data, code) { - console.error('handling set keep screen on fail, code:' + code + ', data: ' + data); - } - }); - brightness.getValue({ - success: (data) => { - console.log("set_value_success_value, brightness: " + data.value); - expect(data.value === setValue).assertTrue(); - } - }); - brightness.setValue({ value: currValue }); - }); - - /** - * @tc.number system_display_js_0202 - * @tc.name set_value_fail - * @tc.desc Set brightness fail - */ - it('set_value_fail', 0, function () { - let setValue = "50"; - brightness.setValue({ - value: setValue, - success: () => { - console.log("set_value_fail success"); - expect().assertFail(); - }, - fail: (data, code) => { - console.log("set_value_fail, data: " + data + ", code: " + code); - expect(code === NPUT_ERROR_CODE).assertTrue(); - expect(data === SET_VALUE_MSG).assertTrue(); - } - }); - }); - - /** - * @tc.number system_display_js_0300 - * @tc.name get_mode_success - * @tc.desc Get mode success - */ - it('get_mode_success', 0, function () { - let modeVal = 0; - let exec = true; - brightness.getMode({ - success: (data) => { - console.log("get_mode_success: get mode: " + data.mode); - modeVal = data.mode; - } - }); - brightness.setMode({ - mode: modeVal ? 0 : 1, - fail: (data, code) => { - console.log("get_mode_success, data: " + data + ", code: " + code); - exec = false; - } + /** + * @tc.number system_display_js_0300 + * @tc.name get_mode_success + * @tc.desc Get mode success + */ + it('get_mode_success', 0, async function (done) { + brightness.getMode({ + success: (data) => { + console.log("get_mode_success: get mode: " + data.mode); + expect(data.mode === 0 || data.mode === 1).assertTrue(); + done(); + } + }); }) - 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 }); - }) - - /** - * @tc.number system_display_js_0301 - * @tc.name get_mode_success_null - * @tc.desc Get mode success is null - */ - it('get_mode_success_null', 0, function () { - brightness.getMode({ - fail: (data, code) => { - console.log("get_mode_success_null, data: " + data + ", code: " + code); - expect().assertFail(); - }, - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } + /** + * @tc.number system_display_js_0301 + * @tc.name get_mode_success_null + * @tc.desc Get mode success is null + */ + it('get_mode_success_null', 0, async function (done) { + brightness.getMode({ + fail: (data, code) => { + console.log("get_mode_success_null, data: " + data + ", code: " + code); + expect().assertFail(); + done(); + }, + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); }); - }); - /** - * @tc.number system_display_js_0400 - * @tc.name set_mode_success - * @tc.desc set mode success - */ - it('set_mode_success', 0, function () { - let modeVal = 0; - brightness.getMode({ - success: (data) => { - modeVal = data.mode; - } + /** + * @tc.number system_display_js_0400 + * @tc.name set_mode_success + * @tc.desc set mode success + */ + it('set_mode_success', 0, async function (done) { + brightness.setMode({ + mode: 0, + success: () => { + console.log("set_mode_success success"); + brightness.getMode({ + success: (data) => { + console.log("set_mode_success, data: " + data.mode); + expect(data.mode === 0).assertTrue(); + done(); + } + }); + }, + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); }); - brightness.setMode({ - mode: modeVal ? 0 : 1, - success: () => { - console.log("set_mode_success success"); - brightness.getMode({ - success: (data) => { - console.log("set_mode_success, data: " + data.mode); - expect(data.mode === (modeVal ? 0 : 1)).assertTrue(); - } - }); - }, - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } + /** + * @tc.number system_display_js_0401 + * @tc.name set_mode_fail + * @tc.desc set mode fail + */ + it('set_mode_fail', 0, async function (done) { + brightness.setMode({ + mode: "0", + success: () => { + expect().assertFail(); + done(); + }, + fail: (data, code) => { + console.log("set_mode_fail, data: " + data + ", code: " + code); + expect(code === INPUT_ERROR_CODE_CODE).assertTrue(); + expect(data === SET_MODE_MSG).assertTrue(); + done(); + }, + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); }); - brightness.setMode({ mode: modeVal }); - }); - - /** - * @tc.number system_display_js_0401 - * @tc.name set_mode_fail - * @tc.desc set mode fail - */ - it('set_mode_fail', 0, function () { - brightness.setMode({ - mode: "0", - success: () => { - expect().assertFail(); - }, - fail: (data, code) => { - console.log("set_mode_fail, data: " + data + ", code: " + code); - expect(code === INPUT_ERROR_CODE_CODE).assertTrue(); - expect(data === SET_MODE_MSG).assertTrue(); - }, - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } + /** + * @tc.number system_display_js_0500 + * @tc.name set_keep_screen_on_true + * @tc.desc set keep screen on true + */ + it('set_keep_screen_on_true', 0, async function (done) { + brightness.setKeepScreenOn({ + keepScreenOn: true, + success: () => { + expect(true).assertTrue(); + done(); + }, + fail: (data, code) => { + console.log("set_keep_screen_on, data: " + data + ", code: " + code); + expect().assertFail(); + done(); + }, + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); }); - }); - /** - * @tc.number system_display_js_0500 - * @tc.name set_keep_screen_on_true - * @tc.desc set keep screen on true - */ - it('set_keep_screen_on_true', 0, async function () { - brightness.setKeepScreenOn({ - keepScreenOn: true, - success: () => { - expect().assertTrue(); - }, - fail: (data, code) => { - console.log("set_keep_screen_on, data: " + data + ", code: " + code); - expect().assertFail(); - }, - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } + /** + * @tc.number system_display_js_0501 + * @tc.name set_keep_screen_on_false + * @tc.desc set keep screen on false + */ + it('set_keep_screen_on_false', 0, async function (done) { + brightness.setKeepScreenOn({ + keepScreenOn: false, + success: () => { + expect(true).assertTrue(); + done(); + }, + fail: (data, code) => { + console.log("set_keep_screen_on_false, data: " + data + ", code: " + code); + expect().assertFail(); + done(); + }, + complete: () => { + console.log("The device information is obtained successfully. Procedure"); + done(); + } + }); }); - }); - - /** - * @tc.number system_display_js_0501 - * @tc.name set_keep_screen_on_false - * @tc.desc set keep screen on false - */ - it('set_keep_screen_on_false', 0, async function () { - brightness.setKeepScreenOn({ - keepScreenOn: false, - success: () => { - expect().assertTrue(); - }, - fail: (data, code) => { - console.log("set_keep_screen_on_false, data: " + data + ", code: " + code); - expect().assertFail(); - }, - complete: () => { - console.log("The device information is obtained successfully. Procedure"); - } - }); - }); -}) + }) } \ No newline at end of file diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets index 6e24a16fe11a2eac163bbe2c688942d75eefad09..bb1a5b8b3088db6d2d8440b273d5dcf058ba25c4 100644 --- a/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets @@ -19,34 +19,34 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " export default function requestDownloadJSUnit() { 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(function () { - console.info('beforeAll: Prerequisites are executed.'); + console.info('====>beforeAll: Prerequisites are executed.'); }); /** * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. */ beforeEach(function () { - console.info('beforeEach: Prerequisites is executed.'); + console.info('====>beforeEach: Prerequisites is executed.'); }); /** * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. */ afterEach(function () { - console.info('afterEach: Test case-level clearance conditions is executed.'); + console.info('====>afterEach: Test case-level clearance conditions is executed.'); }); /** * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. */ afterAll(function () { - console.info('afterAll: Test suite-level cleanup condition is executed'); + console.info('====>afterAll: Test suite-level cleanup condition is executed'); }); let downloadTask; @@ -72,18 +72,18 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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 { request.download(downloadConfig, (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); }); } catch (err) { console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 error: " + err); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_CALLBACK_0001 end-----------------------"); done(); }); @@ -95,16 +95,16 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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 => { 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); }).catch(err => { console.error("SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 error: " + err); expect().assertFail(); }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PROMISE_0001 end-----------------------"); done(); }); @@ -116,20 +116,20 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); 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 data2 =" + data2); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0001 on data2 =" + data2); expect(true).assertEqual(data1 != 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(); }); @@ -141,21 +141,21 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ downloadTask = data; - console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask); - expect(true).assertEqual(downloadTask != undefined); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 downloadTask: " + downloadTask); try{ + expect(true).assertEqual(downloadTask != undefined); 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){ console.error("SUB_REQUEST_DOWNLOAD_API_CALLBACK_0002 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0002 end-----------------------"); done(); }); @@ -167,21 +167,21 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ downloadTask = data; - console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask); - expect(true).assertEqual(downloadTask != undefined); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 downloadTask: " + downloadTask); try{ + expect(true).assertEqual(downloadTask != undefined); 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){ console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0003 end-----------------------"); done(); }); @@ -193,21 +193,22 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ downloadTask = data; - console.info("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask); - expect(downloadTask != undefined).assertEqual(true); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 downloadTask: " + downloadTask); + try{ + expect(downloadTask != undefined).assertEqual(true); 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){ console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0004 end-----------------------"); done(); }); @@ -219,21 +220,21 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ 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){ console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_ON_0005 end-----------------------"); done(); }); @@ -245,19 +246,19 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); 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 data2 =" + data2); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0001 on data2 =" + data2); expect(data1 != 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(); }); @@ -269,21 +270,21 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ 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){ console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); done(); }); @@ -295,21 +296,21 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ 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){ console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0003 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); done(); }); @@ -321,21 +322,21 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ 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){ console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0004 end-----------------------"); done(); }); @@ -347,21 +348,21 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ 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){ console.error("SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0005 error: " + err); expect().assertFail(); } }); - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DOWNLOADTASK_OFF_0002 end-----------------------"); done(); }); @@ -373,10 +374,10 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); downloadTask.remove((err, data)=>{ if(err) { @@ -384,7 +385,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); } 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(); } else { console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0001 Failed to remove the download task.'); @@ -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(); }); @@ -404,14 +405,14 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); downloadTask.remove().then(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(); } else { console.error('SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 Failed to remove the download task.'); @@ -422,7 +423,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); }) }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMOVE_0002 end-----------------------"); done(); }); @@ -434,14 +435,14 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ 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(); }) }catch(err){ @@ -449,7 +450,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); } }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0001 end-----------------------"); done(); }); @@ -461,20 +462,20 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); 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(); }).catch((err) => { console.error('Failed to pause the download task pause. because: ' + JSON.stringify(err)); expect().assertFail(); }) }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_PAUSE_0002 end-----------------------"); done(); }); @@ -486,14 +487,14 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ 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(); }) }catch(err){ @@ -501,7 +502,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); } }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0001 end-----------------------"); done(); }); @@ -513,20 +514,20 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); 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(); }).catch((err) => { console.error('Failed to pause the download task resume. because: ' + JSON.stringify(err)); expect().assertFail(); }) }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_REMUSE_0002 end-----------------------"); done(); }); @@ -538,10 +539,10 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); try{ downloadTask.query((err, downloadInfo)=>{ @@ -549,17 +550,17 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0001 Failed to query: ' + JSON.stringify(err)); expect().assertFail(); } else { - 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.downloadId); - 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.filePath); - 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.targetURI); - 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.description); + 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.failedReason); + 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.pausedReason); + 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.downloadTitle); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); expect(true).assertTrue(); } }) @@ -568,7 +569,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); } }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0001 end-----------------------"); done(); }); @@ -580,27 +581,27 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); downloadTask.query().then((err, downloadInfo)=>{ if(err) { console.error('SUB_REQUEST_DOWNLOAD_API_QUERY_0002 Failed to query: ' + JSON.stringify(err)); expect().assertFail(); } else { - 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.downloadId); - 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.filePath); - 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.targetURI); - 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.description); + 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.failedReason); + 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.pausedReason); + 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.downloadTitle); + console.info('====>SUB_REQUEST_DOWNLOAD_API_QUERY_0001 query info: '+ downloadInfo.downloadTotalBytes); expect(true).assertTrue(); } }).catch(err => { @@ -608,7 +609,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); }) }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERY_0002 end-----------------------"); done(); }); @@ -620,10 +621,10 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); downloadTask.queryMimeType((err, data)=>{ if(err) { @@ -631,7 +632,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); } 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(); } else { console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0001 Failed to queryMimeType the download task.'); @@ -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(); }); @@ -651,14 +652,14 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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)=>{ 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); downloadTask.queryMimeType().then(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(); } else { console.error('SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 Failed to queryMimeType the download task.'); @@ -669,7 +670,7 @@ export default function requestDownloadJSUnit() { expect().assertFail(); }) }) - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_QUERYMINETYPE_0002 end-----------------------"); done(); }); @@ -681,18 +682,18 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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 { request.download(downloadConfig, (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); downloadTask.delete((err, data) => { if (err) { console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.'); 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(); }); }) @@ -700,7 +701,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0001 end-----------------------"); done(); }); @@ -712,17 +713,17 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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 { request.download(downloadConfig, (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); 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(); }).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(); }) }) @@ -730,7 +731,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error'); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); done(); }); @@ -742,18 +743,18 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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 { request.download(downloadConfig, (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); downloadTask.suspend((err, data) => { if (err) { console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.'); 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(); }); }) @@ -762,7 +763,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 end-----------------------"); done(); }); @@ -774,17 +775,17 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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 { request.download(downloadConfig, (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); 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(); }).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(); }) }) @@ -793,7 +794,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 end-----------------------"); done(); }); @@ -805,18 +806,18 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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{ request.download(downloadConfig, (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); downloadTask.restore((err, data) => { if (err) { console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.'); 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(); }); }); @@ -824,7 +825,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 end-----------------------"); done(); }); @@ -836,17 +837,17 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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{ request.download(downloadConfig, (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); 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(); }).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(); }); }); @@ -854,7 +855,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 end-----------------------"); done(); }); @@ -866,18 +867,18 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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{ request.download(downloadConfig, (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); downloadTask.getTaskInfo((err, data) => { if (err) { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.'); 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(); }); }); @@ -885,7 +886,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 end-----------------------"); done(); }); @@ -897,14 +898,14 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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{ request.download(downloadConfig, (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); 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(); }).catch((err) => { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.'); @@ -915,7 +916,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 end-----------------------"); done(); }); @@ -927,18 +928,18 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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{ request.download(downloadConfig, (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); downloadTask.getTaskMimeType((err, data) => { if (err) { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Failed to getTaskMimeType the download task.'); 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(); }); }); @@ -946,7 +947,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 end-----------------------"); done(); }); @@ -958,14 +959,14 @@ export default function requestDownloadJSUnit() { * @tc.level : Level 2 */ 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{ request.download(downloadConfig, (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); 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(); }).catch((err) => { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Failed to getTaskMimeType the download task.'); @@ -976,7 +977,7 @@ export default function requestDownloadJSUnit() { console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 end-----------------------"); done(); }); diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets index c1810e3bd1e0ecae44854d4f7f4ca041a464d5de..1c52426b51eaf712b4c8b217be8e530f4abdf8ba 100644 --- a/request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestSystem.test.ets @@ -18,7 +18,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " export default function requestSystemJSUnit() { describe('requestSystemJSUnit', function () { - console.info('****************start requestSystemTest*****************') + console.info('====>****************start requestSystemTest*****************') /** * @tc.name: ohos.SUB_REQUESTSYSTEM_UPLOAD_API_0001 @@ -28,7 +28,7 @@ export default function requestSystemJSUnit() { * @tc.level: Level 1 */ 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 = { code: 200, data: '', @@ -52,23 +52,23 @@ export default function requestSystemJSUnit() { }, ], 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) { - console.info('SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload fail'); + console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload fail'); }, complete: function (){ - console.info('SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload complete'); + console.info('====>SUB_REQUESTSYSTEM_UPLOAD_API_0001 upload complete'); } } try{ 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); }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(); }); @@ -80,7 +80,7 @@ export default function requestSystemJSUnit() { * @tc.level: Level 1 */ 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 = { token: "Hm_lpvt_1d6c34c1bc067f5746a5fca18d1c24ab" } @@ -91,23 +91,23 @@ export default function requestSystemJSUnit() { header: '', description: 'this is requeSystem download response', 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) { - console.info('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 handling fail'); + console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 handling fail'); }, complete: function (){ - console.info('SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete'); + console.info('====>SUB_REQUESTSYSTEM_DOWNLOAD_API_0001 download complete'); } } try{ 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); }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(); }); @@ -119,27 +119,27 @@ export default function requestSystemJSUnit() { * @tc.level: Level 1 */ 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 = { uri: "http://www.path.com" } let OnDownloadCompleteOptions = { token: 'token-index', 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); }, fail: function(data, code) { - console.info('SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download fail'); + console.info('====>SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 download fail'); }, 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); - 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); - console.info("-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUESTSYSTEM_DOWNLOADCOMPLETE_API_0001 end-----------------------"); done(); }); }) diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets index 804a98e002c099022e11d73c090e40a7cd4dd96a..0b87999db02e359e1d85f8603c9d98a309b8fe89 100644 --- a/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets @@ -19,34 +19,34 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " export default function requestUploadJSUnit() { 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(function () { - console.info('beforeAll: Prerequisites are executed.'); + console.info('====>beforeAll: Prerequisites are executed.'); }); /** * beforeEach: Prerequisites at the test case level, which are executed before each test case is executed. */ beforeEach(function () { - console.info('beforeEach: Prerequisites is executed.'); + console.info('====>beforeEach: Prerequisites is executed.'); }); /** * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. */ afterEach(function () { - console.info('afterEach: Test case-level clearance conditions is executed.'); + console.info('====>afterEach: Test case-level clearance conditions is executed.'); }); /** * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. */ afterAll(function () { - console.info('afterAll: Test suite-level cleanup condition is executed'); + console.info('====>afterAll: Test suite-level cleanup condition is executed'); }); /** @@ -88,21 +88,21 @@ export default function requestUploadJSUnit() { * @tc.level : Level 0 */ 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 { - 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); - 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); - 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); - 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); } catch (err) { expect(true).assertEqual(true); 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(); }); @@ -115,21 +115,21 @@ export default function requestUploadJSUnit() { * @tc.level : Level 0 */ 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 { - 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); - 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); - 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); - 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); } catch (err) { expect(true).assertEqual(true); 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(); }); @@ -142,21 +142,21 @@ export default function requestUploadJSUnit() { * @tc.level : Level 0 */ 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 { - 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); - 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); - 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); - 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); } catch (err) { expect(true).assertEqual(true); 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(); }); @@ -169,21 +169,21 @@ export default function requestUploadJSUnit() { * @tc.level : Level 0 */ 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 { - 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); - 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); - 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); - 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); } catch (err) { expect(true).assertEqual(true); 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(); }); @@ -196,21 +196,21 @@ export default function requestUploadJSUnit() { * @tc.level : Level 0 */ 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 { - 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); - 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); - 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); - 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); } catch (err) { expect(true).assertEqual(true); 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(); }); @@ -223,31 +223,31 @@ export default function requestUploadJSUnit() { * @tc.level : Level 0 */ 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 { - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); - 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); } catch (err) { expect(true).assertEqual(true); 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(); }); @@ -260,26 +260,26 @@ export default function requestUploadJSUnit() { * @tc.level : Level 1 */ 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 { - 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) => { 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); 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 data2 =" + data2); + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data1 =" + data1); + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 on data2 =" + 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 data2 =" + data2); + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data1 =" + data1); + console.info("====>SUB_REQUEST_UPLOAD_API_CALLBACK_0001 off data2 =" + data2); }); 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) { @@ -287,7 +287,7 @@ export default function requestUploadJSUnit() { expect().assertFail(); } sleep(Date.now(), 20000); - console.info("-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_CALLBACK_0001 end-----------------------"); done(); }); @@ -300,26 +300,26 @@ export default function requestUploadJSUnit() { * @tc.level : Level 1 */ 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 { - 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) => { 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 != {})); 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 != {})); }); 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 != {})); }); 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); }); }); @@ -328,90 +328,11 @@ export default function requestUploadJSUnit() { expect(true).assertFail(true); } sleep(Date.now(), 20000); - console.info("-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_PROMISE_0001 end-----------------------"); 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 @@ -421,18 +342,18 @@ export default function requestUploadJSUnit() { * @tc.level : Level 2 */ 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 { request.upload(uploadConfig, (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); uploadTask.delete((err, data) => { if (err) { console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.'); 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(); }); }) @@ -440,7 +361,7 @@ export default function requestUploadJSUnit() { console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------"); done(); }); @@ -452,17 +373,17 @@ export default function requestUploadJSUnit() { * @tc.level : Level 2 */ 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 { request.upload(uploadConfig, (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); 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(); }).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(); }) }) @@ -470,7 +391,7 @@ export default function requestUploadJSUnit() { console.error('SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch error'); expect().assertFail(); } - console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 end-----------------------"); + console.info("====>-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 end-----------------------"); done(); }); diff --git a/storage/BUILD.gn b/storage/BUILD.gn index 0e2f7040e50d10992faa11ded08e8d4f1235a23c..e4c6a0da41fdcc2c02a3ec3c4d58e4a046857ac3 100644 --- a/storage/BUILD.gn +++ b/storage/BUILD.gn @@ -18,6 +18,7 @@ group("storage") { deps = [ "storagefileioerrorjstest:storagefileioerror_js_test", "storagefileiojstest:storagefileio_js_test", + "storagefileiov9jstest:storagefileiov9_js_test", "storagefilejstest:storagefile_js_test", "storagesecuritylabeljstest:storagesecuritylabel_js_test", "storagestatfsjstest:storagestatfs_js_test", diff --git a/communication/dsoftbus/rpc_server/BUILD.gn b/storage/storagefileiov9jstest/BUILD.gn similarity index 69% rename from communication/dsoftbus/rpc_server/BUILD.gn rename to storage/storagefileiov9jstest/BUILD.gn index 084d3daac96a69c150e0ddd2e60f7b5ca71cb709..96f6917438ee0382ae35d318b5dcc671dd4da8a3 100644 --- a/communication/dsoftbus/rpc_server/BUILD.gn +++ b/storage/storagefileiov9jstest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# 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 @@ -10,25 +10,26 @@ # 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("//test/xts/tools/build/suite.gni") -ohos_hap_assist_suite("ActsRpcJsServer") { +ohos_js_hap_suite("storagefileiov9_js_test") { hap_profile = "./src/main/config.json" deps = [ - ":rpc_js_assets", - ":rpc_js_resources", + ":storagefileiov9_js_assets", + ":storagefileiov9_js_resources", ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsRpcHapServer" - subsystem_name = "communication" - part_name = "ipc" + hap_name = "ActsStorageFileIoV9JSTest" + subsystem_name = "filemanagement" + part_name = "file_api" } -ohos_js_assets("rpc_js_assets") { - source_dir = "./src/main/js" +ohos_js_assets("storagefileiov9_js_assets") { + js2abc = true 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" ] hap_profile = "./src/main/config.json" } diff --git a/storage/storagefileiov9jstest/Test.json b/storage/storagefileiov9jstest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..58245887d6b3806d64a06f263b85488eb1228a71 --- /dev/null +++ b/storage/storagefileiov9jstest/Test.json @@ -0,0 +1,17 @@ +{ + "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 diff --git a/communication/dsoftbus/rpc_server/signature/openharmony_sx.p7b b/storage/storagefileiov9jstest/signature/openharmony_sx.p7b similarity index 51% rename from communication/dsoftbus/rpc_server/signature/openharmony_sx.p7b rename to storage/storagefileiov9jstest/signature/openharmony_sx.p7b index d00afeff6b13a18a2b5fd8aa9b3d7623aabb6a11..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 100644 Binary files a/communication/dsoftbus/rpc_server/signature/openharmony_sx.p7b and b/storage/storagefileiov9jstest/signature/openharmony_sx.p7b differ diff --git a/storage/storagefileiov9jstest/src/main/config.json b/storage/storagefileiov9jstest/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..03424320d248a5a9b2fac7933b550913b30aba35 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/config.json @@ -0,0 +1,95 @@ +{ + "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 diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/app.js b/storage/storagefileiov9jstest/src/main/js/MainAbility/app.js similarity index 73% rename from communication/dsoftbus/rpc_server/src/main/js/MainAbility/app.js rename to storage/storagefileiov9jstest/src/main/js/MainAbility/app.js index 8ae33ddcfbaffc15aa458bb6aa434d7049925ccc..ff6de3ed7a2189ab31dbded34284eb4ce87f644e 100644 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/app.js +++ b/storage/storagefileiov9jstest/src/main/js/MainAbility/app.js @@ -1,23 +1,23 @@ -/* - * 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. - */ - -export default { - onCreate() { - console.info("Application onCreate"); - }, - onDestroy() { - console.info("Application onDestroy"); - } -}; +/* + * 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. + */ + +export default { + onCreate() { + console.info('ohos.acts.storage.fileio onCreate'); + }, + onDestroy() { + console.info('ohos.acts.storage.fileio onDestroy'); + } +}; diff --git a/storage/storagefileiov9jstest/src/main/js/MainAbility/i18n/en-US.json b/storage/storagefileiov9jstest/src/main/js/MainAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..ead52ed2e09ec82aaf7aa9f4e714ed39ea88308e --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/MainAbility/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "Test" + } +} \ No newline at end of file diff --git a/storage/storagefileiov9jstest/src/main/js/MainAbility/i18n/zh-CN.json b/storage/storagefileiov9jstest/src/main/js/MainAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..3f48f2585b24a8fe4a745e8ee2972a9e991a7803 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/MainAbility/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "测试" + } +} \ No newline at end of file diff --git a/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.css b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.hml b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.js b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.js similarity index 61% rename from communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.js rename to storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.js index 694f92fc0e5daefe6ae23cdb88c571a454663488..446cc682b011e7de5a9493990e61ca8f9ce0d6eb 100644 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/second/second.js +++ b/storage/storagefileiov9jstest/src/main/js/MainAbility/pages/index/index.js @@ -1,27 +1,33 @@ -/* - * 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 router from '@system.router' - -export default { - data: { - title: 'World' - }, - 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 app from '@system.app' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: '' + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/app.js b/storage/storagefileiov9jstest/src/main/js/TestAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..d5ee271df29e516d1c8929054283e5f2bf5c981c --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/app.js @@ -0,0 +1,31 @@ +/* + * 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"); + } +}; diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/en-US.json b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..55561b83737c3c31d082fbfa11e5fc987a351104 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/en-US.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } +} \ No newline at end of file diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/zh-CN.json b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..cce1af06761a42add0cac1a0567aa3237eda8cb4 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/i18n/zh-CN.json @@ -0,0 +1,8 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } +} \ No newline at end of file diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.css b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.css similarity index 55% rename from communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.css rename to storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.css index 87b92cb0fa66fabbd552fc73804aab915f79c22e..b21c92c6290ea747bd891e2ab673721afc5521ed 100644 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.css +++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.css @@ -1,24 +1,30 @@ -.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; -} +.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; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} \ No newline at end of file diff --git a/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.hml b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.js b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.js similarity index 75% rename from communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.js rename to storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.js index dc1588bf19750fbfc3cdf94b27acd30c60487029..e7cd2973f81dfe6ca5f3a93aae440cdcfdba3188 100644 --- a/communication/dsoftbus/rpc_server/src/main/js/MainAbility/pages/index/index.js +++ b/storage/storagefileiov9jstest/src/main/js/TestAbility/pages/index/index.js @@ -1,32 +1,23 @@ -/* - * 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 router from '@system.router' - -export default { - data: { - title: "" - }, - onInit() { - 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} diff --git a/storage/storagefileiov9jstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/storage/storagefileiov9jstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js new file mode 100644 index 0000000000000000000000000000000000000000..b9e78ce7cf73f1ade6ba52a408a44e33f5430f0d --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -0,0 +1,59 @@ +/* + * 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); + }) + } +}; diff --git a/storage/storagefileiov9jstest/src/main/js/test/Common.js b/storage/storagefileiov9jstest/src/main/js/test/Common.js new file mode 100644 index 0000000000000000000000000000000000000000..ad39b9337736ad91332ddc0620cfa461906dc158 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/Common.js @@ -0,0 +1,142 @@ +/* + * 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 diff --git a/storage/storagefileiov9jstest/src/main/js/test/List.test.js b/storage/storagefileiov9jstest/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..fe3fc11330093e40ca9cf29b6ecfb39c22c49787 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/List.test.js @@ -0,0 +1,27 @@ +/* + * 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() +} diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js new file mode 100644 index 0000000000000000000000000000000000000000..9589c56b5aaad02a0a6352f43bd86f7f4bcf55d0 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/members/open.test.js @@ -0,0 +1,738 @@ +/* + * 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(); + } + }); +}); +} diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js new file mode 100644 index 0000000000000000000000000000000000000000..9fc47763d483822e29d96d80f2373bf1d84eec2c --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/members/read.test.js @@ -0,0 +1,372 @@ +/* + * 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(); + } + }); +}); +} diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js new file mode 100644 index 0000000000000000000000000000000000000000..23f4b14091c88087482a5f8b2c369ee3c19f5d3d --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/members/stat.test.js @@ -0,0 +1,2013 @@ +/* + * 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(); + }); +}); +} diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ad6002eca25323d1713fc309ec42602eb0d70596 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/members/truncate.test.js @@ -0,0 +1,322 @@ +/* + * 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(); + } + }); +}); +} + diff --git a/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js b/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js new file mode 100644 index 0000000000000000000000000000000000000000..38c9767dfa16f054e1ee1158baa6803428ed8988 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/js/test/members/write.test.js @@ -0,0 +1,465 @@ +/* + * 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(); + } + }); +}); +} diff --git a/storage/storagefileiov9jstest/src/main/resources/base/element/string.json b/storage/storagefileiov9jstest/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ce37a9309f48bf729150ad091ab4f0e8863a8652 --- /dev/null +++ b/storage/storagefileiov9jstest/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "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" + } + ] +} diff --git a/communication/dsoftbus/rpc_server/src/main/resources/base/media/icon.png b/storage/storagefileiov9jstest/src/main/resources/base/media/icon.png similarity index 100% rename from communication/dsoftbus/rpc_server/src/main/resources/base/media/icon.png rename to storage/storagefileiov9jstest/src/main/resources/base/media/icon.png diff --git a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets index f62cc6d90021bba76be4a80aee0cd1f469dff5f8..f17668493681f56f785b520dc914d51f4a73ed2e 100644 --- a/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets +++ b/time/timeTest/entry/src/main/ets/test/systemTimeTest.ets @@ -19,7 +19,7 @@ import systemTime from "@ohos.systemTime"; export default function systemTimeJsunit() { describe('systemTimeTest', function () { - console.info('--------------------systemTimeTest start-----------------------'); + console.info('====>---------------systemTimeTest start-----------------------'); /** * @tc.number SUB_systemTime_getCurrentTime_JS_API_0001 * @tc.name Test systemTime.getCurrentTime @@ -29,7 +29,7 @@ export default function systemTimeJsunit() { * @tc.level : Level 1 */ 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) => { if (error) { console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); @@ -39,7 +39,7 @@ export default function systemTimeJsunit() { expect(data != null).assertEqual(true); }); - console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------"); + console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0100 end-----------------"); done(); }); @@ -52,15 +52,15 @@ export default function systemTimeJsunit() { * @tc.level : Level 1 */ 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) => { - 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); }).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() }); - console.info("----------SUB_systemTime_getCurrentTime_JS_API_0002 end------------"); + console.info("====>-----SUB_systemTime_getCurrentTime_JS_API_0002 end------------"); done(); }); @@ -73,17 +73,17 @@ export default function systemTimeJsunit() { * @tc.level : Level 1 */ 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) => { 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() }; - 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); }); - console.info("---------------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------"); + console.info("====>----------SUB_systemTime_getRealActiveTime_JS_API_0001 end-----------------"); done(); }); @@ -96,15 +96,15 @@ export default function systemTimeJsunit() { * @tc.level : Level 1 */ 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) => { - 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); }).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() }); - console.info("----------SUB_systemTime_getRealActiveTime_JS_API_0002 end------------"); + console.info("====>-----SUB_systemTime_getRealActiveTime_JS_API_0002 end------------"); done(); }); @@ -117,17 +117,17 @@ export default function systemTimeJsunit() { * @tc.level : Level 1 */ 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) => { 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() }; - 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); }); - console.info("---------------SUB_systemTime_getRealTime_JS_API_0001 end-----------------"); + console.info("====>----------SUB_systemTime_getRealTime_JS_API_0001 end-----------------"); done(); }); @@ -140,15 +140,15 @@ export default function systemTimeJsunit() { * @tc.level : Level 1 */ 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) => { - 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); }).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(); }); - console.info("----------SUB_systemTime_getRealTime_JS_API_0002 end------------"); + console.info("====>-----SUB_systemTime_getRealTime_JS_API_0002 end------------"); done(); }); @@ -161,17 +161,17 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ it('SUB_systemTime_setTime_JS_API_0100', 0, async function (done) { - console.info("SUB_systemTime_setTime_JS_API_0100 start"); - systemTime.setTime(1526003846000) - .then(data =>{ - console.info("setTime ===data " + data); - expect(data).assertEqual(true) - }).catch(error => { - console.info("setTime ===error " + error); - expect(0).assertLarger(1) - }); - console.info('SUB_systemTime_setTime_JS_API_0100 end'); - done(); + console.info("====>SUB_systemTime_setTime_JS_API_0100 start"); + let currentTime = new Date().getTime() + 2000 + try{ + await systemTime.setTime(currentTime) + expect(true).assertTrue(); + done(); + }catch(err){ + console.info("====>SUB_systemTime_setTime_JS_API_0100 error " + err); + expect().assertFail(); + done(); + } }); /** @@ -183,17 +183,23 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ it('SUB_systemTime_setTime_JS_API_0200', 0, async function (done) { - console.info("SUB_systemTime_setTime_JS_API_0200 start"); - systemTime.setTime(15222) - .then(data => { - console.info("setTime ===data " + data); + console.info("====>SUB_systemTime_setTime_JS_API_0200 start"); + try{ + systemTime.setTime(15222).then(() => { + 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(); - }).catch(error => { - console.info("setTime ===error " + error); - expect(0).assertLarger(1) - }); - console.info('SUB_systemTime_setTime_JS_API_0200 end'); - done(); + console.debug('SUB_systemTime_setTime_JS_API_0200 end'); + 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() { * @tc.level : Level 0 */ it('SUB_systemTime_setTime_JS_API_0300', 0, async function (done) { - console.info("SUB_systemTime_setTime_JS_API_0300 start"); - systemTime.setTime(1597156246000, (err, data) => { - if (err) { - console.info("setTime ===error: " + err); - expect().assertFail() - }else{ - console.info("setTime ===data: " + data); - expect(true).assertTrue(); - }; + console.info("====>SUB_systemTime_setTime_JS_API_0300 start"); + let currentTime = new Date().getTime() + 2000 + systemTime.setTime(currentTime, (err) => { + try{ + expect(true).assertTrue(); + console.info('SUB_systemTime_setTime_JS_API_0300 end'); + done(); + }catch(err){ + console.info("====>SUB_systemTime_setTime_JS_API_0300 error: " + err); + expect().assertFail(); + done(); + } }); - console.info('SUB_systemTime_setTime_JS_API_0300 end'); - done(); }); /** @@ -228,11 +235,11 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ 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{ systemTime.setTime(18, (err, data) => { - console.info("setTime ===data: " + data); - console.info("setTime ===error: " + err); + console.info("====>SUB_systemTime_setTime_JS_API_0400 data: " + data); + console.info("====>SUB_systemTime_setTime_JS_API_0400 error: " + err); expect(true).assertTrue(); })}catch(error) {error => { expect(1).assertLarger(0); @@ -251,13 +258,13 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ 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"); systemTime.setDate(1).then(data => { - console.info("setTime ===data " + data); + console.info("====>SUB_systemTime_setDate_JS_API_0100 data " + data); expect(true).assertTrue(); }).catch(error => { - console.info("setTime ===error " + error); + console.info("====>SUB_systemTime_setDate_JS_API_0100 error " + error); expect().assertFail(); }); done(); @@ -272,12 +279,12 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ 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 => { - console.info("setTime ===data " + data); + console.info("====>SUB_systemTime_setDate_JS_API_0200 data " + data); expect(true).assertTrue(); }).catch(error => { - console.info("setTime ===error " + error); + console.info("====>SUB_systemTime_setDate_JS_API_0200 error " + error); expect().assertFail(); }); done(); @@ -292,14 +299,14 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ 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"); systemTime.setDate(data, (error, data) => { if(error){ - console.info("setTime ===error " + error); + console.info("====>SUB_systemTime_setDate_JS_API_0300 error " + error); expect().assertFail(); }else{ - console.info("setTime ===data " + data); + console.info("====>SUB_systemTime_setDate_JS_API_0300 data " + data); expect(true).assertTrue(); }; }); @@ -315,12 +322,12 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ 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 => { - console.info("setTime ===data " + data); + console.info("====>SUB_systemTime_setTimezone_JS_API_0100 data " + data); expect().assertFail(); }).catch(error => { - console.info("setTime ===error " + error); + console.info("====>SUB_systemTime_setTimezone_JS_API_0100 error " + error); expect(true).assertTrue(); }); done(); @@ -335,12 +342,12 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ 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 => { - console.info("setTime ===data " + data); + console.info("====>SUB_systemTime_setTimezone_JS_API_0200 data " + data); expect().assertFail(); }).catch(error => { - console.info("setTime ===error " + error); + console.info("====>SUB_systemTime_setTimezone_JS_API_0200 error " + error); expect(true).assertTrue(); }); done(); @@ -355,12 +362,12 @@ export default function systemTimeJsunit() { * @tc.level : Level 0 */ 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 => { - console.info("setTime ===data " + data); + console.info("====>SUB_systemTime_setTimezone_JS_API_0300 data " + data); expect().assertFail(); }).catch(error => { - console.info("setTime ===error " + error); + console.info("====>SUB_systemTime_setTimezone_JS_API_0300 error " + error); expect(true).assertTrue(); }); done(); diff --git a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets index 8cc91d65bf5373ce9757542326a753af6a920f0a..6a55866ce80ba80975916869549384438a1b7a7e 100644 --- a/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets +++ b/time/timeTest/entry/src/main/ets/test/systemTimer.test.ets @@ -19,7 +19,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from export default function systemTimerTest() { describe('systemTimerTest', function () { - console.info('systemTimer Test start'); + console.info('====>systemTimer Test start'); //wantAgent对象 var wantAgent; @@ -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(function () { - console.info('beforeAll: Prerequisites are executed.'); + console.info('====>beforeAll: Prerequisites are executed.'); WantAgent.getWantAgent(wantAgentInfo) .then((data) => { 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; } }) @@ -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(function () { - console.info('beforeEach: Prerequisites is executed.'); + console.info('====>beforeEach: Prerequisites is executed.'); }); /** * afterEach: Test case-level clearance conditions, which are executed after each test case is executed. */ afterEach(function () { - console.info('afterEach: Test case-level clearance conditions is executed.'); + console.info('====>afterEach: Test case-level clearance conditions is executed.'); }); /** * afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed. */ afterAll(function () { - console.info('afterAll: Test suite-level cleanup condition is executed.'); + console.info('====>afterAll: Test suite-level cleanup condition is executed.'); }); /** @@ -86,27 +86,27 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 = { type: systemTimer.TIMER_TYPE_REALTIME, repeat: false }; 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) { if (err) { // 处理业务逻辑错误 expect().assertTrue(); done(); } - console.info('SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID); + console.info('====>SUB_time_systemTimer_createTimer_0000 timerID: ' + timerID); globalTimerID = timerID; expect(Number.isInteger(timerID)).assertTrue(); done(); }); } 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(); done(); }; @@ -121,7 +121,7 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 = { type: systemTimer.TIMER_TYPE_IDLE, repeat: false @@ -129,16 +129,16 @@ export default function systemTimerTest() { try { systemTimer.createTimer(options, function (err, timerID) { 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(); done(); }; - console.info('SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID); + console.info('====>SUB_time_systemTimer_createTimer_0001 timerID: ' + timerID); expect(Number.isInteger(timerID)).assertTrue(); done(); }); } 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(); done(); }; @@ -153,9 +153,9 @@ export default function systemTimerTest() { * @tc.level Level 2 */ 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)=>{ - console.info('SUB_time_systemTimer_createTimer_0002 BundleName: ' + data); + console.info('====>SUB_time_systemTimer_createTimer_0002 BundleName: ' + data); }) let options = { type: systemTimer.TIMER_TYPE_WAKEUP, @@ -164,19 +164,19 @@ export default function systemTimerTest() { interval: interval_time }; 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) { 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(); done(); } - console.info('SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID); + console.info('====>SUB_time_systemTimer_createTimer_0002 timerID: ' + timerID); expect(Number.isInteger(timerID)).assertTrue(); done(); }); } 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(); done(); }; @@ -191,16 +191,16 @@ export default function systemTimerTest() { * @tc.level Level 2 */ 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 = { type: systemTimer.TIMER_TYPE_EXACT, repeat: false }; 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) { 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(); done(); } @@ -208,7 +208,7 @@ export default function systemTimerTest() { done(); }); } 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(); done(); }; @@ -223,9 +223,9 @@ export default function systemTimerTest() { * @tc.level Level 2 */ 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)=>{ - console.info("SUB_time_systemTimer_createTimer_0004 BundleName: " + data); + console.info("====>SUB_time_systemTimer_createTimer_0004 BundleName: " + data); }); let options = { type: systemTimer.TIMER_TYPE_REALTIME, @@ -234,7 +234,7 @@ export default function systemTimerTest() { interval: interval_time }; 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) { if (err) { expect().assertTrue(); @@ -244,7 +244,7 @@ export default function systemTimerTest() { done(); }); } 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(); done(); }; @@ -260,24 +260,24 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 = { type: systemTimer.TIMER_TYPE_REALTIME, repeat: false }; try { - console.info('SUB_time_systemTimer_createTimer_0005 create timer.'); + console.info('====>SUB_time_systemTimer_createTimer_0005 create timer.'); 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(); done(); }).catch(err => { - console.info('SUB_time_systemTimer_createTimer_0005 promise failed ' + err); + console.info('====>SUB_time_systemTimer_createTimer_0005 promise failed ' + err); expect().assertTrue(); done(); }); } 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(); done(); }; @@ -292,23 +292,23 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 = { type: systemTimer.TIMER_TYPE_IDLE, repeat: false }; try { 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(); done(); }).catch(err => { - console.info('SUB_time_systemTimer_createTimer_0006 promise failed ' + err); + console.info('====>SUB_time_systemTimer_createTimer_0006 promise failed ' + err); expect().assertTrue(); done(); }); } 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(); done(); }; @@ -323,9 +323,9 @@ export default function systemTimerTest() { * @tc.level Level 2 */ 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)=>{ - console.info('SUB_time_systemTimer_createTimer_0007 BundleName: ' + data); + console.info('====>SUB_time_systemTimer_createTimer_0007 BundleName: ' + data); }) let options = { type: systemTimer.TIMER_TYPE_WAKEUP, @@ -334,18 +334,18 @@ export default function systemTimerTest() { interval: interval_time }; try { - console.info("SUB_time_systemTimer_createTimer_0007 create timer"); + console.info("====>SUB_time_systemTimer_createTimer_0007 create timer"); 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(); done(); }).catch(err => { - console.info('SUB_time_systemTimer_createTimer_0007 promise failed ' + err); + console.info('====>SUB_time_systemTimer_createTimer_0007 promise failed ' + err); expect().assertTrue(); done(); }); } 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(); done(); }; @@ -360,23 +360,23 @@ export default function systemTimerTest() { * @tc.level Level 2 */ 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 = { type: systemTimer.TIMER_TYPE_EXACT, repeat: false }; try { - console.info("SUB_time_systemTimer_createTimer_0008 create timer") + console.info("====>SUB_time_systemTimer_createTimer_0008 create timer") systemTimer.createTimer(options).then((timerID) => { expect(Number.isInteger(timerID)).assertTrue(); done(); }).catch(err => { - console.info('SUB_time_systemTimer_createTimer_0008 promise failed ' + err); + console.info('====>SUB_time_systemTimer_createTimer_0008 promise failed ' + err); expect().assertTrue(); done(); }); } 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(); done(); }; @@ -391,9 +391,9 @@ export default function systemTimerTest() { * @tc.level Level 2 */ 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)=>{ - console.info("SUB_time_systemTimer_createTimer_0009 BundleName: " + data); + console.info("====>SUB_time_systemTimer_createTimer_0009 BundleName: " + data); }); let options = { type: systemTimer.TIMER_TYPE_REALTIME, @@ -402,17 +402,17 @@ export default function systemTimerTest() { interval: interval_time }; try { - console.info("SUB_time_systemTimer_createTimer_0009 create timer") + console.info("====>SUB_time_systemTimer_createTimer_0009 create timer") systemTimer.createTimer(options).then((timerID) => { expect(Number.isInteger(timerID)).assertTrue(); done(); }).catch(err => { - console.info('SUB_time_systemTimer_createTimer_0009 promise failed ' + err); + console.info('====>SUB_time_systemTimer_createTimer_0009 promise failed ' + err); expect().assertTrue(); done(); }); } 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(); done(); }; @@ -427,21 +427,21 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 { - 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; systemTimer.startTimer(globalTimerID, triggerTime, function (err, data) { 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(); 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(); }); } 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(); done(); }; @@ -456,19 +456,19 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 { - 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) { if (err) { expect().assertTrue(); 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(); }); } 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(); done(); }; @@ -483,19 +483,19 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 { - 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) { if (err) { expect().assertTrue(); 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(); }); } 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(); done(); }; @@ -510,27 +510,27 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 = { type: systemTimer.TIMER_TYPE_REALTIME, repeat: false }; try { - console.info('SUB_time_systemTimer_createTimer_0002 create timer.'); + console.info('====>SUB_time_systemTimer_createTimer_0002 create timer.'); 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(); globalTimerID = timerID; done(); }).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(); done(); }); } 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(); done(); }; @@ -545,23 +545,23 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 { - 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; systemTimer.startTimer(globalTimerID, triggerTime) .then(()=>{ - console.info('SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID); + console.info('====>SUB_time_systemTimer_startTimer_0002 timerID:' + globalTimerID); done(); }).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(); done(); }); } 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(); done(); } @@ -576,22 +576,22 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 { - 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) .then(()=>{ - console.info('SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID); + console.info('====>SUB_time_systemTimer_stopTimer_0002 timerID:' + globalTimerID); done(); }).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(); done(); }); } 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(); done(); }; @@ -606,22 +606,22 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 { - 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) .then(()=>{ - console.info('SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID); + console.info('====>SUB_time_systemTimer_destroyTimer_0002 timerID:' + globalTimerID); done(); }).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(); done(); }); } 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(); done(); }; @@ -636,65 +636,65 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 = { type: systemTimer.TIMER_TYPE_WAKEUP, repeat: false }; try { - console.info('SUB_time_systemTimer_ALL_Promise_0008 create timer.'); + console.info('====>SUB_time_systemTimer_ALL_Promise_0008 create timer.'); systemTimer.createTimer(options) .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(); try { let triggerTime = new Date().getTime() + interval_time * 1.2; systemTimer.startTimer(timerID, triggerTime) .then(()=>{ - console.info('SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID); + console.info('====>SUB_time_systemTimer_ALL_Promise_0008 start timerID: ' + timerID); try { systemTimer.stopTimer(timerID) .then(()=>{ 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(); }); }) .catch(()=>{ // 捕获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(); done(); }) } catch (err) { // 捕获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(); done(); } }) .catch(()=>{ // 捕获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(); done(); }); } 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(); done(); } }) .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(); done(); }); } 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(); done(); } @@ -709,42 +709,42 @@ export default function systemTimerTest() { * @tc.level Level 0 */ 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 = { type: systemTimer.TIMER_TYPE_WAKEUP, repeat: false }; try { - console.info('SUB_time_systemTimer_ALL_Callback_0009 create timer.'); + console.info('====>SUB_time_systemTimer_ALL_Callback_0009 create timer.'); systemTimer.createTimer(options) .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(); try { let triggerTime = new Date().getTime() + interval_time * 1.2; 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 { systemTimer.stopTimer(timerID, ()=>{ 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(); }); }) } 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(); done(); } }) } 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(); done(); } }) } 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(); done(); }