提交 c724790e 编写于 作者: W WOSHIMAHAIFENG

添加file测试用例

上级 716fcaa8
......@@ -937,7 +937,7 @@ describe('ExtApi-FileManagerTest', () => {
});
it('appendFileTest', async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
......@@ -994,7 +994,7 @@ describe('ExtApi-FileManagerTest', () => {
//renameFileSync copyFileSyncTest appendFileSyncTest truncateFileTest truncateFileSyncTest
it('sync test',
async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
......@@ -1149,50 +1149,10 @@ describe('ExtApi-FileManagerTest', () => {
}
return true
}
//saveFileTest saveFileSyncTest getSavedFileListTest removeSavedFileTest
it('savefile test',
async () => {
if(!isAndroid()){
return
}
let globalTempPath = await getData('globalTempPath')
let basePath = await getData('basePath')
await page.setData({
basePath: basePath
})
await clearDir('')
await page.setData({
basePath: globalTempPath,
temFile: 'save/1.txt',
mkdirFile: 'save',
writeFile: 'save/1.txt',
accessFile: '1.txt'
})
await createFile()
await page.setData({
basePath: basePath,
temFile: 'save/1.txt',
})
let btnSaveFile = await page.$('#btn-save-file')
await btnSaveFile.tap()
await isDone()
let saveFileRet = await getData("saveFileRet")
expect(saveFileRet).not.toBe('');
await page.setData({
saveFileRet: ''
})
await clearDir('')
});
it('saveFileSyncTest',
async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
......@@ -1200,10 +1160,12 @@ describe('ExtApi-FileManagerTest', () => {
let globalTempPath = await getData('globalTempPath')
let basePath = await getData('basePath')
await page.setData({
logAble: false,
basePath: basePath
})
await clearDir('')
await page.setData({
logAble: false,
basePath: globalTempPath,
temFile: 'save/2.txt',
mkdirFile: 'save',
......@@ -1217,32 +1179,21 @@ describe('ExtApi-FileManagerTest', () => {
})
btnSaveFile = await page.$('#btn-save-file-sync')
await btnSaveFile.tap()
await isDone()
let btnRemoveSavedFileRet = await page.$('#btn-remove-saved-file')
await btnRemoveSavedFileRet.tap()
let removeSavedFileRet = await getData("removeSavedFileRet")
expect(removeSavedFileRet).toEqual('removeSavedFile:ok')
await isDone()
await page.setData({
removeSavedFileRet: ''
})
let btnSavedFileList = await page.$('#btn-getsaved-filelist')
await btnSavedFileList.tap()
await isDone()
let fileListSuccess = await getData("fileListSuccess")
expect(fileListSuccess.length > 0).toEqual(true)
await clearDir('')
});
it('getSavedFileListTest',
async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
......@@ -1250,10 +1201,12 @@ describe('ExtApi-FileManagerTest', () => {
let globalTempPath = await getData('globalTempPath')
let basePath = await getData('basePath')
await page.setData({
logAble: false,
basePath: basePath
})
await clearDir('')
await page.setData({
logAble: false,
basePath: globalTempPath,
temFile: 'save/2.txt',
mkdirFile: 'save',
......@@ -1267,7 +1220,6 @@ describe('ExtApi-FileManagerTest', () => {
})
btnSaveFile = await page.$('#btn-save-file-sync')
await btnSaveFile.tap()
await isDone()
let btnSavedFileList = await page.$('#btn-getsaved-filelist')
await btnSavedFileList.tap()
......@@ -1275,14 +1227,12 @@ describe('ExtApi-FileManagerTest', () => {
let fileListSuccess = await getData("fileListSuccess")
expect(fileListSuccess.length > 0).toEqual(true)
await clearDir('')
});
it('removeSavedFileTest',
async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
......@@ -1290,10 +1240,12 @@ describe('ExtApi-FileManagerTest', () => {
let globalTempPath = await getData('globalTempPath')
let basePath = await getData('basePath')
await page.setData({
logAble: false,
basePath: basePath
})
await clearDir('')
await page.setData({
logAble: false,
basePath: globalTempPath,
temFile: 'save/2.txt',
mkdirFile: 'save',
......@@ -1318,13 +1270,14 @@ describe('ExtApi-FileManagerTest', () => {
//openFiletest openFileSynctest closeTest closeTestSync writeTest writeSyncTest
it('openFiletest', async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
await clearDir('')
await page.setData({
logAble: false,
mkdirFile: 'fd',
writeFile: 'fd/1.txt',
readFile: 'fd/1.txt'
......@@ -1349,13 +1302,14 @@ describe('ExtApi-FileManagerTest', () => {
});
// closeTest closeTestSync
it('closeTest', async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
await clearDir('')
await page.setData({
logAble: false,
mkdirFile: 'fd',
writeFile: 'fd/1.txt',
readFile: 'fd/1.txt'
......@@ -1380,12 +1334,13 @@ describe('ExtApi-FileManagerTest', () => {
});
//writeTest writeSyncTest
it('writeTest', async () => {
if(!isAndroid()){
if (!isAndroid()) {
return
}
await clearDir('')
await page.setData({
logAble: false,
mkdirFile: 'fd',
writeFile: 'fd/1.txt',
readFile: 'fd/1.txt',
......@@ -1443,4 +1398,46 @@ describe('ExtApi-FileManagerTest', () => {
expect(fstat).not.toEqual('ftruncate:ok')
});
//saveFileTest saveFileSyncTest getSavedFileListTest removeSavedFileTest
it('savefile test',
async () => {
if (!isAndroid()) {
return
}
let globalTempPath = await getData('globalTempPath')
let basePath = await getData('basePath')
await page.setData({
logAble: false,
basePath: basePath
})
await clearDir('')
await page.setData({
basePath: globalTempPath,
temFile: 'save/1.txt',
mkdirFile: 'save',
writeFile: 'save/1.txt',
accessFile: '1.txt'
})
await createFile()
await page.setData({
basePath: basePath,
temFile: 'save/1.txt',
})
let btnSaveFile = await page.$('#btn-save-file')
await btnSaveFile.tap()
await isDone()
let saveFileRet = await getData("saveFileRet")
expect(saveFileRet).not.toBe('');
await page.setData({
saveFileRet: ''
})
// await clearDir('')
});
});
......@@ -718,7 +718,6 @@
},
saveFileTest: function (_ : any) {
const fileManager = uni.getFileSystemManager()
console.log('=====' + uni.env.USER_DATA_PATH)
fileManager.saveFile({
tempFilePath: `${this.globalTempPath}${this.temFile}`,
// filePath:`${this.basePath}local/`,
......@@ -728,13 +727,15 @@
}
console.log('success', res)
this.saveFileRet = res.savedFilePath
this.done = true
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'saveFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('saveFileTest fail', res)
this.lastFailError = res
this.done = true
},
complete: (_) => {
this.done = true
......@@ -752,7 +753,7 @@
//todo 后面打开
// this.saveFileRet=res
} catch (e) {
console.log(e)
console.log('saveFileSyncTest:'+e)
this.done = true
}
},
......@@ -788,14 +789,14 @@
if (this.logAble) {
this.log += 'getSavedFileListTest success:' + JSON.stringify(res) + '\n\n'
}
console.log("success", res)
console.log("getSavedFileListTest success", res)
this.fileListSuccess = res.fileList
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'getSavedFileListTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('getSavedFileListTest fail', res)
this.lastFailError = res
},
complete: (res : any) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册