From 78c3aa203593d2cbc79430b6cd9b7ccbbfc2ed70 Mon Sep 17 00:00:00 2001 From: 15754133731 Date: Thu, 6 Apr 2023 16:16:54 +0800 Subject: [PATCH] =?UTF-8?q?<=E5=AA=92=E4=BD=93validatorPlayer=E4=BF=AE?= =?UTF-8?q?=E6=94=B9>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 15754133731 --- .../src/main/ets/pages/Player/PlayAudio.ets | 35 +- .../main/ets/pages/Player/PlayAudioList.ets | 317 +++++++++++++++++ .../src/main/ets/pages/Player/PlayVideo.ets | 31 +- .../main/ets/pages/Player/PlayVideoList.ets | 318 ++++++++++++++++++ .../main/ets/pages/Player/Player_index.ets | 200 ++++++----- .../src/main/ets/pages/index.ets | 20 +- .../src/main/ets/pages/model/FlushData.ets | 48 +++ .../src/main/ets/pages/model/MediaUtils.ts | 30 +- .../resources/base/profile/main_pages.json | 8 +- 9 files changed, 877 insertions(+), 130 deletions(-) create mode 100644 validator/acts_validator/src/main/ets/pages/Player/PlayAudioList.ets create mode 100644 validator/acts_validator/src/main/ets/pages/Player/PlayVideoList.ets diff --git a/validator/acts_validator/src/main/ets/pages/Player/PlayAudio.ets b/validator/acts_validator/src/main/ets/pages/Player/PlayAudio.ets index 0c53487e3..9b915b15c 100644 --- a/validator/acts_validator/src/main/ets/pages/Player/PlayAudio.ets +++ b/validator/acts_validator/src/main/ets/pages/Player/PlayAudio.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + import { CustomContainer } from '../common/AudioContainer'; import FirstDialog from '../model/FirstDialog'; import router from '@ohos.router'; @@ -21,14 +21,14 @@ import router from '@ohos.router'; @Component struct playAudio { @State FillColor: string = '#FF000000'; - @State name: string = 'PlayAudio'; + @State name: string = router.getParams()['audioTitle'] @State StepTips: string = '测试目的:用于测试音频播放暂停seek\n预期结果:音频播放暂停seek功能正常'; - private tag: string = 'qlw' - @State Vue: boolean = false - @State videoSrc: Resource = $rawfile('StarWars10s-1C-44100-2SW.wav') - @State isAutoPlay: boolean = true - @State showControls: boolean = true - controller: VideoController = new VideoController() + private tag: string = 'qlw'; + @State Vue: boolean = false; + @State audioSrc: string = router.getParams()['audioUrl']; + @State isAutoPlay: boolean = true; + @State showControls: boolean = true; + controller: VideoController = new VideoController(); async aboutToAppear() { await FirstDialog.ChooseDialog(this.StepTips, this.name); @@ -42,7 +42,7 @@ struct playAudio { }.backgroundColor(Color.Black) .onClick(() => { router.back({ - url: 'pages/Player/Player_index', + url: 'pages/Player/PlayAudioList', params: { result: 'None', } }) }) @@ -53,32 +53,33 @@ struct playAudio { Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Video({ - src: this.videoSrc, + src: this.audioSrc, controller: this.controller }) .width('100%') .height('60%') .autoPlay(this.isAutoPlay) .controls(this.showControls) - .onFinish(() => { - this.Vue = true - }) + .onFinish(() => { + this.Vue = true; + }) }.width('100%').height('80%').onClick(() => { - this.showControls = !this.showControls + this.showControls = !this.showControls; }) CustomContainer({ title: this.name, - Url: 'pages/Player/Player_index', + Url: 'pages/Player/PlayAudioList', StepTips: this.StepTips, name: $name, Vue: $Vue }).height('10%').width('100%') }.width('100%').height('100%').backgroundColor(Color.Black) } - onBackPress(){ + + onBackPress() { router.replaceUrl({ - url:'pages/Player/Player_index', + url: 'pages/Player/PlayAudioList', }) } } \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Player/PlayAudioList.ets b/validator/acts_validator/src/main/ets/pages/Player/PlayAudioList.ets new file mode 100644 index 000000000..9b67b7477 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Player/PlayAudioList.ets @@ -0,0 +1,317 @@ +/* + * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary' +import data_preferences from '@ohos.data.preferences'; +import MediaUtils from '../model/MediaUtils' + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1 = path + '/Player'; + +let VarColor = []; +let ColorBackPath = path1 + '/PlayerAudioColorBack.txt'; +let txtPath = path1 + '/PlayerAudioReport.txt'; + +@Entry +@Component +struct audioNew { + @State ClearAll: boolean = false; + @State name: string = 'PlayerAudio'; + @State Vue: boolean = false; + private current: number = undefined; + @State MediaLib: MediaUtils = new MediaUtils(); + @State count: number = 0; + @State result: string = ''; + @State TEST: number = 0; + @State Url: string = ''; + @State TestCaseList: Array = []; + @State ColorObject: string[] = VarColor; + + async aboutToAppear() { + this.getAudioData(); + } + + async getAudioData() { + this.TestCaseList = await this.MediaLib.getFileAssetsAlbum('Audios/ValidatorData/'); + } + + 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('PlayerAudio', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'PlayerAudio'. 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].displayName + ';' + '#ff808080' + ';').toString(); + fileio.writeSync(fd, log); + } + fileio.closeSync(fd); + } + promise = preferences.put('PlayerAudio', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'PlayerAudio'."); + }); + 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 === 'true') { + 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 === 'false') { + 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]; + } + } + // 所有测试项满足返回ture + let color = '#ff008000'; + let colorBol = this.ColorObject.every((item) => item === color); + this.Vue = colorBol; + } + + build() { + Column() { + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black).size({ width: '40vp', height: '30vp' }) + .onClick(() => { + router.back({ + url: 'pages/Player/Player_index', + params: { result: 'None', } + }) + }) + + Row() { + Text('Player Audio') + .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: () => { + + } + } + ) + }) + } + } + .width('100%') + .justifyContent(FlexAlign.SpaceAround) + .margin({ top: '15vp' }) + .height('6%') + .backgroundColor(Color.Black) + + List({ space: 5 }) { + ForEach(this.TestCaseList, (item: mediaLibrary.FileAsset, index) => { + ListItem() { + Row() { + Text(item.displayName).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: 'pages/Player/PlayAudio', + params: { + audioUrl: item.uri, + audioTitle: item.displayName + } + }) + }) + } + }, item => item.title) + }.width('100%').height('80%') + + Row() { + Blank() + Button() { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + } + .width('40%') + .height('30vp') + .backgroundColor(Color.Grey) + .enabled(this.Vue) + .opacity(this.Vue ? 1 : 0.4) + .onClick(() => { + router.back({ + url: 'pages/Player/Player_index', + params: { result: 'true', title: this.name, + } + }) + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + + Blank().width(40) + Button() { + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('40%').height('30vp').backgroundColor(Color.Grey) + .onClick(() => { + router.back({ + url: 'pages/Player/Player_index', + params: { result: 'false', title: this.name, + } + }) + console.log('wwwwwwwwww' + this.Url) + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + + Blank() + }.width('100%').height('14%').backgroundColor(Color.Black).justifyContent(FlexAlign.Center) + }.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].displayName + ';' + '#ff808080' + ';').toString(); + fileio.writeSync(fd, log); + } + } + + onBackPress() { + router.replaceUrl({ + url: 'pages/Player/Player_index', + }) + } +} + +function filewrite(name1, results, titles) { + 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 WriteResult = (results).toString(); + let number = WriteTitle.length + WriteResult.length + 2; + 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); + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Player/PlayVideo.ets b/validator/acts_validator/src/main/ets/pages/Player/PlayVideo.ets index ce7cfe043..5dfae64fc 100644 --- a/validator/acts_validator/src/main/ets/pages/Player/PlayVideo.ets +++ b/validator/acts_validator/src/main/ets/pages/Player/PlayVideo.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + import { CustomContainer } from '../common/AudioContainer'; import FirstDialog from '../model/FirstDialog'; @@ -22,14 +22,14 @@ import router from '@ohos.router'; @Component struct playVideo { @State FillColor: string = '#FF000000'; - @State name: string = 'PlayVideo'; + @State name: string = router.getParams()['audioTitle']; @State StepTips: string = '测试目的:用于测试视频播放暂停seek\n预期结果:视频播放暂停seek功能正常'; - private tag: string = 'qlw' - @State Vue: boolean = false - @State videoSrc: Resource = $rawfile('H264_AAC.mkv') - @State isAutoPlay: boolean = true - @State showControls: boolean = true - controller: VideoController = new VideoController() + private tag: string = 'qlw'; + @State Vue: boolean = false; + @State videoSrc: Resource = $rawfile('H264_AAC.mkv'); + @State isAutoPlay: boolean = true; + @State showControls: boolean = true; + controller: VideoController = new VideoController(); async aboutToAppear() { await FirstDialog.ChooseDialog(this.StepTips, this.name); @@ -43,7 +43,7 @@ struct playVideo { }.backgroundColor(Color.Black) .onClick(() => { router.back({ - url: 'pages/Player/Player_index', + url: 'pages/Player/PlayVideoList', params: { result: 'None', } }) }) @@ -61,25 +61,26 @@ struct playVideo { .height('60%') .autoPlay(this.isAutoPlay) .controls(this.showControls) - .onFinish(() => { - this.Vue = true - }) + .onFinish(() => { + this.Vue = true; + }) }.width('100%').height('80%').onClick(() => { this.showControls = !this.showControls }) CustomContainer({ title: this.name, - Url: 'pages/Player/Player_index', + Url: 'pages/Player/PlayVideoList', StepTips: this.StepTips, name: $name, Vue: $Vue }).height('10%').width('100%') }.width('100%').height('100%').backgroundColor(Color.Black) } - onBackPress(){ + + onBackPress() { router.replaceUrl({ - url:'pages/Player/Player_index', + url: 'pages/Player/PlayVideoList', }) } } \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/Player/PlayVideoList.ets b/validator/acts_validator/src/main/ets/pages/Player/PlayVideoList.ets new file mode 100644 index 000000000..b7fa39cfb --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/Player/PlayVideoList.ets @@ -0,0 +1,318 @@ +/* + * 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 mediaLibrary from '@ohos.multimedia.mediaLibrary' +import data_preferences from '@ohos.data.preferences'; +import MediaUtils from '../model/MediaUtils' + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1 = path + '/Player'; + +let VarColor = []; +let ColorBackPath = path1 + '/PlayerVideoColorBack.txt'; +let txtPath = path1 + '/PlayerVideoReport.txt'; + +@Entry +@Component +struct videoNew { + @State ClearAll: boolean = false; + @State name: string = 'PlayerVideo'; + @State Vue: boolean = false; + private current: number = undefined; + @State MediaLib: MediaUtils = new MediaUtils(); + @State count: number = 0; + @State result: string = ''; + @State TEST: number = 0; + @State Url: string = 'pages/Player/Player_index'; + @State TestCaseList: Array = []; + @State ColorObject: string[] = VarColor; + + async aboutToAppear() { + this.getVideoData(); + } + + async getVideoData() { + this.TestCaseList = await this.MediaLib.getFileAssetsAlbum('Videos/ValidatorData/'); + } + + 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('PlayerVideo', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'PlayerVideo'. 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].displayName + ';' + '#ff808080' + ';').toString(); + fileio.writeSync(fd, log); + } + fileio.closeSync(fd); + } + promise = preferences.put('PlayerVideo', 1); + promise.then(() => { + console.info("Succeeded in putting value of 'PlayerVideo'."); + }); + 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 === 'true') { + 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 === 'false') { + 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]; + } + } + // 所有测试项满足返回ture + let color = '#ff008000'; + let colorBol = this.ColorObject.every((item) => item === color); + this.Vue = colorBol; + } + + build() { + Column() { + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black).size({ width: '40vp', height: '30vp' }) + .onClick(() => { + router.back({ + url: 'pages/Player/Player_index', + params: { result: 'None', } + }) + }) + + Row() { + Text('Player Video') + .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: () => { + + } + } + ) + }) + + } + } + .width('100%') + .justifyContent(FlexAlign.SpaceAround) + .margin({ top: '15vp' }) + .height('6%') + .backgroundColor(Color.Black) + + List({ space: 5 }) { + ForEach(this.TestCaseList, (item: mediaLibrary.FileAsset, index) => { + ListItem() { + Row() { + Text(item.displayName).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: 'pages/Player/PlayVideo', + params: { + audioUrl: item.uri, + audioTitle: item.displayName + } + }) + }) + } + }, item => item.title) + }.width('100%').height('80%') + + Row() { + Blank() + Button({ stateEffect: this.Vue }) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + } + .width('40%') + .height('30vp') + .backgroundColor(Color.Grey) + .enabled(this.Vue) + .opacity(this.Vue ? 1 : 0.4) + .onClick(() => { + router.back({ + url: this.Url, + params: { result: 'true', title: this.name, + } + }) + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + + Blank().width(40) + Button() { + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('40%').height('30vp').backgroundColor(Color.Grey) + .onClick(() => { + router.back({ + url: this.Url, + params: { result: 'false', title: this.name, + } + }) + console.log('wwwwwwwwww' + this.Url) + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + + Blank() + }.width('100%').height('14%').backgroundColor(Color.Black).justifyContent(FlexAlign.Center) + }.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].displayName + ';' + '#ff808080' + ';').toString(); + fileio.writeSync(fd, log); + } + } + + onBackPress() { + router.replaceUrl({ + url: 'pages/Player/Player_index', + }) + } +} + +function filewrite(name1, results, titles) { + 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 WriteResult = (results).toString(); + let number = WriteTitle.length + WriteResult.length + 2; + 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); + } +} \ 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 index 45620202b..a7f3f79f4 100644 --- a/validator/acts_validator/src/main/ets/pages/Player/Player_index.ets +++ b/validator/acts_validator/src/main/ets/pages/Player/Player_index.ets @@ -20,6 +20,7 @@ import xml from '@ohos.xml'; import fileIO from '@ohos.fileio'; import util from '@ohos.util'; import data_preferences from '@ohos.data.preferences'; +import FlushData from '../model/FlushData'; const TAG = 'ParseXML'; let path = globalThis.dir; @@ -28,28 +29,29 @@ let path1 = path + '/Player'; let VarColor = []; let ColorBackPath = path + '/PlayerColorBack.txt'; let txtPath = path1 + '/PlayerReport.txt'; -let xmlPath =path1 + '/PlayerTest.xml'; +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; + @State ClearAll: boolean = false; + private current: number = undefined; + @State count: number = 0; + @State result: string = ''; + @State TEST: number = 0; private TestCaseList = [ - {title:'PlayAudio',uri:'pages/Player/PlayAudio'}, - {title:'PlayVideo',uri:'pages/Player/PlayVideo'}, + { title: 'PlayerAudio', uri: 'pages/Player/PlayAudioList' }, + { title: 'PlayerVideo', uri: 'pages/Player/PlayVideoList' }, ] - @State ColorObject : string[] = VarColor; - async onPageShow(){ + @State ColorObject: string[] = VarColor; + + async onPageShow() { let Test = null; - let context =null; + let context = null; context = globalThis.getContext(); let preferences; - let promise = data_preferences.getPreferences(context,'mystore'); + let promise = data_preferences.getPreferences(context, 'mystore'); await promise.then((object) => { preferences = object; }); @@ -59,11 +61,11 @@ struct IndexPage { console.info("Succeeded in getting value of 'Player'. Data: " + data); }); - if(Test != 1) { + 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); + for (let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title + ';' + '#ff808080' + ';').toString(); + fileio.writeSync(fd, log); } fileio.closeSync(fd); } @@ -79,58 +81,60 @@ struct IndexPage { let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664); let buff = new ArrayBuffer(40960); - fileio.readSync(opt,buff); + 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]; + VarColor[i] = TestList[i * 2+1]; } fileio.closeSync(opt); - if (this.count === 1){ + if (this.count === 1) { + this.result = router.getParams()['result']; let titles = router.getParams()['title']; - let name1 = '刚刚点进了哪个用例:'+ titles; + let name1 = '刚刚点进了哪个用例:' + titles; let results = this.result; let WriteTitle = (titles).toString(); let number = WriteTitle.length + 11; let Index = ColorBack.indexOf(WriteTitle); - if (this.result === 'true'){ + if (this.result === 'true') { this.ColorObject[this.current] = '#ff008000'; - let Log = (titles+';'+'#ff008000'+';'); - let key = ColorBack.substring(Index,Index+number); + let Log = (titles + ';' + '#ff008000' + ';'); + let key = ColorBack.substring(Index, Index + number); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); - ColorBack = ColorBack.replace(key,Log); + ColorBack = ColorBack.replace(key, Log); let buffer = new ArrayBuffer(4096); - let rd = fileio.readSync(FD,buffer); - let Report = ColorBack.substring(0,rd); + 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) + fileio.writeSync(Fd, Report); + filewrite(name1, results, titles) } - else if (this.result === 'false'){ + else if (this.result === 'false') { this.ColorObject[this.current] = '#ffff0000'; - let Log = (titles+';'+'#ffff0000'+';'); - let key = ColorBack.substring(Index,Index+number); + let Log = (titles + ';' + '#ffff0000' + ';'); + let key = ColorBack.substring(Index, Index + number); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); - ColorBack = ColorBack.replace(key,Log); + ColorBack = ColorBack.replace(key, Log); let buffer = new ArrayBuffer(4096); - let rd = fileio.readSync(FD,buffer); - let Report = ColorBack.substring(0,rd); + 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); + fileio.writeSync(Fd, Report); + filewrite(name1, results, titles); } - else if (this.result === 'None'){ + else if (this.result === 'None') { this.ColorObject[this.current] = this.ColorObject[this.current]; } } } - build(){ - Column(){ + + build() { + Column() { Row() { Button() { Image($r('app.media.ic_public_back')).width('20vp').height('18vp') @@ -138,13 +142,15 @@ struct IndexPage { .onClick(() => { router.back(); }) - Row(){ + + Row() { Text('Player SubSystem') .fontColor(Color.White) .fontSize('22fp') }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) + Row() { - Button(){ + Button() { Image($r('app.media.ic_public_delete')) .width('30vp') .height('30vp') @@ -158,7 +164,7 @@ struct IndexPage { action: () => { this.ClearAll = true; this.ColorObject.forEach((value, index) => { - this.ColorObject[index] = '#ff808080'; + this.ColorObject[index] = '#ff808080'; }); this.ClearText(); prompt.showToast({ @@ -178,7 +184,8 @@ struct IndexPage { } ) }) - Button(){ + + Button() { Image($r('app.media.ic_public_save')) .width('30vp') .height('30vp') @@ -188,9 +195,9 @@ struct IndexPage { 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:()=>{ + confirm: { + value: 'OK', + action: () => { prompt.showToast({ message: '报告已生成', duration: 1000 }) @@ -204,62 +211,78 @@ struct IndexPage { }) }) } - }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) - List({space:5}){ - ForEach(this.TestCaseList,(item,index) => { - ListItem(){ - Row(){ + } + .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(( )=>{ + } + .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.ClearAll = false; this.current = index; router.push({ url: item.uri, }) }) } - },item => item.title) + }, item => item.title) }.width('100%').height('92%') }.width('100%').height('100%').backgroundColor(Color.Black) } - ClearText(){ + + 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); + for (let i = 0; i < this.TestCaseList.length; i++) { + let log = (this.TestCaseList[i].title + ';' + '#ff808080' + ';').toString(); + fileio.writeSync(fd, log); } + FlushData.ResetPlayerAudio(); + FlushData.ResetPlayerVideo(); } - ReadTextParseXml(){ + + ReadTextParseXml() { let ReportPath = path1 + '/PlayerReport.txt'; let dir = fileio.opendirSync(path1); - console.info("ssssss"+dir); + 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 RD = fileio.readSync(OP, buf); + console.info("ddddd" + RD); let report; + function ab2str(buf) { - return report = String.fromCharCode.apply(null,new Uint8Array(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{ + 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('PlayerAudio', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'PlayerAudio'. Data: " + data); + }); + promise = preferences.put('PlayerAudio', 0); + promise.then(() => { + console.info("Succeeded in putting value of 'PlayerAudio'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } + static ResetPlayerVideo = 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('PlayerVideo', 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'PlayerVideo'. Data: " + data); + }); + promise = preferences.put('PlayerVideo', 0); + promise.then(() => { + console.info("Succeeded in putting value of 'PlayerVideo'."); + }); + 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 index 1499adf94..1249a11c5 100644 --- a/validator/acts_validator/src/main/ets/pages/model/MediaUtils.ts +++ b/validator/acts_validator/src/main/ets/pages/model/MediaUtils.ts @@ -37,9 +37,9 @@ export default class MediaUtils { Logger.info(this.tag, `displayName = ${displayName},mediaType = ${mediaType}`) let publicPath = await this.mediaTest.getPublicDirectory(info.directory) Logger.info(this.tag, `publicPath = ${publicPath}`) - try{ + try { return await this.mediaTest.createAsset(mediaType, displayName, publicPath) - }catch(err){ + } catch (err) { Logger.info(this.tag, `createAsset err ` + JSON.stringify(err)) } @@ -77,9 +77,26 @@ export default class MediaUtils { } } + async getFileAssetsAlbum(path){ + let fileKeyObj = mediaLibrary.FileKey + // ALBUM_NAME + let fetchOp = { + selections: `${fileKeyObj.RELATIVE_PATH}=?`, + selectionArgs: [`${path}`], + } + const fetchFileResult = await this.mediaTest.getFileAssets(fetchOp) + Logger.info(this.tag, `getFileAssetsAlbum,fetchFileResult.count = ${fetchFileResult.getCount()}`) + let fileAssets:Array = [] + if (fetchFileResult.getCount() > 0) { + fileAssets = await fetchFileResult.getAllObject() + } + return fileAssets + } + async getFileAssetsFromType(mediaType: number) { Logger.info(this.tag, `getFileAssetsFromType,mediaType = ${mediaType}`) let fileKeyObj = mediaLibrary.FileKey + // ALBUM_NAME let fetchOp = { selections: `${fileKeyObj.MEDIA_TYPE}=?`, selectionArgs: [`${mediaType}`], @@ -97,10 +114,10 @@ export default class MediaUtils { 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) + 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 @@ -120,6 +137,7 @@ export default class MediaUtils { deleteFile(media: any) { let uri = media.uri Logger.info(this.tag, `deleteFile,uri = ${uri}`) + // @ts-ignore return this.mediaTest.deleteAsset(uri) } 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 a228b7c75..c32dda660 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 @@ -39,8 +39,6 @@ "pages/Audio/AudioOutputRoutingTypeC", "pages/Audio/AudioOutputRoutingBT", "pages/Player/Player_index", - "pages/Player/PlayAudio", - "pages/Player/PlayVideo", "pages/Experience/Experience_index", "pages/Experience/PhotoFps", "pages/Experience/DeskFps", @@ -59,6 +57,10 @@ "pages/Experience/StartBackgroundTask", "pages/Experience/StartNotification", "pages/Experience/ScrollPhotosList", - "pages/Experience/KeyboardInputTest" + "pages/Experience/KeyboardInputTest", + "pages/Player/PlayAudio", + "pages/Player/PlayVideo", + "pages/Player/PlayAudioList", + "pages/Player/PlayVideoList" ] } -- GitLab