未验证 提交 3f3b45c9 编写于 作者: O openharmony_ci 提交者: Gitee

!9868 Supplemental XTS testcases for synchronous interfaces.

Merge pull request !9868 from 冯俊青/copyDirSync
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License'); * Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -19,6 +19,204 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -19,6 +19,204 @@ import featureAbility from '@ohos.ability.featureAbility';
export default function statvfs_test() { export default function statvfs_test() {
describe('statvfs_test', function () { describe('statvfs_test', function () {
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0000
* @tc.name statvfs_test_get_free_size_sync_000
* @tc.desc Test getFreeSizeSync() interfaces, when the path is a sandbox path, promise way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_free_size_sync_000', 0, async function () {
try {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let number = statvfs.getFreeSizeSync(data);
console.log("getFreeSize getFilesDir===>" + (number / 1024));
expect(isIntNum(number)).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0100
* @tc.name statvfs_test_get_free_size_sync_001
* @tc.desc Test getFreeSizeSync() interfaces, when the path is dev, callback way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_free_size_sync_001', 0, async function () {
try {
let number = statvfs.getFreeSizeSync("/dev");
console.log("getFreeSizeNumber dev===>:" + (number / 1024));
expect(isIntNum(number)).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0200
* @tc.name statvfs_test_get_free_size_sync_002
* @tc.desc Test getFreeSizeSync() interfaces, when the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('statvfs_test_get_free_size_sync_002', 3, async function () {
try {
statvfs.getFreeSizeSync(1);
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0300
* @tc.name statvfs_test_get_free_size_sync_003
* @tc.desc Test getFreeSizeSync() interfaces, when there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('statvfs_test_get_free_size_sync_003', 3, async function () {
try {
statvfs.getFreeSizeSync();
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0500
* @tc.name statvfs_test_get_free_size_sync_005
* @tc.desc Test getFreeSizeSync() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('statvfs_test_get_free_size_sync_005', 3, async function () {
try {
statvfs.getFreeSizeSync("");
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_sync_005 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0000
* @tc.name statvfs_test_get_total_size_sync_000
* @tc.desc Test getTotalSizeSync() interfaces, when the path is a sandbox path, promise way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_total_size_sync_000', 0, async function () {
try {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let number = statvfs.getTotalSizeSync(data);
console.log("getTotalSizeNumber GetFilesDir====>:" + (number / 1024));
expect(isIntNum(number)).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_sync_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0100
* @tc.name statvfs_test_get_total_size_sync_001
* @tc.desc Test getTotalSizeSync() interfaces, when the path is dev, callback way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_total_size_sync_001', 0, async function () {
try {
let number = statvfs.getTotalSizeSync("/dev");
console.log("getTotalSizeNumber dev===>:" + (number / 1024));
expect(isIntNum(number)).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_sync_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0200
* @tc.name statvfs_test_get_total_size_sync_002
* @tc.desc Test getTotalSizeSync() interfaces, when the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('statvfs_test_get_total_size_sync_002', 3, async function () {
try {
statvfs.getTotalSizeSync(1);
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_sync_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0300
* @tc.name statvfs_test_get_total_size_sync_003
* @tc.desc Test getTotalSizeSync() interfaces, when there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('statvfs_test_get_total_size_sync_003', 3, async function () {
try {
statvfs.getTotalSizeSync();
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_sync_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0400
* @tc.name statvfs_test_get_total_size_sync_004
* @tc.desc Test getTotalSizeSync() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it('statvfs_test_get_total_size_sync_004', 3, async function () {
try {
statvfs.getTotalSizeSync("");
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_sync_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
}
});
/** /**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0000 * @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0000
* @tc.name statvfs_test_get_free_size_async_000 * @tc.name statvfs_test_get_free_size_async_000
...@@ -203,7 +401,7 @@ describe('statvfs_test', function () { ...@@ -203,7 +401,7 @@ describe('statvfs_test', function () {
expect(false).assertTrue(); expect(false).assertTrue();
} }
}); });
/** /**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0200 * @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0200
* @tc.name statvfs_test_get_total_size_async_002 * @tc.name statvfs_test_get_total_size_async_002
...@@ -224,7 +422,7 @@ describe('statvfs_test', function () { ...@@ -224,7 +422,7 @@ describe('statvfs_test', function () {
done(); done();
} }
}); });
/** /**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0300 * @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0300
* @tc.name statvfs_test_get_total_size_async_003 * @tc.name statvfs_test_get_total_size_async_003
...@@ -245,7 +443,7 @@ describe('statvfs_test', function () { ...@@ -245,7 +443,7 @@ describe('statvfs_test', function () {
done(); done();
} }
}); });
/** /**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0400 * @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0400
* @tc.name statvfs_test_get_total_size_async_004 * @tc.name statvfs_test_get_total_size_async_004
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册