未验证 提交 4a8a85b0 编写于 作者: O openharmony_ci 提交者: Gitee

!9761 Add XTS for the properties of File object which named name and path.

Merge pull request !9761 from 冯俊青/fileObject
......@@ -21,7 +21,6 @@ import fileIOCreateRandomAccessFile from './members/createRandomAccessFile.test.
import fileIOCreateStream from './members/createStream.test.js'
import fileIOFdatasync from './members/fdatasync.test.js'
import fileIOFdOpenStream from './members/fdopenStream.test.js'
import fileIOFileLock from './members/fileLock.test.js'
import fileIOFsync from './members/fsync.test.js'
import fileIOHash from './members/hash.test.js'
import fileIOListfile from './members/listFile.test.js'
......@@ -40,6 +39,8 @@ import fileIOReadtext from './members/readtext.test.js'
import fileIORename from './members/rename.test.js'
import fileIORmdir from './members/rmdir.test'
import fileIOStat from './members/stat.test.js'
import fileIOFileLock from './class_file/fileLock.test.js'
import fileIOFileProperties from './class_file/file.test.js'
import fileIOStreamClose from './class_stream/close.test.js'
import fileIOStreamFlush from './class_stream/flush.test.js'
import fileIOStreamRead from './class_stream/read.test.js'
......@@ -60,6 +61,7 @@ export default function testsuite() {
fileIOFdatasync()
fileIOFdOpenStream()
fileIOFileLock()
fileIOFileProperties()
fileIOFsync()
fileIOHash()
fileIOListfile()
......
/*
* Copyright (C) 2023 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 featureAbility from '@ohos.ability.featureAbility';
import {
fileIO, FILE_CONTENT, prepareFile, isIntNum, describe, it, expect,
} from '../Common';
export default function fileIOFileProperties() {
describe('fileIO_file_properties', function () {
/**
* @tc.number SUB_DF_FILEIO_FILE_0000
* @tc.name fileIO_test_open_file_000
* @tc.desc Test the properties of the File object.
* The File object is obtained through the open interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_open_file_000', 0, async function () {
let filesDir = await featureAbility.getContext().getFilesDir();
let fpath = filesDir + '/fileIO_test_open_file_000';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
expect(isIntNum(file.fd)).assertTrue();
expect(file.path === fpath).assertTrue();
expect(file.name === 'fileIO_test_open_file_000').assertTrue();
fileIO.closeSync(file);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_open_file_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_FILE_0100
* @tc.name fileIO_test_dup_file_001
* @tc.desc Test the properties of the File object.
* The File object is obtained through the dup interface.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileIO_test_dup_file_001', 0, async function () {
let filesDir = await featureAbility.getContext().getFilesDir();
let fpath = filesDir + '/fileIO_test_dup_file_001';
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let file = fileIO.openSync(fpath, fileIO.OpenMode.READ_ONLY);
let newFile = fileIO.dup(file.fd);
expect(isIntNum(newFile.fd)).assertTrue();
expect(newFile.path == fpath).assertTrue();
expect(file.name === 'fileIO_test_dup_file_001').assertTrue();
fileIO.closeSync(file);
fileIO.closeSync(newFile);
fileIO.unlinkSync(fpath);
} catch (e) {
console.log('fileIO_test_dup_file_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册