diff --git a/validator/acts_validator/signature/openharmony_sx.p7b b/validator/acts_validator/signature/openharmony_sx.p7b index 8abb4304720461f4c706e0b3e2dd8d230c187d88..2deeb5e58386441796942f30d72e0379895bb626 100644 Binary files a/validator/acts_validator/signature/openharmony_sx.p7b and b/validator/acts_validator/signature/openharmony_sx.p7b differ diff --git a/validator/acts_validator/src/main/ets/MainAbility/MainAbility.ts b/validator/acts_validator/src/main/ets/MainAbility/MainAbility.ts index d9d71b0baf86d043e39f485fcaa4017cab3de9c3..9280def8c712b01e1f359852ad867d35568c12b1 100644 --- a/validator/acts_validator/src/main/ets/MainAbility/MainAbility.ts +++ b/validator/acts_validator/src/main/ets/MainAbility/MainAbility.ts @@ -18,7 +18,7 @@ export default class MainAbility extends Ability { console.log("[Demo] MainAbility onWindowStageCreate") let AtManager = abilityAccessCtrl.createAtManager(); AtManager.requestPermissionsFromUser(this.context,["ohos.permission.READ_MEDIA","ohos.permission.WRITE_MEDIA", - "ohos.permission.CAPTURE_SCREEN","ohos.permission.INTERNET"]).then(() => {}) + "ohos.permission.CAPTURE_SCREEN","ohos.permission.INTERNET","ohos.permission.CAMERA"]).then(() => {}) windowStage.loadContent("pages/index", (err, data) => { if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/ArkUI_index.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/ArkUI_index.ets index 71fcaf0adb964431b91ce5c9352962825ac37464..6e2e40b2aad45de5e556126d8f476a80c481077d 100644 --- a/validator/acts_validator/src/main/ets/pages/ArkUI/ArkUI_index.ets +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/ArkUI_index.ets @@ -18,24 +18,27 @@ import fileio from '@ohos.fileio'; import xml from '@ohos.xml'; import fileIO from '@ohos.fileio'; import util from '@ohos.util'; +import data_preferences from '@ohos.data.preferences'; const TAG = 'ParseXML'; let path = globalThis.dir; -let path1; -path1 = path + '/ArkUI'; - +let path1 = path + '/ArkUI'; +let VarColor = []; +let ColorBackPath = path + '/ArkUIColorBack.txt'; +let txtPath = path1 + 'ArkUIReport.txt'; +let xmlPath =path1 + 'ArkUITest.xml'; @Entry @Component struct IndexPage { - @State BackColor: string = '#ff808080'; @State ClearAll : boolean = false; private current : number = undefined; @State count : number = 0; @State result : string = ''; + @State TEST : number = 0; private TestCaseList = [ - {title:'Scroll List',uri:'pages/ArkUI/ScrollListTest'}, + {title:'ScrollingList',uri:'pages/ArkUI/ScrollListTest'}, {title:'TouchMove',uri:'pages/ArkUI/TouchMoveTest'}, {title:'PinchGesture',uri:'pages/ArkUI/PinchGestureTest'}, {title:'RotationGesture',uri:'pages/ArkUI/RotationGestureTest'}, @@ -58,30 +61,93 @@ struct IndexPage { {title:'CanvasShadowColor',uri:'pages/ArkUI/CanvasShadowColor'}, {title:'CanvasShadowOffsetX',uri:'pages/ArkUI/CanvasShadowOffsetX'}, {title:'CanvasShadowOffsetY',uri:'pages/ArkUI/CanvasShadowOffsetY'}, - {title:'CanvasImageSmoothingEnabled',uri:'pages/ArkUI/CanvasImageSmoothingEnabled'}, ] - @State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080', - '#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080', - '#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080'] - onPageShow(){ + @State ColorObject : string[] = VarColor; + async onPageShow(){ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('ArkUI', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'ArkUI'. Data: " + data); + }); + + if(Test != 1) { + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + fileio.closeSync(fd); + } + promise = preferences.put('ArkUI', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'ArkUI'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + this.TEST = Test; + + let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664); + let buff = new ArrayBuffer(40960); + fileio.readSync(opt,buff); + let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff)); + let TestList = ColorBack.split(';'); + for (let i = 0; i < Math.floor(TestList.length / 2); i++) { + VarColor[i] = TestList[i*2+1]; + } + fileio.closeSync(opt); + if (this.count === 1){ this.result = router.getParams()['result']; let titles = router.getParams()['title']; let name1 = '刚刚点进了哪个用例:'+ titles; let results = this.result; + let WriteTitle = (titles).toString(); + let number = WriteTitle.length + 11; + let Index = ColorBack.indexOf(WriteTitle); + if (this.result === 'Pass'){ this.ColorObject[this.current] = '#ff008000'; + let Log = (titles+';'+'#ff008000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); filewrite(name1,results,titles) } else if (this.result === 'Fail'){ this.ColorObject[this.current] = '#ffff0000'; + let Log = (titles+';'+'#ffff0000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); filewrite(name1,results,titles); } else if (this.result === 'None'){ this.ColorObject[this.current] = this.ColorObject[this.current]; } } - } build(){ Column(){ @@ -164,8 +230,7 @@ struct IndexPage { ListItem(){ Row(){ Text(item.title).fontSize(16).fontColor(Color.Black) - Text(this.BackColor.toString()).visibility(Visibility.None) - }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index]) + }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) .onClick(( )=>{ this.count = 1; this.ClearAll=false; @@ -182,6 +247,11 @@ struct IndexPage { ClearText(){ fileio.rmdirSync(path1); fileio.mkdirSync(path1); + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } } ReadTextParseXml(){ let ReportPath = path1 + '/ArkUIReport.txt'; @@ -252,7 +322,6 @@ struct IndexPage { let that = new util.TextDecoder('utf-8'); let array = new Uint8Array(arrayBuffer); let serializerStr = that.decode(array); - let xmlPath = path1 + "/ArkUITest.xml"; console.info(xmlPath); try{ console.error(TAG,"write xmlPath =" +xmlPath); @@ -268,8 +337,7 @@ struct IndexPage { } } function filewrite(name1,results,titles){ - let txtpath = path1 + '/ArkUIReport.txt'; - let fd = fileio.openSync(txtpath, 0o100 | 0o2002, 0o664); + let fd = fileio.openSync(txtPath, 0o100 | 0o2002, 0o664); let buf = new ArrayBuffer(4096); let RD = fileio.readSync(fd,buf); console.info("RRRRRRRRRRd"+RD); @@ -283,13 +351,13 @@ function filewrite(name1,results,titles){ } else if (Index != -1){ let key = report.substring(Index,Index+number); - let FD = fileio.openSync(txtpath, 0o102, 0o666); + let FD = fileio.openSync(txtPath, 0o102, 0o666); report = report.replace(key,Log); let buffer = new ArrayBuffer(4096); let rd = fileio.readSync(FD,buffer); let Report = report.substring(0,rd); fileio.closeSync(FD); - let Fd = fileio.openSync(txtpath, 0o102, 0o666); + let Fd = fileio.openSync(txtPath, 0o102, 0o666); fileio.writeSync(Fd,Report); } } \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasFont.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasFont.ets index 1315e4b6a2b6ba0d59c66778723974793ffed7a4..9e27e60f9788d731fe04690d2d3ce91f779bc1b8 100644 --- a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasFont.ets +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasFont.ets @@ -20,7 +20,7 @@ struct SetCircle { private settings: RenderingContextSettings = new RenderingContextSettings(true); private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); @State FillColor: string = '#FF000000'; - @State name: string = 'CanvasFillStyle'; + @State name: string = 'CanvasFont'; @State StepTips: string = '操作步骤:点击不同的字体控件'+'\n'+'预期结果:原本默认字体会改变'; @State Vue: boolean = false; async aboutToAppear(){ diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasImageSmoothingEnabled.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasImageSmoothingEnabled.ets deleted file mode 100644 index a6ab794d3fdddeaa39f955c4499df9aafe152b8c..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasImageSmoothingEnabled.ets +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 {CustomContainer} from '../common/CanvasCustomContainer2'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - private settings: RenderingContextSettings = new RenderingContextSettings(true); - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); - private img:ImageBitmap = new ImageBitmap("src/main/resources/base/media/flower.jpg"); - @State FillColor: string = '#FF000000'; - @State X: number = 0; - @State name: string = 'CanvasImageSmoothingEnabled'; - @State StepTips: string = '操作步骤:点击不同的控件'+'\n'+'预期结果:切换平滑过渡效果'; - @State Vue: boolean = false; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ - Text('True').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) - .onClick(()=>{ - this.context.clearRect(10, 100, 400, 300); - this.context.imageSmoothingEnabled = true; - this.context.drawImage( this.img,0,0,400,200); - this.Vue = true; - }) - Text('False').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) - .onClick(()=>{ - this.context.clearRect(10, 100, 400, 300); - this.context.imageSmoothingEnabled = false; - this.context.drawImage( this.img,0,0,400,200); - this.Vue = true; - }) - }.width('70%').height('30%') - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffffffff') - .onReady(() =>{ - this.context.imageSmoothingEnabled = false; - this.context.drawImage( this.img,0,0,200,200); - }) - }.width('100%').height('60%') - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url: 'pages/ArkUI/ArkUI_index', - StepTips: this.StepTips, - content: this.specificNoParam, - FillColor: $FillColor, - X: $X, - name: $name, - Vue: $Vue, - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/PinchGestureTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/PinchGestureTest.ets index c695570f68739dce66e2b4248ad93f0ee9a895b3..1576577f0e4efb65f7fd6519aa6bfaeeb8bed39b 100644 --- a/validator/acts_validator/src/main/ets/pages/ArkUI/PinchGestureTest.ets +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/PinchGestureTest.ets @@ -18,7 +18,7 @@ import FirstDialog from '../model/FirstDialog'; @Component struct PinchGuestureTest { @State X: number = 1; - @State name: string = 'PinchGuesture'; + @State name: string = 'PinchGesture'; @State StepTips: string = '操作步骤:用手指触摸捏合图片(至少2根手指,最大为5指)'+'\n'+'预期结果:图片能够被正常捏合放缩'; @State Vue: boolean = false; async aboutToAppear(){ diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/RotationGestureTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/RotationGestureTest.ets index 27ead1c14a1435496a7b11527bf4efd85a15e9ef..649f29bf6ffd24041642b39f5715f814333c797c 100644 --- a/validator/acts_validator/src/main/ets/pages/ArkUI/RotationGestureTest.ets +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/RotationGestureTest.ets @@ -18,7 +18,7 @@ import FirstDialog from '../model/FirstDialog'; @Component struct RotationGuestureTest { @State X: number = 0; - @State name: string = 'RotationGuesture'; + @State name: string = 'RotationGesture'; @State StepTips: string = '操作步骤:用至少两根手指旋转图像(最多五根手指)'+'\n'+'预期结果:图片能够正常旋转'; @State Vue: boolean = false; async aboutToAppear(){ diff --git a/validator/acts_validator/src/main/ets/pages/Audio/Audio_index.ets b/validator/acts_validator/src/main/ets/pages/Audio/Audio_index.ets new file mode 100644 index 0000000000000000000000000000000000000000..275f9db6a9dc868831ea2de31c37f846d8e76d07 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Audio/Audio_index.ets @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2022-2023 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 prompt from '@ohos.prompt'; +import router from '@ohos.router'; +import fileio from '@ohos.fileio'; +import xml from '@ohos.xml'; +import fileIO from '@ohos.fileio'; +import util from '@ohos.util'; +import data_preferences from '@ohos.data.preferences'; + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1 = path + '/Audio'; + +let VarColor = []; +let ColorBackPath = path + '/AudioColorBack.txt'; +let txtPath = path1 + 'AudioReport.txt'; +let xmlPath =path1 + 'AudioTest.xml'; + +@Entry +@Component +struct IndexPage { + @State ClearAll : boolean = false; + private current : number = undefined; + @State count : number = 0; + @State result : string = ''; + @State TEST : number = 0; + private TestCaseList = [ + {title:'ScrollingList',uri:'pages/Audio/ScrollListTest'}, + ] + @State ColorObject : string[] = VarColor; + async onPageShow(){ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Audio', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'Audio'. Data: " + data); + }); + + if(Test != 1) { + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + fileio.closeSync(fd); + } + promise = preferences.put('Audio', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'Audio'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + this.TEST = Test; + + let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664); + let buff = new ArrayBuffer(40960); + fileio.readSync(opt,buff); + let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff)); + let TestList = ColorBack.split(';'); + for (let i = 0; i < Math.floor(TestList.length / 2); i++) { + VarColor[i] = TestList[i*2+1]; + } + fileio.closeSync(opt); + + if (this.count === 1){ + this.result = router.getParams()['result']; + let titles = router.getParams()['title']; + let name1 = '刚刚点进了哪个用例:'+ titles; + let results = this.result; + let WriteTitle = (titles).toString(); + let number = WriteTitle.length + 11; + let Index = ColorBack.indexOf(WriteTitle); + + if (this.result === 'Pass'){ + this.ColorObject[this.current] = '#ff008000'; + let Log = (titles+';'+'#ff008000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles) + } + else if (this.result === 'Fail'){ + this.ColorObject[this.current] = '#ffff0000'; + let Log = (titles+';'+'#ffff0000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles); + } + else if (this.result === 'None'){ + this.ColorObject[this.current] = this.ColorObject[this.current]; + } + } + } + build(){ + Column(){ + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black) + .onClick(() => { + router.back(); + }) + Row(){ + Text('Audio SubSystem') + .fontColor(Color.White) + .fontSize('22fp') + }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) + Row() { + Button(){ + Image($r('app.media.ic_public_delete')) + .width('30vp') + .height('30vp') + }.backgroundColor(Color.Black) + .onClick(() => { + AlertDialog.show( + { + message: "是否删除所有记录", + primaryButton: { + value: 'Yes', + action: () => { + this.ClearAll = true; + this.ColorObject.forEach((value, index) => { + this.ColorObject[index] = '#ff808080'; + }); + this.ClearText(); + prompt.showToast({ + message: '结果已删除', duration: 1000 + }); + } + }, + secondaryButton: { + value: 'No', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + }) + Button(){ + Image($r('app.media.ic_public_save')) + .width('30vp') + .height('30vp') + .margin({ left: 30 }) + }.backgroundColor(Color.Black) + .onClick(() => { + this.ReadTextParseXml(); + AlertDialog.show({ + message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/Audio/AudioTest.xml -本地路径'", + confirm:{ + value:'OK', + action:()=>{ + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }, + cancel: () => { + prompt.showToast({ + message: '报告已生成', duration: 1000 + }); + } + }) + }) + } + }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) + List({space:5}){ + ForEach(this.TestCaseList,(item,index) => { + ListItem(){ + Row(){ + Text(item.title).fontSize(16).fontColor(Color.Black) + }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) + .onClick(( )=>{ + this.count = 1; + this.ClearAll=false; + this.current = index; + router.push({ + url: item.uri, + }) + }) + } + },item => item.title) + }.width('100%').height('92%') + }.width('100%').height('100%').backgroundColor(Color.Black) + } + ClearText(){ + fileio.rmdirSync(path1); + fileio.mkdirSync(path1); + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + } + ReadTextParseXml(){ + let ReportPath = path1 + '/AudioReport.txt'; + let dir = fileio.opendirSync(path1); + console.info("ssssss"+dir); + while (dir) { + let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(40960); + let RD = fileio.readSync(OP,buf); + console.info("ddddd"+RD); + let report; + function ab2str(buf) { + return report = String.fromCharCode.apply(null,new Uint8Array(buf)); + } + ab2str(buf); + let str1 = report.split(";"); + let title = []; + let result = []; + for(let i=0; i { + ListItem() { + Text('Item #' + (index + 1)).width('100%').height(50).fontSize(16).fontColor(Color.White).margin({left:'10vp'}) + } + },index => index) + }.height('100%').width('100%').divider({strokeWidth:1,color:Color.Grey}) + }.height('83%').width('100%') + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/Audio/Audio_index', + StepTips: this.StepTips, + content: this.specificNoParam.bind(this), + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraFormat.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraFormat.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1cd1077264a586cf8e579f01e46ea6b2ee3d5eb --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraFormat.ets @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022-2023 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 camera from '@ohos.multimedia.camera' +import Logger from '../model/Logger' +import CameraService from '../model/CameraService' +import {CustomContainer} from '../common/CameraOrientation'; +import FirstDialog from '../model/FirstDialog'; +const CameraMode = { + MODE_PHOTO: 0, // 拍照模式 + MODE_VIDEO: 1 // 录像模式 +} + +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'CameraFormat'; + @State StepTips: string = '测试目的:用于测试相机预览和拍照旋转能力\n-左侧显示给定旋转角度后的预览窗口\n-右侧显示拍照后的图片\n-对于前置摄像头会有镜像效果'+'\n'+'预期结果:拍照图片与预览窗口的画面一致'; + private tag: string = 'qlw' + private mXComponentController: XComponentController = new XComponentController() + @State surfaceId: number = 0; + private x: number = 0; + @State curModel: number = CameraMode.MODE_PHOTO + @State cameraDeviceIndex: number = 0 + @State imageRotationValue: number = camera.ImageRotation.ROTATION_90 + @State qualityLevelValue: number = camera.QualityLevel.QUALITY_LEVEL_LOW + @State photoUri: string = undefined + @State Vue: boolean = false + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + handleTakePicture = (photoUri: string) => { + this.photoUri = photoUri + Logger.info(this.tag, `takePicture end, photoUri: ${this.photoUri}`) + } + + @Builder specificNoParam() { + Column() { + } + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/Camera/Camera_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name: $name, + Vue: $Vue + }).height('30%').width('100%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + XComponent({ + id: 'componentId', + type: 'surface', + controller: this.mXComponentController + }) + .onLoad(async () => { + Logger.info(this.tag, 'onLoad is called') + // @ts-ignore + this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 10, surfaceHeight: 10 }) + // @ts-ignore + this.surfaceId = this.mXComponentController.getXComponentSurfaceId() + Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`) + this.curModel = CameraMode.MODE_PHOTO + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) + }) + .height('40%') + .width('40%') + Text('Camera Preview').fontSize('20fp') + Text('Camera').fontSize(20) +// Select(qualityLevel) +// .selected(2) +// .value('请选择') +// .font({ size: 20, weight: 20, family: 'serif', style: FontStyle.Normal }) +// .selectedOptionFont({ size: 20, weight: 20, family: 'serif', style: FontStyle.Normal }) +// .optionFont({ size: 20, weight: 40, family: 'serif', style: FontStyle.Normal }) +// .onSelect((index: number, value: string) => { +// console.info("Select:" + index) +// console.info("Select qualityLevelValue:" + value) +// this.qualityLevelValue = Number(value) +// }) + Button('NEXT', { + type: ButtonType.Normal, + stateEffect: true + }).borderRadius(8).backgroundColor(0x317aff).width('20%').onClick(() => { + CameraService.takePicture(this.imageRotationValue, this.qualityLevelValue) + CameraService.setTakePictureCallback(this.handleTakePicture.bind(this)) + this.Vue = true + }) + }.width('100%').height('70%').backgroundColor(Color.White) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} +//@CustomDialog +//struct CustomDialogExample { +// @Link textValue: string +// @Link inputValue: string +// @Link qualityLevelValue: number +// @Link imageRotationValue: number +// @Link imageResolutionValue: string +// controller: CustomDialogController +// cancel: () => void +// confirm: () => void +//} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation0.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation0.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd5541816ed7d4ab7f40a88dc44d6d72a800f7ac --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation0.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022-2023 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 camera from '@ohos.multimedia.camera' +import Logger from '../model/Logger' +import CameraService from '../model/CameraService' +import {CustomContainer} from '../common/CameraOrientation'; +import FirstDialog from '../model/FirstDialog'; +const CameraMode = { + MODE_PHOTO: 0, // 拍照模式 + MODE_VIDEO: 1 // 录像模式 +} + +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'CameraOrientation0'; + @State StepTips: string = '测试目的:用于测试相机预览和拍照旋转能力\n-左侧显示给定旋转角度后的预览窗口\n-右侧显示拍照后的图片\n-对于前置摄像头会有镜像效果'+'\n'+'预期结果:拍照图片与预览窗口的画面一致'; + private tag: string = 'qlw' + private mXComponentController: XComponentController = new XComponentController() + @State surfaceId: number = 0; + @State curModel: number = CameraMode.MODE_PHOTO + @State cameraDeviceIndex: number = 0 + @State imageRotationValue: number = camera.ImageRotation.ROTATION_90 + @State qualityLevelValue: number = camera.QualityLevel.QUALITY_LEVEL_LOW + @State assetUri: string = undefined + @State Vue: boolean = false + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + handleTakePicture = (assetUri: string) => { + this.assetUri = assetUri + Logger.info(this.tag, `takePicture end, assetUri: ${this.assetUri}`) + } + + @Builder specificNoParam() { + Column() { + } + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/Camera/Camera_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name: $name, + Vue: $Vue + }).height('30%').width('100%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + XComponent({ + id: 'componentId', + type: 'surface', + controller: this.mXComponentController + }) + .onLoad(async () => { + Logger.info(this.tag, 'onLoad is called') + // @ts-ignore + this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 10, surfaceHeight: 10 }) + // @ts-ignore + this.surfaceId = this.mXComponentController.getXComponentSurfaceId() + Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`) + this.curModel = CameraMode.MODE_PHOTO + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) + }) + .height('40%') + .width('40%') + Text('Camera Preview').fontSize('20fp') + Image(this.assetUri || $r('app.media.img')) + .width('40%').height('40%').border({ width: 1 }).objectFit(ImageFit.Contain) + Text('Oriented Photo').fontSize('20fp') + Button('拍照', { + type: ButtonType.Normal, + stateEffect: true + }).borderRadius(8).backgroundColor(0x317aff).width('20%').onClick(() => { + CameraService.takePicture(this.imageRotationValue, this.qualityLevelValue) + CameraService.setTakePictureCallback(this.handleTakePicture.bind(this)) + this.Vue = true + }) + }.width('100%').height('70%').backgroundColor(Color.White) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation180.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation180.ets new file mode 100644 index 0000000000000000000000000000000000000000..706d062cd0cdd2d46b437fe19466d10bca0d818a --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation180.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022-2023 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 camera from '@ohos.multimedia.camera' +import Logger from '../model/Logger' +import CameraService from '../model/CameraService' +import {CustomContainer} from '../common/CameraOrientation'; +import FirstDialog from '../model/FirstDialog'; +const CameraMode = { + MODE_PHOTO: 0, // 拍照模式 + MODE_VIDEO: 1 // 录像模式 +} +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'CameraOrientation180'; + @State StepTips: string = '测试目的:用于测试相机预览和拍照旋转能力\n-左侧显示给定旋转角度后的预览窗口\n-右侧显示拍照后的图片\n-对于前置摄像头会有镜像效果'+'\n'+'预期结果:拍照图片与预览窗口的画面一致'; + private tag: string = 'qlw' + private mXComponentController: XComponentController = new XComponentController() + @State surfaceId: number = 0; + @State curModel: number = CameraMode.MODE_PHOTO + @State cameraDeviceIndex: number = 0 + @State imageRotationValue: number = camera.ImageRotation.ROTATION_180 + @State qualityLevelValue: number = camera.QualityLevel.QUALITY_LEVEL_LOW + @State assetUri: string = undefined + @State Vue: boolean = false + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + handleTakePicture = (assetUri: string) => { + this.assetUri = assetUri + Logger.info(this.tag, `takePicture end, assetUri: ${this.assetUri}`) + } + + @Builder specificNoParam() { + Column() { + } + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/Camera/Camera_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name, + Vue: $Vue, + }).height('30%').width('100%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + XComponent({ + id: 'componentId', + type: 'surface', + controller: this.mXComponentController + }) + .onLoad(async () => { + Logger.info(this.tag, 'onLoad is called') + // @ts-ignore + this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 10, surfaceHeight: 10 }) + // @ts-ignore + this.surfaceId = this.mXComponentController.getXComponentSurfaceId() + Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`) + this.curModel = CameraMode.MODE_PHOTO + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) + }) + .height('40%') + .width('40%') + Text('Camera Preview').fontSize('20fp') + Image(this.assetUri || $r('app.media.img')) + .width('40%').height('40%').border({ width: 1 }).objectFit(ImageFit.Contain) + Text('Oriented Photo').fontSize('20fp') + Button('拍照', { + type: ButtonType.Normal, + stateEffect: true + }).borderRadius(8).backgroundColor(0x317aff).width('20%').onClick(() => { + CameraService.takePicture(this.imageRotationValue, this.qualityLevelValue) + CameraService.setTakePictureCallback(this.handleTakePicture.bind(this)) + this.Vue = true + }) + }.width('100%').height('70%').backgroundColor(Color.White) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation270.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation270.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9005a2e8cdee196131299096ff3a2b89de51771 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation270.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022-2023 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 camera from '@ohos.multimedia.camera' +import Logger from '../model/Logger' +import CameraService from '../model/CameraService' +import {CustomContainer} from '../common/CameraOrientation'; +import FirstDialog from '../model/FirstDialog'; +const CameraMode = { + MODE_PHOTO: 0, // 拍照模式 + MODE_VIDEO: 1 // 录像模式 +} +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'CameraOrientation270'; + @State StepTips: string = '测试目的:用于测试相机预览和拍照旋转能力\n-左侧显示给定旋转角度后的预览窗口\n-右侧显示拍照后的图片\n-对于前置摄像头会有镜像效果'+'\n'+'预期结果:拍照图片与预览窗口的画面一致'; + private tag: string = 'qlw' + private mXComponentController: XComponentController = new XComponentController() + @State surfaceId: number = 0; + @State curModel: number = CameraMode.MODE_PHOTO + @State cameraDeviceIndex: number = 0 + @State imageRotationValue: number = camera.ImageRotation.ROTATION_270 + @State qualityLevelValue: number = camera.QualityLevel.QUALITY_LEVEL_LOW + @State assetUri: string = undefined + @State Vue: boolean = false + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + handleTakePicture = (assetUri: string) => { + this.assetUri = assetUri + Logger.info(this.tag, `takePicture end, assetUri: ${this.assetUri}`) + } + + @Builder specificNoParam() { + Column() { + } + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/Camera/Camera_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name, + Vue: $Vue + }).height('30%').width('100%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + XComponent({ + id: 'componentId', + type: 'surface', + controller: this.mXComponentController + }) + .onLoad(async () => { + Logger.info(this.tag, 'onLoad is called') + // @ts-ignore + this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 10, surfaceHeight: 10 }) + // @ts-ignore + this.surfaceId = this.mXComponentController.getXComponentSurfaceId() + Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`) + this.curModel = CameraMode.MODE_PHOTO + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) + }) + .height('40%') + .width('40%') + Text('Camera Preview').fontSize('20fp') + Image(this.assetUri || $r('app.media.img')) + .width('40%').height('40%').border({ width: 1 }).objectFit(ImageFit.Contain) + Text('Oriented Photo').fontSize('20fp') + Button('拍照', { + type: ButtonType.Normal, + stateEffect: true + }).borderRadius(8).backgroundColor(0x317aff).width('20%').onClick(() => { + CameraService.takePicture(this.imageRotationValue, this.qualityLevelValue) + CameraService.setTakePictureCallback(this.handleTakePicture.bind(this)) + this.Vue = true + }) + }.width('100%').height('70%').backgroundColor(Color.White) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation90.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation90.ets new file mode 100644 index 0000000000000000000000000000000000000000..857889f4c0988788f8825f7a0d405c8d0f955050 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraOrientation90.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022-2023 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 camera from '@ohos.multimedia.camera' +import Logger from '../model/Logger' +import CameraService from '../model/CameraService' +import {CustomContainer} from '../common/CameraOrientation'; +import FirstDialog from '../model/FirstDialog'; +const CameraMode = { + MODE_PHOTO: 0, // 拍照模式 + MODE_VIDEO: 1 // 录像模式 +} +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'CameraOrientation90'; + @State StepTips: string = '测试目的:用于测试相机预览和拍照旋转能力\n-左侧显示给定旋转角度后的预览窗口\n-右侧显示拍照后的图片\n-对于前置摄像头会有镜像效果'+'\n'+'预期结果:拍照图片与预览窗口的画面一致'; + private tag: string = 'qlw' + private mXComponentController: XComponentController = new XComponentController() + @State surfaceId: number = 0; + @State curModel: number = CameraMode.MODE_PHOTO + @State cameraDeviceIndex: number = 0 + @State imageRotationValue: number = camera.ImageRotation.ROTATION_0 + @State qualityLevelValue: number = camera.QualityLevel.QUALITY_LEVEL_LOW + @State assetUri: string = undefined + @State Vue: boolean = false + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + handleTakePicture = (assetUri: string) => { + this.assetUri = assetUri + Logger.info(this.tag, `takePicture end, assetUri: ${this.assetUri}`) + } + + @Builder specificNoParam() { + Column() { + } + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/Camera/Camera_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name, + Vue: $Vue + }).height('30%').width('100%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + XComponent({ + id: 'componentId', + type: 'surface', + controller: this.mXComponentController + }) + .onLoad(async () => { + Logger.info(this.tag, 'onLoad is called') + // @ts-ignore + this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 10, surfaceHeight: 10 }) + // @ts-ignore + this.surfaceId = this.mXComponentController.getXComponentSurfaceId() + Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`) + this.curModel = CameraMode.MODE_PHOTO + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) + }) + .height('40%') + .width('40%') + Text('Camera Preview').fontSize('20fp') + Image(this.assetUri || $r('app.media.img')) + .width('40%').height('40%').border({ width: 1 }).objectFit(ImageFit.Contain) + Text('Oriented Photo').fontSize('20fp') + Button('拍照', { + type: ButtonType.Normal, + stateEffect: true + }).borderRadius(8).backgroundColor(0x317aff).width('20%').onClick(() => { + CameraService.takePicture(this.imageRotationValue, this.qualityLevelValue) + CameraService.setTakePictureCallback(this.handleTakePicture.bind(this)) + this.Vue = true + }) + }.width('100%').height('70%').backgroundColor(Color.White) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraVideo.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraVideo.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b7c2c2d326fd1cdf58ee88f491f3b4034bdefcd --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraVideo.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022-2023 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 camera from '@ohos.multimedia.camera' +import Logger from '../model/Logger' +import CameraService from '../model/CameraService' +import {CustomContainer} from '../common/CameraOrientation'; +import FirstDialog from '../model/FirstDialog'; +const CameraMode = { + MODE_PHOTO: 0, // 拍照模式 + MODE_VIDEO: 1 // 录像模式 +} + +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'CameraVideo'; + @State StepTips: string = '测试目的:用于测试相机不同分辨率下的录像能力\n-上边显示录像的预览窗口\n-按下测试按钮后触发3s录像,回放的录像文件将在录像结束后显示在下边窗口\n-使用下拉框可以选择相机设备和分辨率'+'\n'+'预期结果:回放的录像视频与预览窗口的画面一致'; + private tag: string = 'qlw' + private mXComponentController: XComponentController = new XComponentController() + @State surfaceId: number = 0; + private x: number = 0; + @State curModel: number = CameraMode.MODE_PHOTO + @State cameraDeviceIndex: number = 0 + @State imageRotationValue: number = camera.ImageRotation.ROTATION_90 + @State qualityLevelValue: number = camera.QualityLevel.QUALITY_LEVEL_LOW + @State assetUri: string = undefined + @State Vue: boolean = false + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + handleTakePicture = (assetUri: string) => { + this.assetUri = assetUri + Logger.info(this.tag, `Video recorder end, assetUri: ${this.assetUri}`) + } + + @Builder specificNoParam() { + Column() { + } + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/Camera/Camera_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name: $name, + Vue: $Vue + }).height('30%').width('100%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + XComponent({ + id: 'componentId', + type: 'surface', + controller: this.mXComponentController + }) + .onLoad(async () => { + Logger.info(this.tag, 'onLoad is called') + // @ts-ignore + this.mXComponentController.setXComponentSurfaceSize({ surfaceWidth: 10, surfaceHeight: 10 }) + // @ts-ignore + this.surfaceId = this.mXComponentController.getXComponentSurfaceId() + Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`) + this.curModel = CameraMode.MODE_PHOTO + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) + }) + .height('40%') + .width('40%') + Text('Camera Preview').fontSize('20fp') +// Video() + Text('Video playback').fontSize('20fp') + Button('Test', { + type: ButtonType.Normal, + stateEffect: true + }).borderRadius(8).backgroundColor(0x317aff).width('20%').onClick(() => { + CameraService.startVideo() + CameraService.setTakePictureCallback(this.handleTakePicture.bind(this)) + this.Vue = true + }) + }.width('100%').height('70%').backgroundColor(Color.White) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Camera/Camera_index.ets b/validator/acts_validator/src/main/ets/pages/Camera/Camera_index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c17b1772616526bf70e38f57219572cb229dff1 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Camera/Camera_index.ets @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2022-2023 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 prompt from '@ohos.prompt'; +import router from '@ohos.router'; +import fileio from '@ohos.fileio'; +import xml from '@ohos.xml'; +import fileIO from '@ohos.fileio'; +import util from '@ohos.util'; +import data_preferences from '@ohos.data.preferences'; + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1 = path + '/Camera'; + +let VarColor = []; +let ColorBackPath = path + '/CameraColorBack.txt'; +let txtPath = path1 + 'CameraReport.txt'; +let xmlPath = path1 + 'CameraTest.xml'; + +@Entry +@Component +struct IndexPage { + @State ClearAll : boolean = false; + private current : number = undefined; + @State count : number = 0; + @State result : string = ''; + @State TEST : number = 0; + private TestCaseList = [ + {title:'CameraOrientation0',uri:'pages/Camera/CameraOrientation0'}, + {title:'CameraOrientation90',uri:'pages/Camera/CameraOrientation90'}, + {title:'CameraOrientation180',uri:'pages/Camera/CameraOrientation180'}, + {title:'CameraOrientation270',uri:'pages/Camera/CameraOrientation270'}, + {title:'CameraFormat',uri:'pages/Camera/CameraFormat'}, + {title:'CameraVideo',uri:'pages/Camera/CameraVideo'}, + ] + @State ColorObject : string[] = VarColor; + async onPageShow(){ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Camera', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'Camera'. Data: " + data); + }); + + if(Test != 1) { + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + fileio.closeSync(fd); + } + promise = preferences.put('Camera', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'Camera'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + this.TEST = Test; + + let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664); + let buff = new ArrayBuffer(40960); + fileio.readSync(opt,buff); + let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff)); + let TestList = ColorBack.split(';'); + for (let i = 0; i < Math.floor(TestList.length / 2); i++) { + VarColor[i] = TestList[i*2+1]; + } + fileio.closeSync(opt); + + if (this.count === 1){ + this.result = router.getParams()['result']; + let titles = router.getParams()['title']; + let name1 = '刚刚点进了哪个用例:'+ titles; + let results = this.result; + let WriteTitle = (titles).toString(); + let number = WriteTitle.length + 11; + let Index = ColorBack.indexOf(WriteTitle); + + if (this.result === 'Pass'){ + this.ColorObject[this.current] = '#ff008000'; + let Log = (titles+';'+'#ff008000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles) + } + else if (this.result === 'Fail'){ + this.ColorObject[this.current] = '#ffff0000'; + let Log = (titles+';'+'#ffff0000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles); + } + else if (this.result === 'None'){ + this.ColorObject[this.current] = this.ColorObject[this.current]; + } + } + } + build(){ + Column(){ + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black) + .onClick(() => { + router.back(); + }) + Row(){ + Text('Camera') + .fontColor(Color.White) + .fontSize('20fp') + }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) + Row() { + Button(){ + Image($r('app.media.ic_public_delete')) + .width('30vp') + .height('30vp') + }.backgroundColor(Color.Black) + .onClick(() => { + AlertDialog.show( + { + message: "是否删除所有记录", + primaryButton: { + value: 'Yes', + action: () => { + this.ClearAll = true; + this.ColorObject.forEach((value, index) => { + this.ColorObject[index] = '#ff808080'; + }); + this.ClearText(); + prompt.showToast({ + message: '结果已删除', duration: 1000 + }); + } + }, + secondaryButton: { + value: 'No', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + }) + Button(){ + Image($r('app.media.ic_public_save')) + .width('30vp') + .height('30vp') + .margin({ left: 30 }) + }.backgroundColor(Color.Black) + .onClick(() => { + this.ReadTextParseXml(); + AlertDialog.show({ + message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/report1/CameraTest.xml -本地路径'", + confirm:{ + value:'OK', + action:()=>{ + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }, + cancel: () => { + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }) + }) + } + }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) + List({space:5}){ + ForEach(this.TestCaseList,(item,index) => { + ListItem(){ + Row(){ + Text(item.title).fontSize(16).fontColor(Color.Black) + }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) + .onClick(( )=>{ + this.count = 1; + this.ClearAll=false; + this.current = index; + router.push({ + url: item.uri, + }) + }) + } + },item => item.title) + }.width('100%').height('92%') + }.width('100%').height('100%').backgroundColor(Color.Black) + } + ClearText(){ + fileio.rmdirSync(path1); + fileio.mkdirSync(path1); + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + } + ReadTextParseXml(){ + let ReportPath = path1 + '/CameraReport.txt'; + let dir = fileio.opendirSync(path1); + console.info("ssssss"+dir); + while (dir) { + let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(40960); + let RD = fileio.readSync(OP,buf); + console.info("ddddd"+RD); + let report; + function ab2str(buf) { + return report = String.fromCharCode.apply(null,new Uint8Array(buf)); + } + ab2str(buf); + let str1 = report.split(";"); + let title = []; + let result = []; + for(let i=0; i { - router.back(); - }) - Row(){ - Text('MediaLibrary') - .fontColor(Color.White) - .fontSize('22fp') - }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) - Row() { - Button(){ - Image($r('app.media.ic_public_delete')) - .width('30vp') - .height('30vp') - }.backgroundColor(Color.Black) - .onClick(() => { - AlertDialog.show( - { - message: "是否删除所有记录", - primaryButton: { - value: 'Yes', - action: () => { - this.ClearAll = true; - this.ColorObject.forEach((value, index) => { - this.ColorObject[index] = '#ff808080'; - }); - this.ClearText(); - prompt.showToast({ - message: '结果已删除', duration: 1000 - }); - } - }, - secondaryButton: { - value: 'No', - action: () => { - - } - }, - cancel: () => { - - } - } - ) - }) - Button(){ - Image($r('app.media.ic_public_save')) - .width('30vp') - .height('30vp') - .margin({ left: 30 }) - }.backgroundColor(Color.Black) - .onClick(() => { - this.ReadTextParseXml(); - AlertDialog.show({ - message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/MediaLibrary/MediaLibraryTest.xml -本地路径'", - confirm:{ - value:'OK', - action:()=>{ - prompt.showToast({ - message: '报告已生成', duration: 1000 - }) - } - }, - cancel: () => { - prompt.showToast({ - message: '报告已生成', duration: 1000 - }) - } - }) - }) - } - }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) - List({space:5}){ - ForEach(this.TestCaseList,(item,index) => { - ListItem(){ - Row(){ - Text(item.title).fontSize(16).fontColor(Color.Black) - Text(this.BackColor.toString()).visibility(Visibility.None) - }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index]) - .onClick(( )=>{ - this.count = 1; - this.ClearAll=false; - this.current = index; - router.push({ - url: item.uri, - }); - }) - } - },item => item.title) - }.width('100%').height('92%') - }.width('100%').height('100%').backgroundColor(Color.Black) - } - ClearText(){ - fileio.rmdirSync(path1); - fileio.mkdirSync(path1); - } - ReadTextParseXml() { - let ReportPath = path1 + '/MediaLibraryReport.txt'; - let dir = fileio.opendirSync(path1); - console.info("ssssss" + dir); - while (dir) { - let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); - let buf = new ArrayBuffer(40960); - let RD = fileio.readSync(OP,buf); - console.info("ddddd"+RD); - let report; - function ab2str(buf) { - return report = String.fromCharCode.apply(null, new Uint8Array(buf)); - } - ab2str(buf); - let str1 = report.split(";"); - let title = []; - let result = []; - for (let i = 0; i < Math.floor(str1.length / 2); i++) { - title[i] = str1[i*2]; - result[i] = str1[i * 2+1]; - } - let FailIndex = report.indexOf('Fail'); - let FailNum = 0; - while (FailIndex != -1) { - console.log(FailIndex); - FailNum++; - FailIndex = report.indexOf('Fail',FailIndex + 1); - } - let failNum = (FailNum).toString(); - let PassIndex = report.indexOf('Pass'); - let PassNum = 0; - while (PassIndex != -1) { - console.log(PassIndex); - PassNum++; - PassIndex = report.indexOf('Pass',PassIndex + 1); - } - let TestNum = FailNum + PassNum; - let testNum = (TestNum).toString(); - let ignoreNum = (28-TestNum).toString(); - let arrayBuffer = new ArrayBuffer(40960); - let bufView = new DataView(arrayBuffer); - let serializer = new xml.XmlSerializer(bufView); - serializer.setDeclaration(); - serializer.startElement("testsuite"); - serializer.setAttributes("name", "ActsMediaLibraryTest"); - serializer.setAttributes("time", " "); - serializer.setAttributes("errors", "0"); - serializer.setAttributes("disabled", "0"); - serializer.setAttributes("failures", failNum); - serializer.setAttributes("ignored", ignoreNum); - serializer.setAttributes("tests", testNum); - serializer.setAttributes("message", " "); - serializer.setAttributes("modulename", "ActsMediaLibraryTest"); - for (let i = 0; i < title.length; i++) { - serializer.startElement("testcase"); - serializer.setAttributes("name", String(title[i])); - serializer.setAttributes("status", " "); - serializer.setAttributes("time", " "); - serializer.setAttributes("classname", " "); - serializer.setAttributes("result", String(result[i])); - serializer.setAttributes("level", " "); - serializer.setAttributes("message", " "); - serializer.endElement(); - } - serializer.endElement(); - - let that = new util.TextDecoder('utf-8'); - let array = new Uint8Array(arrayBuffer); - let serializerStr = that.decode(array); - let xmlPath = path1 + "/MediaLibraryTest.xml"; - console.info(xmlPath); - try { - console.error(TAG, "write xmlPath =" + xmlPath); - var xmlfd = fileIO.openSync(xmlPath, 0o102, 0o666); - fileIO.writeSync(xmlfd, serializerStr); - } catch (err) { - console.error(TAG, "read xmlPath =" + xmlPath + "error:" + err); - } finally { - fileIO.closeSync(xmlfd); - } - return; - } - } -} -function filewrite(name1,results,titles){ - let txtpath = path1 + '/MediaLibraryReport.txt'; - let fd = fileio.openSync(txtpath, 0o100 | 0o2002, 0o664); - let buf = new ArrayBuffer(4096); - let RD = fileio.readSync(fd,buf); - console.info("RRRRRRRRRRd"+RD); - let report = String.fromCharCode.apply(null,new Uint8Array(buf)); - let WriteTitle = (titles).toString(); - let number = WriteTitle.length + 6; - let Index = report.indexOf(WriteTitle); - let Log = (titles+";"+results+";").toString(); - if (Index == -1){ - fileio.writeSync(fd,Log); - } - else if (Index != -1){ - let key = report.substring(Index,Index+number); - let FD = fileio.openSync(txtpath, 0o102, 0o666); - report = report.replace(key,Log); - let buffer = new ArrayBuffer(4096); - let rd = fileio.readSync(FD,buffer); - let Report = report.substring(0,rd); - fileio.closeSync(FD); - let Fd = fileio.openSync(txtpath, 0o102, 0o666); - fileio.writeSync(Fd,Report); - } +/* + * Copyright (c) 2022-2023 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 prompt from '@ohos.prompt'; +import router from '@ohos.router'; +import fileio from '@ohos.fileio'; +import xml from '@ohos.xml'; +import fileIO from '@ohos.fileio'; +import util from '@ohos.util'; +import data_preferences from '@ohos.data.preferences'; + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1 = path + '/Experience'; + +let VarColor = []; +let ColorBackPath = path + '/ExperienceColorBack.txt'; +let txtPath = path1 + 'ExperienceReport.txt'; +let xmlPath =path1 + 'ExperienceTest.xml'; + +@Entry +@Component +struct IndexPage { + @State ClearAll : boolean = false; + private current : number = undefined; + @State count : number = 0; + @State result : string = ''; + @State TEST : number = 0; + private TestCaseList = [ + {title:'ScrollingList',uri:'pages/Experience/ScrollListTest'}, + ] + @State ColorObject : string[] = VarColor; + async onPageShow(){ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Experience', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'Experience'. Data: " + data); + }); + + if(Test != 1) { + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + fileio.closeSync(fd); + } + promise = preferences.put('Experience', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'Experience'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + this.TEST = Test; + + let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664); + let buff = new ArrayBuffer(40960); + fileio.readSync(opt,buff); + let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff)); + let TestList = ColorBack.split(';'); + for (let i = 0; i < Math.floor(TestList.length / 2); i++) { + VarColor[i] = TestList[i*2+1]; + } + fileio.closeSync(opt); + + if (this.count === 1){ + this.result = router.getParams()['result']; + let titles = router.getParams()['title']; + let name1 = '刚刚点进了哪个用例:'+ titles; + let results = this.result; + let WriteTitle = (titles).toString(); + let number = WriteTitle.length + 11; + let Index = ColorBack.indexOf(WriteTitle); + + if (this.result === 'Pass'){ + this.ColorObject[this.current] = '#ff008000'; + let Log = (titles+';'+'#ff008000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles) + } + else if (this.result === 'Fail'){ + this.ColorObject[this.current] = '#ffff0000'; + let Log = (titles+';'+'#ffff0000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles); + } + else if (this.result === 'None'){ + this.ColorObject[this.current] = this.ColorObject[this.current]; + } + } + } + build(){ + Column(){ + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black) + .onClick(() => { + router.back(); + }) + Row(){ + Text('Experience SubSystem') + .fontColor(Color.White) + .fontSize('22fp') + }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) + Row() { + Button(){ + Image($r('app.media.ic_public_delete')) + .width('30vp') + .height('30vp') + }.backgroundColor(Color.Black) + .onClick(() => { + AlertDialog.show( + { + message: "是否删除所有记录", + primaryButton: { + value: 'Yes', + action: () => { + this.ClearAll = true; + this.ColorObject.forEach((value, index) => { + this.ColorObject[index] = '#ff808080'; + }); + this.ClearText(); + prompt.showToast({ + message: '结果已删除', duration: 1000 + }); + } + }, + secondaryButton: { + value: 'No', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + }) + Button(){ + Image($r('app.media.ic_public_save')) + .width('30vp') + .height('30vp') + .margin({ left: 30 }) + }.backgroundColor(Color.Black) + .onClick(() => { + this.ReadTextParseXml(); + AlertDialog.show({ + message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/Experience/ExperienceTest.xml -本地路径'", + confirm:{ + value:'OK', + action:()=>{ + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }, + cancel: () => { + prompt.showToast({ + message: '报告已生成', duration: 1000 + }); + } + }) + }) + } + }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) + List({space:5}){ + ForEach(this.TestCaseList,(item,index) => { + ListItem(){ + Row(){ + Text(item.title).fontSize(16).fontColor(Color.Black) + }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) + .onClick(( )=>{ + this.count = 1; + this.ClearAll=false; + this.current = index; + router.push({ + url: item.uri, + }) + }) + } + },item => item.title) + }.width('100%').height('92%') + }.width('100%').height('100%').backgroundColor(Color.Black) + } + ClearText(){ + fileio.rmdirSync(path1); + fileio.mkdirSync(path1); + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + } + ReadTextParseXml(){ + let ReportPath = path1 + '/ExperienceReport.txt'; + let dir = fileio.opendirSync(path1); + console.info("ssssss"+dir); + while (dir) { + let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(40960); + let RD = fileio.readSync(OP,buf); + console.info("ddddd"+RD); + let report; + function ab2str(buf) { + return report = String.fromCharCode.apply(null,new Uint8Array(buf)); + } + ab2str(buf); + let str1 = report.split(";"); + let title = []; + let result = []; + for(let i=0; i { + ListItem() { + Text('Item #' + (index + 1)).width('100%').height(50).fontSize(16).fontColor(Color.White).margin({left:'10vp'}) + } + },index => index) + }.height('100%').width('100%').divider({strokeWidth:1,color:Color.Grey}) + }.height('83%').width('100%') + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/Experience/Experience_index', + StepTips: this.StepTips, + content: this.specificNoParam.bind(this), + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback1.ets deleted file mode 100644 index dda216ee9df7199d4478254d4e631edf12d87b00..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback1.ets +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewCallback1'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:可以预览到一张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewCallback1'; - let images = [ - "datashare:///media/image/3", - ]; - let index = 1; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { - if (err) { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - return; - } - console.log(TAG + "Succeeded in previewing the images."); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback2.ets deleted file mode 100644 index 23a15813e1bfc30ec51263b3b9828a6e94cbddb9..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback2.ets +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewCallback2'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:起始图片为第一张图片,一共可以预览到两张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewCallback2'; - let images = [ - "datashare:///media/image/3", - "datashare:///media/image/4", - ]; - let index = 1; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { - if (err) { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - return; - } - console.log(TAG + "Succeeded in previewing the images."); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback3.ets deleted file mode 100644 index 3c6cb554007f2aa6ff1da1b077384de6c0987fe4..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback3.ets +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewCallback3'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:起始图片为第三张图片,一共可以预览到四张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewCallback3'; - let images = [ - "datashare:///media/image/3", - "datashare:///media/image/4", - "datashare:///media/image/5", - "datashare:///media/image/6", - ]; - let index = 2; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { - if (err) { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - return; - } - console.log(TAG + "Succeeded in previewing the images."); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback4.ets deleted file mode 100644 index ab23b2ba5232bc588c0f5d6a909f5f572ede81cd..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback4.ets +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewCallback4'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:预览图片失败'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewCallback4'; - let images = [ - "datashare:///media/image/9999", - "datashare:///media/image/9998", - "datashare:///media/image/9997", - "datashare:///media/image/9996", - ]; - let index = 2; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { - if (err) { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - return; - } - console.log(TAG + "Succeeded in previewing the images."); - }); - }) - - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback5.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback5.ets deleted file mode 100644 index a7c74d7d0ddc5d33e49809700efb5f5220260a71..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback5.ets +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewCallback5'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:成功预览一张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewCallback5'; - let images = [ - "datashare:///media/image/3", - ]; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => { - if (err) { - console.log(TAG + "startImagePreview_One An error occurred when previewing the images." + JSON.stringify(err)); - return; - } - console.log(TAG + "startImagePreview_One Succeeded in previewing the images."); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback6.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback6.ets deleted file mode 100644 index 15cb61dcb08fcf58c48b2780356c6d4b46aa482d..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback6.ets +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewCallback6'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:成功预览五张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewCallback6'; - let images = [ - "datashare:///media/image/3", - "datashare:///media/image/4", - "datashare:///media/image/5", - "datashare:///media/image/6", - "datashare:///media/image/2", - ]; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => { - if (err) { - console.log(TAG + "startImagePreview_MultiPle An error occurred when previewing the images." + JSON.stringify(err)); - return; - } - console.log(TAG + "startImagePreview_MultiPle Succeeded in previewing the images."); - }); - }) - - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback7.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback7.ets deleted file mode 100644 index db8c63dc1aae81d452b4b1879c11511062200434..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback7.ets +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewCallback7'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:预览图片失败'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewCallback7'; - let images = [ - "datashare:///media/image/9999", - ]; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => { - if (err) { - console.log(TAG + "startImagePreview_One An error occurred when previewing the images." + JSON.stringify(err)); - return; - } - console.log(TAG + "startImagePreview_One Succeeded in previewing the images."); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise1.ets deleted file mode 100644 index 0ef1b89fe9b8c69af03e323fb9739a225ff84407..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise1.ets +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewPromise1'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:可以成功预览到一张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewPromise1'; - let images = [ - "datashare:///media/image/3", - ]; - let index = 1; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { - console.log(TAG + "Succeeded in previewing the images."); - }).catch((err) => { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url: 'pages/MediaLibrary/MediaLibrary_index', - StepTips: this.StepTips, - content: this.specificNoParam, - FillColor: $FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} - diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise2.ets deleted file mode 100644 index 20bd9528651807e248902ad7004e0f30df7b5fd1..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise2.ets +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewPromise2'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:起始图片为第一张图片,一共可以预览到两张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewPromise2'; - let images = [ - "datashare:///media/image/3", - "datashare:///media/image/4", - ]; - let index = 1; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { - console.log(TAG + "Succeeded in previewing the images."); - }).catch((err) => { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - - build() { - Column() { - CustomContainer({ - title: this.name, - Url: 'pages/MediaLibrary/MediaLibrary_index', - StepTips: this.StepTips, - content: this.specificNoParam, - FillColor: $FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} - diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise3.ets deleted file mode 100644 index 77779380181f1a48b7238ba0bc1f9c878d3b9e70..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise3.ets +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewPromise3'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:起始图片为第二张图片,一共可以预览到三张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewPromise3'; - let images = [ - "datashare:///media/image/3", - "datashare:///media/image/4", - "datashare:///media/image/5", - ]; - let index = 1; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { - console.log(TAG + "Succeeded in previewing the images."); - }).catch((err) => { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - }); - }) - - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - - build() { - Column() { - CustomContainer({ - title: this.name, - Url: 'pages/MediaLibrary/MediaLibrary_index', - StepTips: this.StepTips, - content: this.specificNoParam, - FillColor: $FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} - diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise4.ets deleted file mode 100644 index a0978c6f296af0fbffd2696abb29813b12af94c1..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise4.ets +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startImagePreviewPromise4'; - @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:预览图片失败'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startImagePreviewPromise4'; - let images = [ - "datashare:///media/image/9999", - "datashare:///media/image/9998", - "datashare:///media/image/9997", - ]; - let index = 1; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { - console.log(TAG + "Succeeded in previewing the images."); - }).catch((err) => { - console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - - build() { - Column() { - CustomContainer({ - title: this.name, - Url: 'pages/MediaLibrary/MediaLibrary_index', - StepTips: this.StepTips, - content: this.specificNoParam, - FillColor: $FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} - diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback1.ets deleted file mode 100644 index 53c617af6fcf8c6accd2905ccf7457c7b6f23fdf..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback1.ets +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectCallback1'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择一张图片(单选)'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelectCallback1'; - let option : mediaLibrary.MediaSelectOption = { - type : "image", - count : 1 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { - if (err) { - console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); - return; - } - console.log(TAG + "image resources selected." + JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback2.ets deleted file mode 100644 index f5f5af80518242e9da64c3b641ede041a2895806..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback2.ets +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectCallback2'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多张图片(多选)'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelectCallback2'; - let option : mediaLibrary.MediaSelectOption = { - type : "image", - count : 2 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { - if (err) { - console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); - return; - } - console.log(TAG + "image resources selected." + JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback3.ets deleted file mode 100644 index 1fd60fdf14bf744eb9a4cddcc3b4222b3bb8a562..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback3.ets +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectCallback3'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个图片、视频文件'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelectCallback3'; - let option : mediaLibrary.MediaSelectOption = { - type : "media", - count : 2 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { - if (err) { - console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); - return; - } - console.log(TAG + "image resources selected." + JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback4.ets deleted file mode 100644 index cde6cafa14d8cf607286e284ade9c519bdf36dcb..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback4.ets +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectCallback4'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个视频资源'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelectCallback4'; - let option : mediaLibrary.MediaSelectOption = { - type : "video", - count : 2 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { - if (err) { - console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); - return; - } - console.log(TAG + "image resources selected." + JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise1.ets deleted file mode 100644 index 2105f1598e41333aa51af539167147337e5e4074..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise1.ets +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectPromise1'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择单张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelectPromise1'; - let option : mediaLibrary.MediaSelectOption = { - type : "image", - count : 1 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { - console.log(TAG + "Media resources selected." + JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise2.ets deleted file mode 100644 index 577e05fdf7146d2dba607fc8791c8bd0a4ed2280..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise2.ets +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectPromise2'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多张图片'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelectPromise2'; - let option : mediaLibrary.MediaSelectOption = { - type : "image", - count : 2 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { - console.log(TAG + "Media resources selected." + JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise3.ets deleted file mode 100644 index 6d07d3f969113c26be54652f136e3902af6cd8fb..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise3.ets +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectPromise3'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个图片、视频资源'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelect5_media2'; - let option : mediaLibrary.MediaSelectOption = { - type : "media", - count : 2 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { - console.log(TAG + "Media resources selected." + JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise4.ets deleted file mode 100644 index 5e33a6d9f6bca0b58e467f5243437d429654170d..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise4.ets +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'startMediaSelectPromise4'; - @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择单个视频'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) - .onClick(() => { - let TAG = 'startMediaSelect5_video2'; - let option : mediaLibrary.MediaSelectOption = { - type : "video", - count : -1 - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { - console.log(TAG + "Media resources selected." + JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); - }); - }) - - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback1.ets deleted file mode 100644 index 5093fd261cc6517c29b9ce6e226b9b09ac52dd00..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback1.ets +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetCallback1'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存一张图片,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam(){ - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetCallback1'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let JpgPath = data + "/files/"+time + ".jpg"; - - let srcFd =await fileio.open(JpgPath,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : JpgPath, - mimeType : "image/*", - relativePath : "Pictures/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { - if (err) { - console.log(TAG +"An error occurred when storing image resources." + JSON.stringify(err)); - return; - } - AlertDialog.show( - { - title: '保存成功', - message: '查询到Pictures路径下新增一个.jpg格式的图片资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed callbacks') - } - } - ) - console.log(TAG + "image resources stored. "+ JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback2.ets deleted file mode 100644 index 050fcf8b1ba4c9bd8100daf454b90c6bdd69f223..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback2.ets +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetCallback2'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存音频,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam(){ - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetCallback2'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let PathMp3 = data + "/files/"+time + ".mp3"; - - let srcFd =await fileio.open(PathMp3,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : PathMp3, - mimeType : "audio/mp3", - relativePath : "Audios/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { - if (err) { - console.log(TAG + "An error occurred when storing audios resources."+ JSON.stringify(err)); - return; - } - AlertDialog.show( - { - title: '保存成功', - message: '查询到Audios路径下新增一个.mp3格式的音频资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed callbacks') - } - } - ) - console.log(TAG + "audios resources stored. "+ JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback3.ets deleted file mode 100644 index 9c714626632e335be479b557a9ace2c28ac42d1f..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback3.ets +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetCallback3'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存视频,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam(){ - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetCallback3'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let PathMp4 = data + "/files/"+time + ".mp4"; - - let srcFd =await fileio.open(PathMp4,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : PathMp4, - mimeType : "video/mp4", - relativePath : "Videos/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { - if (err) { - console.log(TAG + "An error occurred when storing videos resources."+ JSON.stringify(err)); - return; - } - AlertDialog.show( - { - title: '保存成功', - message: '查询到Videos路径下新增一个.mp4格式的视频资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed callbacks') - } - } - ) - console.log(TAG + "videos resources stored. "+ JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback4.ets deleted file mode 100644 index c0f349cc3f8a7df257046ef02ef45fccdefb3e51..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback4.ets +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetCallback4'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存文件,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam(){ - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetCallback4'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let PathPdf = data + "/files/"+time + ".Pdf"; - - let srcFd =await fileio.open(PathPdf,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : PathPdf, - mimeType : "file/pdf", - relativePath : "Documents/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { - if (err) { - console.log(TAG + "An error occurred when storing files resources."+ JSON.stringify(err)); - return; - } - AlertDialog.show( - { - title: '保存成功', - message: '查询到Documents路径下新增一个.Pdf格式的文件资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking1 callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed1 callbacks') - } - } - ) - console.log(TAG + "files resources stored. "+ JSON.stringify(value)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise1.ets deleted file mode 100644 index 5ead6443b048225c00cd39835f7989e86d52efc0..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise1.ets +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetPromise1'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存图片,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetPromise1'; - let context0 = featureAbility.getContext(); - let data = await context0.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let JpgPath = data + "/files/"+time + ".jpg"; - - let srcFd =await fileio.open(JpgPath,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : JpgPath, - mimeType : "image/*", - relativePath : "Pictures/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { - AlertDialog.show( - { - title: '保存成功', - message: '查询到Pictures路径下新增一个.jpg格式的图片资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed callbacks') - } - } - ) - console.log(TAG + "image resources stored. "+ JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + "An error occurred when storing image resources."+ JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise2.ets deleted file mode 100644 index 1201ec8a2962eb6616bee793c17c08516c49c19e..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise2.ets +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetPromise2'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存音频,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetPromise2'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let PathMp3 = data + "/files/"+time + ".mp3"; - - let srcFd =await fileio.open(PathMp3,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : PathMp3, - mimeType : "audio/mp3", - relativePath : "Audios/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { - AlertDialog.show( - { - title: '保存成功', - message: '查询到Audios路径下新增一个.mp3格式的音频资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed callbacks') - } - } - ) - console.log(TAG + "audios resources stored. "+ JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + "An error occurred when storing audios resources."+ JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise3.ets deleted file mode 100644 index 58be029a61ba538438b290ab2ca49bdc8db30f8a..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise3.ets +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetPromise3'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存视频,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetPromise3'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let PathMp4 = data + "/files/"+time + ".mp4"; - - let srcFd =await fileio.open(PathMp4,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : PathMp4, - mimeType : "video/mp4", - relativePath : "Videos/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { - AlertDialog.show( - { - title: '保存成功', - message: '查询到Videos路径下新增一个.mp4格式的视频资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + ' Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + ' Closed callbacks') - } - } - ) - console.log(TAG + " videos resources stored. "+ JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + " An error occurred when storing videos resources."+ JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise4.ets deleted file mode 100644 index d1c4171c19fef07770f3f23311556f3c8cc06796..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise4.ets +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetPromise4'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存文件,资源内容为“hello world”'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetPromise4'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let PathPdf = data + "/files/"+time + ".Pdf"; - - let srcFd =await fileio.open(PathPdf,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : PathPdf, - mimeType : "file/pdf", - relativePath : "Documents/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { - AlertDialog.show( - { - title: '保存成功', - message: '查询到Documents路径下新增一个.Pdf格式的文件资源,资源内容为“hello world”', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed callbacks') - } - } - ) - console.log(TAG + "files resources stored. "+ JSON.stringify(value)); - }).catch((err) => { - console.log(TAG + "An error occurred when storing files resources."+ JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise5.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise5.ets deleted file mode 100644 index d949690565d6388751dd002213707569236c171e..0000000000000000000000000000000000000000 --- a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise5.ets +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary'; -import fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import {CustomContainer} from '../common/MediaCustomContainer'; -import FirstDialog from '../model/FirstDialog'; -@Entry -@Component -struct SetCircle { - @State FillColor: string = '#FF000000'; - @State name: string = 'storeMediaAssetPromise5'; - @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:保存图片失败'; - async aboutToAppear(){ - await FirstDialog.ChooseDialog(this.StepTips,this.name); - } - @Builder specificNoParam() { - Column() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) - .onClick(async () => { - let TAG = 'storeMediaAssetPromise5'; - let data = await globalThis.abilityContext.getFilesDir(); - let time = new Date().getTime(); - console.log("data is"+ JSON.stringify(data)); - data = 'data/storage/el2/base/haps/entry'; - let JpgPath = data + "/files/"+time + ".jpg"; - - let srcFd =await fileio.open(JpgPath,0o102,0o0600); - await fileio.write(srcFd,"hello world"); - await fileio.close(srcFd); - - let option = { - src : JpgPath, - mimeType : "123", - relativePath : "Pictures/" - }; - mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { - console.log(TAG + "image resources stored. "+ JSON.stringify(value)); - }).catch((err) => { - AlertDialog.show( - { - title: '保存失败', - message: '媒体MIME类型错误', - confirm: { - value: 'OK', - action: () => { - console.info(TAG + 'Button-clicking callback') - } - }, - cancel: () => { - console.info(TAG + 'Closed callbacks') - } - } - ) - console.log(TAG + "An error occurred when storing image resources."+ JSON.stringify(err)); - }); - }) - } - }.width('100%').height('80%').backgroundColor(Color.White) - } - build() { - Column() { - CustomContainer({ - title: this.name, - Url:'pages/MediaLibrary/MediaLibrary_index', - StepTips:this.StepTips, - content: this.specificNoParam, - FillColor:$FillColor, - name:$name - }) - }.width('100%').height('100%').backgroundColor(Color.Black) - } -} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Player/Player_index.ets b/validator/acts_validator/src/main/ets/pages/Player/Player_index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cec40ee45bcc62d6e5022544bc9da116c8c089a6 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Player/Player_index.ets @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2022-2023 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 prompt from '@ohos.prompt'; +import router from '@ohos.router'; +import fileio from '@ohos.fileio'; +import xml from '@ohos.xml'; +import fileIO from '@ohos.fileio'; +import util from '@ohos.util'; +import data_preferences from '@ohos.data.preferences'; + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1 = path + '/Player'; + +let VarColor = []; +let ColorBackPath = path + '/PlayerColorBack.txt'; +let txtPath = path1 + 'PlayerReport.txt'; +let xmlPath =path1 + 'PlayerTest.xml'; + +@Entry +@Component +struct IndexPage { + @State ClearAll : boolean = false; + private current : number = undefined; + @State count : number = 0; + @State result : string = ''; + @State TEST : number = 0; + private TestCaseList = [ + {title:'ScrollingList',uri:'pages/Player/ScrollListTest'}, + ] + @State ColorObject : string[] = VarColor; + async onPageShow(){ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Player', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'Player'. Data: " + data); + }); + + if(Test != 1) { + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + fileio.closeSync(fd); + } + promise = preferences.put('Player', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'Player'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + this.TEST = Test; + + let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664); + let buff = new ArrayBuffer(40960); + fileio.readSync(opt,buff); + let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff)); + let TestList = ColorBack.split(';'); + for (let i = 0; i < Math.floor(TestList.length / 2); i++) { + VarColor[i] = TestList[i*2+1]; + } + fileio.closeSync(opt); + + if (this.count === 1){ + this.result = router.getParams()['result']; + let titles = router.getParams()['title']; + let name1 = '刚刚点进了哪个用例:'+ titles; + let results = this.result; + let WriteTitle = (titles).toString(); + let number = WriteTitle.length + 11; + let Index = ColorBack.indexOf(WriteTitle); + + if (this.result === 'Pass'){ + this.ColorObject[this.current] = '#ff008000'; + let Log = (titles+';'+'#ff008000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles) + } + else if (this.result === 'Fail'){ + this.ColorObject[this.current] = '#ffff0000'; + let Log = (titles+';'+'#ffff0000'+';'); + let key = ColorBack.substring(Index,Index+number); + let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); + ColorBack = ColorBack.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = ColorBack.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + filewrite(name1,results,titles); + } + else if (this.result === 'None'){ + this.ColorObject[this.current] = this.ColorObject[this.current]; + } + } + } + build(){ + Column(){ + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black) + .onClick(() => { + router.back(); + }) + Row(){ + Text('Player SubSystem') + .fontColor(Color.White) + .fontSize('22fp') + }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) + Row() { + Button(){ + Image($r('app.media.ic_public_delete')) + .width('30vp') + .height('30vp') + }.backgroundColor(Color.Black) + .onClick(() => { + AlertDialog.show( + { + message: "是否删除所有记录", + primaryButton: { + value: 'Yes', + action: () => { + this.ClearAll = true; + this.ColorObject.forEach((value, index) => { + this.ColorObject[index] = '#ff808080'; + }); + this.ClearText(); + prompt.showToast({ + message: '结果已删除', duration: 1000 + }); + } + }, + secondaryButton: { + value: 'No', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + }) + Button(){ + Image($r('app.media.ic_public_save')) + .width('30vp') + .height('30vp') + .margin({ left: 30 }) + }.backgroundColor(Color.Black) + .onClick(() => { + this.ReadTextParseXml(); + AlertDialog.show({ + message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/Player/PlayerTest.xml -本地路径'", + confirm:{ + value:'OK', + action:()=>{ + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }, + cancel: () => { + prompt.showToast({ + message: '报告已生成', duration: 1000 + }); + } + }) + }) + } + }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) + List({space:5}){ + ForEach(this.TestCaseList,(item,index) => { + ListItem(){ + Row(){ + Text(item.title).fontSize(16).fontColor(Color.Black) + }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) + .onClick(( )=>{ + this.count = 1; + this.ClearAll=false; + this.current = index; + router.push({ + url: item.uri, + }) + }) + } + },item => item.title) + }.width('100%').height('92%') + }.width('100%').height('100%').backgroundColor(Color.Black) + } + ClearText(){ + fileio.rmdirSync(path1); + fileio.mkdirSync(path1); + let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); + for(let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); + fileio.writeSync(fd,log); + } + } + ReadTextParseXml(){ + let ReportPath = path1 + '/PlayerReport.txt'; + let dir = fileio.opendirSync(path1); + console.info("ssssss"+dir); + while (dir) { + let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(40960); + let RD = fileio.readSync(OP,buf); + console.info("ddddd"+RD); + let report; + function ab2str(buf) { + return report = String.fromCharCode.apply(null,new Uint8Array(buf)); + } + ab2str(buf); + let str1 = report.split(";"); + let title = []; + let result = []; + for(let i=0; i { + ListItem() { + Text('Item #' + (index + 1)).width('100%').height(50).fontSize(16).fontColor(Color.White).margin({left:'10vp'}) + } + },index => index) + }.height('100%').width('100%').divider({strokeWidth:1,color:Color.Grey}) + }.height('83%').width('100%') + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/Player/Player_index', + StepTips: this.StepTips, + content: this.specificNoParam.bind(this), + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/common/CameraOrientation.ets b/validator/acts_validator/src/main/ets/pages/common/CameraOrientation.ets new file mode 100644 index 0000000000000000000000000000000000000000..44fb1188ed18a138be2b74c2ace6a2979cd8eb00 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CameraOrientation.ets @@ -0,0 +1,165 @@ +/* + * 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 fileio from '@ohos.fileio'; +import prompt from '@ohos.prompt'; +import router from '@ohos.router'; +import screenshot from '@ohos.screenshot'; +import image from '@ohos.multimedia.image'; +import Logger from '../model/Logger'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; + +let path = globalThis.dir; +const TAG = '[Screenshot]'; +@Component +export struct CustomContainer { + @Link FillColor: string; + @Link name: string; + @Link Vue : boolean; + Url : string = ''; + title : string = ''; + StepTips: string = ''; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None',} + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} diff --git a/validator/acts_validator/src/main/ets/pages/index.ets b/validator/acts_validator/src/main/ets/pages/index.ets index 5c402903b97430dc4d87a0de3a3b3f1918f216ed..2bf81aa2d17758a1ca5fcd48116cf71ba7ee7488 100644 --- a/validator/acts_validator/src/main/ets/pages/index.ets +++ b/validator/acts_validator/src/main/ets/pages/index.ets @@ -18,35 +18,89 @@ import fileio from '@ohos.fileio'; import xml from '@ohos.xml'; import fileIO from '@ohos.fileio'; import util from '@ohos.util'; -import DateTimeUtil from './model/DateTimeUtil' +import DateTimeUtil from './model/DateTimeUtil'; +import data_preferences from '@ohos.data.preferences'; +import FlushData from '../pages/model/FlushData' const TAG = 'ParseXML'; let path=globalThis.dir; -let path1; -let path2; -console.info("ssssssssss"+path); -path1 = path + '/ArkUI'; -console.info("ssssssssss"+path1); -path2 = path + '/MediaLibrary'; -console.info("ssssssssss"+path2); -fileio.rmdirSync(path); -fileio.mkdirSync(path); -fileio.mkdirSync(path1); -fileio.mkdirSync(path2); +let path1 = path + '/ArkUI'; +let path2 = path + '/Audio'; +let path3 = path + '/Camera'; +let path4 = path + '/Player'; +let path5 = path + '/Experience'; +let ArkUIColorBackPath = path + '/ArkUIColorBack.txt'; +let AudioColorBackPath = path + '/AudioColorBack.txt'; +let CameraColorBackPath = path + '/CameraColorBack.txt'; +let PlayerColorBackPath = path + '/PlayerColorBack.txt'; +let ExperienceColorBackPath = path + '/ExperienceColorBack.txt'; +fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664); +fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664); +fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664); +fileio.openSync(PlayerColorBackPath, 0o100 | 0o2002, 0o664); +fileio.openSync(ExperienceColorBackPath, 0o100 | 0o2002, 0o664); +let TimePath = path + '/Time.txt'; +fileio.openSync(TimePath, 0o100 | 0o2002, 0o664); +let xmlPath = path + '/Test.xml'; +fileio.openSync(xmlPath, 0o100 | 0o2002, 0o664); +let path11 = path1 + '/ArkUIReport.txt'; +let path22 = path2 + '/AudioReport.txt'; +let path33 = path3 + '/CameraReport.txt'; +let path44 = path4 + '/PlayerReport.txt'; +let path55 = path5 + '/ExperienceReport.txt'; @Entry @Component struct IndexPage { private TestCaseList = [ {title:'ArkUI',uri:'pages/ArkUI/ArkUI_index'}, - {title:'MediaLibrary',uri:'pages/MediaLibrary/MediaLibrary_index'}, + {title:'Audio',uri:'pages/Audio/Audio_index'}, {title:'Camera',uri:'pages/Camera/Camera_index'}, + {title:'Player',uri:'pages/Player/Player_index'}, + {title:'Experience',uri:'pages/Experience/Experience_index'}, ] - @State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080'] + @State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080'] + async onPageShow(){ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('index', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'index'. Data: " + data); + }); + if(Test != 1) { + fileio.mkdirSync(path1); + fileio.mkdirSync(path2); + fileio.mkdirSync(path3); + fileio.mkdirSync(path4); + fileio.mkdirSync(path5); + + let promise = preferences.put('index', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'index'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } + fileio.openSync(path11, 0o100 | 0o2002, 0o664); + fileio.openSync(path22, 0o100 | 0o2002, 0o664); + fileio.openSync(path33, 0o100 | 0o2002, 0o664); + fileio.openSync(path44, 0o100 | 0o2002, 0o664); + fileio.openSync(path55, 0o100 | 0o2002, 0o664); + } build(){ Column(){ Row() { - Text('ActValidator') + Text('ActsValidator') .fontColor(Color.White) .fontSize('22fp') Row() { @@ -118,7 +172,7 @@ struct IndexPage { url: item.uri, }) let dateTimeUtil = new DateTimeUtil(); - let time = `${dateTimeUtil.getFullYear()}-${dateTimeUtil.getMonth()}-${dateTimeUtil.getDate()} ${dateTimeUtil.getHour()}:${dateTimeUtil.getMinute()}:${dateTimeUtil.getSecond()}`; + let time = `${dateTimeUtil.getFullYear()}-${dateTimeUtil.getMonth()}-${dateTimeUtil.getDay()} ${dateTimeUtil.getHour()}:${dateTimeUtil.getMinute()}:${dateTimeUtil.getSecond()}`; let TimePath = path + "/Time.txt"; let OP = fileio.openSync(TimePath, 0o100 | 0o2002, 0o664); let buf = new ArrayBuffer(4096); @@ -132,34 +186,57 @@ struct IndexPage { }.width('100%').height('100%').backgroundColor(Color.Black) } ClearText(){ - fileio.rmdirSync(path); - fileio.mkdirSync(path); - fileio.mkdirSync(path1); - fileio.mkdirSync(path2); + fileio.unlinkSync(TimePath); + fileio.unlinkSync(xmlPath); + fileio.unlinkSync(path11); + fileio.unlinkSync(path22); + fileio.unlinkSync(path33); + fileio.unlinkSync(path44); + fileio.unlinkSync(path55); + fileio.unlinkSync(ArkUIColorBackPath); + fileio.unlinkSync(AudioColorBackPath); + fileio.unlinkSync(CameraColorBackPath); + fileio.unlinkSync(PlayerColorBackPath); + fileio.unlinkSync(ExperienceColorBackPath); + fileio.openSync(TimePath, 0o100 | 0o2002, 0o664); + fileio.openSync(xmlPath, 0o100 | 0o2002, 0o664); + fileio.openSync(path11, 0o100 | 0o2002, 0o664); + fileio.openSync(path22, 0o100 | 0o2002, 0o664); + fileio.openSync(path33, 0o100 | 0o2002, 0o664); + fileio.openSync(path44, 0o100 | 0o2002, 0o664); + fileio.openSync(path55, 0o100 | 0o2002, 0o664); + fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664); + fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664); + fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664); + fileio.openSync(PlayerColorBackPath, 0o100 | 0o2002, 0o664); + fileio.openSync(ExperienceColorBackPath, 0o100 | 0o2002, 0o664); + FlushData.ResetArkUI(); + FlushData.ResetAudio(); + FlushData.ResetCamera(); + FlushData.ResetPlayer(); + FlushData.ResetExperience(); } SaveXml() { let dateTimeUtil = new DateTimeUtil(); - let endtime = `${dateTimeUtil.getFullYear()}-${dateTimeUtil.getMonth()}-${dateTimeUtil.getDate()} ${dateTimeUtil.getHour()}:${dateTimeUtil.getMinute()}:${dateTimeUtil.getSecond()}`; - let TimePath = path + "/Time.txt"; + let endtime = `${dateTimeUtil.getFullYear()}-${dateTimeUtil.getMonth()}-${dateTimeUtil.getDay()} ${dateTimeUtil.getHour()}:${dateTimeUtil.getMinute()}:${dateTimeUtil.getSecond()}`; let fd = fileio.openSync(TimePath, 0o100 | 0o2002, 0o664); let buf = new ArrayBuffer(40960); fileio.readSync(fd,buf); let StartTime = String.fromCharCode.apply(null, new Uint8Array(buf)); let Index = StartTime.indexOf(';'); let starttime = StartTime.substring(0,Index); - - let path11 = path1 + '/ArkUI.txt'; - let path22 = path2 + '/MediaLibrary.txt'; + let ArkUIReport; + let AudioReport; + let CameraReport; + let PlayerReport; + let ExperienceReport; + /* + * ArkUI + */ let OP1 = fileio.openSync(path11, 0o100 | 0o2002, 0o664); let buf1 = new ArrayBuffer(40960); fileio.readSync(OP1,buf1); - let ArkUIReport; - let MediaLibraryReport; - - function ab2str1(buf1) { - return ArkUIReport = String.fromCharCode.apply(null, new Uint8Array(buf1)); - } - ab2str1(buf1); + ArkUIReport = String.fromCharCode.apply(null, new Uint8Array(buf1)); let str1 = ArkUIReport.split(";"); let title1 = []; let result1 = []; @@ -167,23 +244,64 @@ struct IndexPage { title1[i] = str1[i * 2]; result1[i] = str1[i * 2 + 1]; } - + /* + * Audio + */ let OP2 = fileio.openSync(path22, 0o100 | 0o2002, 0o664); let buf2 = new ArrayBuffer(40960); fileio.readSync(OP2,buf2); - function ab2str2(buf2) { - return MediaLibraryReport = String.fromCharCode.apply(null, new Uint8Array(buf2)); - } - ab2str2(buf2); - let str2 = MediaLibraryReport.split(";"); + AudioReport = String.fromCharCode.apply(null, new Uint8Array(buf2)); + let str2 = AudioReport.split(";"); let title2 = []; let result2 = []; for (let i = 0; i < Math.floor(str2.length / 2); i++) { title2[i] = str2[i * 2]; result2[i] = str2[i * 2 + 1]; } + /* + * Camera + */ + let OP3 = fileio.openSync(path33, 0o100 | 0o2002, 0o664); + let buf3 = new ArrayBuffer(40960); + fileio.readSync(OP3,buf3); + CameraReport = String.fromCharCode.apply(null, new Uint8Array(buf3)); + let str3 = CameraReport.split(";"); + let title3 = []; + let result3 = []; + for (let i = 0; i < Math.floor(str3.length / 2); i++) { + title3[i] = str3[i * 2]; + result3[i] = str3[i * 2 + 1]; + } + /* + * Player + */ + let OP4 = fileio.openSync(path44, 0o100 | 0o2002, 0o664); + let buf4 = new ArrayBuffer(40960); + fileio.readSync(OP4,buf4); + PlayerReport = String.fromCharCode.apply(null, new Uint8Array(buf4)); + let str4 = PlayerReport.split(";"); + let title4 = []; + let result4 = []; + for (let i = 0; i < Math.floor(str4.length / 2); i++) { + title4[i] = str4[i * 2]; + result4[i] = str4[i * 2 + 1]; + } + /* + * Experience + */ + let OP5 = fileio.openSync(path55, 0o100 | 0o2002, 0o664); + let buf5 = new ArrayBuffer(40960); + fileio.readSync(OP5,buf5); + ExperienceReport = String.fromCharCode.apply(null, new Uint8Array(buf5)); + let str5 = ExperienceReport.split(";"); + let title5 = []; + let result5 = []; + for (let i = 0; i < Math.floor(str5.length / 2); i++) { + title5[i] = str5[i * 2]; + result5[i] = str5[i * 2 + 1]; + } - let report = ArkUIReport + MediaLibraryReport; + let report = ArkUIReport + AudioReport + CameraReport + PlayerReport + ExperienceReport; let FailIndex = report.indexOf('Fail'); let FailNum = 0; while(FailIndex != -1) { @@ -201,8 +319,10 @@ struct IndexPage { } let TestNum = FailNum + PassNum; let testNum = (TestNum).toString(); - let ignoreNum = (52-TestNum).toString(); - + let ignoreNum = (54-TestNum).toString(); + /* + * ArkUI + */ let ArkUIFailIndex = ArkUIReport.indexOf('Fail'); let ArkUIFailNum = 0; while (ArkUIFailIndex != -1) { @@ -220,26 +340,91 @@ struct IndexPage { } let ArkUITestNum = ArkUIFailNum + ArkUIPassNum; let ArkuiTestNum = (ArkUIPassNum).toString(); - let ArkUIIgnoreNum = (24-ArkUITestNum).toString(); - - let MediaLibraryFailIndex = MediaLibraryReport.indexOf('Fail'); - let MediaLibraryFailNum = 0; - while (MediaLibraryFailIndex != -1) { - console.log(MediaLibraryFailIndex); - MediaLibraryFailNum++; - MediaLibraryFailIndex = MediaLibraryReport.indexOf('Fail',MediaLibraryFailIndex + 1); + let ArkUIIgnoreNum = (23-ArkUITestNum).toString(); + /* + * Audio + */ + let AudioFailIndex = AudioReport.indexOf('Fail'); + let AudioFailNum = 0; + while (AudioFailIndex != -1) { + console.log(AudioFailIndex); + AudioFailNum++; + AudioFailIndex = AudioReport.indexOf('Fail',AudioFailIndex + 1); } - let medialibraryFailNum = (MediaLibraryFailNum).toString(); - let MediaLibraryPassIndex = MediaLibraryReport.indexOf('Pass'); - let MediaLibraryPassNum = 0; - while (MediaLibraryPassIndex != -1) { - console.log(MediaLibraryPassIndex); - MediaLibraryPassNum++; - MediaLibraryPassIndex = MediaLibraryReport.indexOf('Pass',MediaLibraryPassIndex + 1); + let audioFailNum = (AudioFailNum).toString(); + let AudioPassIndex = AudioReport.indexOf('Pass'); + let AudioPassNum = 0; + while (AudioPassIndex != -1) { + console.log(AudioPassIndex); + AudioPassNum++; + AudioPassIndex = AudioReport.indexOf('Pass',AudioPassIndex + 1); } - let MediaLibraryTestNum = MediaLibraryFailNum + MediaLibraryPassNum; - let medialibraryTestNum = (MediaLibraryPassNum).toString(); - let MediaLibraryIgnoreNum = (28-MediaLibraryTestNum).toString(); + let AudioTestNum = AudioFailNum + AudioPassNum; + let audioTestNum = (AudioPassNum).toString(); + let AudioIgnoreNum = (28-AudioTestNum).toString(); + /* + * Camera + */ + let CameraFailIndex = CameraReport.indexOf('Fail'); + let CameraFailNum = 0; + while (CameraFailIndex != -1) { + console.log(CameraFailIndex); + CameraFailNum++; + CameraFailIndex = CameraReport.indexOf('Fail',CameraFailIndex + 1); + } + let cameraFailNum = (CameraFailNum).toString(); + let CameraPassIndex = CameraReport.indexOf('Pass'); + let CameraPassNum = 0; + while (CameraPassIndex != -1) { + console.log(CameraPassIndex); + CameraPassNum++; + CameraPassIndex = CameraReport.indexOf('Pass',CameraPassIndex + 1); + } + let CameraTestNum = CameraFailNum + CameraPassNum; + let cameraTestNum = (CameraPassNum).toString(); + let CameraIgnoreNum = (28-CameraTestNum).toString(); + /* + * Player + */ + let PlayerFailIndex = PlayerReport.indexOf('Fail'); + let PlayerFailNum = 0; + while (PlayerFailIndex != -1) { + console.log(PlayerFailIndex); + PlayerFailNum++; + PlayerFailIndex = PlayerReport.indexOf('Fail',PlayerFailIndex + 1); + } + let playerFailNum = (PlayerFailNum).toString(); + let PlayerPassIndex = PlayerReport.indexOf('Pass'); + let PlayerPassNum = 0; + while (PlayerPassIndex != -1) { + console.log(PlayerPassIndex); + PlayerPassNum++; + PlayerPassIndex = PlayerReport.indexOf('Pass',PlayerPassIndex + 1); + } + let PlayerTestNum = PlayerFailNum + PlayerPassNum; + let playerTestNum = (PlayerPassNum).toString(); + let PlayerIgnoreNum = (28-PlayerTestNum).toString(); + /* +* Experience +*/ + let ExperienceFailIndex = ExperienceReport.indexOf('Fail'); + let ExperienceFailNum = 0; + while (ExperienceFailIndex != -1) { + console.log(ExperienceFailIndex); + ExperienceFailNum++; + ExperienceFailIndex = ExperienceReport.indexOf('Fail',ExperienceFailIndex + 1); + } + let experienceFailNum = (ExperienceFailNum).toString(); + let ExperiencePassIndex = ExperienceReport.indexOf('Pass'); + let ExperiencePassNum = 0; + while (ExperiencePassIndex != -1) { + console.log(ExperiencePassIndex); + ExperiencePassNum++; + ExperiencePassIndex = ExperienceReport.indexOf('Pass',ExperiencePassIndex + 1); + } + let ExperienceTestNum = ExperienceFailNum + ExperiencePassNum; + let experienceTestNum = (ExperiencePassNum).toString(); + let ExperienceIgnoreNum = (28-ExperienceTestNum).toString(); let arrayBuffer = new ArrayBuffer(40960); let bufView = new DataView(arrayBuffer); @@ -258,6 +443,9 @@ struct IndexPage { serializer.setAttributes("productinfo", "{ }"); serializer.setAttributes("modules", " "); serializer.setAttributes("runmodules", " "); + /* + * ArkUI + */ serializer.startElement("testsuite"); serializer.setAttributes("name", "ActsArkUITest"); serializer.setAttributes("time", " "); @@ -280,17 +468,19 @@ struct IndexPage { serializer.endElement(); } serializer.endElement(); - + /* + * Audio + */ serializer.startElement("testsuite"); - serializer.setAttributes("name", "ActsMediaLibraryTest"); + serializer.setAttributes("name", "ActsAudioTest"); serializer.setAttributes("time", " "); serializer.setAttributes("errors", "0"); serializer.setAttributes("disabled", "0"); - serializer.setAttributes("failures", medialibraryFailNum); - serializer.setAttributes("ignored", MediaLibraryIgnoreNum); - serializer.setAttributes("tests", medialibraryTestNum); + serializer.setAttributes("failures", audioFailNum); + serializer.setAttributes("ignored", AudioIgnoreNum); + serializer.setAttributes("tests", audioTestNum); serializer.setAttributes("message", " "); - serializer.setAttributes("modulename", "ActsMediaLibraryTest"); + serializer.setAttributes("modulename", "ActsAudioTest"); for (let i = 0; i < title2.length; i++) { serializer.startElement("testcase"); serializer.setAttributes("name", String(title2[i])); @@ -303,12 +493,86 @@ struct IndexPage { serializer.endElement(); } serializer.endElement(); + /* + * Camera + */ + serializer.startElement("testsuite"); + serializer.setAttributes("name", "ActsCameraTest"); + serializer.setAttributes("time", " "); + serializer.setAttributes("errors", "0"); + serializer.setAttributes("disabled", "0"); + serializer.setAttributes("failures", cameraFailNum); + serializer.setAttributes("ignored", CameraIgnoreNum); + serializer.setAttributes("tests", cameraTestNum); + serializer.setAttributes("message", " "); + serializer.setAttributes("modulename", "ActsCameraTest"); + for (let i = 0; i < title2.length; i++) { + serializer.startElement("testcase"); + serializer.setAttributes("name", String(title3[i])); + serializer.setAttributes("status", " "); + serializer.setAttributes("time", " "); + serializer.setAttributes("classname", " "); + serializer.setAttributes("result", String(result3[i])); + serializer.setAttributes("level", " "); + serializer.setAttributes("message", " "); + serializer.endElement(); + } + serializer.endElement(); + /* + * Player + */ + serializer.startElement("testsuite"); + serializer.setAttributes("name", "ActsPlayerTest"); + serializer.setAttributes("time", " "); + serializer.setAttributes("errors", "0"); + serializer.setAttributes("disabled", "0"); + serializer.setAttributes("failures", playerFailNum); + serializer.setAttributes("ignored", PlayerIgnoreNum); + serializer.setAttributes("tests", playerTestNum); + serializer.setAttributes("message", " "); + serializer.setAttributes("modulename", "ActsPlayerTest"); + for (let i = 0; i < title2.length; i++) { + serializer.startElement("testcase"); + serializer.setAttributes("name", String(title4[i])); + serializer.setAttributes("status", " "); + serializer.setAttributes("time", " "); + serializer.setAttributes("classname", " "); + serializer.setAttributes("result", String(result4[i])); + serializer.setAttributes("level", " "); + serializer.setAttributes("message", " "); + serializer.endElement(); + } + serializer.endElement(); + /* +* Experience +*/ + serializer.startElement("testsuite"); + serializer.setAttributes("name", "ActsExperienceTest"); + serializer.setAttributes("time", " "); + serializer.setAttributes("errors", "0"); + serializer.setAttributes("disabled", "0"); + serializer.setAttributes("failures", experienceFailNum); + serializer.setAttributes("ignored", ExperienceIgnoreNum); + serializer.setAttributes("tests", experienceTestNum); + serializer.setAttributes("message", " "); + serializer.setAttributes("modulename", "ActsExperienceTest"); + for (let i = 0; i < title2.length; i++) { + serializer.startElement("testcase"); + serializer.setAttributes("name", String(title5[i])); + serializer.setAttributes("status", " "); + serializer.setAttributes("time", " "); + serializer.setAttributes("classname", " "); + serializer.setAttributes("result", String(result5[i])); + serializer.setAttributes("level", " "); + serializer.setAttributes("message", " "); + serializer.endElement(); + } + serializer.endElement(); serializer.endElement(); let that = new util.TextDecoder('utf-8'); let array = new Uint8Array(arrayBuffer); let serializerStr = that.decode(array); - let xmlPath = path + "/Test.xml"; console.info(xmlPath); try { console.error(TAG, "write xmlPath =" + xmlPath); diff --git a/validator/acts_validator/src/main/ets/pages/model/CameraService.ts b/validator/acts_validator/src/main/ets/pages/model/CameraService.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7326f767ae27d1070c7bc5346f8d5ef6097a66b --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/model/CameraService.ts @@ -0,0 +1,326 @@ +/* + * 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 camera from '@ohos.multimedia.camera' +import deviceInfo from '@ohos.deviceInfo' +import fileio from '@ohos.fileio' +import image from '@ohos.multimedia.image' +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' +import Logger from '../model/Logger' +import MediaUtils from '../model/MediaUtils' + +const CameraMode = { + MODE_PHOTO: 0, // 拍照模式 + MODE_VIDEO: 1 // 录像模式 +} + +//const CameraSize = { +// WIDTH: 1280, +// HEIGHT: 960 +//} +const CameraSize = { + WIDTH: 4096, + HEIGHT: 3072 +} + +class CameraService { + private tag: string = 'qlw CameraService' + private static instance: CameraService = new CameraService() + private mediaUtil = MediaUtils.getInstance() + private cameraManager: camera.CameraManager = undefined + private cameras: Array = undefined + private cameraOutputCapability: camera.CameraOutputCapability = undefined + private cameraId: string = '' + private cameraInput: camera.CameraInput = undefined + private previewOutput: camera.PreviewOutput = undefined + private photoOutPut: camera.PhotoOutput = undefined + private captureSession: camera.CaptureSession = undefined + private mReceiver: image.ImageReceiver = undefined + private photoUri: string = '' + private fileAsset: mediaLibrary.FileAsset = undefined + private fd: number = -1 + private curMode = CameraMode.MODE_PHOTO + private videoRecorder: media.VideoRecorder = undefined + private videoOutput: camera.VideoOutput = undefined + private handleTakePicture: (photoUri: string) => void = undefined + private mirrorValue: boolean = false + private videoConfig: any = { + audioSourceType: 1, + videoSourceType: 0, + profile: { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4v-es', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', +// videoFrameWidth: globalThis.videoSize.width, +// videoFrameHeight: globalThis.videoSize.height, + videoFrameWidth: 176, + videoFrameHeight: 144, + videoFrameRate: 30 + }, + url: '', + orientationHint: 0, + location: { latitude: 30, longitude: 130 }, + maxSize: 10000, + maxDuration: 10000 + } + + constructor() { + this.mReceiver = image.createImageReceiver(CameraSize.WIDTH, CameraSize.HEIGHT, image.ImageFormat.JPEG, 8) + Logger.info(this.tag, 'createImageReceiver') + this.mReceiver.on('imageArrival', () => { + Logger.info(this.tag, 'imageArrival') + this.mReceiver.readNextImage((err, image) => { + Logger.info(this.tag, 'readNextImage') + if (err || image === undefined) { + Logger.error(this.tag, 'failed to get valid image') + return + } + image.getComponent(4, (errMsg, img) => { + Logger.info(this.tag, 'getComponent') + if (errMsg || img === undefined) { + Logger.info(this.tag, 'failed to get valid buffer') + return + } + let buffer + if (img.byteBuffer) { + buffer = img.byteBuffer + } else { + Logger.error(this.tag, 'img.byteBuffer is undefined') + } + this.savePicture(buffer, image) + }) + }) + }) + } + + async savePicture(buffer: ArrayBuffer, img: image.Image) { + Logger.info(this.tag, 'savePicture') + this.fileAsset = await this.mediaUtil.createAndGetUri(mediaLibrary.MediaType.IMAGE) + this.photoUri = this.fileAsset.uri + Logger.info(this.tag, `this.photoUri = ${this.photoUri}`) + this.fd = await this.mediaUtil.getFdPath(this.fileAsset) + Logger.info(this.tag, `this.fd = ${this.fd}`) + await fileio.write(this.fd, buffer) + await this.fileAsset.close(this.fd) + await img.release() + Logger.info(this.tag, 'save image done') + if (this.handleTakePicture) { + this.handleTakePicture(this.photoUri) + } + } + + async initCamera(surfaceId: number, cameraDeviceIndex: number) { + try{ + Logger.info(this.tag, 'initCamera') + if (this.curMode === CameraMode.MODE_VIDEO) { + await this.releaseCamera() + } + if (this.curMode === CameraMode.MODE_PHOTO) { + await this.releasePhotoCamera() + } + Logger.info(this.tag, `deviceInfo.deviceType = ${deviceInfo.deviceType}`) + if (deviceInfo.deviceType === 'default') { + this.videoConfig.videoSourceType = 1 + } else { + this.videoConfig.videoSourceType = 0 + } + this.cameraManager = await camera.getCameraManager(globalThis.abilityContext) + Logger.info(this.tag, 'getCameraManager') + this.cameras = await this.cameraManager.getSupportedCameras() + Logger.info(this.tag, `get cameras ${this.cameras.length}`) + if (this.cameras.length === 0) { + Logger.info(this.tag, 'cannot get cameras') + return + } + this.cameraInput = await this.cameraManager.createCameraInput(this.cameras[cameraDeviceIndex]) + await this.cameraInput.open((err) => { + if(err){ + Logger.info(this.tag, `cameraInput open Failed : ${err}`) + return + } + Logger.info(this.tag, `cameraInput open success`) + }) + Logger.info(this.tag, 'createCameraInput') + this.cameraOutputCapability = await this.cameraManager.getSupportedOutputCapability(this.cameras[cameraDeviceIndex]) + Logger.info(this.tag, 'cameraOutputCapability: ' + JSON.stringify(this.cameraOutputCapability)) + Logger.info(this.tag, 'cameraOutputCapability previewProfiles: ' + JSON.stringify(this.cameraOutputCapability.previewProfiles)) + Logger.info(this.tag, 'cameraOutputCapability photoProfiles: ' + JSON.stringify(this.cameraOutputCapability.photoProfiles)) + Logger.info(this.tag, 'cameraOutputCapability videoProfiles: ' + JSON.stringify(this.cameraOutputCapability.videoProfiles)) + + this.previewOutput = await this.cameraManager.createPreviewOutput(this.cameraOutputCapability.previewProfiles[0], surfaceId.toString()) + Logger.info(this.tag, 'createPreviewOutput') + let mSurfaceId = await this.mReceiver.getReceivingSurfaceId() + this.photoOutPut = await this.cameraManager.createPhotoOutput(this.cameraOutputCapability.photoProfiles[0], (mSurfaceId)) + Logger.info(this.tag, 'createPhotoOutput') + this.captureSession = await this.cameraManager.createCaptureSession() + Logger.info(this.tag, 'createCaptureSession') + await this.captureSession.beginConfig() + Logger.info(this.tag, 'beginConfig') + await this.captureSession.addInput(this.cameraInput) + await this.captureSession.addOutput(this.previewOutput) + await this.captureSession.addOutput(this.photoOutPut) + await this.captureSession.commitConfig() + await this.captureSession.start() + Logger.info(this.tag, 'captureSession start') + }catch(err){ + Logger.info(this.tag, 'initCamera err: ' + err) + } + + } + + setTakePictureCallback(callback) { + this.handleTakePicture = callback + } + + async takePicture(rotationValue, qualityLevel) { + Logger.info(this.tag, 'takePicture') + if (this.curMode === CameraMode.MODE_VIDEO) { + this.curMode = CameraMode.MODE_PHOTO + } +// if(this.photoOutPut.isMirrorSupported()){ +// this.mirrorValue = true +// } + let photoSettings = { + rotation: rotationValue, + quality: qualityLevel, + location: { // 位置信息,经纬度 + latitude: 0, + longitude: 0, + altitude: 1000 + }, + mirror: this.mirrorValue + } + Logger.info(this.tag, JSON.stringify(photoSettings)) + try{ + await this.photoOutPut.capture(photoSettings) + }catch(err){ + Logger.info(this.tag, `takePicture err ${err.message}`) + } + + Logger.info(this.tag, 'takePicture done') + } + + async startVideo() { + try{ + Logger.info(this.tag, 'startVideo begin') + await this.captureSession.stop() + + await this.captureSession.beginConfig() + Logger.info(this.tag, 'beginConfig') + if (this.curMode === CameraMode.MODE_PHOTO) { + this.curMode = CameraMode.MODE_VIDEO + if (this.photoOutPut) { + await this.captureSession.removeOutput(this.photoOutPut) + } + } else { + if (this.videoOutput) { + await this.captureSession.removeOutput(this.videoOutput) + } + } + }catch(err){ + Logger.info(this.tag, 'startVideo err1: ' + err) + } + + this.fileAsset = await this.mediaUtil.createAndGetUri(mediaLibrary.MediaType.VIDEO) + this.fd = await this.mediaUtil.getFdPath(this.fileAsset) + this.videoRecorder = await media.createVideoRecorder() + this.videoConfig.url = `fd://${this.fd}` + await this.videoRecorder.prepare(this.videoConfig) + let videoId = await this.videoRecorder.getInputSurface() + Logger.info(this.tag, `cameraOutputCapability.videoProfiles ${this.cameraOutputCapability.videoProfiles.length}`) +// let index = 0 +// this.videoOutput = await this.cameraManager.createVideoOutput(this.cameraOutputCapability.videoProfiles[index], videoId) + + // @ts-ignore + let videoProfilesObj: camera.VideoProfile = { + "format": 1003, + "size":{ + "width": 176, + "height": 144 + }, + "frameRateRange":{ + "min": -1, + "max": 0 + } + } + try{ + this.videoOutput = await this.cameraManager.createVideoOutput(videoProfilesObj, videoId) + await this.captureSession.addOutput(this.videoOutput) + await this.captureSession.commitConfig() + Logger.info(this.tag, 'captureSession commitConfig') + await this.captureSession.start() + Logger.info(this.tag, 'captureSession start') + await this.videoOutput.start() + Logger.info(this.tag, 'videoOutput start') + await this.videoRecorder.start() + Logger.info(this.tag, 'videoRecorder start') + }catch(err){ + Logger.info(this.tag, 'startVideo err2: ' + err) + } + } + + async stopVideo() { + Logger.info(this.tag, 'stopVideo called') + await this.videoRecorder.stop() + await this.videoRecorder.release() + await this.videoOutput.stop() + await this.fileAsset.close(this.fd) + } + + async releaseCamera() { + Logger.info(this.tag, 'releaseCamera') + if (this.cameraInput) { + // @ts-ignore + await this.cameraInput.release() + } + if (this.previewOutput) { + await this.previewOutput.release() + } + if (this.photoOutPut) { + await this.photoOutPut.release() + } + if (this.videoOutput) { + await this.videoOutput.release() + } + if (this.captureSession) { + await this.captureSession.release() + } + } + + async releasePhotoCamera() { + Logger.info(this.tag, 'releaseCamera') + if (this.cameraInput) { + // @ts-ignore + await this.cameraInput.release() + } + if (this.previewOutput) { + await this.previewOutput.release() + } + if (this.photoOutPut) { + await this.photoOutPut.release() + } + if (this.captureSession) { + await this.captureSession.release() + } + } +} + +export default new CameraService() \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/model/DateTimeUtil.ts b/validator/acts_validator/src/main/ets/pages/model/DateTimeUtil.ts index 0bcf322db52b22ef28c7c824bdbef56c326279cd..31378b8f0d056b714695ec630f0e115cc002a010 100644 --- a/validator/acts_validator/src/main/ets/pages/model/DateTimeUtil.ts +++ b/validator/acts_validator/src/main/ets/pages/model/DateTimeUtil.ts @@ -21,6 +21,10 @@ export default class DateTimeUtil { /** * 时分秒 */ + getTime() { + const DATETIME = new Date() + return this.concatTime(DATETIME.getHours(), DATETIME.getMinutes(), DATETIME.getSeconds()) + } getHour() { const DATETIME = new Date() return DATETIME.getHours() @@ -37,6 +41,10 @@ export default class DateTimeUtil { /** * 年月日 */ + getDate() { + const DATETIME = new Date() + return this.concatDate(DATETIME.getFullYear(), DATETIME.getMonth() + 1, DATETIME.getDate()) + } getFullYear() { const DATETIME = new Date() return DATETIME.getFullYear() @@ -45,7 +53,7 @@ export default class DateTimeUtil { const DATETIME = new Date() return DATETIME.getMonth() + 1 } - getDate() { + getDay() { const DATETIME = new Date() return DATETIME.getDate() } diff --git a/validator/acts_validator/src/main/ets/pages/model/FlushData.ets b/validator/acts_validator/src/main/ets/pages/model/FlushData.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0fba05a050a64c49de500071c0fb96b8e142f40 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/model/FlushData.ets @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2022-2023 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 data_preferences from '@ohos.data.preferences'; + +export default class FlushData{ + static ResetArkUI = async ()=>{ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('ArkUI', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'startup'. Data: " + data); + }); + promise = preferences.put('ArkUI', 0); + promise.then(() => { + console.info("Succeeded in putting value of 'test'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } + static ResetAudio = async ()=>{ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Audio', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'Audio'. Data: " + data); + }); + promise = preferences.put('Audio', 0); + promise.then(() => { + console.info("Succeeded in putting value of 'Audio'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } + static ResetCamera = async ()=>{ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Camera', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'startup'. Data: " + data); + }); + promise = preferences.put('Camera', 0); + promise.then(() => { + console.info("Succeeded in putting value of 'test'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } + static ResetPlayer = async ()=>{ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Player', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'Player'. Data: " + data); + }); + promise = preferences.put('Player', 0); + promise.then(() => { + console.info("Succeeded in putting value of 'Player'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } + static ResetExperience = async ()=>{ + let Test = null; + let context =null; + context = globalThis.getContext(); + let preferences; + + let promise = data_preferences.getPreferences(context,'mystore'); + await promise.then((object) => { + preferences = object; + }); + promise = preferences.get('Experience', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'Experience'. Data: " + data); + }); + promise = preferences.put('Experience', 0); + promise.then(() => { + console.info("Succeeded in putting value of 'Experience'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/model/MediaUtils.ts b/validator/acts_validator/src/main/ets/pages/model/MediaUtils.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6e6bc8945b949b6692735508b7b09deb41b474d --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/model/MediaUtils.ts @@ -0,0 +1,180 @@ +/* + * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary' +import DateTimeUtil from '../model/DateTimeUtil' +import Logger from './Logger' + +export default class MediaUtils { + private tag: string = 'qlw MediaUtils' + private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext) + private static instance: MediaUtils = new MediaUtils() + + public static getInstance() { + if (this.instance === undefined) { + this.instance = new MediaUtils() + } + return this.instance + } + + async createAndGetUri(mediaType: number) { + let info = this.getInfoFromType(mediaType) + let dateTimeUtil = new DateTimeUtil() + let name = `${dateTimeUtil.getDate()}_${dateTimeUtil.getTime()}` + let displayName = `${info.prefix}${name}${info.suffix}` + Logger.info(this.tag, `displayName = ${displayName},mediaType = ${mediaType}`) + let publicPath = await this.mediaTest.getPublicDirectory(info.directory) + Logger.info(this.tag, `publicPath = ${publicPath}`) + return await this.mediaTest.createAsset(mediaType, displayName, publicPath) + } + + async queryFile(dataUri: any) { + let fileKeyObj = mediaLibrary.FileKey + if (dataUri !== undefined) { + let args = dataUri.id.toString() + let fetchOp = { + selections: `${fileKeyObj.ID}=?`, + selectionArgs: [args], + } + const fetchFileResult = await this.mediaTest.getFileAssets(fetchOp) + Logger.info(this.tag, `fetchFileResult.getCount() = ${fetchFileResult.getCount()}`) + const fileAsset = await fetchFileResult.getAllObject() + return fileAsset[0] + } + } + + async getFdPath(fileAsset: any) { + let fd = await fileAsset.open('Rw') + Logger.info(this.tag, `fd = ${fd}`) + return fd + } + + async createFile(mediaType: number) { + let dataUri = await this.createAndGetUri(mediaType) + if (dataUri) { + let fileAsset = await this.queryFile(dataUri) + if (fileAsset) { + let fd = await this.getFdPath(fileAsset) + return fd + } + } + } + + async getFileAssetsFromType(mediaType: number) { + Logger.info(this.tag, `getFileAssetsFromType,mediaType = ${mediaType}`) + let fileKeyObj = mediaLibrary.FileKey + let fetchOp = { + selections: `${fileKeyObj.MEDIA_TYPE}=?`, + selectionArgs: [`${mediaType}`], + } + const fetchFileResult = await this.mediaTest.getFileAssets(fetchOp) + Logger.info(this.tag, `getFileAssetsFromType,fetchFileResult.count = ${fetchFileResult.getCount()}`) + let fileAssets = [] + if (fetchFileResult.getCount() > 0) { + fileAssets = await fetchFileResult.getAllObject() + } + return fileAssets + } + + async getAlbums() { + Logger.info(this.tag, 'getAlbums begin') + let albums = [] + const [ files, images, videos, audios ] = await Promise.all([ + this.getFileAssetsFromType(mediaLibrary.MediaType.FILE), + this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE), + this.getFileAssetsFromType(mediaLibrary.MediaType.VIDEO), + this.getFileAssetsFromType(mediaLibrary.MediaType.AUDIO) + ]) + albums.push({ + albumName: 'Documents', count: files.length, mediaType: mediaLibrary.MediaType.FILE + }) + albums.push({ + albumName: 'Pictures', count: images.length, mediaType: mediaLibrary.MediaType.IMAGE + }) + albums.push({ + albumName: 'Videos', count: videos.length, mediaType: mediaLibrary.MediaType.VIDEO + }) + albums.push({ + albumName: 'Audios', count: audios.length, mediaType: mediaLibrary.MediaType.AUDIO + }) + return albums + } + + deleteFile(media: any) { + let uri = media.uri + Logger.info(this.tag, `deleteFile,uri = ${uri}`) + return this.mediaTest.deleteAsset(uri) + } + + onDateChange(callback: () => void) { + this.mediaTest.on('albumChange', () => { + Logger.info(this.tag, 'albumChange called') + callback() + }) + this.mediaTest.on('imageChange', () => { + Logger.info(this.tag, 'imageChange called') + callback() + }) + this.mediaTest.on('audioChange', () => { + Logger.info(this.tag, 'audioChange called') + callback() + }) + this.mediaTest.on('videoChange', () => { + Logger.info(this.tag, 'videoChange called') + callback() + }) + this.mediaTest.on('fileChange', () => { + Logger.info(this.tag, 'fileChange called') + callback() + }) + } + + offDateChange() { + this.mediaTest.off('albumChange') + this.mediaTest.off('imageChange') + this.mediaTest.off('audioChange') + this.mediaTest.off('videoChange') + this.mediaTest.off('fileChange') + } + + getInfoFromType(mediaType: number) { + let result = { + prefix: '', suffix: '', directory: 0 + } + switch (mediaType) { + case mediaLibrary.MediaType.FILE: + result.prefix = 'FILE_' + result.suffix = '.txt' + result.directory = mediaLibrary.DirectoryType.DIR_DOCUMENTS + break + case mediaLibrary.MediaType.IMAGE: + result.prefix = 'IMG_' + result.suffix = '.jpg' + result.directory = mediaLibrary.DirectoryType.DIR_IMAGE + break + case mediaLibrary.MediaType.VIDEO: + result.prefix = 'VID_' + result.suffix = '.mp4' + result.directory = mediaLibrary.DirectoryType.DIR_VIDEO + break + case mediaLibrary.MediaType.AUDIO: + result.prefix = 'AUD_' + result.suffix = '.wav' + result.directory = mediaLibrary.DirectoryType.DIR_AUDIO + break + } + return result + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/model/RecordModel.ts b/validator/acts_validator/src/main/ets/pages/model/RecordModel.ts new file mode 100644 index 0000000000000000000000000000000000000000..e5316464bd806e0c58daae2c7752648400b39dfd --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/model/RecordModel.ts @@ -0,0 +1,97 @@ +/* + * 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 media from '@ohos.multimedia.media' +import Logger from '../model/Logger' + +let audioConfig = { + audioSourceType: 1, + audioEncoder: 3, + audioEncodeBitRate: 22050, + audioSampleRate: 22050, + numberOfChannels: 2, + format: 6, + uri: '' +} + +export default class RecordModel { + private tag: string = 'qlw RecordModel' + private audioRecorder: media.AudioRecorder = undefined + + initAudioRecorder(handleStateChange: () => void) { + this.release(); + this.audioRecorder = media.createAudioRecorder() + Logger.info(this.tag, 'create audioRecorder success') + this.audioRecorder.on('prepare', () => { + Logger.info(this.tag, 'setCallback prepare case callback is called') + this.audioRecorder.start() + }) + this.audioRecorder.on('start', () => { + Logger.info(this.tag, 'setCallback start case callback is called') + handleStateChange() + }) + this.audioRecorder.on('stop', () => { + Logger.info(this.tag, 'audioRecorder stop called') + this.audioRecorder.release() + }) + this.audioRecorder.on('pause', () => { + Logger.info(this.tag, 'audioRecorder pause finish') + handleStateChange() + }) + this.audioRecorder.on('resume', () => { + Logger.info(this.tag, 'audioRecorder resume finish') + handleStateChange() + }) + } + + release() { + if (typeof (this.audioRecorder) !== `undefined`) { + Logger.info(this.tag, 'audioRecorder release') + this.audioRecorder.release() + this.audioRecorder = undefined + } + } + + startRecorder(pathName: string) { + Logger.info(this.tag, `startRecorder, pathName = ${pathName}`) + if (typeof (this.audioRecorder) !== 'undefined') { + Logger.info(this.tag, 'start prepare') + audioConfig.uri = pathName + this.audioRecorder.prepare(audioConfig) + } else { + Logger.error(this.tag, 'case failed, audioRecorder is null') + } + } + + pause() { + Logger.info(this.tag, 'audioRecorder pause called') + if (typeof (this.audioRecorder) !== `undefined`) { + this.audioRecorder.pause() + } + } + + resume() { + Logger.info(this.tag, 'audioRecorder resume called') + if (typeof (this.audioRecorder) !== `undefined`) { + this.audioRecorder.resume() + } + } + + finish() { + if (typeof (this.audioRecorder) !== `undefined`) { + this.audioRecorder.stop() + } + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/module.json b/validator/acts_validator/src/main/module.json index a5fb0097a6d4e45e824bf7b2e8c3955a730204dd..48716010dd31a879e7fb2d7f608aa2e1663e195a 100644 --- a/validator/acts_validator/src/main/module.json +++ b/validator/acts_validator/src/main/module.json @@ -13,12 +13,6 @@ "installationFree": false, "pages": "$profile:main_pages", "uiSyntax": "ets", - "metadata": [ - { - "name": "ArkTSPartialUpdate", - "value": "false" - } - ], "abilities": [ { "name": "MainAbility", @@ -50,6 +44,15 @@ }, { "name": "ohos.permission.READ_MEDIA" + }, + { + "name": "ohos.permission.INTERNET" + }, + { + "name": "ohos.permission.MEDIA_LOCATION" + }, + { + "name": "ohos.permission.CAMERA" } ] } diff --git a/validator/acts_validator/src/main/resources/base/profile/main_pages.json b/validator/acts_validator/src/main/resources/base/profile/main_pages.json index 9d09ade29223478b0274ce088aa82f4625d6a1e3..ec032756899922e9ca44d3fbfb89466a1039401b 100644 --- a/validator/acts_validator/src/main/resources/base/profile/main_pages.json +++ b/validator/acts_validator/src/main/resources/base/profile/main_pages.json @@ -23,38 +23,21 @@ "pages/ArkUI/CanvasShadowBlur", "pages/ArkUI/CanvasShadowColor", "pages/ArkUI/CanvasShadowOffsetX", - "pages/ArkUI/CanvasImageSmoothingEnabled", "pages/ArkUI/CanvasGlobalAlpha", "pages/ArkUI/CanvasLineDashOffset", "pages/ArkUI/CanvasShadowOffsetY", - "pages/MediaLibrary/MediaLibrary_index", - "pages/MediaLibrary/startImagePreviewCallback1", - "pages/MediaLibrary/startImagePreviewCallback2", - "pages/MediaLibrary/startImagePreviewCallback3", - "pages/MediaLibrary/startImagePreviewCallback4", - "pages/MediaLibrary/startImagePreviewCallback5", - "pages/MediaLibrary/startImagePreviewCallback6", - "pages/MediaLibrary/startImagePreviewCallback7", - "pages/MediaLibrary/startImagePreviewPromise1", - "pages/MediaLibrary/startImagePreviewPromise2", - "pages/MediaLibrary/startImagePreviewPromise3", - "pages/MediaLibrary/startImagePreviewPromise4", - "pages/MediaLibrary/startMediaSelectCallback1", - "pages/MediaLibrary/startMediaSelectCallback2", - "pages/MediaLibrary/startMediaSelectCallback3", - "pages/MediaLibrary/startMediaSelectCallback4", - "pages/MediaLibrary/startMediaSelectPromise1", - "pages/MediaLibrary/startMediaSelectPromise2", - "pages/MediaLibrary/startMediaSelectPromise3", - "pages/MediaLibrary/startMediaSelectPromise4", - "pages/MediaLibrary/storeMediaAssetCallback1", - "pages/MediaLibrary/storeMediaAssetCallback2", - "pages/MediaLibrary/storeMediaAssetCallback3", - "pages/MediaLibrary/storeMediaAssetCallback4", - "pages/MediaLibrary/storeMediaAssetPromise1", - "pages/MediaLibrary/storeMediaAssetPromise2", - "pages/MediaLibrary/storeMediaAssetPromise3", - "pages/MediaLibrary/storeMediaAssetPromise4", - "pages/MediaLibrary/storeMediaAssetPromise5" + "pages/Camera/Camera_index", + "pages/Camera/CameraOrientation0", + "pages/Camera/CameraOrientation90", + "pages/Camera/CameraOrientation180", + "pages/Camera/CameraOrientation270", + "pages/Camera/CameraFormat", + "pages/Camera/CameraVideo", + "pages/Audio/Audio_index", + "pages/Audio/ScrollListTest", + "pages/Player/Player_index", + "pages/Player/ScrollListTest", + "pages/Experience/Experience_index", + "pages/Experience/ScrollListTest" ] }