提交 9d891885 编写于 作者: Z zhangxingxia

update filemanager xts

Signed-off-by: Nzhangxingxia <zhangxingxia1@huawei.com>
上级 11080a63
......@@ -2,7 +2,7 @@
"description": "Configuration for filemanager Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "2000000",
"test-timeout": "60000",
"package": "ohos.acts.storage.filemanager",
"shell-timeout": "60000"
},
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022 Huawei device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -34,7 +34,7 @@ let VIDEO_ROOT = "";
let FILE_ROOT = "";
let AUDIO_ROOT = "";
let IMAGE_ALBUM = "";
let LOG_ = "FMS_XTS_TEXT: "
let LOG_ = "FMS_XTS_TEXT: ";
describe("filemanager_test", function () {
/**
......@@ -71,11 +71,11 @@ describe("filemanager_test", function () {
console.log(LOG_ + FILE_ROOT)
}
}
done();
} catch (error) {
console.log("filemanager_test_get_root_async_000 has failed for " + error);
expect(null).assertFail();
}
done();
});
/**
......@@ -89,42 +89,67 @@ describe("filemanager_test", function () {
*/
it("filemanager_test_get_root_async_001", 0, async function (done) {
try {
filemanager.getRoot((error, fileInfos) => {
filemanager.getRoot(function(error, fileInfos){
expect(Array.isArray(fileInfos)).assertTrue();
expect(JSON.stringify(fileInfos) == JSON.stringify(ROOTFILE)).assertTrue();
done();
});
} catch (error) {
console.log("filemanager_test_get_root_async_001 has failed for " + error);
expect(null).assertFail();
}
done();
});
/**
* @tc.number SUB_DF_FILEMANAGER_GET_ROOT_0020
* @tc.name filemanager_test_get_root_async_002
* @tc.desc Test getRoot() interfaces, without any parameters, throw an exception.
* @tc.desc Test getRoot() interfaces, the first layer directory album information, callback way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it("filemanager_test_get_root_async_002", 0, async function (done) {
try {
filemanager.getRoot("1")
.then(file => {
console.log("filemanager_test_get_root_async_002 file " + JSON.stringify(file));
expect(null).assertFail();
}).catch(e => {
console.log("filemanager_test_get_root_async_002 e " + e);
})
} catch (error) {
console.log("filemanager_test_get_root_async_002 has failed for " + error);
expect(error.toString().indexOf("Number of argments unmatched") != -1).assertTrue();
}
done();
});
it("filemanager_test_get_root_async_002", 0, async function (done) {
try {
let options = {
dev:{
"name":"local"
}
}
filemanager.getRoot(options,function(error, fileInfos) {
expect(Array.isArray(fileInfos)).assertTrue();
expect(JSON.stringify(fileInfos) == JSON.stringify(ROOTFILE)).assertTrue();
done();
});
} catch (error) {
console.log("filemanager_test_get_root_async_002 has failed for " + error);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEMANAGER_GET_ROOT_0030
* @tc.name filemanager_test_get_root_async_003
* @tc.desc Test getRoot() interfaces, when the parameter type is wrong,throw an exception.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it("filemanager_test_get_root_async_003", 0, async function (done) {
try {
let options = {
dev:{
"name":1
}
}
await filemanager.getRoot(options)
} catch (error) {
console.log("filemanager_test_get_root_async_003 has failed for " + error);
expect(error.message == "GetRoot func get dev para fails").assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEMANAGER_LIST_FILE_0000
* @tc.name filemanager_test_list_file_async_000
......@@ -148,11 +173,11 @@ describe("filemanager_test", function () {
console.log(LOG_ + IMAGE_ALBUM)
}
}
done();
} catch (error) {
console.log("filemanager_test_list_file_async_000 has failed for " + error);
expect(null).assertFail();
}
done();
});
/**
......@@ -169,11 +194,11 @@ describe("filemanager_test", function () {
let path = IMAGE_ALBUM;
let fileInfos = await filemanager.listFile(path, "image");
expect(Array.isArray(fileInfos)).assertTrue();
done();
} catch (error) {
console.log("filemanager_test_list_file_async_001 has failed for " + error);
expect(null).assertFail();
}
done();
});
/**
......@@ -188,20 +213,20 @@ describe("filemanager_test", function () {
it("filemanager_test_list_file_async_002", 0, async function (done) {
try {
let path = FILE_ROOT;
filemanager.listFile(path, "file", (error,fileInfos)=>{
filemanager.listFile(path, "file", function(error,fileInfos){
expect(Array.isArray(fileInfos)).assertTrue();
done();
});
} catch (error) {
console.log("filemanager_test_list_file_async_002 has failed for " + error);
expect(null).assertFail();
}
done();
});
/**
* @tc.number SUB_DF_FILEMANAGER_LIST_FILE_0030
* @tc.name filemanager_test_list_file_async_003
* @tc.desc Test listFile() interfaces, when the type parameter to an empty string, throw an exception.
* @tc.desc Test listFile() interfaces, When the number of query files is two,return path of files information accordingly and The number of files is two.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
......@@ -210,31 +235,145 @@ describe("filemanager_test", function () {
it("filemanager_test_list_file_async_003", 0, async function (done) {
try {
let path = FILE_ROOT;
await filemanager.listFile(path, " ");
let options = {
dev: {
"name":"local",
},
offset:0,
count:2
};
filemanager.listFile(path, "file", options, function(error,fileInfos){
expect(Array.isArray(fileInfos)).assertTrue();
expect(fileInfos.length == 2).assertTrue();
done();
});
} catch (error) {
console.log("filemanager_test_list_file_async_003 has failed for " + error);
expect(error.message == "Not a directory").assertTrue();
expect(null).assertFail();
}
done();
});
/**
* @tc.number SUB_DF_FILEMANAGER_LIST_FILE_0040
* @tc.name filemanager_test_list_file_async_004
* @tc.desc Test listFile() interfaces, when the path parameter to an empty string, throw an exception..
* @tc.desc Test listFile() interfaces, When the number of offset files is two, The number of returned files is the total number of files minus two.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it("filemanager_test_list_file_async_004", 0, async function (done) {
it("filemanager_test_list_file_async_004", 0, async function (done) {
try {
await filemanager.listFile(" ", "file");
let path = FILE_ROOT;
let options = {
dev: {
"name":"local",
},
offset:2
};
filemanager.listFile(path, "file", options, function(error,fileInfos){
expect(Array.isArray(fileInfos)).assertTrue();
done();
});
} catch (error) {
console.log("filemanager_test_list_file_async_004 has failed for " + error);
expect(error.message == "No such file or directory").assertTrue();
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEMANAGER_LIST_FILE_0050
* @tc.name filemanager_test_list_file_async_005
* @tc.desc Test listFile() interfaces, when the number of query files is two, return path of files information accordingly.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it("filemanager_test_list_file_async_005", 0, async function (done) {
try {
let path = FILE_ROOT;
let options = {
dev: {
"name":"local",
},
count:2
};
filemanager.listFile(path, "file", options, function(error,fileInfos){
expect(Array.isArray(fileInfos)).assertTrue();
expect(fileInfos.length == 2).assertTrue();
done();
});
} catch (error) {
console.log("filemanager_test_list_file_async_005 has failed for " + error);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEMANAGER_LIST_FILE_0060
* @tc.name filemanager_test_list_file_async_006
* @tc.desc Test listFile() interfaces, when the dev parameter does not exist, return path of files information accordingly.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it("filemanager_test_list_file_async_006", 0, async function (done) {
try {
let path = FILE_ROOT;
let options = {
offset:1,
count:2
};
filemanager.listFile(path, "file", options, function(error,fileInfos){
expect(Array.isArray(fileInfos)).assertTrue();
expect(fileInfos.length == 2).assertTrue();
done();
});
} catch (error) {
console.log("filemanager_test_list_file_async_006 has failed for " + error);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEMANAGER_LIST_FILE_0070
* @tc.name filemanager_test_list_file_async_007
* @tc.desc Test listFile() interfaces, when the type parameter to an empty string, throw an exception.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it("filemanager_test_list_file_async_007", 0, async function (done) {
try {
let path = FILE_ROOT;
await filemanager.listFile(path, " ");
} catch (error) {
console.log("filemanager_test_list_file_async_007 has failed for " + error);
expect(error.message == "Not a directory").assertTrue();
done();
}
});
/**
* @tc.number SUB_DF_FILEMANAGER_LIST_FILE_0080
* @tc.name filemanager_test_list_file_async_008
* @tc.desc Test listFile() interfaces, when there are no parameters, throw an exception.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it("filemanager_test_list_file_async_008", 0, async function (done) {
try {
await filemanager.listFile();
} catch (error) {
console.log("filemanager_test_list_file_async_008 has failed for " + error);
expect(error.message == "Number of argments unmatched").assertTrue();
done();
}
done();
});
/**
......@@ -254,11 +393,11 @@ describe("filemanager_test", function () {
console.log(LOG_ + name + " " + path)
console.log(LOG_ + uri)
expect(uri != undefined).assertTrue();
done();
} catch (error) {
console.log("filemanager_test_createfile_async_000 has failed for " + error);
expect(null).assertFail();
}
done();
});
/**
......@@ -273,11 +412,11 @@ describe("filemanager_test", function () {
it("filemanager_test_createfile_async_001", 0, async function (done) {
let name = "create00" + new Date().getTime() + ".txt";
let path = IMAGE_ROOT;
filemanager.createFile(path, name, (err, uri) => {
filemanager.createFile(path, name, function(err, uri) {
expect(uri != undefined).assertTrue();
console.log(LOG_ + uri)
done();
});
done();
});
/**
......@@ -294,17 +433,17 @@ describe("filemanager_test", function () {
let name = "1.jpg";
let path = IMAGE_ROOT;
filemanager.createFile(path, name)
.then(uri => {
.then(function(uri){
console.log("filemanager_test_createfile_async_002 uri " + uri);
expect(null).assertFail();
}).catch(e => {
}).catch(function(e) {
console.log("filemanager_test_createfile_async_002 e " + e);
expect(e.message == "Operation not permitted").assertTrue();
done();
})
} catch (error) {
console.log("filemanager_test_createfile_async_002 for " + error);
}
done();
});
/**
......@@ -320,17 +459,17 @@ describe("filemanager_test", function () {
try {
let name = "filemanager_test_createfile_async_003";
filemanager.createFile("123", name)
.then(uri => {
.then(function(uri) {
console.log("filemanager_test_createfile_async_003 uri " + uri);
expect(null).assertFail();
}).catch(error => {
}).catch(function(error) {
console.log("filemanager_test_createfile_async_003 e " + error);
expect(error.message == "No such file or directory").assertTrue();
done();
})
} catch (error) {
console.log("filemanager_test_createfile_async_003 has failed for " + error);
}
done();
});
/**
......@@ -345,17 +484,17 @@ describe("filemanager_test", function () {
it("filemanager_test_createfile_async_004", 0, async function (done) {
try {
filemanager.createFile()
.then(uri => {
.then(function(uri) {
console.log("filemanager_test_createfile_async_004 uri " + uri);
expect(null).assertFail();
}).catch(e => {
}).catch(function(e) {
console.log("filemanager_test_createfile_async_004 e " + e);
})
} catch (error) {
console.log("filemanager_test_createfile_async_004 has failed for " + error);
console.log("filemanager_test_createfile_async_004 has failed for1 " + error);
expect(error.toString().indexOf("Number of arguments unmatched") !=-1).assertTrue();
done();
}
done();
});
/**
......@@ -369,18 +508,17 @@ describe("filemanager_test", function () {
*/
it("filemanager_test_createfile_async_005", 0, async function (done) {
try {
filemanager.createFile("", "", "")
.then(uri => {
console.log("filemanager_test_createfile_async_005 uri " + uri);
expect(null).assertFail();
}).catch(error => {
console.log("filemanager_test_createfile_async_005 e " + error);
expect(error.message == "No such file or directory").assertTrue();
filemanager.createFile("", "", "").then(function(uri) {
console.log("filemanager_test_createfile_async_005 uri " + uri);
expect(null).assertFail();
}).catch(function(error) {
console.log("filemanager_test_createfile_async_005 e " + error);
expect(error.message == "No such file or directory").assertTrue();
done();
})
} catch (error) {
console.log("filemanager_test_createfile_async_005 has failed for " + error);
}
done();
});
/**
......@@ -395,18 +533,18 @@ describe("filemanager_test", function () {
it("filemanager_test_createfile_async_006", 0, async function (done) {
try {
let name = "filemanager_test_createfile_async_006";
filemanager.createFile("internal://cache%d%sfile", name)
.then(uri => {
console.log("filemanager_test_createfile_async_006 uri " + uri);
expect(null).assertFail();
}).catch(error => {
console.log("filemanager_test_createfile_async_006 e " + error);
expect(error.message == "No such file or directory").assertTrue();
})
filemanager.createFile("internal://cache%d%sfile", name)
.then(function(uri) {
console.log("filemanager_test_createfile_async_006 uri " + uri);
expect(null).assertFail();
}).catch(function(error) {
console.log("filemanager_test_createfile_async_006 e " + error);
expect(error.message == "No such file or directory").assertTrue();
done();
})
} catch (error) {
console.log("filemanager_test_createfile_async_006 has failed for " + error);
}
done();
});
/**
......@@ -421,17 +559,17 @@ describe("filemanager_test", function () {
it("filemanager_test_createfile_async_007", 0, async function (done) {
try {
filemanager.createFile("internal://cache/@#$&^", "filemanager_test_createfile_async_007")
.then(uri => {
.then(function(uri) {
console.log("filemanager_test_createfile_async_007 uri " + uri);
expect(null).assertFail();
}).catch(error => {
}).catch(function(error) {
console.log("filemanager_test_createfile_async_007 e " + error);
expect(error.message == "No such file or directory").assertTrue();
done();
})
} catch (error) {
console.log("filemanager_test_createfile_async_007 has failed for " + error);
}
done();
});
/**
......@@ -447,16 +585,16 @@ describe("filemanager_test", function () {
let name = "filemanager_test_createfile_async_008";
try {
filemanager.createFile(name)
.then(uri => {
.then(function(uri) {
console.log("filemanager_test_createfile_async_008 uri " + uri);
expect(null).assertFail();
}).catch(e => {
}).catch(function(e) {
console.log("filemanager_test_createfile_async_008 e " + e);
})
} catch (error) {
console.log("filemanager_test_createfile_async_008 has failed for " + error);
expect(error.toString().indexOf("Number of arguments unmatched") !=-1).assertTrue();
done();
}
done();
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册