1.测试文件IO界面,误操作可能出现crash,需要按照要求操作

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2023-05-29 10:09:03 +08:00
parent a181164375
commit 9fa12b84ea
1 changed files with 15 additions and 1 deletions

View File

@ -22,7 +22,8 @@ struct basicTestFileIOPage {
@State filePath: string = '查看featureAbility路径';
appFilePath = '';
appCachePath = '';
@State imageFile: string = ''
@State imageHint: string = ''
@State imageFile: string = '文字提醒'
@State imageRes: Resource = $r('app.media.pngSample')
@State imagePixelMap: PixelMap = undefined
@State normalPixelMap: boolean = false;
@ -56,9 +57,14 @@ struct basicTestFileIOPage {
this.appFilePath = data;
})
Text(this.imageHint)
Button('files目录创建Folder1和Folder2 验证statSync mkdirSync')
.margin({ top: 10 })
.onClick(() => {
if(this.appFilePath == '' || this.appFilePath == null){
this.appFilePath = 'appFilePath未取到值,请按顺序从上往下,从左往右依次测试'
return
}
console.log('files目录创建Folder1和Folder2 验证statSync mkdirSync')
FileUtils.getInstance()
.createFolder(this.appFilePath + '/Folder1');
@ -69,6 +75,10 @@ struct basicTestFileIOPage {
.margin({ top: 10 })
.onClick(() => {
console.log('将media资源存入Folder1 验证writeSync mkdirSync createStreamSync')
if(this.appFilePath == '' || this.appFilePath == null){
this.appFilePath = 'appFilePath未取到值,请按顺序从上往下,从左往右依次测试'
return
}
globalThis.ImageKnife.getImageKnifeContext().resourceManager
.getMedia($r('app.media.gifSample').id)
.then(data => {
@ -87,6 +97,10 @@ struct basicTestFileIOPage {
.margin({ top: 10 })
.onClick(() => {
console.log('copy:Folder1至Folder2 验证copyFileSync')
if(this.appFilePath == '' || this.appFilePath == null){
this.appFilePath = 'appFilePath未取到值,请按顺序从上往下,从左往右依次测试'
return
}
let filePath1 = this.appFilePath + '/Folder1/jpgSample.gif';
let filePath2 = this.appFilePath + '/Folder2/jpgSample.gif';
FileUtils.getInstance().createFolder(this.appFilePath + '/Folder1')