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 942700d6ed59381119fa79c9354be2c18a6d63d7..d4d8a64436cffcba494e4fe29a1a475aa6e58600 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 @@ -116,7 +116,7 @@ struct IndexPage { 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); @@ -282,12 +282,12 @@ struct IndexPage { FailIndex = report.indexOf('false',FailIndex + 1); } let failNum = (FailNum).toString(); - let PassIndex = report.indexOf('true'); + let PassIndex = report.indexOf('true '); let PassNum = 0; 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(); diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/TouchMoveTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/TouchMoveTest.ets index 3623a446ec9477e7c8675c89306bec357ec536ff..95985691141e86a002a0a4010835e3eab9d296d5 100644 --- a/validator/acts_validator/src/main/ets/pages/ArkUI/TouchMoveTest.ets +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/TouchMoveTest.ets @@ -50,7 +50,7 @@ struct CustomContainer1 { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); @@ -126,7 +126,7 @@ struct CustomContainer1 { }; let name = this.name; let displayName = `${info.prefix}${name}${info.suffix}`; - let dirPath = path + '/' + displayName; + let dirPath = path + '/screenshot' + '/' + displayName; let imagePackerApi = image.createImagePacker(); let arrayBuffer = await imagePackerApi.packing(data, packOpts); let fd = fileio.openSync(dirPath,0o102,0o666); 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 index a93343b52d815e4f26026c8e17cd481993ad1df0..22e82cfd8fa6dda07d51b2873c4d5fca509870d3 100644 --- a/validator/acts_validator/src/main/ets/pages/Audio/Audio_index.ets +++ b/validator/acts_validator/src/main/ets/pages/Audio/Audio_index.ets @@ -99,7 +99,7 @@ struct IndexPage { 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); @@ -265,12 +265,12 @@ struct IndexPage { FailIndex = report.indexOf('false',FailIndex + 1); } let failNum = (FailNum).toString(); - let PassIndex = report.indexOf('true'); + let PassIndex = report.indexOf('true '); let PassNum = 0; 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(); 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 index d401c2efe64e7c7be85be36b4662c0f1f5a97f84..875909cb3c66267d05ae08039838c41eb70822e4 100644 --- a/validator/acts_validator/src/main/ets/pages/Camera/Camera_index.ets +++ b/validator/acts_validator/src/main/ets/pages/Camera/Camera_index.ets @@ -100,7 +100,7 @@ struct IndexPage { 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); @@ -266,12 +266,12 @@ struct IndexPage { FailIndex = report.indexOf('false',FailIndex + 1); } let failNum = (FailNum).toString(); - let PassIndex = report.indexOf('true'); + let PassIndex = report.indexOf('true '); let PassNum = 0; 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(); diff --git a/validator/acts_validator/src/main/ets/pages/Experience/Experience_index.ets b/validator/acts_validator/src/main/ets/pages/Experience/Experience_index.ets index 64627c7e95ef58d399cfd5506855f96b990b67ba..c3132a018dc1d7902b2576a9022adb6f927192ed 100644 --- a/validator/acts_validator/src/main/ets/pages/Experience/Experience_index.ets +++ b/validator/acts_validator/src/main/ets/pages/Experience/Experience_index.ets @@ -113,7 +113,7 @@ struct IndexPage { 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); @@ -255,7 +255,6 @@ struct IndexPage { 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); @@ -281,12 +280,12 @@ struct IndexPage { FailIndex = report.indexOf('false',FailIndex + 1); } let failNum = (FailNum).toString(); - let PassIndex = report.indexOf('true'); + let PassIndex = report.indexOf('true '); let PassNum = 0; 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(); 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 30d4dee0cc8e40e7c3bbadb39ce85091d8f6d740..1104cbe989c95180c052d6760b1e98918e44363a 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 @@ -99,7 +99,7 @@ struct IndexPage { 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); @@ -285,12 +285,12 @@ struct IndexPage { FailIndex = report.indexOf('false', FailIndex + 1); } let failNum = (FailNum).toString(); - let PassIndex = report.indexOf('true'); + let PassIndex = report.indexOf('true '); let PassNum = 0; 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(); diff --git a/validator/acts_validator/src/main/ets/pages/common/AudioContainer.ets b/validator/acts_validator/src/main/ets/pages/common/AudioContainer.ets index 2c72543f8e790796b3e0c9d94d628214d01a6c95..efa44798cce684e38a7719511b166fcfdd3446ca 100644 --- a/validator/acts_validator/src/main/ets/pages/common/AudioContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/AudioContainer.ets @@ -1,147 +1,147 @@ -/* - * 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 prompt from '@ohos.prompt'; -import fileio from '@ohos.fileio'; -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 name : string; - title : string = ''; - StepTips: string = ''; - Url : string = ''; - @Link Vue : boolean; - @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 : 'true', 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 : 'false',title : this.name, - } - }) - this.getScreen(isFullScreen); - prompt.showToast({ - message: '失败', duration: 1000 - }); - }) - } - build() { - Column() { - 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 + '/screenshot' + '/' + 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}`); - } - } -} +/* + * 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 prompt from '@ohos.prompt'; +import fileio from '@ohos.fileio'; +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 name : string; + title : string = ''; + StepTips: string = ''; + Url : string = ''; + @Link Vue : boolean; + @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 : 'true ', 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 : 'false',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + 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 + '/screenshot' + '/' + 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/common/CameraFlashContainer.ets b/validator/acts_validator/src/main/ets/pages/common/CameraFlashContainer.ets index 004da7410028643126566c3743ae5576f2b7753a..f9e7b0ec0ac3c3bf7c54ceff13eaaa6e27f2aac2 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CameraFlashContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CameraFlashContainer.ets @@ -55,7 +55,7 @@ export struct CustomContainer { .onClick(() => { router.back({ url: this.Url, - params: { result: 'true', title: this.name, + params: { result: 'true ', title: this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CameraOrientationContainer.ets b/validator/acts_validator/src/main/ets/pages/common/CameraOrientationContainer.ets index d1f091190601f889d619e7a396006b1dc2bfc737..885b4e56abdda93448611f2edf4ebe401992f0a1 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CameraOrientationContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CameraOrientationContainer.ets @@ -1,162 +1,162 @@ -/* - * 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; - @Link isEnabled: boolean; - Url : string = ''; - title : string = ''; - StepTips: string = ''; - @Link testingFrequency: number - @Link clickFrequency: number - @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(()=>{ - this.isEnabled = true - this.Vue = false - this.clickFrequency++ - Logger.info(`TAG`, `clickFrequency: ${this.clickFrequency}`) - Logger.info(`TAG`, `testingFrequency: ${this.testingFrequency}`) - if (this.clickFrequency === this.testingFrequency){ - router.back({ - url:this.Url, - params: {result : 'true', 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 : 'false',title : this.name, - } - }) - this.getScreen(isFullScreen); - prompt.showToast({ - message: '失败', duration: 1000 - }); - }) - } - build() { - Column() { - Flex({ - justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center - }){ - 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); - }.height('98%').width('100%').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 + '/screenshot' + '/' + 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}`); - } - } -} +/* + * 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; + @Link isEnabled: boolean; + Url : string = ''; + title : string = ''; + StepTips: string = ''; + @Link testingFrequency: number + @Link clickFrequency: number + @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(()=>{ + this.isEnabled = true + this.Vue = false + this.clickFrequency++ + Logger.info(`TAG`, `clickFrequency: ${this.clickFrequency}`) + Logger.info(`TAG`, `testingFrequency: ${this.testingFrequency}`) + if (this.clickFrequency === this.testingFrequency){ + router.back({ + url:this.Url, + params: {result : 'true ', 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 : 'false',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Flex({ + justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center + }){ + 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); + }.height('98%').width('100%').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 + '/screenshot' + '/' + 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/common/CameraPhotoContainer.ets b/validator/acts_validator/src/main/ets/pages/common/CameraPhotoContainer.ets index 2d52d5bdfa9e427e3b8177824a95c5ee6ee002bf..0680cdf75d1d1baa743b88a50339ec330374ba81 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CameraPhotoContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CameraPhotoContainer.ets @@ -48,7 +48,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CameraPreviewFormatContainer.ets b/validator/acts_validator/src/main/ets/pages/common/CameraPreviewFormatContainer.ets index 2d52d5bdfa9e427e3b8177824a95c5ee6ee002bf..0680cdf75d1d1baa743b88a50339ec330374ba81 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CameraPreviewFormatContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CameraPreviewFormatContainer.ets @@ -48,7 +48,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CameraVideoContainer.ets b/validator/acts_validator/src/main/ets/pages/common/CameraVideoContainer.ets index 2d52d5bdfa9e427e3b8177824a95c5ee6ee002bf..0680cdf75d1d1baa743b88a50339ec330374ba81 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CameraVideoContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CameraVideoContainer.ets @@ -48,7 +48,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer1.ets b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer1.ets index ee61f7d48ec57c85b6fad30aa1be7489b35eb484..7e66dd9c9521badf2af7a11f5b5e7db825d5b496 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer1.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer1.ets @@ -50,7 +50,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer2.ets b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer2.ets index 3d357dfbdbb42f986964aea1329d11d9886878fe..976448c0b37fd3b1d4b1c49202609b80ce56d551 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer2.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer2.ets @@ -52,7 +52,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer.ets index 963a99214514a3a9f2f3d531328a9e49ab6d76d9..de8c7d3d4612d4934140bd4f85dcaefa8aab3d70 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CustomContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer.ets @@ -48,7 +48,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer2.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer2.ets index 1b7e513dc2d9d1a0cbc172cae6c522497c1d4701..b7192fe49bdd7fe50cb776deb1e4a46c225c8d06 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CustomContainer2.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer2.ets @@ -48,7 +48,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer3.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer3.ets index a490beeb61e19750cf5609cd11d0c7636fade2e6..2b7cd7d8f8548dbbba1b77b18bd4ed2c8fd028a1 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CustomContainer3.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer3.ets @@ -49,7 +49,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer4.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer4.ets index dfc64921532d781f448d4a1bba5b052cd42f451e..b10cb6aa2e7db2e7ca62f24353a5aecc88abe9e0 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CustomContainer4.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer4.ets @@ -48,7 +48,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer5.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer5.ets index e37a2f6379ab583362145e994e8b12e614102beb..3cf39167798dcdfb66e797df756b2beb515b13c7 100644 --- a/validator/acts_validator/src/main/ets/pages/common/CustomContainer5.ets +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer5.ets @@ -50,7 +50,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/ExperienceCustomContainer.ets b/validator/acts_validator/src/main/ets/pages/common/ExperienceCustomContainer.ets index 7e91ee0d4c7d2d08928bf4529ec2f846e5d2e6b0..7cdd56f4c0f1d98e7eea9c708e4ce686f5baefeb 100644 --- a/validator/acts_validator/src/main/ets/pages/common/ExperienceCustomContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/ExperienceCustomContainer.ets @@ -50,7 +50,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/StartExperienceCustomContainer.ets b/validator/acts_validator/src/main/ets/pages/common/StartExperienceCustomContainer.ets index 80e9d3db94a850fafea5d4c8f45a97a9b08fc1c1..04eb1ed67bd7034c414afd4fd85e7d63f71fc3a3 100644 --- a/validator/acts_validator/src/main/ets/pages/common/StartExperienceCustomContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/StartExperienceCustomContainer.ets @@ -55,7 +55,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/common/TimeExperienceCustomContainer.ets b/validator/acts_validator/src/main/ets/pages/common/TimeExperienceCustomContainer.ets index a5928cb93beb6f316bba4e29152ca19e8243fce4..913effa55c03ec3b3fe5c54aec913254599b0747 100644 --- a/validator/acts_validator/src/main/ets/pages/common/TimeExperienceCustomContainer.ets +++ b/validator/acts_validator/src/main/ets/pages/common/TimeExperienceCustomContainer.ets @@ -50,7 +50,7 @@ export struct CustomContainer { .onClick(()=>{ router.back({ url:this.Url, - params: {result : 'true', title : this.name, + params: {result : 'true ', title : this.name, } }) this.getScreen(isFullScreen); diff --git a/validator/acts_validator/src/main/ets/pages/index.ets b/validator/acts_validator/src/main/ets/pages/index.ets index 6414770c730eadfa9d8ba2ebadd1b886f287553a..9f1aa245b4008019b01b8fd20afe91c91f22c6b8 100644 --- a/validator/acts_validator/src/main/ets/pages/index.ets +++ b/validator/acts_validator/src/main/ets/pages/index.ets @@ -339,12 +339,12 @@ struct IndexPage { FailIndex = report.indexOf('false',FailIndex + 1); } let failNum = (FailNum).toString(); - let PassIndex = report.indexOf('true'); + let PassIndex = report.indexOf('true '); let PassNum = 0; 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(); @@ -359,12 +359,12 @@ struct IndexPage { ArkUIFailIndex = ArkUIReport.indexOf('false',ArkUIFailIndex + 1); } let ArkuiFailNum = (ArkUIFailNum).toString(); - let ArkUIPassIndex = ArkUIReport.indexOf('true'); + let ArkUIPassIndex = ArkUIReport.indexOf('true '); let ArkUIPassNum = 0; while (ArkUIPassIndex != -1) { console.log(ArkUIPassIndex); ArkUIPassNum++; - ArkUIPassIndex = ArkUIReport.indexOf('true',ArkUIPassIndex + 1); + ArkUIPassIndex = ArkUIReport.indexOf('true ',ArkUIPassIndex + 1); } let ArkUITestNum = ArkUIFailNum + ArkUIPassNum; let ArkuiTestNum = (ArkUITestNum).toString(); @@ -379,12 +379,12 @@ struct IndexPage { AudioFailIndex = AudioReport.indexOf('false',AudioFailIndex + 1); } let audioFailNum = (AudioFailNum).toString(); - let AudioPassIndex = AudioReport.indexOf('true'); + let AudioPassIndex = AudioReport.indexOf('true '); let AudioPassNum = 0; while (AudioPassIndex != -1) { console.log(AudioPassIndex); AudioPassNum++; - AudioPassIndex = AudioReport.indexOf('true',AudioPassIndex + 1); + AudioPassIndex = AudioReport.indexOf('true ',AudioPassIndex + 1); } let AudioTestNum = AudioFailNum + AudioPassNum; let audioTestNum = (AudioTestNum).toString(); @@ -399,12 +399,12 @@ struct IndexPage { CameraFailIndex = CameraReport.indexOf('false',CameraFailIndex + 1); } let cameraFailNum = (CameraFailNum).toString(); - let CameraPassIndex = CameraReport.indexOf('true'); + let CameraPassIndex = CameraReport.indexOf('true '); let CameraPassNum = 0; while (CameraPassIndex != -1) { console.log(CameraPassIndex); CameraPassNum++; - CameraPassIndex = CameraReport.indexOf('true',CameraPassIndex + 1); + CameraPassIndex = CameraReport.indexOf('true ',CameraPassIndex + 1); } let CameraTestNum = CameraFailNum + CameraPassNum; let cameraTestNum = (CameraTestNum).toString(); @@ -419,12 +419,12 @@ struct IndexPage { PlayerFailIndex = PlayerReport.indexOf('false',PlayerFailIndex + 1); } let playerFailNum = (PlayerFailNum).toString(); - let PlayerPassIndex = PlayerReport.indexOf('true'); + let PlayerPassIndex = PlayerReport.indexOf('true '); let PlayerPassNum = 0; while (PlayerPassIndex != -1) { console.log(PlayerPassIndex); PlayerPassNum++; - PlayerPassIndex = PlayerReport.indexOf('true',PlayerPassIndex + 1); + PlayerPassIndex = PlayerReport.indexOf('true ',PlayerPassIndex + 1); } let PlayerTestNum = PlayerFailNum + PlayerPassNum; let playerTestNum = (PlayerTestNum).toString(); @@ -439,12 +439,12 @@ struct IndexPage { ExperienceFailIndex = ExperienceReport.indexOf('false',ExperienceFailIndex + 1); } let experienceFailNum = (ExperienceFailNum).toString(); - let ExperiencePassIndex = ExperienceReport.indexOf('true'); + let ExperiencePassIndex = ExperienceReport.indexOf('true '); let ExperiencePassNum = 0; while (ExperiencePassIndex != -1) { console.log(ExperiencePassIndex); ExperiencePassNum++; - ExperiencePassIndex = ExperienceReport.indexOf('true',ExperiencePassIndex + 1); + ExperiencePassIndex = ExperienceReport.indexOf('true ',ExperiencePassIndex + 1); } let ExperienceTestNum = ExperienceFailNum + ExperiencePassNum; let experienceTestNum = (ExperienceTestNum).toString();