未验证 提交 20a693aa 编写于 作者: O openharmony_ci 提交者: Gitee

!8367 【媒体子系统】validator Player修改

Merge pull request !8367 from 秦莉文/OpenHarmony-3.2-Release
......@@ -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,7 +53,7 @@ struct playAudio {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Video({
src: this.videoSrc,
src: this.audioSrc,
controller: this.controller
})
.width('100%')
......@@ -61,24 +61,25 @@ struct playAudio {
.autoPlay(this.isAutoPlay)
.controls(this.showControls)
.onFinish(() => {
this.Vue = true
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
/*
* 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<mediaLibrary.FileAsset> = [];
@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
......@@ -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', }
})
})
......@@ -62,7 +62,7 @@ struct playVideo {
.autoPlay(this.isAutoPlay)
.controls(this.showControls)
.onFinish(() => {
this.Vue = true
this.Vue = true;
})
}.width('100%').height('80%').onClick(() => {
this.showControls = !this.showControls
......@@ -70,16 +70,17 @@ struct playVideo {
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
/*
* 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<mediaLibrary.FileAsset> = [];
@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
......@@ -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')
......@@ -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<Math.floor(str1.length/2); i++){
for (let i = 0; i < Math.floor(str1.length / 2); i++) {
title[i] = str1[i*2];
result[i] = str1[i*2+1];
result[i] = str1[i * 2+1];
}
let FailIndex = report.indexOf('false');
let FailNum = 0;
while (FailIndex != -1) {
console.log(FailIndex);
FailNum++;
FailIndex = report.indexOf('false',FailIndex + 1);
FailIndex = report.indexOf('false', FailIndex + 1);
}
let failNum = (FailNum).toString();
let PassIndex = report.indexOf('true');
......@@ -267,7 +290,7 @@ struct IndexPage {
while (PassIndex != -1) {
console.log(PassIndex);
PassNum++;
PassIndex = report.indexOf('true',PassIndex + 1);
PassIndex = report.indexOf('true', PassIndex + 1);
}
let TestNum = FailNum + PassNum;
let testNum = (TestNum).toString();
......@@ -276,7 +299,7 @@ struct IndexPage {
let serializer = new xml.XmlSerializer(bufView);
serializer.setDeclaration();
serializer.startElement("testsuite");
serializer.setAttributes("name","ActsPlayerTest");
serializer.setAttributes("name", "ActsPlayerTest");
serializer.setAttributes("time", "*");
serializer.setAttributes("errors", "0");
serializer.setAttributes("disabled", "0");
......@@ -302,42 +325,43 @@ struct IndexPage {
let array = new Uint8Array(arrayBuffer);
let serializerStr = that.decode(array);
console.info(xmlPath);
try{
console.error(TAG,"write xmlPath =" +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.writeSync(xmlfd, serializerStr);
} catch (err) {
console.error(TAG, "read xmlPath =" + xmlPath + "error:" + err);
} finally {
fileIO.closeSync(xmlfd);
}
return;
}
}
}
function filewrite(name1,results,titles){
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 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);
let Log = (titles + ";" + results + ";").toString();
if (Index == -1) {
fileio.writeSync(fd, Log);
}
else if (Index != -1){
let key = report.substring(Index,Index+number);
else if (Index != -1) {
let key = report.substring(Index, Index + number);
let FD = fileio.openSync(txtPath, 0o102, 0o666);
report = report.replace(key,Log);
report = report.replace(key, Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD,buffer);
let Report = report.substring(0,rd);
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);
fileio.writeSync(Fd, Report);
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ import fileIO from '@ohos.fileio';
import util from '@ohos.util';
import DateTimeUtil from './model/DateTimeUtil';
import data_preferences from '@ohos.data.preferences';
import FlushData from '../pages/model/FlushData'
import FlushData from '../pages/model/FlushData';
const TAG = 'ParseXML';
let path=globalThis.dir;
......@@ -34,6 +34,8 @@ let ArkUIColorBackPath = path + '/ArkUIColorBack.txt';
let AudioColorBackPath = path + '/AudioColorBack.txt';
let CameraColorBackPath = path + '/CameraColorBack.txt';
let PlayerColorBackPath = path + '/PlayerColorBack.txt';
let PlayerAudioColorBackPath = path4 + '/PlayerAudioColorBack.txt';
let PlayerVideoColorBackPath = path4 + '/PlayerVideoColorBack.txt';
let ExperienceColorBackPath = path + '/ExperienceColorBack.txt';
fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664);
......@@ -48,6 +50,8 @@ let path11 = path1 + '/ArkUIReport.txt';
let path22 = path2 + '/AudioReport.txt';
let path33 = path3 + '/CameraReport.txt';
let path44 = path4 + '/PlayerReport.txt';
let PlayerAudioTxtPath = path4 + '/PlayerAudioReport.txt';
let PlayerVideoTxtPath = path4 + '/PlayerVideoReport.txt';
let path55 = path5 + '/ExperienceReport.txt';
@Entry
......@@ -97,6 +101,10 @@ struct IndexPage {
fileio.openSync(path22, 0o100 | 0o2002, 0o664);
fileio.openSync(path33, 0o100 | 0o2002, 0o664);
fileio.openSync(path44, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerAudioColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerAudioTxtPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoTxtPath, 0o100 | 0o2002, 0o664);
fileio.openSync(path55, 0o100 | 0o2002, 0o664);
}
build(){
......@@ -194,11 +202,15 @@ struct IndexPage {
fileio.unlinkSync(path22);
fileio.unlinkSync(path33);
fileio.unlinkSync(path44);
fileio.unlinkSync(PlayerAudioTxtPath);
fileio.unlinkSync(PlayerVideoTxtPath);
fileio.unlinkSync(path55);
fileio.unlinkSync(ArkUIColorBackPath);
fileio.unlinkSync(AudioColorBackPath);
fileio.unlinkSync(CameraColorBackPath);
fileio.unlinkSync(PlayerColorBackPath);
fileio.unlinkSync(PlayerAudioColorBackPath);
fileio.unlinkSync(PlayerVideoColorBackPath);
fileio.unlinkSync(ExperienceColorBackPath);
fileio.rmdirSync(picturePath);
fileio.mkdirSync(picturePath);
......@@ -208,17 +220,23 @@ struct IndexPage {
fileio.openSync(path22, 0o100 | 0o2002, 0o664);
fileio.openSync(path33, 0o100 | 0o2002, 0o664);
fileio.openSync(path44, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerAudioTxtPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoTxtPath, 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(PlayerAudioColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(ExperienceColorBackPath, 0o100 | 0o2002, 0o664);
FlushData.ResetArkUI();
FlushData.ResetAudio();
FlushData.ResetCamera();
FlushData.ResetPlayer();
FlushData.ResetExperience();
FlushData.ResetPlayerAudio();
FlushData.ResetPlayerVideo();
}
SaveXml() {
let dateTimeUtil = new DateTimeUtil();
......
......@@ -136,4 +136,52 @@ export default class FlushData{
console.info("Succeeded in flushing.");
});
}
static ResetPlayerAudio = 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('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
......@@ -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<mediaLibrary.FileAsset> = []
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}`],
......@@ -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)
}
......
......@@ -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"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册