提交 11a92737 编写于 作者: W WOSHIMAHAIFENG

修改file测试用例,防止ios测试失败

上级 5a5371a9
......@@ -1137,15 +1137,11 @@ describe('ExtApi-FileManagerTest', () => {
function isAndroid() {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW === 'true') {
it('web', () => {
expect(1).toBe(1)
})
expect(1).toBe(1)
return false
}
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
it('ios', () => {
expect(1).toBe(1)
})
expect(1).toBe(1)
return false
}
return true
......@@ -1247,7 +1243,7 @@ describe('ExtApi-FileManagerTest', () => {
logAble: false,
basePath: basePath
})
await clearDir('')
// await clearDir('')
await page.setData({
logAble: false,
basePath: globalTempPath,
......@@ -1341,7 +1337,7 @@ describe('ExtApi-FileManagerTest', () => {
if (!isAndroid()) {
return
}
console.log('writeTest', 'start')
// await clearDir('')
await page.setData({
logAble: false,
......@@ -1351,13 +1347,13 @@ describe('ExtApi-FileManagerTest', () => {
writeData: '我是一只小小鸟'
})
await createFile()
console.log('writeTest', '1')
let btnWrite = await page.$('#btn-write')
await btnWrite.tap()
await isDone()
let bytesWritten = await getData("bytesWritten")
expect(bytesWritten).toEqual(7)
console.log('writeTest', '2')
//writeSyncTest
await page.setData({
writeFile: 'fd/1.txt',
......@@ -1365,18 +1361,19 @@ describe('ExtApi-FileManagerTest', () => {
writeData: '我是'
})
btnWrite = await page.$('#btn-write')
btnWrite = await page.$('#btn-write-sync')
await btnWrite.tap()
await isDone()
bytesWritten = await getData("bytesWritten")
expect(bytesWritten).toEqual(2)
console.log('writeTest', '3')
//fstatTest
let btnFstat = await page.$('#btn-fstat-file')
await btnFstat.tap()
await isDone()
let fstat = await getData("fstat")
expect(fstat.size > 0).toBe(true)
console.log('writeTest', '4')
//fstatSyncTest
btnFstat = await page.$('#btn-fstat-file-sync')
......@@ -1384,6 +1381,7 @@ describe('ExtApi-FileManagerTest', () => {
await isDone()
fstat = await getData("fstat")
expect(fstat.size > 0).toBe(true)
console.log('writeTest', '5')
//ftruncateFileTest
let btnFTruncateFile = await page.$('#btn-ftruncate-file')
......@@ -1394,15 +1392,57 @@ describe('ExtApi-FileManagerTest', () => {
await page.setData({
ftruncate: '',
})
console.log('writeTest', '6')
//ftruncateFileSyncTest
btnFTruncateFile = await page.$('#btn-ftruncate-file-sync')
await btnFTruncateFile.tap()
await isDone()
ftruncateRet = await getData("ftruncateRet")
expect(fstat).not.toEqual('ftruncate:ok')
console.log('writeTest', '7')
});
//writeTest writeSyncTest
it('ftruncateFileTest', async () => {
if (!isAndroid()) {
return
}
console.log('ftruncateFileTest', 'start')
// await clearDir('')
await page.setData({
logAble: false,
mkdirFile: 'fd',
writeFile: 'fd/1.txt',
readFile: 'fd/1.txt',
writeData: '我是一只小小鸟我是'
})
await createFile()
console.log('ftruncateFileTest', '1')
btnWrite = await page.$('#btn-write-sync')
await btnWrite.tap()
await isDone()
bytesWritten = await getData("bytesWritten")
expect(bytesWritten).toEqual(9)
console.log('ftruncateFileTest', '3')
//ftruncateFileTest
let btnFTruncateFile = await page.$('#btn-ftruncate-file')
await btnFTruncateFile.tap()
await isDone()
let ftruncateRet = await getData("ftruncateRet")
expect(ftruncateRet).toEqual('ftruncate:ok')
await page.setData({
ftruncate: '',
})
console.log('ftruncateFileTest', '6')
//ftruncateFileSyncTest
btnFTruncateFile = await page.$('#btn-ftruncate-file-sync')
await btnFTruncateFile.tap()
await isDone()
ftruncateRet = await getData("ftruncateRet")
expect(ftruncateRet).toEqual('ftruncate:ok')
console.log('ftruncateFileTest', '7')
});
//saveFileTest saveFileSyncTest getSavedFileListTest removeSavedFileTest
it('savefile test',
async () => {
......
......@@ -66,7 +66,7 @@
<button class="btnstyle" type="primary" @tap="closeSyncTest"
id="btn-close-file-sync">通过文件描述符同步关闭文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="writeTest" id="btn-write">通过文件描述符写入文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="writeSyncTest" id="btn-read-file">同步通过文件描述符写入文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="writeSyncTest" id="btn-write-sync">同步通过文件描述符写入文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="fstatTest" id="btn-fstat-file">通过文件描述符获取{{statFile}}的状态信息</button>
<button class="btnstyle" type="primary" @tap="fstatSyncTest"
id="btn-fstat-file-sync">同步通过文件描述符获取{{statFile}}的状态信息</button>
......@@ -135,7 +135,7 @@
fstat: null as Stats | null,
ftruncateRet: '',
readZipFile: 'to.zip',
getSavedFileListRet:'',
getSavedFileListRet: '',
/**
* 待测试的全局环境变量
*/
......@@ -1007,87 +1007,47 @@
closeSyncTest() {
console.log('closeSyncTest')
const fileManager = uni.getFileSystemManager()
fileManager.open({
filePath: `${this.basePath}${this.readFile}`,
flag: "r+",
success: (res : OpenFileSuccessResult) => {
console.log("success", res)
if (res.fd.length <= 0) {
this.done = true
return
}
try {
console.log('closeSync')
fileManager.closeSync({
fd: res.fd
} as CloseSyncOptions)
if (this.logAble) {
this.log += 'closeSyncTest success:' + '\n\n'
}
this.done = true
this.closeFileRet = "close:ok"
} catch (e) {
if (this.logAble) {
this.log += 'closeSyncTest fail:' + JSON.stringify(e) + '\n\n'
}
console.log('fail', e)
this.done = true
}
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.done = true
try {
console.log('closeSync')
fileManager.closeSync({
fd: this.openFileSyncTest()
} as CloseSyncOptions)
if (this.logAble) {
this.log += 'closeSyncTest success:' + '\n\n'
}
} as OpenFileOptions)
this.done = true
this.closeFileRet = "close:ok"
} catch (e) {
if (this.logAble) {
this.log += 'closeSyncTest fail:' + JSON.stringify(e) + '\n\n'
}
console.log('fail', e)
this.done = true
}
},
closeTest() {
const fileManager = uni.getFileSystemManager()
fileManager.open({
filePath: `${this.basePath}${this.readFile}`,
flag: "r+",
success: (res : OpenFileSuccessResult) => {
console.log("success", res)
if (res.fd.length <= 0) {
this.done = true
return
fileManager.close({
fd: this.openFileSyncTest(),
success: (res : FileManagerSuccessResult) => {
if (this.logAble) {
this.log += 'closeTest success:' + JSON.stringify(res) + '\n\n'
}
fileManager.close({
fd: res.fd,
success: (res : FileManagerSuccessResult) => {
if (this.logAble) {
this.log += 'closeTest success:' + JSON.stringify(res) + '\n\n'
}
this.closeFileRet = res.errMsg
console.log("success", res)
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'closeTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (_) => {
this.done = true
}
} as CloseOptions)
this.closeFileRet = res.errMsg
console.log("success", res)
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n'
this.log += 'closeTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (_) => {
this.done = true
}
} as OpenFileOptions)
} as CloseOptions)
},
writeTest() {
const fileManager = uni.getFileSystemManager()
......@@ -1257,7 +1217,7 @@
this.log += 'ftruncateFileSyncTest success:' + '\n\n'
}
this.done = true
this.ftruncateRet = ''
this.ftruncateRet = 'ftruncate:ok'
} catch (e) {
if (this.logAble) {
this.log += 'ftruncateFileSyncTest fail:' + JSON.stringify(e) + '\n\n'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册