diff --git a/distributeddatamgr/BUILD.gn b/distributeddatamgr/BUILD.gn index 77f131ccd2c8c41e6070dfed655535d2f63b38e4..c661eb502b342941ec566de6ab6453899c31a0ae 100755 --- a/distributeddatamgr/BUILD.gn +++ b/distributeddatamgr/BUILD.gn @@ -18,7 +18,6 @@ group("distributeddatamgr") { deps = [ "appdatamgrjstest/hap:appdatamgr_js_test", "distributeddatamgrjstest/hap:distributeddatamgr_js_test", - "distributedfilejstest:distributedfile_js_test", ] } else { deps = [ diff --git a/distributeddatamgr/distributedfilejstest/BUILD.gn b/distributeddatamgr/distributedfilejstest/BUILD.gn deleted file mode 100644 index f13847a4a3bf584ba2454a5a0fcb3654559b5aa9..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/BUILD.gn +++ /dev/null @@ -1,18 +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("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("distributedfile_js_test") { - test_hap_name = "DistributedfileJSTest" - hap_source_path = "hap/entry-debug-rich-signed.hap" -} diff --git a/distributeddatamgr/distributedfilejstest/Test.json b/distributeddatamgr/distributedfilejstest/Test.json deleted file mode 100644 index de4c6d3e61b3d856ef5cfd0de5f8c2698e2a93d6..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for distributed file Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "21600000", - "package": "ohos.acts.distributeddatamgr.distributedfile", - "shell-timeout": "21600000" - }, - "kits": [ - { - "test-file-name": [ - "DistributedfileJSTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/distributeddatamgr/distributedfilejstest/hap/entry-debug-rich-signed.hap b/distributeddatamgr/distributedfilejstest/hap/entry-debug-rich-signed.hap deleted file mode 100644 index 1e7e627b2611ff03c28822e681f9b715070f7a69..0000000000000000000000000000000000000000 Binary files a/distributeddatamgr/distributedfilejstest/hap/entry-debug-rich-signed.hap and /dev/null differ diff --git a/distributeddatamgr/distributedfilejstest/project/entry/package.json b/distributeddatamgr/distributedfilejstest/project/entry/package.json deleted file mode 100644 index 69a88e3b65423624fe7ea8b0f8beefcc62cc3d5f..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/package.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/config.json b/distributeddatamgr/distributedfilejstest/project/entry/src/main/config.json deleted file mode 100644 index 21b8cd9b99c2e3997b860c575345162ede8d55be..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/config.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "app": { - "bundleName": "ohos.acts.distributeddatamgr.distributedfile", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 4, - "target": 4 - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.distributeddatamgr.distributedfile", - "name": ".DistributedFileJSTest", - "deviceType": [ - "phone" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "name": "ohos.acts.distributeddatamgr.distributedfile.MainAbility", - "icon": "$media:icon", - "description": "$string:mainability_description", - "label": "DistributedFileJSTest", - "type": "page", - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/app.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/app.js deleted file mode 100644 index 2e630f35bd5a9ba035f43c996db3f9a24349448f..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/app.js +++ /dev/null @@ -1,25 +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 device from '@system.device'; - -export default { - onCreate() { - console.info('ohos.acts.distributeddatamgr.distributedfile onCreate'); - }, - onDestroy() { - console.info('ohos.acts.distributeddatamgr.distributedfile onCreate'); - } -}; diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/i18n/en-US.json b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/i18n/zh-CN.json b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.css b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.hml b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.hml deleted file mode 100644 index 1c26cf73deab18390844a53a103458b10ed11e93..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{title}} - -
diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.js deleted file mode 100644 index 5ccd313b0bbe54a8b8a316fc5509b30a2bbafbd0..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,48 +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 file from '@system.file' -import app from '@system.app' - -import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.init() - - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/Common.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/Common.js deleted file mode 100644 index 0da46e3844bcbf5190cdbfcb81b8fe3fafc76437..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/Common.js +++ /dev/null @@ -1,38 +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 fileio from '@ohos.fileio' - -export const FILE_CONTENT = "hello, world" - -export function prepareFile(fpath, content) { - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - fileio.ftruncateSync(fd) - fileio.writeSync(fd, content) - fileio.fsyncSync(fd) - fileio.closeSync(fd) - return true - } catch (e) { - console.log("Failed to prepareFile for " + e) - return false - } -} - -var fileSeed = 0 -export function nextFileName(testName) { - const BASE_PATH = "/data/accounts/account_0/appdata/ohos.acts.distributeddatamgr.distributedfile/cache/" - return BASE_PATH + testName + fileSeed++ -} \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIO.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIO.test.js deleted file mode 100755 index 13212a963a385b5897729d3f409ded96805f2b22..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIO.test.js +++ /dev/null @@ -1,1000 +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 fileio from '@ohos.fileio' -import bundle_mgr from '@ohos.bundle_mgr' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -import { FILE_CONTENT, prepareFile, nextFileName } from './Common' - -describe('fileIOTest', function () { - /** - * @tc.number SUB_DF_FileIO_UnlinkSync_0000 - * @tc.name fileio_test_unlink_sync_000 - * @tc.desc Test unlinkSync() interface. - */ - it('fileio_test_unlink_sync_000', 0, function () { - let fpath = nextFileName('fileIOTest') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_unlink_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_UnlinkSync_0010 - * @tc.name fileio_test_unlink_sync_001 - * @tc.desc Test unlinkSync() interface. - */ - it('fileio_test_unlink_sync_001', 0, function () { - try { - fileio.unlinkSync() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_UnlinkSync_0020 - * @tc.name fileio_test_unlink_sync_002 - * @tc.desc Test unlinkSync() interface. - */ - it('fileio_test_unlink_sync_002', 0, function () { - let fpath = nextFileName('fileIOTest') - - try { - fileio.unlinkSync(fpath) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_AccessSync_0000 - * @tc.name fileio_test_access_sync_000 - * @tc.desc Test accessSync() interface. - */ - it('fileio_test_access_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_access_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - expect(fileio.accessSync(fpath)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_access_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_AccessSync_0010 - * @tc.name fileio_test_access_sync_001 - * @tc.desc Test accessSync() interface. - */ - it('fileio_test_access_sync_001', 0, function () { - try { - fileio.accessSync() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_AccessSync_0020 - * @tc.name fileio_test_access_sync_002 - * @tc.desc Test accessSync() interface. - */ - it('fileio_test_access_sync_002', 0, function () { - let fpath = nextFileName('fileIOTest') - - try { - fileio.accessSync(fpath) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_OpenCloseSync_0000 - * @tc.name fileio_test_open_close_sync_000 - * @tc.desc Test openSync() and closeSync() interfaces. - */ - it('fileio_test_open_close_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_open_close_sync_000') - - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_open_close_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_OpenSync_0000 - * @tc.name fileio_test_open_sync_000 - * @tc.desc Test openSync() interface. - */ - it('fileio_test_open_sync_000', 0, function () { - try { - fileio.openSync("/", 0o102, 0o666) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_OpenSync_0010 - * @tc.name fileio_test_open_sync_001 - * @tc.desc Test openSync() interface. - */ - it('fileio_test_open_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_open_sync_001') - - try { - fileio.openSync(fpath, 0o102) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_CloseSync_0000 - * @tc.name fileio_test_close_sync_000 - * @tc.desc Test closeSync() interface. - */ - it('fileio_test_close_sync_000', 0, function () { - try { - fileio.closeSync() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_CloseSync_0010 - * @tc.name fileio_test_close_sync_001 - * @tc.desc Test closeSync() interface. - */ - it('fileio_test_close_sync_001', 0, function () { - try { - fileio.closeSync(-1) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0000 - * @tc.name fileio_test_write_sync_000 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_write_sync_000') - - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.writeSync(fd, FILE_CONTENT)).assertEqual(FILE_CONTENT.length) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_write_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0010 - * @tc.name fileio_test_write_sync_001 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_write_sync_001') - - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.writeSync(fd, FILE_CONTENT, { - encoding: "utf-8", - })).assertEqual(FILE_CONTENT.length) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_write_sync_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0020 - * @tc.name fileio_test_write_sync_002 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_002', 0, function () { - let fpath = nextFileName('fileio_test_write_sync_002') - - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.writeSync(fd, FILE_CONTENT, { - offset: 1, - })).assertEqual(FILE_CONTENT.length - 1) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_write_sync_002 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0030 - * @tc.name fileio_test_write_sync_003 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_003', 0, function () { - let fpath = nextFileName('fileio_test_write_sync_003') - - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.writeSync(fd, FILE_CONTENT, { - length: FILE_CONTENT.length - 1, - })).assertEqual(FILE_CONTENT.length - 1) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_write_sync_003 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0040 - * @tc.name fileio_test_write_sync_004 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_004', 0, function () { - let fpath = nextFileName('fileio_test_write_sync_004') - - try { - let fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.writeSync(fd, FILE_CONTENT, { - offset: 1, - length: 1, - })).assertEqual(1) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_write_sync_004 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0050 - * @tc.name fileio_test_write_sync_005 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_005', 0, function () { - let fpath = nextFileName('fileio_test_write_sync_005') - const invalidOffset = 999 - let fd - - try { - fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.writeSync(fd, FILE_CONTENT, { - offset: invalidOffset, - })).assertEqual(1) - expect(null).assertFail() - } catch (e) { - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0060 - * @tc.name fileio_test_write_sync_006 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_006', 0, function () { - let fpath = nextFileName('fileio_test_write_sync_006') - const invalidLength = 999 - let fd - - try { - fd = fileio.openSync(fpath, 0o102, 0o666) - expect(fd).assertInstanceOf('Number') - expect(fileio.writeSync(fd, FILE_CONTENT, { - length: invalidLength, - })).assertEqual(1) - expect(null).assertFail() - } catch (e) { - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0070 - * @tc.name fileio_test_write_sync_007 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_007', 0, function () { - try { - fileio.writeSync() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_WriteSync_0080 - * @tc.name fileio_test_write_sync_008 - * @tc.desc Test writeSync() interface. - */ - it('fileio_test_write_sync_008', 0, function () { - try { - fileio.writeSync(-1, FILE_CONTENT) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0000 - * @tc.name fileio_test_read_sync_000 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_read_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - let len = fileio.readSync(fd, new ArrayBuffer(4096)) - expect(len).assertEqual(FILE_CONTENT.length) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_read_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0001 - * @tc.name fileio_test_read_sync_001 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_001', 0, function () { - let bufLen = 5 - expect(FILE_CONTENT.length).assertLarger(bufLen) - let fpath = nextFileName('fileio_test_read_sync_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - let len = fileio.readSync(fd, new ArrayBuffer(bufLen), { - offset: 1, - }) - expect(len).assertEqual(bufLen - 1) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_read_sync_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0020 - * @tc.name fileio_test_read_sync_002 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_002', 0, function () { - let fpath = nextFileName('fileio_test_read_sync_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - let len = fileio.readSync(fd, new ArrayBuffer(4096), { - length: 1, - }) - expect(len).assertEqual(1) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_read_sync_002 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0030 - * @tc.name fileio_test_read_sync_003 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_003', 0, function () { - let fd - const invalidOffset = 99999 - let fpath = nextFileName('fileio_test_read_sync_003') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - fileio.readSync(fd, new ArrayBuffer(4096), { - offset: invalidOffset, - }) - expect(null).assertFail() - } catch (e) { - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0040 - * @tc.name fileio_test_read_sync_004 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_004', 0, function () { - let fd - const invalidLength = 9999 - let fpath = nextFileName('fileio_test_read_sync_004') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - fileio.readSync(fd, new ArrayBuffer(4096), { - length: invalidLength, - }) - expect(null).assertFail() - } catch (e) { - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0050 - * @tc.name fileio_test_read_sync_005 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_005', 0, function () { - let fpath = nextFileName('fileio_test_read_sync_005') - let fd - - try { - fileio.readSync(-1, new ArrayBuffer(4096)) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0060 - * @tc.name fileio_test_read_sync_006 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_006', 0, function () { - let fpath = nextFileName('fileio_test_read_sync_006') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - let len = fileio.readSync(fd, new ArrayBuffer(4096), { - position: 1, - }) - expect(len).assertEqual(FILE_CONTENT.length - 1) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_read_sync_006 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ReadSync_0070 - * @tc.name fileio_test_read_sync_007 - * @tc.desc Test readSync() interface. - */ - it('fileio_test_read_sync_007', 0, function () { - let fpath = nextFileName('fileio_test_read_sync_007') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - let invalidPos = FILE_CONTENT.length + 1 - let len = fileio.readSync(fd, new ArrayBuffer(4096), { - position: invalidPos, - }) - expect(len).assertEqual(0) - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_read_sync_007 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ChmodSync_0000 - * @tc.name fileio_test_chmod_sync_000 - * @tc.desc Test chmodSync() interface. - */ - it('fileio_test_chmod_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_chmod_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - expect(fileio.chmodSync(fpath, 0o660)).assertNull() - expect(fileio.statSync(fpath).mode & 0o777).assertEqual(0o660) - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_chmod_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ChmodSync_0010 - * @tc.name fileio_test_chmod_sync_001 - * @tc.desc Test chmodSync() interface. - */ - it('fileio_test_chmod_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_chmod_sync_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - fileio.chmodSync(fpath) - expect(null).assertFail() - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_ChmodSync_0020 - * @tc.name fileio_test_chmod_sync_002 - * @tc.desc Test chmodSync() interface. - */ - it('fileio_test_chmod_sync_002', 0, function () { - let fpath = nextFileName('fileio_test_chmod_sync_002') - - try { - fileio.chmodSync(fpath, 0o660) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_CopyFileSync_0000 - * @tc.name fileio_test_copy_file_sync_000 - * @tc.desc Test copyFileSync() interface. - */ - it('fileio_test_copy_file_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_copy_file_sync_000') - let fpathTarget = fpath + 'tgt' - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - expect(fileio.copyFileSync(fpath, fpathTarget)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.unlinkSync(fpathTarget)).assertNull() - } catch (e) { - console.log("fileio_test_copy_file_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_CopyFileSync_0010 - * @tc.name fileio_test_copy_file_sync_001 - * @tc.desc Test copyFileSync() interface. - */ - it('fileio_test_copy_file_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_copy_file_sync_000') - let fpathTarget = fpath + 'tgt' - - try { - fileio.copyFileSync(fpath, fpathTarget) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_CopyFileSync_0020 - * @tc.name fileio_test_copy_file_sync_002 - * @tc.desc Test copyFileSync() interface. - */ - it('fileio_test_copy_file_sync_002', 0, function () { - try { - fileio.copyFileSync() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_TruncateSync_0000 - * @tc.name fileio_test_truncate_sync_000 - * @tc.desc Test truncateSync() interface. - */ - it('fileio_test_truncate_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_truncate_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - expect(fileio.truncateSync(fpath)).assertNull() - expect(fileio.statSync(fpath).size).assertEqual(0) - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_truncate_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_TruncateSync_0010 - * @tc.name fileio_test_truncate_sync_001 - * @tc.desc Test truncateSync() interface. - */ - it('fileio_test_truncate_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_truncate_sync_001') - - try { - fileio.truncateSync(fpath) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_TruncateSync_0020 - * @tc.name fileio_test_truncate_sync_002 - * @tc.desc Test truncateSync() interface. - */ - it('fileio_test_truncate_sync_002', 0, function () { - try { - fileio.truncateSync() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_RenameSync_0000 - * @tc.name fileio_test_rename_sync_000 - * @tc.desc Test renameSync() interface. - */ - it('fileio_test_rename_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_rename_sync_000') - let fpathTarget = fpath + 'tgt' - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - expect(fileio.renameSync(fpath, fpathTarget)).assertNull() - expect(fileio.accessSync(fpathTarget)).assertNull() - expect(fileio.unlinkSync(fpathTarget)).assertNull() - } catch (e) { - console.log("fileio_test_rename_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_RenameSync_0010 - * @tc.name fileio_test_rename_sync_001 - * @tc.desc Test renameSync() interface. - */ - it('fileio_test_rename_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_rename_sync_001') - let fpathTarget = fpath + 'tgt' - - try { - fileio.renameSync(fpath, fpathTarget) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_RenameSync_0020 - * @tc.name fileio_test_rename_sync_002 - * @tc.desc Test renameSync() interface. - */ - it('fileio_test_rename_sync_002', 0, function () { - let fpath = nextFileName('fileio_test_rename_sync_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - fileio.renameSync(fpath, "/") - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_FchmodSync_0000 - * @tc.name fileio_test_fchmod_sync_000 - * @tc.desc Test fchmodSync() interface. - */ - it('fileio_test_fchmod_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_fchmod_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fileio.fchmodSync(fd, 0o660)).assertNull() - expect(fileio.statSync(fpath).mode & 0o777).assertEqual(0o660) - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_fchmod_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_FchmodSync_0010 - * @tc.name fileio_test_fchmod_sync_001 - * @tc.desc Test fchmodSync() interface. - */ - it('fileio_test_fchmod_sync_001', 0, function () { - try { - expect(fileio.fchmodSync(-1, 0o660)).assertNull() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_FtruncateSync_0000 - * @tc.name fileio_test_ftruncate_sync_000 - * @tc.desc Test ftruncateSync() interface. - */ - it('fileio_test_ftruncate_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_ftruncate_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fileio.ftruncateSync(fd)).assertNull() - expect(fileio.statSync(fpath).size).assertEqual(0) - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_ftruncate_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_FtruncateSync_0010 - * @tc.name fileio_test_ftruncate_sync_001 - * @tc.desc Test ftruncateSync() interface. - */ - it('fileio_test_ftruncate_sync_001', 0, function () { - try { - fileio.ftruncateSync(-1) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_FsyncSync_0000 - * @tc.name fileio_test_fsync_sync_000 - * @tc.desc Test fsyncSync() interface. - */ - it('fileio_test_fsync_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_fsync_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fileio.fsyncSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_fsync_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_FsyncSync_0010 - * @tc.name fileio_test_fsync_sync_001 - * @tc.desc Test fsyncSync() interface. - */ - it('fileio_test_fsync_sync_001', 0, function () { - try { - fileio.fsyncSync(-1) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_MkdirSync_0000 - * @tc.name fileio_test_mkdir_sync_rmdir_sync_000 - * @tc.desc Test mkdirSync() interface. - */ - it('fileio_test_mkdir_sync_rmdir_sync_000', 0, function () { - let dpath = nextFileName('fileio_test_fsync_sync_000') + 'd' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_mkdir_sync_rmdir_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_MkdirSync_0010 - * @tc.name fileio_test_mkdir_sync_rmdir_sync_001 - * @tc.desc Test mkdirSync() interface. - */ - it('fileio_test_mkdir_sync_rmdir_sync_001', 0, function () { - try { - expect(fileio.mkdirSync("/")).assertNull() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_ChownSync_0000 - * @tc.name fileio_test_chown_sync_000 - * @tc.desc Test chownSync() interface. - */ - it('fileio_test_chown_sync_000', 0, async function (done) { - let fpath = nextFileName('fileio_test_chown_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let bundleInfo = await bundle_mgr.getBundleInfo("ohos.acts.distributeddatamgr.distributedfile") - let UID = bundleInfo.uid - let GID = bundleInfo.gid - - try { - expect(fileio.chownSync(fpath, UID, GID)) - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_chown_sync_000 has failed for " + e) - expect(null).assertFail() - } - done() - }) - - /** - * @tc.number SUB_DF_FileIO_ChownSync_0010 - * @tc.name fileio_test_chown_sync_001 - * @tc.desc Test chownSync() interface. - */ - it('fileio_test_chown_sync_001', 0, async function (done) { - let bundleInfo = await bundle_mgr.getBundleInfo("ohos.acts.distributeddatamgr.distributedfile") - let UID = bundleInfo.uid - let GID = bundleInfo.gid - let fpath = nextFileName('fileio_test_chown_sync_001') - - try { - expect(fileio.chownSync(fpath, UID, GID)) - expect(null).assertFail() - } catch (e) { - } - done() - }) - - /** - * @tc.number SUB_DF_FileIO_ChownSync_0020 - * @tc.name fileio_test_chown_sync_002 - * @tc.desc Test chownSync() interface. - */ - it('fileio_test_chown_sync_002', 0, function () { - let fpath = nextFileName('fileio_test_chown_sync_002') - - try { - expect(fileio.chownSync(fpath, 0, 0)) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_FchownSync_0000 - * @tc.name fileio_test_fchown_sync_000 - * @tc.desc Test fchownSync() interface. - */ - it('fileio_test_fchown_sync_000', 0, async function (done) { - let fpath = nextFileName('fileio_test_fchown_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let bundleInfo = await bundle_mgr.getBundleInfo("ohos.acts.distributeddatamgr.distributedfile") - let UID = bundleInfo.uid - let GID = bundleInfo.gid - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fileio.fchownSync(fd, UID, GID)) - expect(fd).assertInstanceOf('Number') - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - - } catch (e) { - console.log("fileio_test_fchown_sync_000 has failed for " + e) - expect(null).assertFail() - } - done() - }) - - /** - * @tc.number SUB_DF_FileIO_FchownSync_0010 - * @tc.name fileio_test_fchown_sync_001 - * @tc.desc Test fchownSync() interface. - */ - it('fileio_test_fchown_sync_001', 0, async function (done) { - let bundleInfo = await bundle_mgr.getBundleInfo("ohos.acts.distributeddatamgr.distributedfile") - let UID = bundleInfo.uid - let GID = bundleInfo.gid - - try { - expect(fileio.fchownSync(-1, UID, GID)) - expect(null).assertFail() - } catch (e) { - } - done() - }) - - /** - * @tc.number SUB_DF_FileIO_FchownSync_0020 - * @tc.name fileio_test_fchown_sync_002 - * @tc.desc Test fchownSync() interface. - */ - it('fileio_test_fchown_sync_002', 0, function () { - let fd - let fpath = nextFileName('fileio_test_fchown_sync_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - fd = fileio.openSync(fpath, 0o2) - fileio.fchownSync(fd, 0, 0) - expect(null).assertFail() - - } catch (e) { - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) -}) \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODir.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODir.test.js deleted file mode 100755 index 01bd141ddf068efa4532c2ccd3270dbb8ba9bbc9..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODir.test.js +++ /dev/null @@ -1,118 +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 fileio from '@ohos.fileio' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -import { FILE_CONTENT, prepareFile, nextFileName } from './Common' - -describe('fileIOTestDir', function () { - /** - * @tc.number SUB_DF_FileIO_OpenClosedirSync_0000 - * @tc.name fileio_test_dir_open_close_sync_000 - * @tc.desc Test opendirSync() and Dir.closeSync() interfaces. - */ - it('fileio_test_dir_open_close_sync_000', 0, function () { - let dpath = nextFileName('fileio_test_dir_open_close_sync_000') + 'd' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - expect(dd.closeSync()).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dir_open_close_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_OpenClosedirSync_0010 - * @tc.name fileio_test_dir_open_close_sync_001 - * @tc.desc Test opendirSync() interface. - */ - it('fileio_test_dir_open_close_sync_001', 0, function () { - try { - fileio.opendirSync() - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_OpenClosedirSync_0020 - * @tc.name fileio_test_dir_open_close_sync_002 - * @tc.desc Test opendirSync() interface. - */ - it('fileio_test_dir_open_close_sync_002', 0, function () { - let dpath = nextFileName('fileio_test_dir_read_sync_000') + 'd' - - try { - fileio.opendirSync(dpath) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_ReadSync_0000 - * @tc.name fileio_test_dir_read_sync_000 - * @tc.desc Test Dir.readSync() interface. - */ - it('fileio_test_dir_read_sync_000', 0, function () { - let dpath = nextFileName('fileio_test_dir_read_sync_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - expect(dd.readSync() != null).assertTrue() - expect(dd.closeSync()).assertNull() - - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dir_read_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_ReadSync_0010 - * @tc.name fileio_test_dir_read_sync_001 - * @tc.desc Test Dir.readSync() interface. - */ - it('fileio_test_dir_read_sync_001', 0, function () { - let dpath = nextFileName('fileio_test_dir_read_sync_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - expect(dd.readSync(-1) != null).assertTrue() - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) -}) \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODirent.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODirent.test.js deleted file mode 100755 index 22b5a810a582b32b623f3e9688db736297eb8deb..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIODirent.test.js +++ /dev/null @@ -1,411 +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 fileio from '@ohos.fileio' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -import {FILE_CONTENT, prepareFile, nextFileName} from './Common' - -describe('fileIOTestDirent', function () { - /** - * @tc.number SUB_DF_FileIO_Dir_ReadSync_0000 - * @tc.name fileio_test_dirent_name_000 - * @tc.desc Test Dir.readSync() interface. - */ - it('fileio_test_dirent_name_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_name_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.name).assertInstanceOf('String') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_name_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsBlockDevice_0000 - * @tc.name fileio_test_dirent_is_block_device_000 - * @tc.desc Test Dir.isBlockDevice() interface. - */ - it('fileio_test_dirent_is_block_device_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_block_device_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.isBlockDevice()).assertInstanceOf('Boolean') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_is_block_device_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsBlockDevice_0010 - * @tc.name fileio_test_dirent_is_block_device_001 - * @tc.desc Test Dir.isBlockDevice() interface. - */ - it('fileio_test_dirent_is_block_device_001', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_block_device_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - dirent.isBlockDevice(-1) - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsCharacterDevice_0000 - * @tc.name fileio_test_dirent_is_character_device_000 - * @tc.desc Test Dir.isCharacterDevice() interface. - */ - it('fileio_test_dirent_is_character_device_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_character_device_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.isCharacterDevice()).assertInstanceOf('Boolean') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_is_character_device_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsCharacterDevice_0010 - * @tc.name fileio_test_dirent_is_character_device_001 - * @tc.desc Test Dir.isCharacterDevice() interface. - */ - it('fileio_test_dirent_is_character_device_001', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_character_device_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - dirent.isCharacterDevice(-1) - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsDirectory_0000 - * @tc.name fileio_test_dirent_is_directory_000 - * @tc.desc Test Dir.isDirectory() interface. - */ - it('fileio_test_dirent_is_directory_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_directory_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.isDirectory()).assertInstanceOf('Boolean') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_is_directory_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsDirectory_0010 - * @tc.name fileio_test_dirent_is_directory_001 - * @tc.desc Test Dir.isDirectory() interface. - */ - it('fileio_test_dirent_is_directory_001', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_directory_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - dirent.isDirectory(-1) - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsFIFO_0000 - * @tc.name fileio_test_dirent_is_fifo_000 - * @tc.desc Test Dir.isFIFO() interface. - */ - it('fileio_test_dirent_is_fifo_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_fifo_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.isFIFO()).assertInstanceOf('Boolean') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_is_fifo_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsFIFO_0010 - * @tc.name fileio_test_dirent_is_fifo_001 - * @tc.desc Test Dir.isFIFO() interface. - */ - it('fileio_test_dirent_is_fifo_001', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_fifo_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - dirent.isFIFO(-1) - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsFILE_0000 - * @tc.name fileio_test_dirent_is_file_000 - * @tc.desc Test Dir.isFILE() interface. - */ - it('fileio_test_dirent_is_file_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_file_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.isFile()).assertInstanceOf('Boolean') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_is_file_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsFILE_0010 - * @tc.name fileio_test_dirent_is_file_001 - * @tc.desc Test Dir.isFILE() interface. - */ - it('fileio_test_dirent_is_file_001', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_file_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - dirent.isFile(-1) - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsSocket_0000 - * @tc.name fileio_test_dirent_is_socket_000 - * @tc.desc Test Dir.isSocket() interface. - */ - it('fileio_test_dirent_is_socket_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_socket_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.isSocket()).assertInstanceOf('Boolean') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_is_socket_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsSocket_0010 - * @tc.name fileio_test_dirent_is_socket_001 - * @tc.desc Test Dir.isSocket() interface. - */ - it('fileio_test_dirent_is_socket_001', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_socket_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - dirent.isSocket(-1) - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsSymbolicLink_0000 - * @tc.name fileio_test_dirent_is_symbolic_link_000 - * @tc.desc Test Dir.isSymbolicLink() interface. - */ - it('fileio_test_dirent_is_symbolic_link_000', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_symbolic_link_000') + 'd' - let fpath = dpath + '/f1' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - let dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - expect(dirent.isSymbolicLink()).assertInstanceOf('Boolean') - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_dirent_is_symbolic_link_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Dir_IsSymbolicLink_0010 - * @tc.name fileio_test_dirent_is_symbolic_link_001 - * @tc.desc Test Dir.isSymbolicLink() interface. - */ - it('fileio_test_dirent_is_symbolic_link_001', 0, function () { - let dpath = nextFileName('fileio_test_dirent_is_symbolic_link_001') + 'd' - let fpath = dpath + '/f1' - let dd - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - dd = fileio.opendirSync(dpath) - expect(dd !== null).assertTrue() - let dirent = dd.readSync() - expect(dirent !== null).assertTrue() - dirent.isSymbolicLink(-1) - expect(null).assertFail() - } catch (e) { - expect(dd.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) -}) diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStat.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStat.test.js deleted file mode 100755 index a4331db908369f9de8526c4c13218b9d6ec83cfd..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStat.test.js +++ /dev/null @@ -1,749 +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 fileio from '@ohos.fileio' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -import { FILE_CONTENT, prepareFile, nextFileName } from './Common' - -describe('fileIOTestStat', function () { - /** - * @tc.number SUB_DF_FileIO_Stat_FstatSync_0000 - * @tc.name fileio_test_stat_fstat_sync_000 - * @tc.desc Test fileio.fstatSync() interface. - */ - it('fileio_test_stat_fstat_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_fstat_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let fd = fileio.openSync(fpath, 0o2) - expect(fd).assertInstanceOf('Number') - let stat = fileio.fstatSync(fd) - expect(stat !== null).assertTrue() - expect(fileio.closeSync(fd)).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_stat_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_FstatSync_0010 - * @tc.name fileio_test_stat_fstat_sync_001 - * @tc.desc Test fstatSync() interface. - */ - it('fileio_test_stat_fstat_sync_001', 0, function () { - try { - let invalidFD = -1 - fileio.fstatSync(invalidFD) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_StatSync_0000 - * @tc.name fileio_test_stat_stat_sync_000 - * @tc.desc Test Stat.statSync() interface. - */ - it('fileio_test_stat_stat_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_stat_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat !== null).assertTrue() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_stat_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_StatSync_0010 - * @tc.name fileio_test_stat_stat_sync_001 - * @tc.desc Test Stat.statSync() interface. - */ - it('fileio_test_stat_stat_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_stat_sync_001') - - try { - let stat = fileio.statSync(fpath) - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Dev_0000 - * @tc.name fileio_test_stat_dev_000 - * @tc.desc Test Stat.dev() interface. - */ - it('fileio_test_stat_dev_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_dev_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.dev).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_dev_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Ino_0000 - * @tc.name fileio_test_stat_ino_000 - * @tc.desc Test Stat.ino() interface. - */ - it('fileio_test_stat_ino_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_ino_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.ino).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_ino_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Mode_0000 - * @tc.name fileio_test_stat_mode_000 - * @tc.desc Test Stat.mode() interface. - */ - it('fileio_test_stat_mode_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_mode_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.mode).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_mode_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Nlink_0000 - * @tc.name fileio_test_stat_nlink_000 - * @tc.desc Test Stat.nlink() interface. - */ - it('fileio_test_stat_nlink_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_nlink_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.nlink).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_nlink_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Uid_0000 - * @tc.name fileio_test_stat_uid_000 - * @tc.desc Test Stat.uid() interface. - */ - it('fileio_test_stat_uid_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_uid_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.uid).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_uid_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Gid_0000 - * @tc.name fileio_test_stat_gid_000 - * @tc.desc Test Stat.gid() interface. - */ - it('fileio_test_stat_gid_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_gid_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.gid).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_gid_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Rdev_0000 - * @tc.name fileio_test_stat_rdev_000 - * @tc.desc Test Stat.rdev() interface. - */ - it('fileio_test_stat_rdev_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_rdev_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.rdev).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_rdev_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Size_0000 - * @tc.name fileio_test_stat_size_000 - * @tc.desc Test Stat.size() interface. - */ - it('fileio_test_stat_size_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_size_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.size).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_size_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Blocks_0000 - * @tc.name fileio_test_stat_blocks_000 - * @tc.desc Test Stat.blocks() interface. - */ - it('fileio_test_stat_blocks_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_blocks_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.blocks).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_blocks_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Atime_0000 - * @tc.name fileio_test_stat_atime_000 - * @tc.desc Test Stat.atime() interface. - */ - it('fileio_test_stat_atime_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_atime_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.atime).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_atime_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Mtime_0000 - * @tc.name fileio_test_stat_mtime_000 - * @tc.desc Test Stat.mtime() interface. - */ - it('fileio_test_stat_mtime_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_mtime_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.mtime).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_mtime_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_Ctime_0000 - * @tc.name fileio_test_stat_ctime_000 - * @tc.desc Test Stat.ctime() interface. - */ - it('fileio_test_stat_ctime_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_ctime_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.ctime).assertInstanceOf('Number') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_ctime_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsBlockDevice_0000 - * @tc.name fileio_test_stat_is_block_device_000 - * @tc.desc Test Stat.isBlockDevice() interface. - */ - it('fileio_test_stat_is_block_device_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_block_device_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isBlockDevice()).assertInstanceOf('Boolean') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_block_device_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsBlockDevice_0010 - * @tc.name fileio_test_stat_is_block_device_001 - * @tc.desc Test Stat.isBlockDevice() interface. - */ - it('fileio_test_stat_is_block_device_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_block_device_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isBlockDevice()).assertFalse() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_block_device_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsBlockDevice_0020 - * @tc.name fileio_test_stat_is_block_device_002 - * @tc.desc Test Stat.isBlockDevice() interface. - */ - it('fileio_test_stat_is_block_device_002', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_block_device_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isBlockDevice(-1)).assertFalse() - expect(null).assertFail() - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsCharacterDevice_0000 - * @tc.name fileio_test_stat_is_character_device_000 - * @tc.desc Test Stat.isCharacterDevice() interface. - */ - it('fileio_test_stat_is_character_device_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_character_device_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isCharacterDevice()).assertInstanceOf('Boolean') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_character_device_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsCharacterDevice_0010 - * @tc.name fileio_test_stat_is_character_device_001 - * @tc.desc Test Stat.isCharacterDevice() interface. - */ - it('fileio_test_stat_is_character_device_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_character_device_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isCharacterDevice()).assertFalse() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_character_device_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsCharacterDevice_0020 - * @tc.name fileio_test_stat_is_character_device_002 - * @tc.desc Test Stat.isCharacterDevice() interface. - */ - it('fileio_test_stat_is_character_device_002', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_character_device_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isCharacterDevice(-1)).assertFalse() - expect(null).assertFail() - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsDirectory_0000 - * @tc.name fileio_test_stat_is_directory_000 - * @tc.desc Test Stat.isDirectory() interface. - */ - it('fileio_test_stat_is_directory_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_directory_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isDirectory()).assertInstanceOf('Boolean') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_directory_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsDirectory_0010 - * @tc.name fileio_test_stat_is_directory_001 - * @tc.desc Test Stat.isDirectory() interface. - */ - it('fileio_test_stat_is_directory_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_directory_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isDirectory()).assertFalse() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_directory_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsDirectory_0020 - * @tc.name fileio_test_stat_is_directory_002 - * @tc.desc Test Stat.isDirectory() interface. - */ - it('fileio_test_stat_is_directory_002', 0, function () { - let dpath = nextFileName('fileio_test_stat_is_directory_002') + 'd' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - let stat = fileio.statSync(dpath) - expect(stat.isDirectory()).assertTrue() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_directory_002 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsDirectory_0030 - * @tc.name fileio_test_stat_is_directory_003 - * @tc.desc Test Stat.isDirectory() interface. - */ - it('fileio_test_stat_is_directory_003', 0, function () { - let dpath = nextFileName('fileio_test_stat_is_directory_003') + 'd' - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - let stat = fileio.statSync(dpath) - expect(stat.isDirectory(-1)).assertTrue() - expect(null).assertFail() - } catch (e) { - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsFIFO_0000 - * @tc.name fileio_test_stat_is_fifo_000 - * @tc.desc Test Stat.isFIFO() interface. - */ - it('fileio_test_stat_is_fifo_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_fifo_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isFIFO()).assertInstanceOf('Boolean') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_fifo_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsFIFO_0010 - * @tc.name fileio_test_stat_is_fifo_001 - * @tc.desc Test Stat.isFIFO() interface. - */ - it('fileio_test_stat_is_fifo_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_fifo_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isFIFO()).assertFalse() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_fifo_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsFIFO_0020 - * @tc.name fileio_test_stat_is_fifo_002 - * @tc.desc Test Stat.isFIFO() interface. - */ - it('fileio_test_stat_is_fifo_002', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_fifo_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isFIFO(-1)).assertFalse() - expect(null).assertFail() - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsFILE_0000 - * @tc.name fileio_test_stat_is_file_000 - * @tc.desc Test Stat.isFile() interface. - */ - it('fileio_test_stat_is_file_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_file_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertInstanceOf('Boolean') - - try { - let stat = fileio.statSync(fpath) - expect(stat.isFile()).assertInstanceOf('Boolean') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_file_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsFILE_0010 - * @tc.name fileio_test_stat_is_file_001 - * @tc.desc Test Stat.isFile() interface. - */ - it('fileio_test_stat_is_file_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_file_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertInstanceOf('Boolean') - - try { - let stat = fileio.statSync(fpath) - expect(stat.isFile()).assertTrue() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_file_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsFILE_0020 - * @tc.name fileio_test_stat_is_file_002 - * @tc.desc Test Stat.isFile() interface. - */ - it('fileio_test_stat_is_file_002', 0, function () { - let dpath = nextFileName('fileio_test_stat_is_file_002') - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - let stat = fileio.statSync(dpath) - expect(stat.isFile()).assertFalse() - expect(fileio.rmdirSync(dpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_file_002 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsFILE_0030 - * @tc.name fileio_test_stat_is_file_003 - * @tc.desc Test Stat.isFile() interface. - */ - it('fileio_test_stat_is_file_003', 0, function () { - let dpath = nextFileName('fileio_test_stat_is_file_003') - - try { - expect(fileio.mkdirSync(dpath)).assertNull() - let stat = fileio.statSync(dpath) - expect(stat.isFile(-1)).assertFalse() - expect(null).assertFail() - } catch (e) { - expect(fileio.rmdirSync(dpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsSocket_0000 - * @tc.name fileio_test_stat_is_socket_000 - * @tc.desc Test Stat.isSocket() interface. - */ - it('fileio_test_stat_is_socket_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_socket_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isSocket()).assertInstanceOf('Boolean') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_socket_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsSocket_0010 - * @tc.name fileio_test_stat_is_socket_001 - * @tc.desc Test Stat.isSocket() interface. - */ - it('fileio_test_stat_is_socket_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_socket_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isSocket()).assertFalse() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_socket_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsSocket_0020 - * @tc.name fileio_test_stat_is_socket_002 - * @tc.desc Test Stat.isSocket() interface. - */ - it('fileio_test_stat_is_socket_002', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_socket_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isSocket(-1)).assertFalse() - expect(null).assertFail() - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsSymbolicLink_0000 - * @tc.name fileio_test_stat_is_symbolic_link_000 - * @tc.desc Test Stat.isSymbolicLink() interface. - */ - it('fileio_test_stat_is_symbolic_link_000', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_symbolic_link_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isSymbolicLink()).assertInstanceOf('Boolean') - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_symbolic_link_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsSymbolicLink_0010 - * @tc.name fileio_test_stat_is_symbolic_link_001 - * @tc.desc Test Stat.isSymbolicLink() interface. - */ - it('fileio_test_stat_is_symbolic_link_001', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_symbolic_link_001') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isSymbolicLink()).assertFalse() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stat_is_symbolic_link_001 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stat_IsSymbolicLink_0020 - * @tc.name fileio_test_stat_is_symbolic_link_002 - * @tc.desc Test Stat.isSymbolicLink() interface. - */ - it('fileio_test_stat_is_symbolic_link_002', 0, function () { - let fpath = nextFileName('fileio_test_stat_is_symbolic_link_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let stat = fileio.statSync(fpath) - expect(stat.isSymbolicLink(-1)).assertFalse() - expect(null).assertFail() - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) -}) diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStream.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStream.test.js deleted file mode 100755 index 0c7f598e2a1dece71e28259f17cbf827242296ab..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/FileIOStream.test.js +++ /dev/null @@ -1,172 +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 fileio from '@ohos.fileio' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -import { FILE_CONTENT, prepareFile, nextFileName } from './Common' - -describe('fileIOTestStream', function () { - /** - * @tc.number SUB_DF_FileIO_Stream_CreateStreamSync_0000 - * @tc.name fileio_test_stream_create_stream_sync_000 - * @tc.desc Test Stream.createStreamSync() interface. - */ - it('fileio_test_stream_create_stream_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_stream_create_stream_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - var ss = fileio.createStreamSync(fpath, "r+") - expect(ss !== null).assertTrue() - expect(ss.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stream_create_stream_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stream_CreateStreamSync_0010 - * @tc.name fileio_test_stream_create_stream_sync_001 - * @tc.desc Test Stream.createStreamSync() interface. - */ - it('fileio_test_stream_create_stream_sync_001', 0, function () { - let fpath = nextFileName('fileio_test_stream_create_stream_sync_001') - - try { - fileio.createStreamSync(fpath, "r+") - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stream_CreateStreamSync_0020 - * @tc.name fileio_test_stream_create_stream_sync_002 - * @tc.desc Test Stream.createStreamSync() interface. - */ - it('fileio_test_stream_create_stream_sync_002', 0, function () { - let fpath = nextFileName('fileio_test_stream_create_stream_sync_002') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - fileio.createStreamSync(fpath, "ohos") - expect(null).assertFail() - } catch (e) { - expect(fileio.unlinkSync(fpath)).assertNull() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stream_FdopenStreamSync_0000 - * @tc.name fileio_test_stream_fdopen_stream_sync_000 - * @tc.desc Test Stream.fdopenStreamSync() interface. - */ - it('fileio_test_stream_fdopen_stream_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_stream_fdopen_stream_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - var fd = fileio.openSync(fpath, 0o2) - let ss = fileio.fdopenStreamSync(fd, "r+") - expect(ss !== null).assertTrue() - expect(ss.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stream_fdopen_stream_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stream_FdopenStreamSync_0010 - * @tc.name fileio_test_stream_fdopen_stream_sync_001 - * @tc.desc Test Stream.fdopenStreamSync() interface. - */ - it('fileio_test_stream_fdopen_stream_sync_001', 0, function () { - try { - let ss = fileio.fdopenStreamSync(-1, "r+") - expect(null).assertFail() - } catch (e) { - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stream_ReadSync_0000 - * @tc.name fileio_test_stream_read_sync_000 - * @tc.desc Test Stream.readSync() interface. - */ - it('fileio_test_stream_read_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_stream_read_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let ss = fileio.createStreamSync(fpath, "r+") - expect(ss !== null).assertTrue() - let len = ss.readSync(new ArrayBuffer(4096)) - expect(len).assertEqual(FILE_CONTENT.length) - expect(ss.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stream_read_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stream_WriteSync_0000 - * @tc.name fileio_test_stream_write_sync_000 - * @tc.desc Test Stream.writeSync() interface. - */ - it('fileio_test_stream_write_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_stream_write_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let ss = fileio.createStreamSync(fpath, "r+") - expect(ss !== null).assertTrue() - expect(ss.writeSync(FILE_CONTENT)).assertEqual(FILE_CONTENT.length) - expect(ss.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stream_write_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) - - /** - * @tc.number SUB_DF_FileIO_Stream_FlushSync_0000 - * @tc.name fileio_test_stream_flush_sync_000 - * @tc.desc Test Stream.flushSync() interface. - */ - it('fileio_test_stream_flush_sync_000', 0, function () { - let fpath = nextFileName('fileio_test_stream_flush_sync_000') - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue() - - try { - let ss = fileio.createStreamSync(fpath, "r+") - expect(ss !== null).assertTrue() - expect(ss.writeSync(FILE_CONTENT)).assertEqual(FILE_CONTENT.length) - expect(ss.flushSync()).assertNull() - expect(ss.closeSync()).assertNull() - expect(fileio.unlinkSync(fpath)).assertNull() - } catch (e) { - console.log("fileio_test_stream_flush_sync_000 has failed for " + e) - expect(null).assertFail() - } - }) -}) \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/List.test.js b/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/List.test.js deleted file mode 100644 index a0313e7c9a62553512b1cd73364c0a41af37714c..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,20 +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. - */ - -require('./FileIO.test.js') -require('./FileIODir.test.js') -require('./FileIODirent.test.js') -require('./FileIOStat.test.js') -require('./FileIOStream.test.js') \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/resources/base/element/string.json b/distributeddatamgr/distributedfilejstest/project/entry/src/main/resources/base/element/string.json deleted file mode 100644 index e270bb102c245b6f217a8589954021d89cd9059b..0000000000000000000000000000000000000000 --- a/distributeddatamgr/distributedfilejstest/project/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "DistributedFileJSTest" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/distributeddatamgr/distributedfilejstest/project/entry/src/main/resources/base/media/icon.png b/distributeddatamgr/distributedfilejstest/project/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/distributeddatamgr/distributedfilejstest/project/entry/src/main/resources/base/media/icon.png and /dev/null differ