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

!7016 Add xts for mod_securitylabel and mod_statfs

Merge pull request !7016 from futurezhou/master
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -13,8 +13,9 @@
* limitations under the License.
*/
import securityLabel from '@ohos.securityLabel';
import securityLabel from '@ohos.file.securityLabel';
import fileio from '@ohos.fileio';
import fileIO from '@ohos.file.fs';
import featureAbility from '@ohos.ability.featureAbility';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -35,5 +36,6 @@ export {
it,
expect,
securityLabel,
fileio
fileio,
fileIO
};
\ No newline at end of file
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import securitylabel from './securitylabel.test.js'
import security_label from './securitylabel.test.js'
export default function testsuite() {
securitylabel()
security_label()
}
......@@ -14,6 +14,7 @@
*/
import statfs from '@ohos.statfs';
import statvfs from '@ohos.file.statvfs'
export const FILE_CONTENT = 'hello world';
......@@ -32,5 +33,6 @@ export {
afterAll,
it,
expect,
statfs
statfs,
statvfs
};
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -14,6 +14,8 @@
*/
import statfs_test from './statfs.test.js'
import statvfs_test from './statvfs.test.js'
export default function testsuite() {
statfs_test()
statvfs_test()
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect, isIntNum, statvfs} from './Common';
import featureAbility from '@ohos.ability.featureAbility';
export default function statvfs_test() {
describe('statvfs_test', function () {
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0000
* @tc.name statvfs_test_get_free_size_async_000
* @tc.desc Test getFreeSize() 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_async_000', 0, async function (done) {
try {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let number = await statvfs.getFreeSize(data);
console.log("getFreeSize getFilesDir===>" + (number / 1024));
expect(isIntNum(number)).assertTrue();
done();
} catch (e) {
console.log('statvfs_test_get_free_size_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0100
* @tc.name statvfs_test_get_free_size_async_001
* @tc.desc Test getFreeSize() 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_async_001', 0, async function (done) {
try {
statvfs.getFreeSize("/dev", (err, number) => {
if (err) {
console.log('statvfs_test_get_free_size_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
console.log("getFreeSizeNumber dev===>:" + (number / 1024));
expect(isIntNum(number)).assertTrue();
done();
});
} catch (e) {
console.log('statvfs_test_get_free_size_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0200
* @tc.name statvfs_test_get_free_size_async_002
* @tc.desc Test getFreeSize() interfaces, when the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_free_size_async_002', 0, async function (done) {
try {
await statvfs.getFreeSize(1);
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0300
* @tc.name statvfs_test_get_free_size_async_003
* @tc.desc Test getFreeSize() interfaces, when there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_free_size_async_003', 0, async function (done) {
try {
await statvfs.getFreeSize();
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0400
* @tc.name statvfs_test_get_free_size_async_004
* @tc.desc Test getFreeSize() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_free_size_async_004', 0, async function (done) {
try {
await statvfs.getFreeSize("");
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_free_size_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0500
* @tc.name statvfs_test_get_free_size_async_005
* @tc.desc Test getFreeSize() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_free_size_async_005', 0, async function (done) {
try {
statvfs.getFreeSize("", (err) => {
if (err) {
console.log(
'statvfs_test_get_free_size_async_005 error package: {' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
}
});
} catch (e) {
console.log('statvfs_test_get_free_size_async_005 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0000
* @tc.name statvfs_test_get_total_size_async_000
* @tc.desc Test getTotalSize() 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_async_000', 0, async function (done) {
try {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let number = await statvfs.getTotalSize(data);
console.log("getTotalSizeNumber GetFilesDir====>:" + (number / 1024));
expect(isIntNum(number)).assertTrue();
done();
} catch (e) {
console.log('statvfs_test_get_total_size_async_000 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0100
* @tc.name statvfs_test_get_total_size_async_001
* @tc.desc Test getTotalSize() 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_async_001', 0, async function (done) {
try {
statvfs.getTotalSize("/dev", (err, number) => {
if (err) {
console.log('statvfs_test_get_total_size_async_001 error package: ' + JSON.stringify(err));
expect(false).assertTrue();
}
console.log("getTotalSizeNumber dev===>:" + (number / 1024));
expect(isIntNum(number)).assertTrue();
done();
});
} catch (e) {
console.log('statvfs_test_get_total_size_async_001 has failed for ' + e.message + ', code: ' + e.code);
expect(false).assertTrue();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0200
* @tc.name statvfs_test_get_total_size_async_002
* @tc.desc Test getTotalSize() interfaces, when the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_total_size_async_002', 0, async function (done) {
try {
await statvfs.getTotalSize(1);
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_async_002 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0300
* @tc.name statvfs_test_get_total_size_async_003
* @tc.desc Test getTotalSize() interfaces, when there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_total_size_async_003', 0, async function (done) {
try {
await statvfs.getTotalSize();
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_async_003 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900020 && e.message == "Invalid argument").assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0400
* @tc.name statvfs_test_get_total_size_async_004
* @tc.desc Test getTotalSize() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_total_size_async_004', 0, async function (done) {
try {
await statvfs.getTotalSize("");
expect(false).assertTrue();
} catch (e) {
console.log('statvfs_test_get_total_size_async_004 has failed for ' + e.message + ', code: ' + e.code);
expect(e.code == 13900002 && e.message == 'No such file or directory').assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0500
* @tc.name statvfs_test_get_total_size_async_005
* @tc.desc Test getTotalSize() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('statvfs_test_get_total_size_async_005', 0, async function (done) {
try {
statvfs.getTotalSize("", (err) => {
if (err) {
console.log(
'statvfs_test_get_total_size_async_005 error package: {' + err.message + ', code: ' + err.code + '}');
expect(err.code == 13900002 && err.message == 'No such file or directory').assertTrue();
done();
}
});
} catch (e) {
console.log('statvfs_test_get_total_size_async_004 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.
先完成此消息的编辑!
想要评论请 注册