diff --git a/test_packages.gni b/test_packages.gni index 44398f11835ce4656b107ba4f78ff93dbe8e13ea..3f42c3e8b9fd882e00a7fd0d42b4762dbea04331 100644 --- a/test_packages.gni +++ b/test_packages.gni @@ -49,6 +49,7 @@ _all_test_packages = [ "${ACTS_ROOT}/applications:applications", "${ACTS_ROOT}/wukong:wukong", "${ACTS_ROOT}/msdp:msdp", + "${ACTS_ROOT}/validator:validator", ] _all_test_packages_ivi = [ diff --git a/validator/BUILD.gn b/validator/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f50b63e603d4cac948c98e6fe43c0420430be623 --- /dev/null +++ b/validator/BUILD.gn @@ -0,0 +1,22 @@ +# 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("//build/ohos_var.gni") +import("//test/xts/tools/build/suite.gni") + +group("validator") { + testonly = true + if (is_standard_system) { + deps = [ "acts_validator:acts_validator_test" ] + } +} diff --git a/validator/acts_validator/AppScope/app.json b/validator/acts_validator/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..aef203c1fc12a0c9e58daae01fd9ecf21c50315c --- /dev/null +++ b/validator/acts_validator/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.example.actsvalidator", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/validator/acts_validator/AppScope/resources/base/element/string.json b/validator/acts_validator/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9d9f5b5c3c376438121699ce3369794c202cf69f --- /dev/null +++ b/validator/acts_validator/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ActsValidator" + } + ] +} diff --git a/validator/acts_validator/AppScope/resources/base/media/app_icon.png b/validator/acts_validator/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/validator/acts_validator/AppScope/resources/base/media/app_icon.png differ diff --git a/validator/acts_validator/BUILD.gn b/validator/acts_validator/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..19bb06138154fad5a5f7612706768ff32f4dc119 --- /dev/null +++ b/validator/acts_validator/BUILD.gn @@ -0,0 +1,38 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("acts_validator_test") { + hap_profile = "./src/main/module.json" + js_build_mode = "debug" + deps = [ + ":acts_validator_assets", + ":acts_validator_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsValidatorTest" +} +ohos_app_scope("acts_validator_app_profile") { + app_profile = "./AppScope/app.json" + sources = [ "./AppScope/resources" ] +} +ohos_js_assets("acts_validator_assets") { + source_dir = "./src/main/ets" +} +ohos_resources("acts_validator_resources") { + sources = [ "./src/main/resources" ] + deps = [ ":acts_validator_app_profile" ] + hap_profile = "./src/main/module.json" +} diff --git a/validator/acts_validator/Test.json b/validator/acts_validator/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..a59f408a1c729ba7f3cda708666014c6ec1fe170 --- /dev/null +++ b/validator/acts_validator/Test.json @@ -0,0 +1,26 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "300000", + "testcase-timeout": "300000", + "shell-timeout": "300000", + "bundle-name": "com.example.actsvalidator", + "package-name": "com.example.actsvalidator" + }, + "kits": [ + { + "test-file-name": [ + "ActsValidatorTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "hilog -Q pidoff" + ] + } + ] +} \ No newline at end of file diff --git a/validator/acts_validator/signature/openharmony_sx.p7b b/validator/acts_validator/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..8abb4304720461f4c706e0b3e2dd8d230c187d88 Binary files /dev/null and b/validator/acts_validator/signature/openharmony_sx.p7b differ diff --git a/validator/acts_validator/src/main/ets/Application/MyAbilityStage.ts b/validator/acts_validator/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..937630c76a0ee09b9408db2b6149101d47ce890f --- /dev/null +++ b/validator/acts_validator/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,8 @@ +import AbilityStage from "@ohos.app.ability.AbilityStage" +import Logger from '../pages/model/Logger' + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + Logger.info('[MyAbilityStage]', 'MyAbilityStage onCreate') + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/MainAbility/MainAbility.ts b/validator/acts_validator/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9d71b0baf86d043e39f485fcaa4017cab3de9c3 --- /dev/null +++ b/validator/acts_validator/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,42 @@ +import Ability from '@ohos.app.ability.UIAbility' +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + globalThis.dir=this.context.filesDir; + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + + console.log("[Demo] MainAbility onWindowStageCreate") + let AtManager = abilityAccessCtrl.createAtManager(); + AtManager.requestPermissionsFromUser(this.context,["ohos.permission.READ_MEDIA","ohos.permission.WRITE_MEDIA", + "ohos.permission.CAPTURE_SCREEN","ohos.permission.INTERNET"]).then(() => {}) + windowStage.loadContent("pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + } + + onWindowStageDestroy() { + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + console.log("[Demo] MainAbility onBackground") + } +}; 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 new file mode 100644 index 0000000000000000000000000000000000000000..71fcaf0adb964431b91ce5c9352962825ac37464 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/ArkUI_index.ets @@ -0,0 +1,295 @@ +/* + * 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 router from '@ohos.router'; +import fileio from '@ohos.fileio'; +import xml from '@ohos.xml'; +import fileIO from '@ohos.fileio'; +import util from '@ohos.util'; + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1; +path1 = path + '/ArkUI'; + + + +@Entry +@Component +struct IndexPage { + @State BackColor: string = '#ff808080'; + @State ClearAll : boolean = false; + private current : number = undefined; + @State count : number = 0; + @State result : string = ''; + private TestCaseList = [ + {title:'Scroll List',uri:'pages/ArkUI/ScrollListTest'}, + {title:'TouchMove',uri:'pages/ArkUI/TouchMoveTest'}, + {title:'PinchGesture',uri:'pages/ArkUI/PinchGestureTest'}, + {title:'RotationGesture',uri:'pages/ArkUI/RotationGestureTest'}, + {title:'SwipeGesture',uri:'pages/ArkUI/SwipeGestureTest'}, + {title:'LongPressGesture',uri:'pages/ArkUI/LongPressGesture'}, + {title:'TapGesture',uri:'pages/ArkUI/TapGesture'}, + {title:'PanGesture',uri:'pages/ArkUI/PanGesture'}, + {title:'CanvasFillStyle',uri:'pages/ArkUI/CanvasFillStyle'}, + {title:'CanvasLineWidth',uri:'pages/ArkUI/CanvasLineWidth'}, + {title:'CanvasStrokeStyle',uri:'pages/ArkUI/CanvasStrokeStyle'}, + {title:'CanvasLineCap',uri:'pages/ArkUI/CanvasLineCap'}, + {title:'CanvasLineJoin',uri:'pages/ArkUI/CanvasLineJoin'}, + {title:'CanvasMiterLimit',uri:'pages/ArkUI/CanvasMiterLimit'}, + {title:'CanvasFont',uri:'pages/ArkUI/CanvasFont'}, + {title:'CanvasTextAlign',uri:'pages/ArkUI/CanvasTextAlign'}, + {title:'CanvasGlobalAlpha',uri:'pages/ArkUI/CanvasGlobalAlpha'}, + {title:'CanvasLineDashOffset',uri:'pages/ArkUI/CanvasLineDashOffset'}, + {title:'CanvasGlobalCompositeOperation',uri:'pages/ArkUI/CanvasGlobalCompositeOperation'}, + {title:'CanvasShadowBlur',uri:'pages/ArkUI/CanvasShadowBlur'}, + {title:'CanvasShadowColor',uri:'pages/ArkUI/CanvasShadowColor'}, + {title:'CanvasShadowOffsetX',uri:'pages/ArkUI/CanvasShadowOffsetX'}, + {title:'CanvasShadowOffsetY',uri:'pages/ArkUI/CanvasShadowOffsetY'}, + {title:'CanvasImageSmoothingEnabled',uri:'pages/ArkUI/CanvasImageSmoothingEnabled'}, + ] + @State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080', + '#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080', + '#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080'] + onPageShow(){ + if (this.count === 1){ + this.result = router.getParams()['result']; + let titles = router.getParams()['title']; + let name1 = '刚刚点进了哪个用例:'+ titles; + let results = this.result; + if (this.result === 'Pass'){ + this.ColorObject[this.current] = '#ff008000'; + filewrite(name1,results,titles) + } + else if (this.result === 'Fail'){ + this.ColorObject[this.current] = '#ffff0000'; + filewrite(name1,results,titles); + } + else if (this.result === 'None'){ + this.ColorObject[this.current] = this.ColorObject[this.current]; + } + } + + } + build(){ + Column(){ + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black) + .onClick(() => { + router.back(); + }) + Row(){ + Text('ArkUI SubSystem') + .fontColor(Color.White) + .fontSize('22fp') + }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) + Row() { + Button(){ + Image($r('app.media.ic_public_delete')) + .width('30vp') + .height('30vp') + }.backgroundColor(Color.Black) + .onClick(() => { + AlertDialog.show( + { + message: "是否删除所有记录", + primaryButton: { + value: 'Yes', + action: () => { + this.ClearAll = true; + this.ColorObject.forEach((value, index) => { + this.ColorObject[index] = '#ff808080'; + }); + this.ClearText(); + prompt.showToast({ + message: '结果已删除', duration: 1000 + }); + } + }, + secondaryButton: { + value: 'No', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + }) + Button(){ + Image($r('app.media.ic_public_save')) + .width('30vp') + .height('30vp') + .margin({ left: 30 }) + }.backgroundColor(Color.Black) + .onClick(() => { + this.ReadTextParseXml(); + AlertDialog.show({ + message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/ArkUI/ArkUITest.xml -本地路径'", + confirm:{ + value:'OK', + action:()=>{ + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }, + cancel: () => { + prompt.showToast({ + message: '报告已生成', duration: 1000 + }); + } + }) + }) + } + }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) + List({space:5}){ + ForEach(this.TestCaseList,(item,index) => { + ListItem(){ + Row(){ + Text(item.title).fontSize(16).fontColor(Color.Black) + Text(this.BackColor.toString()).visibility(Visibility.None) + }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index]) + .onClick(( )=>{ + this.count = 1; + this.ClearAll=false; + this.current = index; + router.push({ + url: item.uri, + }) + }) + } + },item => item.title) + }.width('100%').height('92%') + }.width('100%').height('100%').backgroundColor(Color.Black) + } + ClearText(){ + fileio.rmdirSync(path1); + fileio.mkdirSync(path1); + } + ReadTextParseXml(){ + let ReportPath = path1 + '/ArkUIReport.txt'; + let dir = fileio.opendirSync(path1); + console.info("ssssss"+dir); + while (dir) { + let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(40960); + let RD = fileio.readSync(OP,buf); + console.info("ddddd"+RD); + let report; + function ab2str(buf) { + return report = String.fromCharCode.apply(null,new Uint8Array(buf)); + } + ab2str(buf); + let str1 = report.split(";"); + let title = []; + let result = []; + for(let i=0; i{ + this.context.clearRect(100, 160, 150, 100); + this.FillColor = '#FFFF0000'; + this.context.fillStyle = this.FillColor; + this.context.fillRect(100, 160, 150, 100); + this.Vue = true; + }) + Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(100, 160, 150, 100); + this.FillColor = '#fffffc3c'; + this.context.fillStyle = this.FillColor; + this.context.fillRect(100, 160, 150, 100); + this.Vue = true; + }) + Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(100, 160, 150, 100); + this.FillColor = '#ff19fa00'; + this.context.fillStyle = this.FillColor; + this.context.fillRect(100, 160, 150, 100); + this.Vue = true; + }) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.fillStyle = this.FillColor; + this.context.fillRect(100, 160, 150, 100); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/ArkUI/ArkUI_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} + diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasFont.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasFont.ets new file mode 100644 index 0000000000000000000000000000000000000000..1315e4b6a2b6ba0d59c66778723974793ffed7a4 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasFont.ets @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer1'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasFillStyle'; + @State StepTips: string = '操作步骤:点击不同的字体控件'+'\n'+'预期结果:原本默认字体会改变'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Row(){ + Text('').fontSize(0).border({width:0}).size({width:'0%',height:'1%'}) + } + Row({space:10}){ + Text('font-style').fontSize(13).border({width:0}).size({width:'24%',height:'18%'}) + Text('normal').fontSize(13).border({width:2}).size({width:'24%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('italic').fontSize(13).border({width:2}).size({width:'24%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'italic normal 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + } + Row({space:8}) { + Text('font-weight').fontSize(13).border({ width: 0 }).size({ width: '24%', height: '18%' }) + Text('normal').fontSize(13).border({ width: 2 }).size({ width: '16%', height: '18%' }) + .onClick(() => { + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('bold').fontSize(13).border({width:2}).size({width:'16%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal bold 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('bolder').fontSize(13).border({width:2}).size({width:'16%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal bolder 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('lighter').fontSize(13).border({width:2}).size({width:'16%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal lighter 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + } + Row({space:5}) { + Text('100').fontSize(13).border({ width: 2 }).size({ width: '10%', height: '18%' }) + .onClick(() => { + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 100 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('200').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 200 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('300').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 300 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('400').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 400 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('500').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 500 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('600').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 600 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('700').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 700 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('800').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 800 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('900').fontSize(13).border({width:2}).size({width:'10%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal 900 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + } + Row({space:10}){ + Text('font-family').fontSize(13).border({width:0}).size({width:'24%',height:'18%'}) + Text('sans-serif').fontSize(13).border({width:2}).size({width:'24%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('serif').fontSize(13).border({width:2}).size({width:'24%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 120px serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('monospace').fontSize(13).border({width:2}).size({width:'24%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 120px monospace'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + } + Row({space:10}) { + Text('font-size').fontSize(13).border({ width: 0 }).size({ width: '18%', height: '18%' }) + Text('small').fontSize(13).border({ width: 2 }).size({ width: '18%', height: '18%' }) + .onClick(() => { + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 10px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('medium').fontSize(13).border({width:2}).size({width:'18%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 50px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('large').fontSize(13).border({width:2}).size({width:'18%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 80px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + Text('extra').fontSize(13).border({width:2}).size({width:'18%',height:'18%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.font = 'normal normal 120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + this.Vue = true; + }) + } + }.width('90%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.font = '120px sans-serif'; + this.context.fillText("Hello World", 80, 120); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasGlobalAlpha.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasGlobalAlpha.ets new file mode 100644 index 0000000000000000000000000000000000000000..3dd5606c6f51679d3171a1370c222c583cab4007 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasGlobalAlpha.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State X: number = 20; + @State name: string = 'CanvasGlobalAlpha'; + @State StepTips: string = '操作步骤:拖动滑块向右移动'+'\n'+'预期结果:透明度随着拖拽距离而改变,并显示透明度'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) + .translate({ x: this.X, y: 20, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + this.context.clearRect(100, 100, 250, 200); + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('透明度: ' + (this.X)*0.005 ) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalAlpha = (this.X)*0.005; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(200, 200, 50, 50); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasGlobalCompositeOperation.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasGlobalCompositeOperation.ets new file mode 100644 index 0000000000000000000000000000000000000000..54bda6405a7631235819ccb099363e1519234846 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasGlobalCompositeOperation.ets @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer1'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasGlobalCompositeOperation'; + @State StepTips: string = '操作步骤:点击不同的合成操作的方式'+'\n'+'预期结果:原本默认合成方式会随点击变化'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Row(){ + Text('').fontSize(0).border({width:0}).size({width:'0%',height:'2%'}) + } + Row({space:10}){ + Text('s-over').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'source-over'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('s-atop').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'source-atop'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('s-in').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'source-in'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('s-out').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'source-out'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + } + Row({space:10}){ + Text('d-over').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'destination-over'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('d-atop').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'destination-atop'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('d-in').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'destination-in'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('d-out').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'destination-out'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + } + Row({space:10}){ + Text('lighter').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'lighter'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('copy').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'copy'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('xor').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'xor'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + this.Vue = true; + }) + Text('').fontSize(0).border({width:0}).size({width:'18%',height:'20%'}) + } + }.width('90%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 50, 50); + this.context.globalCompositeOperation = 'source-over'; + this.context.fillStyle = 'rgb(0,0,255)'; + this.context.fillRect(180, 180, 50, 50); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasImageSmoothingEnabled.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasImageSmoothingEnabled.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6ab794d3fdddeaa39f955c4499df9aafe152b8c --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasImageSmoothingEnabled.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + private img:ImageBitmap = new ImageBitmap("src/main/resources/base/media/flower.jpg"); + @State FillColor: string = '#FF000000'; + @State X: number = 0; + @State name: string = 'CanvasImageSmoothingEnabled'; + @State StepTips: string = '操作步骤:点击不同的控件'+'\n'+'预期结果:切换平滑过渡效果'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('True').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(10, 100, 400, 300); + this.context.imageSmoothingEnabled = true; + this.context.drawImage( this.img,0,0,400,200); + this.Vue = true; + }) + Text('False').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(10, 100, 400, 300); + this.context.imageSmoothingEnabled = false; + this.context.drawImage( this.img,0,0,400,200); + this.Vue = true; + }) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.imageSmoothingEnabled = false; + this.context.drawImage( this.img,0,0,200,200); + }) + }.width('100%').height('60%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineCap.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineCap.ets new file mode 100644 index 0000000000000000000000000000000000000000..dba750ab69f1e254ac8dd3e55bf4acd5c3cd56ae --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineCap.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer1'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasLineCap'; + @State StepTips: string = '操作步骤:点击不同的端点样式控件'+'\n'+'预期结果:原本默认端点样式会随点击变化'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('butt').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 90, 170, 120); + this.context.lineWidth = 8; + this.context.beginPath(); + this.context.lineCap = 'butt'; + this.context.moveTo(100, 100); + this.context.lineTo(250, 100); + this.context.stroke(); + this.Vue = true; + }) + Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 90, 170, 120); + this.context.lineWidth = 8; + this.context.beginPath(); + this.context.lineCap = 'round'; + this.context.moveTo(100, 100); + this.context.lineTo(250, 100); + this.context.stroke(); + this.Vue = true; + }) + Text('square').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 90, 170, 120); + this.context.lineWidth = 8; + this.context.beginPath(); + this.context.lineCap = 'square'; + this.context.moveTo(100, 100); + this.context.lineTo(250, 100); + this.context.stroke(); + this.Vue = true; + }) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.lineWidth = 8; + this.context.beginPath(); + this.context.lineCap = 'round'; + this.context.moveTo(100, 100); + this.context.lineTo(250, 100); + this.context.stroke(); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineDashOffset.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineDashOffset.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a286640f9a1a5fc70c0ba42edd338348ea40d4c --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineDashOffset.ets @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State X: number = 0; + @State name: string = 'CanvasLineDashOffset'; + @State StepTips: string = '操作步骤:拖动滑块向右移动'+'\n'+'预期结果:虚线偏移量随着拖拽距离而改变,并显示偏移量'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) + .translate({ x: this.X, y: 20, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + this.context.clearRect(100, 100, 250, 200); + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('虚线偏移量: ' + (this.X)*0.1 ) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.arc(180, 150, 50, 0, 6.28); + this.context.setLineDash([20,30]); + this.context.lineDashOffset = (this.X)*0.1; + this.context.stroke(); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineJoin.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineJoin.ets new file mode 100644 index 0000000000000000000000000000000000000000..8747420cd2fbb8a6e3c3b938adba7096d0c9b502 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineJoin.ets @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer1'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasLineJoin'; + @State StepTips: string = '操作步骤:点击不同的交点样式控件'+'\n'+'预期结果:原本默认交点样式会随点击变化'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 90, 170, 120); + this.context.beginPath(); + this.context.lineWidth = 8; + this.context.lineJoin = 'round'; + this.context.moveTo(120, 100); + this.context.lineTo(210, 130); + this.context.lineTo(120, 180); + this.context.stroke(); + this.Vue = true; + }) + Text('bevel').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 90, 170, 120); + this.context.beginPath(); + this.context.lineWidth = 8; + this.context.lineJoin = 'bevel'; + this.context.moveTo(120, 100); + this.context.lineTo(210, 130); + this.context.lineTo(120, 180); + this.context.stroke(); + this.Vue = true; + }) + Text('miter').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 90, 170, 120); + this.context.beginPath(); + this.context.lineWidth = 8; + this.context.lineJoin = 'miter'; + this.context.moveTo(120, 100); + this.context.lineTo(210, 130); + this.context.lineTo(120, 180); + this.context.stroke(); + this.Vue = true; + }) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.beginPath(); + this.context.lineWidth = 8; + this.context.lineJoin = 'miter'; + this.context.moveTo(120, 100); + this.context.lineTo(210, 130); + this.context.lineTo(120, 180); + this.context.stroke(); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineWidth.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineWidth.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f081ccbf5d41517da860e3672afbcff06ba05de --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasLineWidth.ets @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasLineWidth'; + @State StepTips: string = '操作步骤:拖动滑块向右移动'+'\n'+'预期结果:边框会随着移动距离而变粗,并显示边框粗细'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @State X: number = 20; + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) + .translate({ x: this.X, y: 20, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + this.context.clearRect(100, 100, 250, 200); + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('边框粗细: ' + (this.X)*0.05 ) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.lineWidth = (this.X)*0.05; + this.context.strokeRect(120, 120, 120, 120); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasMiterLimit.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasMiterLimit.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b813b80242616e45baac3e19a1995298b385125 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasMiterLimit.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State X: number = 0; + @State name: string = 'CanvasMiterLimit'; + @State StepTips: string = '操作步骤:向右拖动MiterLimit按键'+'\n'+'预期结果:斜接面限制值会随拖动距离变化,并显示限制值大小'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('MiterLimit').fontSize(18).border({width:2}).size({width:'40%',height:'30%'}) + .translate({ x: this.X, y: 20, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + this.context.clearRect(100, 100, 250, 200); + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('边框粗细: ' + (this.X)*0.05 ) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.lineWidth = 8; + this.context.lineJoin = 'miter'; + this.context.miterLimit = (this.X)*0.05; + this.context.moveTo(160, 100); + this.context.lineTo(190, 105); + this.context.lineTo(160, 107); + this.context.stroke(); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowBlur.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowBlur.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e705b03fb39e4259c28d6485b12c8d6ac804fcd --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowBlur.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State X: number = 0; + @State name: string = 'CanvasShadowBlur'; + @State StepTips: string = '操作步骤:拖动滑块向右移动'+'\n'+'预期结果:阴影会随着拖动距离增大而变模糊,并显示模糊数值'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) + .translate({ x: this.X, y: 20, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + this.context.clearRect(10, 50, 400, 300); + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('阴影模糊: ' + this.X ) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.shadowBlur = this.X; + this.context.shadowColor = 'rgb(0,0,0)'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowColor.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowColor.ets new file mode 100644 index 0000000000000000000000000000000000000000..56de4cc14b0a450524480be48573249c98ae640c --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowColor.ets @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State X: number = 0; + @State name: string = 'CanvasShadowColor'; + @State StepTips: string = '操作步骤:点击不同的颜色控件'+'\n'+'预期结果:原本默认蓝色的阴影会随点击变化'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('Blue').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(10, 100, 400, 300); + this.context.shadowBlur = 30; + this.context.shadowColor = 'rgb(0,0,255)'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + this.Vue = true; + }) + Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(10, 100, 400, 300); + this.context.shadowBlur = 30; + this.context.shadowColor = '#fffffc3c'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + this.Vue = true; + }) + Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(10, 100, 400, 300); + this.context.shadowBlur = 30; + this.context.shadowColor = '#ff19fa00'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + this.Vue = true; + }) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.shadowBlur = 30; + this.context.shadowColor = 'rgb(0,0,255)'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + }) + }.width('100%').height('60%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowOffsetX.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowOffsetX.ets new file mode 100644 index 0000000000000000000000000000000000000000..13c9432ac63489b4affb1c0004297403950d364a --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowOffsetX.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State X: number = 0; + @State name: string = 'CanvasShadowOffsetX'; + @State StepTips: string = '操作步骤:拖动滑块向右移动'+'\n'+'预期结果:阴影会随着拖动距离增大而向下偏移,并显示偏移数值'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) + .translate({ x: this.X, y: 20, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + this.context.clearRect(10, 50, 400, 300); + this.context.shadowColor = 'rgb(0,0,0)'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('阴影偏移: ' + (this.X)*0.05 ) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.shadowBlur = 10; + this.context.shadowOffsetX = (this.X)*0.05; + this.context.shadowColor = 'rgb(0,0,0)'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowOffsetY.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowOffsetY.ets new file mode 100644 index 0000000000000000000000000000000000000000..5269d427f8ab58207c8b6af312473296c1915b09 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasShadowOffsetY.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State X: number = 0; + @State name: string = 'CanvasShadowOffsetY'; + @State StepTips: string = '操作步骤:拖动滑块向右移动'+'\n'+'预期结果:阴影会随着拖动距离增大而向下偏移,并显示偏移数值'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) + .translate({ x: this.X, y: 20, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + this.context.clearRect(10, 50, 400, 300); + this.context.shadowColor = 'rgb(0,0,0)'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('阴影偏移: ' + (this.X)*0.05 ) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.shadowBlur = 10; + this.context.shadowOffsetY = (this.X)*0.05; + this.context.shadowColor = 'rgb(0,0,0)'; + this.context.fillStyle = 'rgb(255,0,0)'; + this.context.fillRect(150, 150, 100, 100); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasStrokeStyle.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasStrokeStyle.ets new file mode 100644 index 0000000000000000000000000000000000000000..083c2599b14b4453a5743b3294890cf7e8ef6341 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasStrokeStyle.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer1'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasStrokeStyle'; + @State StepTips: string = '操作步骤:点击不同的颜色控件'+'\n'+'预期结果:原本默认黑色的边框会随点击变化'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('Red').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 150, 170, 120); + this.FillColor = '#FFFF0000'; + this.context.lineWidth = 10; + this.context.strokeStyle = '#FFFF0000'; + this.context.strokeRect(100, 160, 150, 100); + this.Vue = true; + }) + Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 150, 170, 120); + this.FillColor = '#fffffc3c'; + this.context.lineWidth = 10; + this.context.strokeStyle = '#fffffc3c'; + this.context.strokeRect(100, 160, 150, 100); + this.Vue = true; + }) + Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(90, 150, 170, 120); + this.FillColor = '#ff19fa00'; + this.context.lineWidth = 10; + this.context.strokeStyle = '#ff19fa00'; + this.context.strokeRect(100, 160, 150, 100); + this.Vue = true; + }) + }.width('70%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.lineWidth = 10; + this.context.strokeStyle = this.FillColor; + this.context.strokeRect(100, 160, 150, 100); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasTextAlign.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasTextAlign.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf686a91b8e378022e0568815be84aa51952411d --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasTextAlign.ets @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer1'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasTextAlign'; + @State StepTips: string = '操作步骤:点击不同的文本对齐方式控件'+'\n'+'预期结果:原本默认的对齐方式会随点击变化'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('start').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.lineWidth = 2; + this.context.moveTo(180, 10); + this.context.lineTo(180, 310); + this.context.stroke(); + this.context.textAlign = 'start'; + this.context.fillText('textAlign=start', 180, 160); + this.Vue = true; + }) + Text('end').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.lineWidth = 2; + this.context.moveTo(180, 10); + this.context.lineTo(180, 310); + this.context.stroke(); + this.context.textAlign = 'end'; + this.context.fillText('textAlign=end', 180, 160); + this.Vue = true; + }) + Text('left').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.lineWidth = 2; + this.context.moveTo(180, 10); + this.context.lineTo(180, 310); + this.context.stroke(); + this.context.textAlign = 'left'; + this.context.fillText('textAlign=left', 180, 160); + this.Vue = true; + }) + Text('center').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.lineWidth = 2; + this.context.moveTo(180, 10); + this.context.lineTo(180, 310); + this.context.stroke(); + this.context.textAlign = 'center'; + this.context.fillText('textAlign=center', 180, 160); + this.Vue = true; + }) + Text('right').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.lineWidth = 2; + this.context.moveTo(180, 10); + this.context.lineTo(180, 310); + this.context.stroke(); + this.context.textAlign = 'right'; + this.context.fillText('textAlign=right', 180, 160); + this.Vue = true; + }) + }.width('90%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.lineWidth = 2; + this.context.moveTo(180, 10); + this.context.lineTo(180, 310); + this.context.stroke(); + this.context.font = '60px sans-serif'; + this.context.textAlign = 'start'; + this.context.fillText('textAlign=start', 180, 160); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasTextBaseline.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasTextBaseline.ets new file mode 100644 index 0000000000000000000000000000000000000000..2473a85a098100d1010fc3b3f6853432d0b6a403 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/CanvasTextBaseline.ets @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CanvasCustomContainer1'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @State FillColor: string = '#FF000000'; + @State name: string = 'CanvasTextBaseline'; + @State StepTips: string = '操作步骤:点击不同的水平对齐方式'+'\n'+'预期结果:原本默认水平对齐方式会随点击变化'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text('Top').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.strokeStyle = '#0000ff'; + this.context.lineWidth = 2; + this.context.moveTo(0, 120); + this.context.lineTo(400, 120); + this.context.stroke(); + this.context.textBaseline = 'top'; + this.context.fillText('Top', 160, 120); + this.Vue = true; + }) + Text('Bottom').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.strokeStyle = '#0000ff'; + this.context.lineWidth = 2; + this.context.moveTo(0, 120); + this.context.lineTo(400, 120); + this.context.stroke(); + this.context.textBaseline = 'bottom'; + this.context.fillText('Bottom', 160, 120); + this.Vue = true; + }) + Text('Middle').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.strokeStyle = '#0000ff'; + this.context.lineWidth = 2; + this.context.moveTo(0, 120); + this.context.lineTo(400, 120); + this.context.stroke(); + this.context.textBaseline = 'middle'; + this.context.fillText('Middle', 160, 120); + this.Vue = true; + }) + Text('Alphabetic').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=>{ + this.context.clearRect(0, 10, 350, 300); + this.context.strokeStyle = '#0000ff'; + this.context.lineWidth = 2; + this.context.moveTo(0, 120); + this.context.lineTo(400, 120); + this.context.stroke(); + this.context.textBaseline = 'alphabetic'; + this.context.fillText('Alphabetic', 160, 120); + this.Vue = true; + }) + Text('Hanging').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) + .onClick(()=> { + this.context.clearRect(0, 10, 350, 300); + this.context.strokeStyle = '#0000ff'; + this.context.lineWidth = 2; + this.context.moveTo(0, 120); + this.context.lineTo(400, 120); + this.context.stroke(); + this.context.textBaseline = 'hanging'; + this.context.fillText('Hanging', 160, 120); + this.Vue = true; + }) + }.width('90%').height('30%') + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffffffff') + .onReady(() =>{ + this.context.strokeStyle = '#0000ff'; + this.context.lineWidth = 2; + this.context.moveTo(0, 120); + this.context.lineTo(400, 120); + this.context.stroke(); + this.context.font = '60px sans-serif'; + this.context.textBaseline = 'top'; + this.context.fillText('Top', 160, 120); + }) + }.width('100%').height('70%') + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/LongPressGesture.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/LongPressGesture.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1cec3736609ec03849a79a195e0681399a64a79 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/LongPressGesture.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct LongPressGestureExample { + @State X: number = 0; + @State name: string = 'LongPressGesture'; + @State StepTips: string = '操作步骤:用至少一根手指长按图像(最多十根手指)'+'\n'+'预期结果:长按动作触发计数增加'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Image($r("app.media.flower")).height('60%').width('70%') + } + .height('250vp').width('350vp').padding(20) + .gesture( + LongPressGesture({ repeat: true }) + .onAction((event: GestureEvent) => { + if (event.repeat) { + this.X++; + this.Vue = true; + } + }) + .onActionEnd(() => { + this.X = 0; + }) + ) + Text('长按动作连续触发:' + this.X).fontColor(Color.Black) + }.width('100%').height('80%').backgroundColor(Color.White) + .justifyContent(FlexAlign.SpaceEvenly) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + content: this.specificNoParam, + StepTips: this.StepTips, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/PanGesture.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/PanGesture.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb1359bea0d156d94ef0a48212cb98ca1f8365f7 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/PanGesture.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CustomContainer3'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct PanGestureExample { + @State X: number = 0; + @State Y: number = 0; + @State name: string = 'PanGesture'; + @State StepTips: string = '操作步骤:用至少一根手指拖动图像(最多十根手指)'+'\n'+'预期结果:图片正常拖动,偏移坐标显示正常'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Image($r("app.media.flower")).height('60%').width('70%') + } + .height('250vp').width('350vp').padding(20) + .margin(80).translate({ x: this.X, y: this.Y, z: 5 }) + .gesture( + PanGesture({}) + .onActionStart((event: GestureEvent) => { + console.info('Pan start'); + this.Vue = true; + }) + .onActionUpdate((event: GestureEvent) => { + this.X = event.offsetX; + this.Y = event.offsetY; + }) + .onActionEnd(() => { + console.info('Pan end'); + }) + ) + Text('偏移坐标x: ' + this.X + '\n' + '偏移坐标y: ' + this.Y) + }.width('100%').height('80%').backgroundColor(Color.White) + .justifyContent(FlexAlign.SpaceEvenly) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/ArkUI/ArkUI_index', + StepTips:this.StepTips, + content: this.specificNoParam, + X:$X, Y:$Y, + name:$name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/PinchGestureTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/PinchGestureTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..c695570f68739dce66e2b4248ad93f0ee9a895b3 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/PinchGestureTest.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct PinchGuestureTest { + @State X: number = 1; + @State name: string = 'PinchGuesture'; + @State StepTips: string = '操作步骤:用手指触摸捏合图片(至少2根手指,最大为5指)'+'\n'+'预期结果:图片能够被正常捏合放缩'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column(){ + Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Image($r("app.media.flower")).height('60%').width('70%') + } + .height('250vp').width('350vp').padding(20) + .scale({ x: this.X, y: this.X, z: this.X }) + .gesture( + PinchGesture() + .onActionUpdate((event: GestureEvent) => { + this.X = event.scale; + this.Vue = true; + }) + ) + Text('捏合放缩比例:'+this.X).fontColor(Color.Black) + } .width('100%').height('80%').backgroundColor(Color.White) + .justifyContent(FlexAlign.SpaceEvenly) + } + + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/RotationGestureTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/RotationGestureTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..27ead1c14a1435496a7b11527bf4efd85a15e9ef --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/RotationGestureTest.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CustomContainer2'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct RotationGuestureTest { + @State X: number = 0; + @State name: string = 'RotationGuesture'; + @State StepTips: string = '操作步骤:用至少两根手指旋转图像(最多五根手指)'+'\n'+'预期结果:图片能够正常旋转'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column(){ + Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Image($r("app.media.flower")).height('60%').width('70%') + } + .height('250vp').width('350vp').padding(20) + .rotate({ x:1, y:1, z:1, angle: this.X }) + .margin(80) + .gesture( + RotationGesture() + .onActionUpdate((event: GestureEvent) => { + this.X = event.angle; + this.Vue = true; + }) + ) + Text('旋转角度:' + this.X) + }.height('80%').width('100%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + X: $X, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/ScrollListTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/ScrollListTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..19aaac6ed70fd96a98a9c5caa3249914b47d6912 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/ScrollListTest.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct CustomContainerUser { + private listArr: number[] = Array.from(new Array(50).keys()); + @State name: string = 'ScrollingList'; + @State StepTips: string = '操作步骤:滑动列表观察是否能正常滑动'+'\n'+'预期结果:列表滑动正常'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + this.Vue = true; + } + @Builder specificNoParam() { + Column() { + List() { + ForEach(this.listArr,(item:any,index:number) => { + ListItem() { + Text('Item #' + (index + 1)).width('100%').height(50).fontSize(16).fontColor(Color.White).margin({left:'10vp'}) + } + },index => index) + }.height('100%').width('100%').divider({strokeWidth:1,color:Color.Grey}) + }.height('83%').width('100%') + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam.bind(this), + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/SwipeGestureTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/SwipeGestureTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..13b437480acf106e7c63f1aea3545eaca67e5b86 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/SwipeGestureTest.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CustomContainer3'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SwipeGestureTest { + @State X : number = 0; + @State Y : number = 0; + @State name: string = 'SwipeGesture'; + @State StepTips: string = '操作步骤:用至少一根手指滑动图像(最多十根手指)'+'\n'+'预期结果:图片正常滑动,手势滑动角度及速度显示正常'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Image($r("app.media.flower")).height('60%').width('70%') + } + .height('250vp').width('350vp').padding(20) + .rotate({x: 0, y: 0, z: 1, angle: this.X}) + .gesture( + SwipeGesture({fingers: 1, direction: SwipeDirection.Vertical}) + .onAction((event: GestureEvent) => { + this.Y = event.speed; + this.X = event.angle; + this.Vue = true; + }) + ) + Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ + Text("滑动手势速度 : " + this.Y) + Text("滑动手势角度 : " + this.X) + }.height('15%').width('100%').padding(20) + } + .width('100%').height('80%').backgroundColor(Color.White) + .justifyContent(FlexAlign.SpaceEvenly) + } + + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam, + X: $X, Y: $Y, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} + diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/TapGesture.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/TapGesture.ets new file mode 100644 index 0000000000000000000000000000000000000000..a32210ea4498955e98d96dc27903a69fd3e0dbc0 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/TapGesture.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {CustomContainer} from '../common/CustomContainer4'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct TapGestureExample { + @State value: string = ''; + @State name: string = 'TapGesture'; + @State StepTips: string = '操作步骤:用至少一根手指连续双击图像(最多十根手指)'+'\n'+'预期结果:双击图片后文本提示正常弹出'; + @State Vue: boolean = false; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Image($r("app.media.flower")).height('60%').width('70%') + } + .height('250vp').width('350vp').padding(20) + .gesture( + TapGesture({ count: 2 }) + .onAction(() => { + this.value = 'TapGesture onAction'; + this.Vue = true; + }) + ) + Text(this.value) + }.width('100%').height('80%').backgroundColor(Color.White) + .justifyContent(FlexAlign.SpaceEvenly) + } + build() { + Column() { + CustomContainer({ + title: this.name, + StepTips: this.StepTips, + Url: 'pages/ArkUI/ArkUI_index', + content: this.specificNoParam, + value: $value, + name: $name, + Vue: $Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/ArkUI/TouchMoveTest.ets b/validator/acts_validator/src/main/ets/pages/ArkUI/TouchMoveTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..29db7384dbda3ade216844193dc8c7ae4180c143 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/ArkUI/TouchMoveTest.ets @@ -0,0 +1,222 @@ +/* + * 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 FirstDialog from '../model/FirstDialog'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +const TAG = '[Screenshot]'; +let path = globalThis.dir; +@Component +struct CustomContainer1 { + @Link x: number; + @Link y: number; + @Link isshow: Visibility; + @Link name:string; + title : string = ''; + StepTips: string = ''; + Url : string = ''; + Vue : boolean; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None', title:this.name,} + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`) + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} + +@Entry +@Component +struct SetCircle { + @State x: number = 0; + @State y: number = 0; + @State Vue: boolean = false; + @State isshow: Visibility = Visibility.None; + @State name: string = 'TouchMove'; + @State StepTips: string = '操作步骤:手指触摸屏幕并滑动' + '\n' + '预期结果:在手指触摸处出现红色圆圈,并跟随手指滑动'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam1() { + Column() { + Circle() + .width('20vp').height('20vp').position({ x: this.x, y: this.y }).visibility(this.isshow) + .fill(Color.Red) + }.onTouch((event: TouchEvent) => { + let x = event.touches[0].x; + let y = event.touches[0].y; + if (event.type === TouchType.Down) { + this.x = x; + this.y = y; + this.isshow = Visibility.Visible; + } + else if (event.type === TouchType.Move) { + this.x = x; + this.y = y; + this.isshow = Visibility.Visible; + } + else if (event.type === TouchType.Up) { + this.isshow = Visibility.None; + } + this.Vue = true; + }) + .width('100%').height('80%').backgroundColor(Color.White) + + } + + build() { + Column() { + CustomContainer1({ + title: this.name, + Url: 'pages/ArkUI/ArkUI_index', + StepTips: this.StepTips, + content: this.specificNoParam1, + x: $x, + y: $y, + isshow: $isshow, + name: $name, + Vue: this.Vue, + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/MediaLibrary_index.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/MediaLibrary_index.ets new file mode 100644 index 0000000000000000000000000000000000000000..27549150115cb2c865110eca1c86dbe3a19ebc04 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/MediaLibrary_index.ets @@ -0,0 +1,297 @@ +/* + * 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 router from '@ohos.router'; +import fileio from '@ohos.fileio'; +import xml from '@ohos.xml'; +import fileIO from '@ohos.fileio'; +import util from '@ohos.util'; + +const TAG = 'ParseXML'; +let path = globalThis.dir; +let path1; +path1 = path + '/MediaLibrary'; + +@Entry +@Component +struct IndexPage { + @State BackColor: string = '#ff808080'; + @State ClearAll : boolean = false; + private current : number = undefined; + @State count : number = 0; + @State result : string = ''; + private TestCaseList = [ + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_PR_0100',uri:'pages/MediaLibrary/startImagePreviewPromise1'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_PR_0200',uri:'pages/MediaLibrary/startImagePreviewPromise2'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_PR_0300',uri:'pages/MediaLibrary/startImagePreviewPromise3'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_PR_ERR_0400',uri:'pages/MediaLibrary/startImagePreviewPromise4'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_INDEX_CB_0100',uri:'pages/MediaLibrary/startImagePreviewCallback1'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_INDEX_CB_0200',uri:'pages/MediaLibrary/startImagePreviewCallback2'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_INDEX_CB_0300',uri:'pages/MediaLibrary/startImagePreviewCallback3'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_INDEX_CB_ERR_0400',uri:'pages/MediaLibrary/startImagePreviewCallback4'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_CB_0100',uri:'pages/MediaLibrary/startImagePreviewCallback5'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_CB_0200',uri:'pages/MediaLibrary/startImagePreviewCallback6'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGEPREVIEW_CB_ERR_0300',uri:'pages/MediaLibrary/startImagePreviewCallback7'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_CB_0100',uri:'pages/MediaLibrary/startMediaSelectCallback1'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_CB_0200',uri:'pages/MediaLibrary/startMediaSelectCallback2'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_CB_0300',uri:'pages/MediaLibrary/startMediaSelectCallback3'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_CB_0400',uri:'pages/MediaLibrary/startMediaSelectCallback4'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_PR_0100',uri:'pages/MediaLibrary/startMediaSelectPromise1'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_PR_0200',uri:'pages/MediaLibrary/startMediaSelectPromise2'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_PR_0300',uri:'pages/MediaLibrary/startMediaSelectPromise3'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STARTIMAGESELECT_PR_0400',uri:'pages/MediaLibrary/startMediaSelectPromise4'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_PR_0100',uri:'pages/MediaLibrary/storeMediaAssetPromise1'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_PR_0200',uri:'pages/MediaLibrary/storeMediaAssetPromise2'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_PR_0300',uri:'pages/MediaLibrary/storeMediaAssetPromise3'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_PR_0400',uri:'pages/MediaLibrary/storeMediaAssetPromise4'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_PR_ERR_0500',uri:'pages/MediaLibrary/storeMediaAssetPromise5'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_CB_0100',uri:'pages/MediaLibrary/storeMediaAssetCallback1'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_CB_0200',uri:'pages/MediaLibrary/storeMediaAssetCallback2'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_CB_0300',uri:'pages/MediaLibrary/storeMediaAssetCallback3'}, + {title:'SUB_MULTIMEDIA_MEDIALIBRARY_STOREMEDIAASSET_CB_0400',uri:'pages/MediaLibrary/storeMediaAssetCallback4'}, + ] + @State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080', + '#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080', + '#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080','#ff808080'] + onPageShow(){ + if (this.count === 1){ + this.result = router.getParams()['result']; + let titles = router.getParams()['title']; + let name1 = '刚刚点进了哪个用例:'+ titles; + let results = this.result; + if (this.result === 'Pass'){ + this.ColorObject[this.current] = '#ff008000'; + filewrite(name1,results,titles); + } + else if (this.result === 'Fail'){ + this.ColorObject[this.current] = '#ffff0000'; + filewrite(name1,results,titles); + } + else if (this.result === 'None'){ + this.ColorObject[this.current] = this.ColorObject[this.current]; + } + } + + } + build(){ + Column(){ + Row() { + Button() { + Image($r('app.media.ic_public_back')).width('20vp').height('18vp') + }.backgroundColor(Color.Black) + .onClick(() => { + router.back(); + }) + Row(){ + Text('MediaLibrary') + .fontColor(Color.White) + .fontSize('22fp') + }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) + Row() { + Button(){ + Image($r('app.media.ic_public_delete')) + .width('30vp') + .height('30vp') + }.backgroundColor(Color.Black) + .onClick(() => { + AlertDialog.show( + { + message: "是否删除所有记录", + primaryButton: { + value: 'Yes', + action: () => { + this.ClearAll = true; + this.ColorObject.forEach((value, index) => { + this.ColorObject[index] = '#ff808080'; + }); + this.ClearText(); + prompt.showToast({ + message: '结果已删除', duration: 1000 + }); + } + }, + secondaryButton: { + value: 'No', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + }) + Button(){ + Image($r('app.media.ic_public_save')) + .width('30vp') + .height('30vp') + .margin({ left: 30 }) + }.backgroundColor(Color.Black) + .onClick(() => { + this.ReadTextParseXml(); + AlertDialog.show({ + message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/MediaLibrary/MediaLibraryTest.xml -本地路径'", + confirm:{ + value:'OK', + action:()=>{ + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }, + cancel: () => { + prompt.showToast({ + message: '报告已生成', duration: 1000 + }) + } + }) + }) + } + }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) + List({space:5}){ + ForEach(this.TestCaseList,(item,index) => { + ListItem(){ + Row(){ + Text(item.title).fontSize(16).fontColor(Color.Black) + Text(this.BackColor.toString()).visibility(Visibility.None) + }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index]) + .onClick(( )=>{ + this.count = 1; + this.ClearAll=false; + this.current = index; + router.push({ + url: item.uri, + }); + }) + } + },item => item.title) + }.width('100%').height('92%') + }.width('100%').height('100%').backgroundColor(Color.Black) + } + ClearText(){ + fileio.rmdirSync(path1); + fileio.mkdirSync(path1); + } + ReadTextParseXml() { + let ReportPath = path1 + '/MediaLibraryReport.txt'; + let dir = fileio.opendirSync(path1); + console.info("ssssss" + dir); + while (dir) { + let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(40960); + let RD = fileio.readSync(OP,buf); + console.info("ddddd"+RD); + let report; + function ab2str(buf) { + return report = String.fromCharCode.apply(null, new Uint8Array(buf)); + } + ab2str(buf); + let str1 = report.split(";"); + let title = []; + let result = []; + for (let i = 0; i < Math.floor(str1.length / 2); i++) { + title[i] = str1[i*2]; + result[i] = str1[i * 2+1]; + } + let FailIndex = report.indexOf('Fail'); + let FailNum = 0; + while (FailIndex != -1) { + console.log(FailIndex); + FailNum++; + FailIndex = report.indexOf('Fail',FailIndex + 1); + } + let failNum = (FailNum).toString(); + let PassIndex = report.indexOf('Pass'); + let PassNum = 0; + while (PassIndex != -1) { + console.log(PassIndex); + PassNum++; + PassIndex = report.indexOf('Pass',PassIndex + 1); + } + let TestNum = FailNum + PassNum; + let testNum = (TestNum).toString(); + let ignoreNum = (28-TestNum).toString(); + let arrayBuffer = new ArrayBuffer(40960); + let bufView = new DataView(arrayBuffer); + let serializer = new xml.XmlSerializer(bufView); + serializer.setDeclaration(); + serializer.startElement("testsuite"); + serializer.setAttributes("name", "ActsMediaLibraryTest"); + serializer.setAttributes("time", " "); + serializer.setAttributes("errors", "0"); + serializer.setAttributes("disabled", "0"); + serializer.setAttributes("failures", failNum); + serializer.setAttributes("ignored", ignoreNum); + serializer.setAttributes("tests", testNum); + serializer.setAttributes("message", " "); + serializer.setAttributes("modulename", "ActsMediaLibraryTest"); + for (let i = 0; i < title.length; i++) { + serializer.startElement("testcase"); + serializer.setAttributes("name", String(title[i])); + serializer.setAttributes("status", " "); + serializer.setAttributes("time", " "); + serializer.setAttributes("classname", " "); + serializer.setAttributes("result", String(result[i])); + serializer.setAttributes("level", " "); + serializer.setAttributes("message", " "); + serializer.endElement(); + } + serializer.endElement(); + + let that = new util.TextDecoder('utf-8'); + let array = new Uint8Array(arrayBuffer); + let serializerStr = that.decode(array); + let xmlPath = path1 + "/MediaLibraryTest.xml"; + console.info(xmlPath); + try { + console.error(TAG, "write xmlPath =" + xmlPath); + var xmlfd = fileIO.openSync(xmlPath, 0o102, 0o666); + fileIO.writeSync(xmlfd, serializerStr); + } catch (err) { + console.error(TAG, "read xmlPath =" + xmlPath + "error:" + err); + } finally { + fileIO.closeSync(xmlfd); + } + return; + } + } +} +function filewrite(name1,results,titles){ + let txtpath = path1 + '/MediaLibraryReport.txt'; + let fd = fileio.openSync(txtpath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(4096); + let RD = fileio.readSync(fd,buf); + console.info("RRRRRRRRRRd"+RD); + let report = String.fromCharCode.apply(null,new Uint8Array(buf)); + let WriteTitle = (titles).toString(); + let number = WriteTitle.length + 6; + let Index = report.indexOf(WriteTitle); + let Log = (titles+";"+results+";").toString(); + if (Index == -1){ + fileio.writeSync(fd,Log); + } + else if (Index != -1){ + let key = report.substring(Index,Index+number); + let FD = fileio.openSync(txtpath, 0o102, 0o666); + report = report.replace(key,Log); + let buffer = new ArrayBuffer(4096); + let rd = fileio.readSync(FD,buffer); + let Report = report.substring(0,rd); + fileio.closeSync(FD); + let Fd = fileio.openSync(txtpath, 0o102, 0o666); + fileio.writeSync(Fd,Report); + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback1.ets new file mode 100644 index 0000000000000000000000000000000000000000..dda216ee9df7199d4478254d4e631edf12d87b00 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback1.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewCallback1'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:可以预览到一张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewCallback1'; + let images = [ + "datashare:///media/image/3", + ]; + let index = 1; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { + if (err) { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + return; + } + console.log(TAG + "Succeeded in previewing the images."); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback2.ets new file mode 100644 index 0000000000000000000000000000000000000000..23a15813e1bfc30ec51263b3b9828a6e94cbddb9 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback2.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewCallback2'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:起始图片为第一张图片,一共可以预览到两张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewCallback2'; + let images = [ + "datashare:///media/image/3", + "datashare:///media/image/4", + ]; + let index = 1; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { + if (err) { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + return; + } + console.log(TAG + "Succeeded in previewing the images."); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback3.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c6cb554007f2aa6ff1da1b077384de6c0987fe4 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback3.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewCallback3'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:起始图片为第三张图片,一共可以预览到四张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewCallback3'; + let images = [ + "datashare:///media/image/3", + "datashare:///media/image/4", + "datashare:///media/image/5", + "datashare:///media/image/6", + ]; + let index = 2; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { + if (err) { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + return; + } + console.log(TAG + "Succeeded in previewing the images."); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback4.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab23b2ba5232bc588c0f5d6a909f5f572ede81cd --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback4.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewCallback4'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:预览图片失败'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewCallback4'; + let images = [ + "datashare:///media/image/9999", + "datashare:///media/image/9998", + "datashare:///media/image/9997", + "datashare:///media/image/9996", + ]; + let index = 2; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => { + if (err) { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + return; + } + console.log(TAG + "Succeeded in previewing the images."); + }); + }) + + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback5.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback5.ets new file mode 100644 index 0000000000000000000000000000000000000000..a7c74d7d0ddc5d33e49809700efb5f5220260a71 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback5.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewCallback5'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:成功预览一张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewCallback5'; + let images = [ + "datashare:///media/image/3", + ]; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => { + if (err) { + console.log(TAG + "startImagePreview_One An error occurred when previewing the images." + JSON.stringify(err)); + return; + } + console.log(TAG + "startImagePreview_One Succeeded in previewing the images."); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback6.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback6.ets new file mode 100644 index 0000000000000000000000000000000000000000..15cb61dcb08fcf58c48b2780356c6d4b46aa482d --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback6.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewCallback6'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:成功预览五张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewCallback6'; + let images = [ + "datashare:///media/image/3", + "datashare:///media/image/4", + "datashare:///media/image/5", + "datashare:///media/image/6", + "datashare:///media/image/2", + ]; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => { + if (err) { + console.log(TAG + "startImagePreview_MultiPle An error occurred when previewing the images." + JSON.stringify(err)); + return; + } + console.log(TAG + "startImagePreview_MultiPle Succeeded in previewing the images."); + }); + }) + + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback7.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback7.ets new file mode 100644 index 0000000000000000000000000000000000000000..db8c63dc1aae81d452b4b1879c11511062200434 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewCallback7.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewCallback7'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:预览图片失败'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewCallback7'; + let images = [ + "datashare:///media/image/9999", + ]; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => { + if (err) { + console.log(TAG + "startImagePreview_One An error occurred when previewing the images." + JSON.stringify(err)); + return; + } + console.log(TAG + "startImagePreview_One Succeeded in previewing the images."); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise1.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ef1b89fe9b8c69af03e323fb9739a225ff84407 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise1.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewPromise1'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:可以成功预览到一张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewPromise1'; + let images = [ + "datashare:///media/image/3", + ]; + let index = 1; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { + console.log(TAG + "Succeeded in previewing the images."); + }).catch((err) => { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/MediaLibrary/MediaLibrary_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} + diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise2.ets new file mode 100644 index 0000000000000000000000000000000000000000..20bd9528651807e248902ad7004e0f30df7b5fd1 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise2.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewPromise2'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:起始图片为第一张图片,一共可以预览到两张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewPromise2'; + let images = [ + "datashare:///media/image/3", + "datashare:///media/image/4", + ]; + let index = 1; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { + console.log(TAG + "Succeeded in previewing the images."); + }).catch((err) => { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/MediaLibrary/MediaLibrary_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} + diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise3.ets new file mode 100644 index 0000000000000000000000000000000000000000..77779380181f1a48b7238ba0bc1f9c878d3b9e70 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise3.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewPromise3'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:起始图片为第二张图片,一共可以预览到三张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewPromise3'; + let images = [ + "datashare:///media/image/3", + "datashare:///media/image/4", + "datashare:///media/image/5", + ]; + let index = 1; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { + console.log(TAG + "Succeeded in previewing the images."); + }).catch((err) => { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + }); + }) + + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/MediaLibrary/MediaLibrary_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} + diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise4.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0978c6f296af0fbffd2696abb29813b12af94c1 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startImagePreviewPromise4.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startImagePreviewPromise4'; + @State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:预览图片失败'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startImagePreviewPromise4'; + let images = [ + "datashare:///media/image/9999", + "datashare:///media/image/9998", + "datashare:///media/image/9997", + ]; + let index = 1; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => { + console.log(TAG + "Succeeded in previewing the images."); + }).catch((err) => { + console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + + build() { + Column() { + CustomContainer({ + title: this.name, + Url: 'pages/MediaLibrary/MediaLibrary_index', + StepTips: this.StepTips, + content: this.specificNoParam, + FillColor: $FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} + diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback1.ets new file mode 100644 index 0000000000000000000000000000000000000000..53c617af6fcf8c6accd2905ccf7457c7b6f23fdf --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback1.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectCallback1'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择一张图片(单选)'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelectCallback1'; + let option : mediaLibrary.MediaSelectOption = { + type : "image", + count : 1 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { + if (err) { + console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); + return; + } + console.log(TAG + "image resources selected." + JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback2.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5f5af80518242e9da64c3b641ede041a2895806 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback2.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectCallback2'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多张图片(多选)'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelectCallback2'; + let option : mediaLibrary.MediaSelectOption = { + type : "image", + count : 2 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { + if (err) { + console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); + return; + } + console.log(TAG + "image resources selected." + JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback3.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fd60fdf14bf744eb9a4cddcc3b4222b3bb8a562 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback3.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectCallback3'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个图片、视频文件'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelectCallback3'; + let option : mediaLibrary.MediaSelectOption = { + type : "media", + count : 2 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { + if (err) { + console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); + return; + } + console.log(TAG + "image resources selected." + JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback4.ets new file mode 100644 index 0000000000000000000000000000000000000000..cde6cafa14d8cf607286e284ade9c519bdf36dcb --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectCallback4.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectCallback4'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个视频资源'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelectCallback4'; + let option : mediaLibrary.MediaSelectOption = { + type : "video", + count : 2 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => { + if (err) { + console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err)); + return; + } + console.log(TAG + "image resources selected." + JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise1.ets new file mode 100644 index 0000000000000000000000000000000000000000..2105f1598e41333aa51af539167147337e5e4074 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise1.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectPromise1'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择单张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelectPromise1'; + let option : mediaLibrary.MediaSelectOption = { + type : "image", + count : 1 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { + console.log(TAG + "Media resources selected." + JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise2.ets new file mode 100644 index 0000000000000000000000000000000000000000..577e05fdf7146d2dba607fc8791c8bd0a4ed2280 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise2.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectPromise2'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多张图片'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelectPromise2'; + let option : mediaLibrary.MediaSelectOption = { + type : "image", + count : 2 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { + console.log(TAG + "Media resources selected." + JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise3.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d07d3f969113c26be54652f136e3902af6cd8fb --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise3.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectPromise3'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个图片、视频资源'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelect5_media2'; + let option : mediaLibrary.MediaSelectOption = { + type : "media", + count : 2 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { + console.log(TAG + "Media resources selected." + JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise4.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e33a6d9f6bca0b58e467f5243437d429654170d --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/startMediaSelectPromise4.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'startMediaSelectPromise4'; + @State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择单个视频'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' }) + .onClick(() => { + let TAG = 'startMediaSelect5_video2'; + let option : mediaLibrary.MediaSelectOption = { + type : "video", + count : -1 + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => { + console.log(TAG + "Media resources selected." + JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err)); + }); + }) + + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback1.ets new file mode 100644 index 0000000000000000000000000000000000000000..5093fd261cc6517c29b9ce6e226b9b09ac52dd00 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback1.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetCallback1'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存一张图片,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam(){ + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetCallback1'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let JpgPath = data + "/files/"+time + ".jpg"; + + let srcFd =await fileio.open(JpgPath,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : JpgPath, + mimeType : "image/*", + relativePath : "Pictures/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { + if (err) { + console.log(TAG +"An error occurred when storing image resources." + JSON.stringify(err)); + return; + } + AlertDialog.show( + { + title: '保存成功', + message: '查询到Pictures路径下新增一个.jpg格式的图片资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed callbacks') + } + } + ) + console.log(TAG + "image resources stored. "+ JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback2.ets new file mode 100644 index 0000000000000000000000000000000000000000..050fcf8b1ba4c9bd8100daf454b90c6bdd69f223 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback2.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetCallback2'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存音频,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam(){ + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetCallback2'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let PathMp3 = data + "/files/"+time + ".mp3"; + + let srcFd =await fileio.open(PathMp3,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : PathMp3, + mimeType : "audio/mp3", + relativePath : "Audios/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { + if (err) { + console.log(TAG + "An error occurred when storing audios resources."+ JSON.stringify(err)); + return; + } + AlertDialog.show( + { + title: '保存成功', + message: '查询到Audios路径下新增一个.mp3格式的音频资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed callbacks') + } + } + ) + console.log(TAG + "audios resources stored. "+ JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback3.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c714626632e335be479b557a9ace2c28ac42d1f --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback3.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetCallback3'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存视频,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam(){ + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetCallback3'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let PathMp4 = data + "/files/"+time + ".mp4"; + + let srcFd =await fileio.open(PathMp4,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : PathMp4, + mimeType : "video/mp4", + relativePath : "Videos/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { + if (err) { + console.log(TAG + "An error occurred when storing videos resources."+ JSON.stringify(err)); + return; + } + AlertDialog.show( + { + title: '保存成功', + message: '查询到Videos路径下新增一个.mp4格式的视频资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed callbacks') + } + } + ) + console.log(TAG + "videos resources stored. "+ JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback4.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0f349cc3f8a7df257046ef02ef45fccdefb3e51 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetCallback4.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetCallback4'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存文件,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam(){ + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetCallback4'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let PathPdf = data + "/files/"+time + ".Pdf"; + + let srcFd =await fileio.open(PathPdf,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : PathPdf, + mimeType : "file/pdf", + relativePath : "Documents/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => { + if (err) { + console.log(TAG + "An error occurred when storing files resources."+ JSON.stringify(err)); + return; + } + AlertDialog.show( + { + title: '保存成功', + message: '查询到Documents路径下新增一个.Pdf格式的文件资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking1 callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed1 callbacks') + } + } + ) + console.log(TAG + "files resources stored. "+ JSON.stringify(value)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise1.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise1.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ead6443b048225c00cd39835f7989e86d52efc0 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise1.ets @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetPromise1'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存图片,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetPromise1'; + let context0 = featureAbility.getContext(); + let data = await context0.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let JpgPath = data + "/files/"+time + ".jpg"; + + let srcFd =await fileio.open(JpgPath,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : JpgPath, + mimeType : "image/*", + relativePath : "Pictures/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { + AlertDialog.show( + { + title: '保存成功', + message: '查询到Pictures路径下新增一个.jpg格式的图片资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed callbacks') + } + } + ) + console.log(TAG + "image resources stored. "+ JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + "An error occurred when storing image resources."+ JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise2.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise2.ets new file mode 100644 index 0000000000000000000000000000000000000000..1201ec8a2962eb6616bee793c17c08516c49c19e --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise2.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetPromise2'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存音频,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetPromise2'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let PathMp3 = data + "/files/"+time + ".mp3"; + + let srcFd =await fileio.open(PathMp3,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : PathMp3, + mimeType : "audio/mp3", + relativePath : "Audios/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { + AlertDialog.show( + { + title: '保存成功', + message: '查询到Audios路径下新增一个.mp3格式的音频资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed callbacks') + } + } + ) + console.log(TAG + "audios resources stored. "+ JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + "An error occurred when storing audios resources."+ JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise3.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise3.ets new file mode 100644 index 0000000000000000000000000000000000000000..58be029a61ba538438b290ab2ca49bdc8db30f8a --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise3.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetPromise3'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存视频,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetPromise3'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let PathMp4 = data + "/files/"+time + ".mp4"; + + let srcFd =await fileio.open(PathMp4,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : PathMp4, + mimeType : "video/mp4", + relativePath : "Videos/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { + AlertDialog.show( + { + title: '保存成功', + message: '查询到Videos路径下新增一个.mp4格式的视频资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + ' Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + ' Closed callbacks') + } + } + ) + console.log(TAG + " videos resources stored. "+ JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + " An error occurred when storing videos resources."+ JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise4.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise4.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1c4171c19fef07770f3f23311556f3c8cc06796 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise4.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetPromise4'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存文件,资源内容为“hello world”'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetPromise4'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let PathPdf = data + "/files/"+time + ".Pdf"; + + let srcFd =await fileio.open(PathPdf,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : PathPdf, + mimeType : "file/pdf", + relativePath : "Documents/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { + AlertDialog.show( + { + title: '保存成功', + message: '查询到Documents路径下新增一个.Pdf格式的文件资源,资源内容为“hello world”', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed callbacks') + } + } + ) + console.log(TAG + "files resources stored. "+ JSON.stringify(value)); + }).catch((err) => { + console.log(TAG + "An error occurred when storing files resources."+ JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise5.ets b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise5.ets new file mode 100644 index 0000000000000000000000000000000000000000..d949690565d6388751dd002213707569236c171e --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/MediaLibrary/storeMediaAssetPromise5.ets @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import {CustomContainer} from '../common/MediaCustomContainer'; +import FirstDialog from '../model/FirstDialog'; +@Entry +@Component +struct SetCircle { + @State FillColor: string = '#FF000000'; + @State name: string = 'storeMediaAssetPromise5'; + @State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:保存图片失败'; + async aboutToAppear(){ + await FirstDialog.ChooseDialog(this.StepTips,this.name); + } + @Builder specificNoParam() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' }) + .onClick(async () => { + let TAG = 'storeMediaAssetPromise5'; + let data = await globalThis.abilityContext.getFilesDir(); + let time = new Date().getTime(); + console.log("data is"+ JSON.stringify(data)); + data = 'data/storage/el2/base/haps/entry'; + let JpgPath = data + "/files/"+time + ".jpg"; + + let srcFd =await fileio.open(JpgPath,0o102,0o0600); + await fileio.write(srcFd,"hello world"); + await fileio.close(srcFd); + + let option = { + src : JpgPath, + mimeType : "123", + relativePath : "Pictures/" + }; + mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => { + console.log(TAG + "image resources stored. "+ JSON.stringify(value)); + }).catch((err) => { + AlertDialog.show( + { + title: '保存失败', + message: '媒体MIME类型错误', + confirm: { + value: 'OK', + action: () => { + console.info(TAG + 'Button-clicking callback') + } + }, + cancel: () => { + console.info(TAG + 'Closed callbacks') + } + } + ) + console.log(TAG + "An error occurred when storing image resources."+ JSON.stringify(err)); + }); + }) + } + }.width('100%').height('80%').backgroundColor(Color.White) + } + build() { + Column() { + CustomContainer({ + title: this.name, + Url:'pages/MediaLibrary/MediaLibrary_index', + StepTips:this.StepTips, + content: this.specificNoParam, + FillColor:$FillColor, + name:$name + }) + }.width('100%').height('100%').backgroundColor(Color.Black) + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer1.ets b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer1.ets new file mode 100644 index 0000000000000000000000000000000000000000..966c801a29888c0dd9c94e7798b54b0fd64e44f4 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer1.ets @@ -0,0 +1,166 @@ +/* + * 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 { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @Link FillColor: string; + @Link name:string; + Url : string = ''; + title : string = ''; + StepTips: string = ''; + @Link Vue : boolean; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None', } + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} diff --git a/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer2.ets b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer2.ets new file mode 100644 index 0000000000000000000000000000000000000000..431aab946da03971a9a525f34aaaadd34a9963e8 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CanvasCustomContainer2.ets @@ -0,0 +1,168 @@ +/* + * 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 { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + @Link FillColor: string; + @Link X: number; + @Link name: string; + Url : string = ''; + title : string = ''; + StepTips: string = ''; + @Link Vue: boolean; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None',} + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..45b9bb5b1d20b00ffde3aeb3bfb31a2d39f00144 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer.ets @@ -0,0 +1,163 @@ +/* + * 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; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None',} + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show({ + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + }) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer2.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer2.ets new file mode 100644 index 0000000000000000000000000000000000000000..6fd227daba0024905c0bd34218e2fbff3312511f --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer2.ets @@ -0,0 +1,164 @@ +/* + * 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 X: number; + @Link name: string; + title : string = ''; + StepTips: string = ''; + Url : string = ''; + @Link Vue : boolean; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None', } + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer3.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer3.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b930fe678792ab38df392bf1974c26e15fdc6fa --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer3.ets @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import fileio from '@ohos.fileio'; +import prompt from '@ohos.prompt'; +import router from '@ohos.router'; +import screenshot from '@ohos.screenshot'; +import image from '@ohos.multimedia.image'; +import Logger from '../model/Logger'; +import mediaLibrary from '@ohos.multimedia.mediaLibrary'; + +let path = globalThis.dir; +const TAG = '[Screenshot]'; +@Component +export struct CustomContainer { + @Link X: number; + @Link Y: number; + @Link name:string; + title : string = ''; + StepTips: string = ''; + Url : string = ''; + @Link Vue : boolean; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None', } + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer4.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer4.ets new file mode 100644 index 0000000000000000000000000000000000000000..f23f59316719793439ab068cdecde191b577dffc --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer4.ets @@ -0,0 +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 value: string; + @Link name: string; + title : string = ''; + StepTips: string = ''; + Url : string = ''; + @Link Vue : boolean; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None', } + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show({ + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + }) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/common/CustomContainer5.ets b/validator/acts_validator/src/main/ets/pages/common/CustomContainer5.ets new file mode 100644 index 0000000000000000000000000000000000000000..f29cc4c521f993a4643cde094674cbd308ac3d1c --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/CustomContainer5.ets @@ -0,0 +1,166 @@ +/* + * 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 X: number; + @Link Y: number; + @Link V: Visibility; + @Link name: string; + title : string = ''; + StepTips: string = ''; + Url : string = ''; + @Link Vue : boolean; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + if(this.Vue == false){ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey).opacity(0.4) + .onClick(()=>{ + + }) + } + else{ + Button({stateEffect:this.Vue}) { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None',} + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} diff --git a/validator/acts_validator/src/main/ets/pages/common/MediaCustomContainer.ets b/validator/acts_validator/src/main/ets/pages/common/MediaCustomContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..94de1f01b70bd3566da79157b646e68599bec3e0 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/common/MediaCustomContainer.ets @@ -0,0 +1,153 @@ +/* + * 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; + Url : string = ''; + title : string = ''; + StepTips: string = ''; + @BuilderParam content: () => void; + @Builder + PassBtn(text: Resource, isFullScreen: boolean) { + Button() { + Image($r('app.media.ic_public_pass')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Pass', title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '通过', duration: 1000 + }); + }) + } + @Builder + FailBtn(text: Resource, isFullScreen: boolean) { + Button(){ + Image($r('app.media.ic_public_fail')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'Fail',title : this.name, + } + }) + this.getScreen(isFullScreen); + prompt.showToast({ + message: '失败', duration: 1000 + }); + }) + } + build() { + Column() { + Row() { + Button(){ + Image($r('app.media.ic_public_back')).width('20vp').height('18vp').margin({left:'20vp'}) + }.backgroundColor(Color.Black) + .onClick(()=>{ + router.back({ + url:this.Url, + params: {result : 'None',} + }) + }) + Text(this.title).fontColor(Color.White).fontSize('18fp').margin({left:'-20vp'}) + Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) + }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) + this.content(); + Blank() + Row() { + this.PassBtn($r('app.string.btn_fullscreen'), true); + Button(){ + Image($r('app.media.ic_public_help')).width('20vp').height('20vp') + }.width('30%').height('30vp').backgroundColor(Color.Grey) + .onClick(() =>{ + AlertDialog.show( + { + title:'操作提示', + message: this.StepTips, + confirm:{ + value:'OK', + action:()=>{ + } + } + } + ) + }) + this.FailBtn($r('app.string.btn_fullscreen'), true); + }.width('100%').justifyContent(FlexAlign.SpaceEvenly).backgroundColor(Color.Black) + }.height('98%').width('100%') + } + async savePicture(data: image.PixelMap, context: any) { + Logger.info(TAG, `savePicture`); + let packOpts: image.PackingOption = { + format: "image/jpeg", quality: 100 + }; + let info = { + prefix: 'IMG_', suffix: '.jpg', directory: mediaLibrary.DirectoryType.DIR_IMAGE + }; + let name = this.name; + let displayName = `${info.prefix}${name}${info.suffix}`; + let dirPath = path + '/' + displayName; + let imagePackerApi = image.createImagePacker(); + let arrayBuffer = await imagePackerApi.packing(data, packOpts); + let fd = fileio.openSync(dirPath,0o102,0o666); + imagePackerApi.release(); + try { + await fileio.write(fd, arrayBuffer); + } catch (err) { + Logger.error(`write failed, code is ${err.code}, message is ${err.message}`); + } + await fileio.close(fd); + Logger.info(TAG, `write done`); + } + getScreen = (isFullScreen: boolean) => { + let screenshotOptions: screenshot.ScreenshotOptions = { + screenRect: { left: 0, top: 0, width: 400, height: 400 }, + imageSize: { width: 400, height: 400 }, + rotation: 0, + displayId: 0 + }; + if (isFullScreen) { + screenshotOptions = { + rotation: 0 + } + } + try { + screenshot.save(screenshotOptions, (err, data: image.PixelMap) => { + if (err) { + Logger.info(TAG, `Failed to save the screenshot. Error:${JSON.stringify(err)}`); + } + Logger.info(TAG, 'save callback'); + this.savePicture(data, getContext(this) as any); + }) + } catch (err) { + Logger.error(`save failed, code is ${err.code}, message is ${err.message}`); + } + } +} diff --git a/validator/acts_validator/src/main/ets/pages/index.ets b/validator/acts_validator/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c402903b97430dc4d87a0de3a3b3f1918f216ed --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/index.ets @@ -0,0 +1,323 @@ +/* + * 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 router from '@ohos.router'; +import fileio from '@ohos.fileio'; +import xml from '@ohos.xml'; +import fileIO from '@ohos.fileio'; +import util from '@ohos.util'; +import DateTimeUtil from './model/DateTimeUtil' + +const TAG = 'ParseXML'; +let path=globalThis.dir; +let path1; +let path2; +console.info("ssssssssss"+path); +path1 = path + '/ArkUI'; +console.info("ssssssssss"+path1); +path2 = path + '/MediaLibrary'; +console.info("ssssssssss"+path2); +fileio.rmdirSync(path); +fileio.mkdirSync(path); +fileio.mkdirSync(path1); +fileio.mkdirSync(path2); + +@Entry +@Component +struct IndexPage { + private TestCaseList = [ + {title:'ArkUI',uri:'pages/ArkUI/ArkUI_index'}, + {title:'MediaLibrary',uri:'pages/MediaLibrary/MediaLibrary_index'}, + {title:'Camera',uri:'pages/Camera/Camera_index'}, + ] + @State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080'] + build(){ + Column(){ + Row() { + Text('ActValidator') + .fontColor(Color.White) + .fontSize('22fp') + 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.ClearText(); + prompt.showToast({ + message: '结果已删除', duration: 1000 + }); + } + }, + secondaryButton: { + value: 'No', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + }) + Button(){ + Image($r('app.media.ic_public_save')) + .width('30vp') + .height('30vp') + .margin({ left: 30 }) + }.backgroundColor(Color.Black) + .onClick(() => { + this.SaveXml(); + AlertDialog.show({ + message: "报告已生成,如需查看通过命令行输入'hdc_std file recv hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/Test.xml -本地路径'", + confirm:{ + value:'OK', + action:()=>{ + prompt.showToast({ + message: '总报告已生成', duration: 1000 + }) + } + }, + cancel: () => { + prompt.showToast({ + message: '总报告已生成', duration: 1000 + }); + } + }) + }) + } + }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%') + 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.ColorObject[index]) + .onClick(()=>{ + router.push({ + url: item.uri, + }) + let dateTimeUtil = new DateTimeUtil(); + let time = `${dateTimeUtil.getFullYear()}-${dateTimeUtil.getMonth()}-${dateTimeUtil.getDate()} ${dateTimeUtil.getHour()}:${dateTimeUtil.getMinute()}:${dateTimeUtil.getSecond()}`; + let TimePath = path + "/Time.txt"; + let OP = fileio.openSync(TimePath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(4096); + fileio.readSync(OP,buf); + let Log = (time + ";").toString(); + fileio.writeSync(OP,Log); + }) + } + },item => item.title) + }.width('100%').height('92%') + }.width('100%').height('100%').backgroundColor(Color.Black) + } + ClearText(){ + fileio.rmdirSync(path); + fileio.mkdirSync(path); + fileio.mkdirSync(path1); + fileio.mkdirSync(path2); + } + SaveXml() { + let dateTimeUtil = new DateTimeUtil(); + let endtime = `${dateTimeUtil.getFullYear()}-${dateTimeUtil.getMonth()}-${dateTimeUtil.getDate()} ${dateTimeUtil.getHour()}:${dateTimeUtil.getMinute()}:${dateTimeUtil.getSecond()}`; + let TimePath = path + "/Time.txt"; + let fd = fileio.openSync(TimePath, 0o100 | 0o2002, 0o664); + let buf = new ArrayBuffer(40960); + fileio.readSync(fd,buf); + let StartTime = String.fromCharCode.apply(null, new Uint8Array(buf)); + let Index = StartTime.indexOf(';'); + let starttime = StartTime.substring(0,Index); + + let path11 = path1 + '/ArkUI.txt'; + let path22 = path2 + '/MediaLibrary.txt'; + let OP1 = fileio.openSync(path11, 0o100 | 0o2002, 0o664); + let buf1 = new ArrayBuffer(40960); + fileio.readSync(OP1,buf1); + let ArkUIReport; + let MediaLibraryReport; + + function ab2str1(buf1) { + return ArkUIReport = String.fromCharCode.apply(null, new Uint8Array(buf1)); + } + ab2str1(buf1); + let str1 = ArkUIReport.split(";"); + let title1 = []; + let result1 = []; + for (let i = 0; i < Math.floor(str1.length / 2); i++) { + title1[i] = str1[i * 2]; + result1[i] = str1[i * 2 + 1]; + } + + let OP2 = fileio.openSync(path22, 0o100 | 0o2002, 0o664); + let buf2 = new ArrayBuffer(40960); + fileio.readSync(OP2,buf2); + function ab2str2(buf2) { + return MediaLibraryReport = String.fromCharCode.apply(null, new Uint8Array(buf2)); + } + ab2str2(buf2); + let str2 = MediaLibraryReport.split(";"); + let title2 = []; + let result2 = []; + for (let i = 0; i < Math.floor(str2.length / 2); i++) { + title2[i] = str2[i * 2]; + result2[i] = str2[i * 2 + 1]; + } + + let report = ArkUIReport + MediaLibraryReport; + let FailIndex = report.indexOf('Fail'); + let FailNum = 0; + while(FailIndex != -1) { + console.log(FailIndex); + FailNum++; + FailIndex = report.indexOf('Fail',FailIndex + 1); + } + let failNum = (FailNum).toString(); + let PassIndex = report.indexOf('Pass'); + let PassNum = 0; + while(PassIndex != -1) { + console.log(PassIndex); + PassNum++; + PassIndex = report.indexOf('Pass',PassIndex + 1); + } + let TestNum = FailNum + PassNum; + let testNum = (TestNum).toString(); + let ignoreNum = (52-TestNum).toString(); + + let ArkUIFailIndex = ArkUIReport.indexOf('Fail'); + let ArkUIFailNum = 0; + while (ArkUIFailIndex != -1) { + console.log(ArkUIFailIndex); + ArkUIFailNum++; + ArkUIFailIndex = ArkUIReport.indexOf('Fail',ArkUIFailIndex + 1); + } + let ArkuiFailNum = (ArkUIFailNum).toString(); + let ArkUIPassIndex = ArkUIReport.indexOf('Pass'); + let ArkUIPassNum = 0; + while (ArkUIPassIndex != -1) { + console.log(ArkUIPassIndex); + ArkUIPassNum++; + ArkUIPassIndex = ArkUIReport.indexOf('Pass',ArkUIPassIndex + 1); + } + let ArkUITestNum = ArkUIFailNum + ArkUIPassNum; + let ArkuiTestNum = (ArkUIPassNum).toString(); + let ArkUIIgnoreNum = (24-ArkUITestNum).toString(); + + let MediaLibraryFailIndex = MediaLibraryReport.indexOf('Fail'); + let MediaLibraryFailNum = 0; + while (MediaLibraryFailIndex != -1) { + console.log(MediaLibraryFailIndex); + MediaLibraryFailNum++; + MediaLibraryFailIndex = MediaLibraryReport.indexOf('Fail',MediaLibraryFailIndex + 1); + } + let medialibraryFailNum = (MediaLibraryFailNum).toString(); + let MediaLibraryPassIndex = MediaLibraryReport.indexOf('Pass'); + let MediaLibraryPassNum = 0; + while (MediaLibraryPassIndex != -1) { + console.log(MediaLibraryPassIndex); + MediaLibraryPassNum++; + MediaLibraryPassIndex = MediaLibraryReport.indexOf('Pass',MediaLibraryPassIndex + 1); + } + let MediaLibraryTestNum = MediaLibraryFailNum + MediaLibraryPassNum; + let medialibraryTestNum = (MediaLibraryPassNum).toString(); + let MediaLibraryIgnoreNum = (28-MediaLibraryTestNum).toString(); + + let arrayBuffer = new ArrayBuffer(40960); + let bufView = new DataView(arrayBuffer); + let serializer = new xml.XmlSerializer(bufView); + serializer.setDeclaration(); + serializer.startElement("testsuites"); + serializer.setAttributes("name", "ActValidator"); + serializer.setAttributes("starttime", starttime); + serializer.setAttributes("endtime", endtime); + serializer.setAttributes("errors", "0"); + serializer.setAttributes("disabled", "0"); + serializer.setAttributes("failures", failNum); + serializer.setAttributes("tests", testNum); + serializer.setAttributes("ignored", ignoreNum); + serializer.setAttributes("unavailable", "0"); + serializer.setAttributes("productinfo", "{ }"); + serializer.setAttributes("modules", " "); + serializer.setAttributes("runmodules", " "); + serializer.startElement("testsuite"); + serializer.setAttributes("name", "ActsArkUITest"); + serializer.setAttributes("time", " "); + serializer.setAttributes("errors", "0"); + serializer.setAttributes("disabled", "0"); + serializer.setAttributes("failures", ArkuiFailNum); + serializer.setAttributes("ignored", ArkUIIgnoreNum); + serializer.setAttributes("tests", ArkuiTestNum); + serializer.setAttributes("message", " "); + serializer.setAttributes("modulename", "ActsArkUITest"); + for (let i = 0; i < title1.length; i++) { + serializer.startElement("testcase"); + serializer.setAttributes("name", String(title1[i])); + serializer.setAttributes("status", " "); + serializer.setAttributes("time", " "); + serializer.setAttributes("classname", " "); + serializer.setAttributes("result", String(result1[i])); + serializer.setAttributes("level", " "); + serializer.setAttributes("message", " "); + serializer.endElement(); + } + serializer.endElement(); + + serializer.startElement("testsuite"); + serializer.setAttributes("name", "ActsMediaLibraryTest"); + serializer.setAttributes("time", " "); + serializer.setAttributes("errors", "0"); + serializer.setAttributes("disabled", "0"); + serializer.setAttributes("failures", medialibraryFailNum); + serializer.setAttributes("ignored", MediaLibraryIgnoreNum); + serializer.setAttributes("tests", medialibraryTestNum); + serializer.setAttributes("message", " "); + serializer.setAttributes("modulename", "ActsMediaLibraryTest"); + for (let i = 0; i < title2.length; i++) { + serializer.startElement("testcase"); + serializer.setAttributes("name", String(title2[i])); + serializer.setAttributes("status", " "); + serializer.setAttributes("time", " "); + serializer.setAttributes("classname", " "); + serializer.setAttributes("result", String(result2[i])); + serializer.setAttributes("level", " "); + serializer.setAttributes("message", " "); + serializer.endElement(); + } + serializer.endElement(); + serializer.endElement(); + + let that = new util.TextDecoder('utf-8'); + let array = new Uint8Array(arrayBuffer); + let serializerStr = that.decode(array); + let xmlPath = path + "/Test.xml"; + console.info(xmlPath); + try { + console.error(TAG, "write xmlPath =" + xmlPath); + var xmlfd = fileIO.openSync(xmlPath, 0o102, 0o666); + fileIO.writeSync(xmlfd, serializerStr); + } catch (err) { + console.error(TAG, "read xmlPath =" + xmlPath + "error:" + err); + } finally { + fileIO.closeSync(xmlfd); + } + } +} diff --git a/validator/acts_validator/src/main/ets/pages/model/DateTimeUtil.ts b/validator/acts_validator/src/main/ets/pages/model/DateTimeUtil.ts new file mode 100644 index 0000000000000000000000000000000000000000..0bcf322db52b22ef28c7c824bdbef56c326279cd --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/model/DateTimeUtil.ts @@ -0,0 +1,80 @@ +/* + * 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. + */ + +/** + * @file 日期工具 + */ +export default class DateTimeUtil { + + /** + * 时分秒 + */ + getHour() { + const DATETIME = new Date() + return DATETIME.getHours() + } + getMinute() { + const DATETIME = new Date() + return DATETIME.getMinutes() + } + getSecond() { + const DATETIME = new Date() + return DATETIME.getSeconds() + } + + /** + * 年月日 + */ + getFullYear() { + const DATETIME = new Date() + return DATETIME.getFullYear() + } + getMonth() { + const DATETIME = new Date() + return DATETIME.getMonth() + 1 + } + getDate() { + const DATETIME = new Date() + return DATETIME.getDate() + } + + /** + * 日期不足两位补充0 + * @param value-数据值 + */ + fill(value: number) { + return (value > 9 ? '' : '0') + value + } + + /** + * 年月日格式修饰 + * @param year + * @param month + * @param date + */ + concatDate(year: number, month: number, date: number) { + return `${year}${this.fill(month)}${this.fill(date)}` + } + + /** + * 时分秒格式修饰 + * @param hours + * @param minutes + * @param seconds + */ + concatTime(hours: number, minutes: number, seconds: number) { + return `${this.fill(hours)}${this.fill(minutes)}${this.fill(seconds)}` + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/model/FirstDialog.ets b/validator/acts_validator/src/main/ets/pages/model/FirstDialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..d67039dd0c7ae21ee1557a822de670aef7f73377 --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/model/FirstDialog.ets @@ -0,0 +1,66 @@ +/* + * 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 data_preferences from '@ohos.data.preferences'; + + +export default class FirstDialog{ + static ChooseDialog = async (StepTips:string,name: string)=>{ + 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(name, 0); + await promise.then((data) => { + Test = data; + console.info("Succeeded in getting value of 'startup'. Data: " + data); + }); + if(Test != 1) { + AlertDialog.show( + { + title: '操作提示', + message: StepTips, + primaryButton: { + value: '不再提醒',fontColor:Color.Grey, + action: () => { + let promise = preferences.put(name, 1); + promise.then(() => { + console.info("Succeeded in putting value of 'test'."); + }); + promise = preferences.flush(); + promise.then(() => { + console.info("Succeeded in flushing."); + }); + } + }, + secondaryButton: { + value: '我已知晓', + action: () => { + + } + }, + cancel: () => { + + } + } + ) + } + return; + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/ets/pages/model/Logger.ts b/validator/acts_validator/src/main/ets/pages/model/Logger.ts new file mode 100644 index 0000000000000000000000000000000000000000..b69da312cced75f5474ed1e8239f7ef9fd6f76ec --- /dev/null +++ b/validator/acts_validator/src/main/ets/pages/model/Logger.ts @@ -0,0 +1,44 @@ +/* + * 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 hilog from '@ohos.hilog'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = "%{public}s, %{public}s"; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: any[]) { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: any[]) { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: any[]) { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: any[]) { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export default new Logger('[Screenshot]'); \ No newline at end of file diff --git a/validator/acts_validator/src/main/module.json b/validator/acts_validator/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..79d2731336367720c7419989db471a37d7404b89 --- /dev/null +++ b/validator/acts_validator/src/main/module.json @@ -0,0 +1,56 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.CAPTURE_SCREEN" + }, + { + "name": "ohos.permission.WRITE_MEDIA" + }, + { + "name": "ohos.permission.READ_MEDIA" + } + ] + } +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/element/color.json b/validator/acts_validator/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..62a137a61b90c14f109ed8c81d9d551ea0a5888a --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/element/string.json b/validator/acts_validator/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee20d6330f09dbc51a121ba83780986fa54b5ad5 --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "Validator" + }, + { + "name": "entry_MainAbility", + "value": "eTSScreenshot" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "btn_fullscreen", + "value": "FullScreen screenshot" + }, + { + "name": "btn_fixedsize", + "value": "Fixed-size screenshot" + }, + { + "name": "ok", + "value": "OK" + } + ] +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/media/flower.jpg b/validator/acts_validator/src/main/resources/base/media/flower.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a728e771a8b9d69b6f7339bd030857c084e292de Binary files /dev/null and b/validator/acts_validator/src/main/resources/base/media/flower.jpg differ diff --git a/validator/acts_validator/src/main/resources/base/media/ic_public_back.svg b/validator/acts_validator/src/main/resources/base/media/ic_public_back.svg new file mode 100644 index 0000000000000000000000000000000000000000..4f79d258986d1079915377ead156ae253b64202f --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/media/ic_public_back.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/media/ic_public_delete.svg b/validator/acts_validator/src/main/resources/base/media/ic_public_delete.svg new file mode 100644 index 0000000000000000000000000000000000000000..6ded900a897ae7906195745ac4cf4ea20f8e2fff --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/media/ic_public_delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/media/ic_public_fail.svg b/validator/acts_validator/src/main/resources/base/media/ic_public_fail.svg new file mode 100644 index 0000000000000000000000000000000000000000..da97afa2ae23b1afdaf546c901c813491f4bbcac --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/media/ic_public_fail.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_close_filled + + + + + + + + + + \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/media/ic_public_help.svg b/validator/acts_validator/src/main/resources/base/media/ic_public_help.svg new file mode 100644 index 0000000000000000000000000000000000000000..ca469493580dfd445b3c4f478f3dcb62420d3dc6 --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/media/ic_public_help.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/media/ic_public_pass.svg b/validator/acts_validator/src/main/resources/base/media/ic_public_pass.svg new file mode 100644 index 0000000000000000000000000000000000000000..0f31e322f288834e88794304ff5db317ff0cbe13 --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/media/ic_public_pass.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_todo_filled + + + + + + + + + + \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/media/ic_public_save.svg b/validator/acts_validator/src/main/resources/base/media/ic_public_save.svg new file mode 100644 index 0000000000000000000000000000000000000000..48c58dc2fbfef823bb8d017bde3c822cabee0d4b --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/media/ic_public_save.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/base/media/icon.png b/validator/acts_validator/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/validator/acts_validator/src/main/resources/base/media/icon.png differ diff --git a/validator/acts_validator/src/main/resources/base/media/img.png b/validator/acts_validator/src/main/resources/base/media/img.png new file mode 100644 index 0000000000000000000000000000000000000000..59b0ee77105e174b94fc5f5b263f65711c2725df Binary files /dev/null and b/validator/acts_validator/src/main/resources/base/media/img.png differ 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 new file mode 100644 index 0000000000000000000000000000000000000000..9d09ade29223478b0274ce088aa82f4625d6a1e3 --- /dev/null +++ b/validator/acts_validator/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,60 @@ +{ + "src": [ + "pages/index", + "pages/ArkUI/ArkUI_index", + "pages/ArkUI/ScrollListTest", + "pages/ArkUI/CanvasFillStyle", + "pages/ArkUI/LongPressGesture", + "pages/ArkUI/PanGesture", + "pages/ArkUI/PinchGestureTest", + "pages/ArkUI/RotationGestureTest", + "pages/ArkUI/SwipeGestureTest", + "pages/ArkUI/TapGesture", + "pages/ArkUI/TouchMoveTest", + "pages/ArkUI/CanvasLineWidth", + "pages/ArkUI/CanvasStrokeStyle", + "pages/ArkUI/CanvasLineCap", + "pages/ArkUI/CanvasLineJoin", + "pages/ArkUI/CanvasMiterLimit", + "pages/ArkUI/CanvasFont", + "pages/ArkUI/CanvasTextAlign", + "pages/ArkUI/CanvasTextBaseline", + "pages/ArkUI/CanvasGlobalCompositeOperation", + "pages/ArkUI/CanvasShadowBlur", + "pages/ArkUI/CanvasShadowColor", + "pages/ArkUI/CanvasShadowOffsetX", + "pages/ArkUI/CanvasImageSmoothingEnabled", + "pages/ArkUI/CanvasGlobalAlpha", + "pages/ArkUI/CanvasLineDashOffset", + "pages/ArkUI/CanvasShadowOffsetY", + "pages/MediaLibrary/MediaLibrary_index", + "pages/MediaLibrary/startImagePreviewCallback1", + "pages/MediaLibrary/startImagePreviewCallback2", + "pages/MediaLibrary/startImagePreviewCallback3", + "pages/MediaLibrary/startImagePreviewCallback4", + "pages/MediaLibrary/startImagePreviewCallback5", + "pages/MediaLibrary/startImagePreviewCallback6", + "pages/MediaLibrary/startImagePreviewCallback7", + "pages/MediaLibrary/startImagePreviewPromise1", + "pages/MediaLibrary/startImagePreviewPromise2", + "pages/MediaLibrary/startImagePreviewPromise3", + "pages/MediaLibrary/startImagePreviewPromise4", + "pages/MediaLibrary/startMediaSelectCallback1", + "pages/MediaLibrary/startMediaSelectCallback2", + "pages/MediaLibrary/startMediaSelectCallback3", + "pages/MediaLibrary/startMediaSelectCallback4", + "pages/MediaLibrary/startMediaSelectPromise1", + "pages/MediaLibrary/startMediaSelectPromise2", + "pages/MediaLibrary/startMediaSelectPromise3", + "pages/MediaLibrary/startMediaSelectPromise4", + "pages/MediaLibrary/storeMediaAssetCallback1", + "pages/MediaLibrary/storeMediaAssetCallback2", + "pages/MediaLibrary/storeMediaAssetCallback3", + "pages/MediaLibrary/storeMediaAssetCallback4", + "pages/MediaLibrary/storeMediaAssetPromise1", + "pages/MediaLibrary/storeMediaAssetPromise2", + "pages/MediaLibrary/storeMediaAssetPromise3", + "pages/MediaLibrary/storeMediaAssetPromise4", + "pages/MediaLibrary/storeMediaAssetPromise5" + ] +} diff --git a/validator/acts_validator/src/main/resources/en/element/string.json b/validator/acts_validator/src/main/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4016c00b195c3129822e20e0153448cd58aa621d --- /dev/null +++ b/validator/acts_validator/src/main/resources/en/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "Validator" + }, + { + "name": "entry_MainAbility", + "value": "eTSScreenshot" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "btn_fullscreen", + "value": "FullScreen screenshot" + }, + { + "name": "btn_fixedsize", + "value": "Fixed-size screenshot" + }, + { + "name": "ok", + "value": "OK" + } + ] +} \ No newline at end of file diff --git a/validator/acts_validator/src/main/resources/zh/element/string.json b/validator/acts_validator/src/main/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ef866d7c1936e119709843f73d3f8fdfb1e7fef2 --- /dev/null +++ b/validator/acts_validator/src/main/resources/zh/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "Validator" + }, + { + "name": "entry_MainAbility", + "value": "eTS屏幕截图" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "btn_fullscreen", + "value": "全屏截图" + }, + { + "name": "btn_fixedsize", + "value": "固定大小截图" + }, + { + "name": "ok", + "value": "确定" + } + ] +} \ No newline at end of file