未验证 提交 3b14b191 编写于 作者: O openharmony_ci 提交者: Gitee

!9800 增加悬浮球向SP_daemon发送命令拉起服务,同时改变了结果颜色的存储方式

Merge pull request !9800 from 田文哲/master
import Ability from '@ohos.app.ability.UIAbility' import Ability from '@ohos.app.ability.UIAbility';
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import {FloatWindowFun} from '../pages/model/FloatWindowFun';
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
...@@ -7,6 +8,7 @@ export default class MainAbility extends Ability { ...@@ -7,6 +8,7 @@ export default class MainAbility extends Ability {
console.log("[Demo] MainAbility onCreate") console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
globalThis.abilityContext = this.context; globalThis.abilityContext = this.context;
globalThis.showFloatingWindow = false;
} }
onDestroy() { onDestroy() {
...@@ -17,15 +19,16 @@ export default class MainAbility extends Ability { ...@@ -17,15 +19,16 @@ export default class MainAbility extends Ability {
console.log("[Demo] MainAbility onWindowStageCreate") console.log("[Demo] MainAbility onWindowStageCreate")
let AtManager = abilityAccessCtrl.createAtManager(); let AtManager = abilityAccessCtrl.createAtManager();
AtManager.requestPermissionsFromUser(this.context,['ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA', AtManager.requestPermissionsFromUser(this.context,["ohos.permission.READ_MEDIA","ohos.permission.WRITE_MEDIA",
'ohos.permission.CAPTURE_SCREEN', 'ohos.permission.INTERNET', 'ohos.permission.CAMERA', "ohos.permission.CAPTURE_SCREEN","ohos.permission.INTERNET","ohos.permission.CAMERA",
'ohos.permission.MICROPHONE', 'ohos.permission.START_INVISIBLE_ABILITY']).then( () => {} ); "ohos.permission.MICROPHONE", "ohos.permission.START_INVISIBLE_ABILITY",
windowStage.loadContent('pages/index', (err, data) => { "ohos.permission.SYSTEM_FLOAT_WINDOW"]).then(() => {})
windowStage.loadContent("pages/index", (err, data) => {
if (err.code) { if (err.code) {
console.error( 'Failed to load the content. Cause:' + JSON.stringify(err) ); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info( 'Succeeded in loading the content. Data: ' + JSON.stringify(data) ); console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
}); });
} }
...@@ -34,6 +37,7 @@ export default class MainAbility extends Ability { ...@@ -34,6 +37,7 @@ export default class MainAbility extends Ability {
} }
onForeground() { onForeground() {
FloatWindowFun.initAllFun();
console.log("[Demo] MainAbility onForeground") console.log("[Demo] MainAbility onForeground")
} }
......
...@@ -62,7 +62,9 @@ struct IndexPage { ...@@ -62,7 +62,9 @@ struct IndexPage {
{title:'CanvasShadowOffsetX',uri:'pages/ArkUI/CanvasShadowOffsetX'}, {title:'CanvasShadowOffsetX',uri:'pages/ArkUI/CanvasShadowOffsetX'},
{title:'CanvasShadowOffsetY',uri:'pages/ArkUI/CanvasShadowOffsetY'}, {title:'CanvasShadowOffsetY',uri:'pages/ArkUI/CanvasShadowOffsetY'},
] ]
@State ColorObject : string[] = VarColor; @State ColorObject : Object[] = VarColor;
@State ColorTrue : Object[] = [];
@State ColorTrue2 : Object[] = [];
async onPageShow(){ async onPageShow(){
let Test = null; let Test = null;
let context =null; let context =null;
...@@ -82,7 +84,7 @@ struct IndexPage { ...@@ -82,7 +84,7 @@ struct IndexPage {
if(Test != 1) { if(Test != 1) {
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) { for(let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); let log = (this.TestCaseList[i].title+';'+'none '+';').toString();
fileio.writeSync(fd,log); fileio.writeSync(fd,log);
} }
fileio.closeSync(fd); fileio.closeSync(fd);
...@@ -113,12 +115,12 @@ struct IndexPage { ...@@ -113,12 +115,12 @@ struct IndexPage {
let name1 = '刚刚点进了哪个用例:'+ titles; let name1 = '刚刚点进了哪个用例:'+ titles;
let results = this.result; let results = this.result;
let WriteTitle = (titles).toString(); let WriteTitle = (titles).toString();
let number = WriteTitle.length + 11; let number = WriteTitle.length + 7;
let Index = ColorBack.indexOf(WriteTitle); let Index = ColorBack.indexOf(WriteTitle);
if (this.result === 'true '){ if (this.result === 'true '){
this.ColorObject[this.current] = '#ff008000'; this.ColorObject[this.current] = 'true ';
let Log = (titles+';'+'#ff008000'+';'); let Log = (titles+';'+'true '+';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key,Log);
...@@ -131,8 +133,8 @@ struct IndexPage { ...@@ -131,8 +133,8 @@ struct IndexPage {
filewrite(name1,results,titles); filewrite(name1,results,titles);
} }
else if (this.result === 'false'){ else if (this.result === 'false'){
this.ColorObject[this.current] = '#ffff0000'; this.ColorObject[this.current] = 'false';
let Log = (titles+';'+'#ffff0000'+';'); let Log = (titles+';'+'false'+';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key,Log);
...@@ -148,6 +150,22 @@ struct IndexPage { ...@@ -148,6 +150,22 @@ struct IndexPage {
this.ColorObject[this.current] = this.ColorObject[this.current]; this.ColorObject[this.current] = this.ColorObject[this.current];
} }
} }
for (let i = 0; i < TestList.length; i++){
if (this.ColorObject[i] === 'true '){
this.ColorTrue[i] = 0x263526
this.ColorTrue2[i] = 0x0CB60C
}
else if (this.ColorObject[i] === 'false'){
this.ColorTrue[i] = 0x380303
this.ColorTrue2[i] = 0xd60a0a
}
else {
this.ColorTrue[i] = 0x000000
this.ColorTrue2[i] = 0x000000
}
}
} }
build(){ build(){
Column(){ Column(){
...@@ -178,7 +196,7 @@ struct IndexPage { ...@@ -178,7 +196,7 @@ struct IndexPage {
action: () => { action: () => {
this.ClearAll = true; this.ClearAll = true;
this.ColorObject.forEach((value, index) => { this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080'; this.ColorObject[index] = 'none ';
}); });
this.ClearText(); this.ClearText();
prompt.showToast({ prompt.showToast({
...@@ -225,12 +243,13 @@ struct IndexPage { ...@@ -225,12 +243,13 @@ struct IndexPage {
}) })
} }
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black)
List({space:5}){ List({}){
ForEach(this.TestCaseList,(item,index) => { ForEach(this.TestCaseList,(item,index) => {
ListItem(){ ListItem(){
Row(){ Row(){
Text(item.title).fontSize(16).fontColor(Color.Black) Text(item.title).fontSize(20).fontColor(Color.White)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) }.width('100%').height(50).alignItems(VerticalAlign.Center)
.linearGradient(this.count===0&&this.TEST===0?{angle: 90,colors: [[0x000000, 0.0],[0x000000, 1.0]]}:{ angle: 90,colors: [[this.ColorTrue[index], 0.0], [this.ColorTrue2[index], 0.618]]})
.onClick(( )=>{ .onClick(( )=>{
this.count = 1; this.count = 1;
this.ClearAll=false; this.ClearAll=false;
...@@ -241,7 +260,7 @@ struct IndexPage { ...@@ -241,7 +260,7 @@ struct IndexPage {
}) })
} }
},item => item.title) },item => item.title)
}.width('100%').height('92%') }.width('100%').height('92%').divider({strokeWidth:1,color:Color.Grey})
}.width('100%').height('100%').backgroundColor(Color.Black) }.width('100%').height('100%').backgroundColor(Color.Black)
} }
ClearText(){ ClearText(){
...@@ -249,7 +268,7 @@ struct IndexPage { ...@@ -249,7 +268,7 @@ struct IndexPage {
fileio.mkdirSync(path1); fileio.mkdirSync(path1);
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) { for(let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); let log = (this.TestCaseList[i].title+';'+'none '+';').toString();
fileio.writeSync(fd,log); fileio.writeSync(fd,log);
} }
} }
......
...@@ -33,51 +33,55 @@ struct SetCircle { ...@@ -33,51 +33,55 @@ struct SetCircle {
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('Red').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) Column() {
.onClick(()=>{ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
this.context.clearRect(100, 160, 150, 100); Text('Red').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.FillColor = '#FFFF0000'; .onClick(()=>{
this.context.fillStyle = this.FillColor; this.context.clearRect(100, 160, 150, 100);
this.context.fillRect(100, 160, 150, 100); this.FillColor = '#FFFF0000';
this.num1 = 1; this.context.fillStyle = this.FillColor;
if ( this.num1 == this.num3 && this.num2 == 1 ){ this.context.fillRect(100, 160, 150, 100);
this.Vue = true; this.num1 = 1;
} if ( this.num1 == this.num3 && this.num2 == 1 ){
}) this.Vue = true;
Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(100, 160, 150, 100); Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.FillColor = '#fffffc3c'; .onClick(()=>{
this.context.fillStyle = this.FillColor; this.context.clearRect(100, 160, 150, 100);
this.context.fillRect(100, 160, 150, 100); this.FillColor = '#fffffc3c';
this.num2 = 1; this.context.fillStyle = this.FillColor;
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.fillRect(100, 160, 150, 100);
this.Vue = true; this.num2 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(100, 160, 150, 100); Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.FillColor = '#ff19fa00'; .onClick(()=>{
this.context.fillStyle = this.FillColor; this.context.clearRect(100, 160, 150, 100);
this.context.fillRect(100, 160, 150, 100); this.FillColor = '#ff19fa00';
this.num3 = 1; this.context.fillStyle = this.FillColor;
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.fillRect(100, 160, 150, 100);
this.Vue = true; this.num3 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
}.width('70%').height('30%') }
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { })
Canvas(this.context) }.width('70%').height('30%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.fillStyle = this.FillColor; .backgroundColor('#ffffffff')
this.context.fillRect(100, 160, 150, 100); .onReady(() =>{
}) this.context.fillStyle = this.FillColor;
}.width('100%').height('70%') this.context.fillRect(100, 160, 150, 100);
})
}.width('100%').height('70%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -31,54 +31,58 @@ struct SetCircle { ...@@ -31,54 +31,58 @@ struct SetCircle {
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) Column() {
.translate({ x: this.X, y: 20, z: 5 }) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
.gesture( Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'})
PanGesture({}) .translate({ x: this.X, y: 20, z: 5 })
.onActionStart((event: GestureEvent) => { .gesture(
console.info('Pan start'); PanGesture({})
this.Vue = true; .onActionStart((event: GestureEvent) => {
}) console.info('Pan start');
.onActionUpdate((event: GestureEvent) => { this.Vue = true;
this.context.clearRect(100, 100, 250, 200); })
if(event.offsetX>200){ .onActionUpdate((event: GestureEvent) => {
event.offsetX = 200; this.context.clearRect(100, 100, 250, 200);
} if(event.offsetX>200){
else if (event.offsetX < 20){ event.offsetX = 200;
event.offsetX = 20; }
} else if (event.offsetX < 20){
this.X = event.offsetX; event.offsetX = 20;
this.context.globalAlpha = (this.X)*0.005; }
this.context.fillStyle = 'rgb(255,0,0)'; this.X = event.offsetX;
this.context.fillRect(150, 150, 50, 50); this.context.globalAlpha = (this.X)*0.005;
this.context.globalAlpha = (this.X)*0.005; this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillRect(150, 150, 50, 50);
this.context.fillRect(200, 200, 50, 50); this.context.globalAlpha = (this.X)*0.005;
}) this.context.fillStyle = 'rgb(0,0,255)';
.onActionEnd(() => { this.context.fillRect(200, 200, 50, 50);
console.info('Pan end'); })
}) .onActionEnd(() => {
) console.info('Pan end');
})
)
}.width('70%').height('25%') }.width('70%').height('25%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){ Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Text('透明度: ' + (this.X)*0.005 ) Text('透明度: ' + (this.X)*0.005 )
}.width('100%').height('20%') }.width('100%').height('20%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffffffff') .backgroundColor('#ffffffff')
.onReady(() =>{ .onReady(() =>{
this.context.globalAlpha = 0.05; this.context.globalAlpha = 0.05;
this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 50, 50); this.context.fillRect(150, 150, 50, 50);
this.context.globalAlpha = 0.05; this.context.globalAlpha = 0.05;
this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(200, 200, 50, 50); this.context.fillRect(200, 200, 50, 50);
}) })
}.width('100%').height('55%') }.width('100%').height('55%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -32,64 +32,68 @@ struct SetCircle { ...@@ -32,64 +32,68 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('butt').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) Column() {
.onClick(()=>{ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
this.context.clearRect(90, 90, 170, 120); Text('butt').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.lineWidth = 8; .onClick(()=>{
this.context.beginPath(); this.context.clearRect(90, 90, 170, 120);
this.context.lineCap = 'butt'; this.context.lineWidth = 8;
this.context.moveTo(100, 100); this.context.beginPath();
this.context.lineTo(250, 100); this.context.lineCap = 'butt';
this.context.stroke(); this.context.moveTo(100, 100);
this.num1 = 1; this.context.lineTo(250, 100);
if ( this.num1 == this.num3 && this.num2 == 1 ){ this.context.stroke();
this.Vue = true; this.num1 = 1;
} if ( this.num1 == this.num3 && this.num2 == 1 ){
}) this.Vue = true;
Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(90, 90, 170, 120); Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.lineWidth = 8; .onClick(()=>{
this.context.beginPath(); this.context.clearRect(90, 90, 170, 120);
this.context.lineCap = 'round'; this.context.lineWidth = 8;
this.context.moveTo(100, 100); this.context.beginPath();
this.context.lineTo(250, 100); this.context.lineCap = 'round';
this.context.stroke(); this.context.moveTo(100, 100);
this.num2 = 1; this.context.lineTo(250, 100);
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.stroke();
this.Vue = true; this.num2 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
Text('square').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(90, 90, 170, 120); Text('square').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.lineWidth = 8; .onClick(()=>{
this.context.beginPath(); this.context.clearRect(90, 90, 170, 120);
this.context.lineCap = 'square'; this.context.lineWidth = 8;
this.context.moveTo(100, 100); this.context.beginPath();
this.context.lineTo(250, 100); this.context.lineCap = 'square';
this.context.stroke(); this.context.moveTo(100, 100);
this.num3 = 1; this.context.lineTo(250, 100);
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.stroke();
this.Vue = true; this.num3 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
}.width('70%').height('30%') }
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { })
Canvas(this.context) }.width('70%').height('30%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.lineWidth = 8; .backgroundColor('#ffffffff')
this.context.beginPath(); .onReady(() =>{
this.context.lineCap = 'round'; this.context.lineWidth = 8;
this.context.moveTo(100, 100); this.context.beginPath();
this.context.lineTo(250, 100); this.context.lineCap = 'round';
this.context.stroke(); this.context.moveTo(100, 100);
}) this.context.lineTo(250, 100);
}.width('100%').height('70%') this.context.stroke();
})
}.width('100%').height('70%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -30,46 +30,50 @@ struct SetCircle { ...@@ -30,46 +30,50 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) Column() {
.translate({ x: this.X, y: 20, z: 5 }) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
.gesture( Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'})
PanGesture({}) .translate({ x: this.X, y: 20, z: 5 })
.onActionStart((event: GestureEvent) => { .gesture(
console.info('Pan start'); PanGesture({})
this.Vue = true; .onActionStart((event: GestureEvent) => {
}) console.info('Pan start');
.onActionUpdate((event: GestureEvent) => { this.Vue = true;
if(event.offsetX > 200){ })
event.offsetX = 200; .onActionUpdate((event: GestureEvent) => {
} if(event.offsetX > 200){
else if(event.offsetX < 20){ event.offsetX = 200;
event.offsetX = 20; }
} else if(event.offsetX < 20){
this.X = event.offsetX; event.offsetX = 20;
this.context.clearRect(100, 90, 250, 200); }
this.context.setLineDash([20,30]); this.X = event.offsetX;
this.context.beginPath(); this.context.clearRect(100, 90, 250, 200);
this.context.arc(180, 150, 50, 0, 6.28); this.context.setLineDash([20,30]);
this.context.lineDashOffset = (this.X) * 0.2; this.context.beginPath();
this.context.stroke(); this.context.arc(180, 150, 50, 0, 6.28);
}) this.context.lineDashOffset = (this.X) * 0.2;
.onActionEnd(() => { this.context.stroke();
console.info('Pan end'); })
}) .onActionEnd(() => {
) console.info('Pan end');
}.width('70%').height('25%') })
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { )
Text('虚线偏移量: ' + (this.X)*0.2 ) }.width('70%').height('25%')
}.width('100%').height('20%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text('虚线偏移量: ' + (this.X)*0.2 )
Canvas(this.context) }.width('100%').height('20%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
}) .backgroundColor('#ffffffff')
}.width('100%').height('55%') .onReady(() =>{
})
}.width('100%').height('55%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -32,68 +32,72 @@ struct SetCircle { ...@@ -32,68 +32,72 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) Column() {
.onClick(()=>{ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
this.context.clearRect(90, 90, 170, 120); Text('round').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.beginPath(); .onClick(()=>{
this.context.lineWidth = 8; this.context.clearRect(90, 90, 170, 120);
this.context.lineJoin = 'round'; this.context.beginPath();
this.context.moveTo(120, 100); this.context.lineWidth = 8;
this.context.lineTo(210, 130); this.context.lineJoin = 'round';
this.context.lineTo(120, 180); this.context.moveTo(120, 100);
this.context.stroke(); this.context.lineTo(210, 130);
this.num1 = 1; this.context.lineTo(120, 180);
if ( this.num1 == this.num3 && this.num2 == 1 ){ this.context.stroke();
this.Vue = true; this.num1 = 1;
} if ( this.num1 == this.num3 && this.num2 == 1 ){
}) this.Vue = true;
Text('bevel').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(90, 90, 170, 120); Text('bevel').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.beginPath(); .onClick(()=>{
this.context.lineWidth = 8; this.context.clearRect(90, 90, 170, 120);
this.context.lineJoin = 'bevel'; this.context.beginPath();
this.context.moveTo(120, 100); this.context.lineWidth = 8;
this.context.lineTo(210, 130); this.context.lineJoin = 'bevel';
this.context.lineTo(120, 180); this.context.moveTo(120, 100);
this.context.stroke(); this.context.lineTo(210, 130);
this.num2 = 1; this.context.lineTo(120, 180);
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.stroke();
this.Vue = true; this.num2 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
Text('miter').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(90, 90, 170, 120); Text('miter').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.beginPath(); .onClick(()=>{
this.context.lineWidth = 8; this.context.clearRect(90, 90, 170, 120);
this.context.lineJoin = 'miter'; this.context.beginPath();
this.context.moveTo(120, 100); this.context.lineWidth = 8;
this.context.lineTo(210, 130); this.context.lineJoin = 'miter';
this.context.lineTo(120, 180); this.context.moveTo(120, 100);
this.context.stroke(); this.context.lineTo(210, 130);
this.num3 = 1; this.context.lineTo(120, 180);
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.stroke();
this.Vue = true; this.num3 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
}.width('70%').height('30%') }
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { })
Canvas(this.context) }.width('70%').height('30%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.beginPath(); .backgroundColor('#ffffffff')
this.context.lineWidth = 8; .onReady(() =>{
this.context.lineJoin = 'miter'; this.context.beginPath();
this.context.moveTo(120, 100); this.context.lineWidth = 8;
this.context.lineTo(210, 130); this.context.lineJoin = 'miter';
this.context.lineTo(120, 180); this.context.moveTo(120, 100);
this.context.stroke(); this.context.lineTo(210, 130);
}) this.context.lineTo(120, 180);
}.width('100%').height('70%') this.context.stroke();
})
}.width('100%').height('70%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -30,46 +30,50 @@ struct SetCircle { ...@@ -30,46 +30,50 @@ struct SetCircle {
@State X: number = 20; @State X: number = 20;
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) Column() {
.translate({ x: this.X, y: 20, z: 5 }) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
.gesture( Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'})
PanGesture({}) .translate({ x: this.X, y: 20, z: 5 })
.onActionStart((event: GestureEvent) => { .gesture(
console.info('Pan start'); PanGesture({})
this.Vue = true; .onActionStart((event: GestureEvent) => {
}) console.info('Pan start');
.onActionUpdate((event: GestureEvent) => { this.Vue = true;
if(event.offsetX > 200){ })
event.offsetX = 200; .onActionUpdate((event: GestureEvent) => {
} if(event.offsetX > 200){
else if(event.offsetX < 20){ event.offsetX = 200;
event.offsetX = 20; }
} else if(event.offsetX < 20){
this.context.clearRect(100, 100, 250, 200); event.offsetX = 20;
this.X = event.offsetX; }
this.context.lineWidth = (this.X)*0.1; this.context.clearRect(100, 100, 250, 200);
this.context.strokeRect(120, 120, 120, 120); this.X = event.offsetX;
}) this.context.lineWidth = (this.X)*0.1;
.onActionEnd(() => { this.context.strokeRect(120, 120, 120, 120);
console.info('Pan end'); })
}) .onActionEnd(() => {
) console.info('Pan end');
})
)
}.width('70%').height('30%') }.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('边框粗细: ' + (this.X)*0.1 ) Text('边框粗细: ' + (this.X)*0.1 )
}.width('100%').height('20%') }.width('100%').height('20%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffffffff') .backgroundColor('#ffffffff')
.onReady(() =>{ .onReady(() =>{
this.context.lineWidth = 1; this.context.lineWidth = 1;
this.context.strokeRect(120, 120, 120, 120); this.context.strokeRect(120, 120, 120, 120);
}) })
}.width('100%').height('50%') }.width('100%').height('50%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -30,51 +30,55 @@ struct SetCircle { ...@@ -30,51 +30,55 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) Column() {
.translate({ x: this.X, y: 20, z: 5 }) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
.gesture( Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'})
PanGesture({}) .translate({ x: this.X, y: 20, z: 5 })
.onActionStart((event: GestureEvent) => { .gesture(
this.context.fillStyle = 'rgb(255,0,0)'; PanGesture({})
this.context.fillRect(150, 150, 100, 100); .onActionStart((event: GestureEvent) => {
console.info('Pan start'); this.context.fillStyle = 'rgb(255,0,0)';
this.Vue = true; this.context.fillRect(150, 150, 100, 100);
}) console.info('Pan start');
.onActionUpdate((event: GestureEvent) => { this.Vue = true;
if(event.offsetX > 200){ })
event.offsetX = 200; .onActionUpdate((event: GestureEvent) => {
} if(event.offsetX > 200){
else if(event.offsetX < 20){ event.offsetX = 200;
event.offsetX = 20; }
} else if(event.offsetX < 20){
this.context.clearRect(0, 0, 600, 500); event.offsetX = 20;
this.X = event.offsetX; }
this.context.shadowBlur = this.X; this.context.clearRect(0, 0, 600, 500);
this.context.shadowColor = 'rgb(0,0,0)'; this.X = event.offsetX;
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowBlur = this.X;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,0)';
}) this.context.fillStyle = 'rgb(255,0,0)';
.onActionEnd(() => { this.context.fillRect(150, 150, 100, 100);
console.info('Pan end'); })
}) .onActionEnd(() => {
) console.info('Pan end');
}.width('70%').height('25%') })
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { )
Text('阴影模糊: ' + this.X ) }.width('70%').height('25%')
}.width('100%').height('20%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text('阴影模糊: ' + this.X )
Canvas(this.context) }.width('100%').height('20%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.shadowBlur = 0; .backgroundColor('#ffffffff')
this.context.shadowColor = 'rgb(0,0,0)'; .onReady(() =>{
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowBlur = 0;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,0)';
}) this.context.fillStyle = 'rgb(255,0,0)';
}.width('100%').height('55%') this.context.fillRect(150, 150, 100, 100);
})
}.width('100%').height('55%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -33,54 +33,58 @@ struct SetCircle { ...@@ -33,54 +33,58 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('Blue').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) Column() {
.onClick(()=>{ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
this.context.clearRect(10, 100, 400, 300); Text('Blue').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.shadowBlur = 30; .onClick(()=>{
this.context.shadowColor = 'rgb(0,0,255)'; this.context.clearRect(10, 100, 400, 300);
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowBlur = 30;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,255)';
this.num1 = 1; this.context.fillStyle = 'rgb(255,0,0)';
if ( this.num1 == 1 && this.num3 == 1 && this.num2 == 1 ){ this.context.fillRect(150, 150, 100, 100);
this.Vue = true; this.num1 = 1;
} if ( this.num1 == 1 && this.num3 == 1 && this.num2 == 1 ){
}) this.Vue = true;
Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(10, 100, 400, 300); Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.shadowBlur = 30; .onClick(()=>{
this.context.shadowColor = '#fffffc3c'; this.context.clearRect(10, 100, 400, 300);
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowBlur = 30;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = '#fffffc3c';
this.num2 = 1; this.context.fillStyle = 'rgb(255,0,0)';
if ( this.num1 == 1 && this.num3 == 1 && this.num2 == 1 ){ this.context.fillRect(150, 150, 100, 100);
this.Vue = true; this.num2 = 1;
} if ( this.num1 == 1 && this.num3 == 1 && this.num2 == 1 ){
}) this.Vue = true;
Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(10, 100, 400, 300); Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.context.shadowBlur = 30; .onClick(()=>{
this.context.shadowColor = '#ff19fa00'; this.context.clearRect(10, 100, 400, 300);
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowBlur = 30;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = '#ff19fa00';
this.num3 = 1; this.context.fillStyle = 'rgb(255,0,0)';
if ( this.num1 == 1 && this.num3 == 1 && this.num2 == 1 ){ this.context.fillRect(150, 150, 100, 100);
this.Vue = true; this.num3 = 1;
} if ( this.num1 == 1 && this.num3 == 1 && this.num2 == 1 ){
}) this.Vue = true;
}.width('70%').height('30%') }
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { })
Canvas(this.context) }.width('70%').height('30%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.fillStyle = 'rgb(255,0,0)'; .backgroundColor('#ffffffff')
this.context.fillRect(150, 150, 100, 100); .onReady(() =>{
}) this.context.fillStyle = 'rgb(255,0,0)';
}.width('100%').height('60%') this.context.fillRect(150, 150, 100, 100);
})
}.width('100%').height('60%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -30,55 +30,59 @@ struct SetCircle { ...@@ -30,55 +30,59 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) Column() {
.translate({ x: this.X, y: 20, z: 5 }) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
.gesture( Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'})
PanGesture({}) .translate({ x: this.X, y: 20, z: 5 })
.onActionStart((event: GestureEvent) => { .gesture(
this.context.shadowColor = 'rgb(0,0,0)'; PanGesture({})
this.context.fillStyle = 'rgb(255,0,0)'; .onActionStart((event: GestureEvent) => {
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,0)';
console.info('Pan start'); this.context.fillStyle = 'rgb(255,0,0)';
this.Vue = true; this.context.fillRect(150, 150, 100, 100);
}) console.info('Pan start');
.onActionUpdate((event: GestureEvent) => { this.Vue = true;
if(event.offsetX > 200){ })
event.offsetX = 200; .onActionUpdate((event: GestureEvent) => {
} if(event.offsetX > 200){
else if(event.offsetX < 20){ event.offsetX = 200;
event.offsetX = 20; }
} else if(event.offsetX < 20){
this.context.clearRect(10, 50, 400, 300); event.offsetX = 20;
this.X = event.offsetX; }
this.context.shadowBlur = 10; this.context.clearRect(10, 50, 400, 300);
this.context.shadowOffsetX = (this.X)*0.05; this.X = event.offsetX;
this.context.shadowColor = 'rgb(0,0,0)'; this.context.shadowBlur = 10;
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowOffsetX = (this.X)*0.05;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,0)';
}) this.context.fillStyle = 'rgb(255,0,0)';
.onActionEnd(() => { this.context.fillRect(150, 150, 100, 100);
console.info('Pan end'); })
}) .onActionEnd(() => {
) console.info('Pan end');
})
)
}.width('70%').height('25%') }.width('70%').height('25%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){ Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Text('阴影偏移: ' + (this.X)*0.05 ) Text('阴影偏移: ' + (this.X)*0.05 )
}.width('100%').height('20%') }.width('100%').height('20%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffffffff') .backgroundColor('#ffffffff')
.onReady(() =>{ .onReady(() =>{
this.context.shadowBlur = 10; this.context.shadowBlur = 10;
this.context.shadowOffsetX = 0; this.context.shadowOffsetX = 0;
this.context.shadowColor = 'rgb(0,0,0)'; this.context.shadowColor = 'rgb(0,0,0)';
this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 150, 100, 100); this.context.fillRect(150, 150, 100, 100);
}) })
}.width('100%').height('55%') }.width('100%').height('55%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -30,54 +30,58 @@ struct SetCircle { ...@@ -30,54 +30,58 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'}) Column() {
.translate({ x: this.X, y: 20, z: 5 }) Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
.gesture( Text('→').fontSize(16).border({width:2}).size({width:'20%',height:'20%'})
PanGesture({}) .translate({ x: this.X, y: 20, z: 5 })
.onActionStart((event: GestureEvent) => { .gesture(
this.context.shadowColor = 'rgb(0,0,0)'; PanGesture({})
this.context.fillStyle = 'rgb(255,0,0)'; .onActionStart((event: GestureEvent) => {
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,0)';
console.info('Pan start'); this.context.fillStyle = 'rgb(255,0,0)';
this.Vue = true; this.context.fillRect(150, 150, 100, 100);
}) console.info('Pan start');
.onActionUpdate((event: GestureEvent) => { this.Vue = true;
if(event.offsetX > 200){ })
event.offsetX = 200; .onActionUpdate((event: GestureEvent) => {
} if(event.offsetX > 200){
else if(event.offsetX < 20){ event.offsetX = 200;
event.offsetX = 20; }
} else if(event.offsetX < 20){
this.context.clearRect(10, 50, 400, 300); event.offsetX = 20;
this.X = event.offsetX; }
this.context.shadowBlur = 10; this.context.clearRect(10, 50, 400, 300);
this.context.shadowOffsetY = (this.X)*0.05; this.X = event.offsetX;
this.context.shadowColor = 'rgb(0,0,0)'; this.context.shadowBlur = 10;
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowOffsetY = (this.X)*0.05;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,0)';
}) this.context.fillStyle = 'rgb(255,0,0)';
.onActionEnd(() => { this.context.fillRect(150, 150, 100, 100);
console.info('Pan end'); })
}) .onActionEnd(() => {
) console.info('Pan end');
}.width('70%').height('25%') })
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){ )
Text('阴影偏移: ' + (this.X)*0.05 ) }.width('70%').height('25%')
}.width('100%').height('20%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text('阴影偏移: ' + (this.X)*0.05 )
Canvas(this.context) }.width('100%').height('20%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.shadowBlur = 10; .backgroundColor('#ffffffff')
this.context.shadowOffsetY = 0; .onReady(() =>{
this.context.shadowColor = 'rgb(0,0,0)'; this.context.shadowBlur = 10;
this.context.fillStyle = 'rgb(255,0,0)'; this.context.shadowOffsetY = 0;
this.context.fillRect(150, 150, 100, 100); this.context.shadowColor = 'rgb(0,0,0)';
}) this.context.fillStyle = 'rgb(255,0,0)';
}.width('100%').height('55%') this.context.fillRect(150, 150, 100, 100);
})
}.width('100%').height('55%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -32,55 +32,59 @@ struct SetCircle { ...@@ -32,55 +32,59 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('Red').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) Column() {
.onClick(()=>{ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
this.context.clearRect(90, 150, 170, 120); Text('Red').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.FillColor = '#FFFF0000'; .onClick(()=>{
this.context.lineWidth = 10; this.context.clearRect(90, 150, 170, 120);
this.context.strokeStyle = '#FFFF0000'; this.FillColor = '#FFFF0000';
this.context.strokeRect(100, 160, 150, 100); this.context.lineWidth = 10;
this.num1 = 1; this.context.strokeStyle = '#FFFF0000';
if ( this.num1 == this.num3 && this.num2 == 1 ){ this.context.strokeRect(100, 160, 150, 100);
this.Vue = true; this.num1 = 1;
} if ( this.num1 == this.num3 && this.num2 == 1 ){
}) this.Vue = true;
Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(90, 150, 170, 120); Text('Yellow').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.FillColor = '#fffffc3c'; .onClick(()=>{
this.context.lineWidth = 10; this.context.clearRect(90, 150, 170, 120);
this.context.strokeStyle = '#fffffc3c'; this.FillColor = '#fffffc3c';
this.context.strokeRect(100, 160, 150, 100); this.context.lineWidth = 10;
this.num2 = 1; this.context.strokeStyle = '#fffffc3c';
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.strokeRect(100, 160, 150, 100);
this.Vue = true; this.num2 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(90, 150, 170, 120); Text('Green').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
this.FillColor = '#ff19fa00'; .onClick(()=>{
this.context.lineWidth = 10; this.context.clearRect(90, 150, 170, 120);
this.context.strokeStyle = '#ff19fa00'; this.FillColor = '#ff19fa00';
this.context.strokeRect(100, 160, 150, 100); this.context.lineWidth = 10;
this.num3 = 1; this.context.strokeStyle = '#ff19fa00';
if ( this.num1 == 1 && this.num3 == this.num2 ){ this.context.strokeRect(100, 160, 150, 100);
this.Vue = true; this.num3 = 1;
} if ( this.num1 == 1 && this.num3 == this.num2 ){
}) this.Vue = true;
}.width('70%').height('30%') }
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { })
Canvas(this.context) }.width('70%').height('30%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.lineWidth = 10; .backgroundColor('#ffffffff')
this.context.strokeStyle = this.FillColor; .onReady(() =>{
this.context.strokeRect(100, 160, 150, 100); this.context.lineWidth = 10;
}) this.context.strokeStyle = this.FillColor;
}.width('100%').height('70%') this.context.strokeRect(100, 160, 150, 100);
})
}.width('100%').height('70%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -34,91 +34,95 @@ struct SetCircle { ...@@ -34,91 +34,95 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Scroll() {
Text('start').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) Column() {
.onClick(()=>{ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
this.context.clearRect(0, 10, 500, 500); Text('start').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
this.context.lineWidth = 2; .onClick(()=>{
this.context.moveTo(250, 10); this.context.clearRect(0, 10, 500, 500);
this.context.lineTo(250, 310); this.context.lineWidth = 2;
this.context.stroke(); this.context.moveTo(250, 10);
this.context.textAlign = 'start'; this.context.lineTo(250, 310);
this.context.font = '40px sans-serif' this.context.stroke();
this.context.fillText('textAlign=start', 250, 160); this.context.textAlign = 'start';
this.num1 = 1; this.context.font = '40px sans-serif'
if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){ this.context.fillText('textAlign=start', 250, 160);
this.Vue = true; this.num1 = 1;
} if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){
}) this.Vue = true;
Text('end').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(0, 10, 500, 500); Text('end').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
this.context.lineWidth = 2; .onClick(()=>{
this.context.moveTo(250, 10); this.context.clearRect(0, 10, 500, 500);
this.context.lineTo(250, 310); this.context.lineWidth = 2;
this.context.stroke(); this.context.moveTo(250, 10);
this.context.textAlign = 'end'; this.context.lineTo(250, 310);
this.context.fillText('textAlign=end', 250, 160); this.context.stroke();
this.num2 = 1; this.context.textAlign = 'end';
if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){ this.context.fillText('textAlign=end', 250, 160);
this.Vue = true; this.num2 = 1;
} if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){
}) this.Vue = true;
Text('left').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(0, 10, 500, 500); Text('left').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
this.context.lineWidth = 2; .onClick(()=>{
this.context.moveTo(250, 10); this.context.clearRect(0, 10, 500, 500);
this.context.lineTo(250, 310); this.context.lineWidth = 2;
this.context.stroke(); this.context.moveTo(250, 10);
this.context.textAlign = 'left'; this.context.lineTo(250, 310);
this.context.fillText('textAlign=left', 250, 160); this.context.stroke();
this.num3 = 1; this.context.textAlign = 'left';
if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){ this.context.fillText('textAlign=left', 250, 160);
this.Vue = true; this.num3 = 1;
} if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){
}) this.Vue = true;
Text('center').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) }
.onClick(()=>{ })
this.context.clearRect(0, 10, 500, 500); Text('center').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
this.context.lineWidth = 2; .onClick(()=>{
this.context.moveTo(250, 10); this.context.clearRect(0, 10, 500, 500);
this.context.lineTo(250, 310); this.context.lineWidth = 2;
this.context.stroke(); this.context.moveTo(250, 10);
this.context.textAlign = 'center'; this.context.lineTo(250, 310);
this.context.fillText('textAlign=center', 250, 160); this.context.stroke();
this.num4 = 1; this.context.textAlign = 'center';
if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){ this.context.fillText('textAlign=center', 250, 160);
this.Vue = true; this.num4 = 1;
} if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){
}) this.Vue = true;
Text('right').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) }
.onClick(()=> { })
this.context.clearRect(0, 10, 500, 500); Text('right').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
this.context.lineWidth = 2; .onClick(()=> {
this.context.moveTo(250, 10); this.context.clearRect(0, 10, 500, 500);
this.context.lineTo(250, 310); this.context.lineWidth = 2;
this.context.stroke(); this.context.moveTo(250, 10);
this.context.textAlign = 'right'; this.context.lineTo(250, 310);
this.context.fillText('textAlign=right', 250, 160); this.context.stroke();
this.num5 = 1; this.context.textAlign = 'right';
if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){ this.context.fillText('textAlign=right', 250, 160);
this.Vue = true; this.num5 = 1;
} if ( this.num1 == 1 && this.num2 == 1 && this.num3 == 1 && this.num4 == 1 && this.num5 == 1 ){
}) this.Vue = true;
}.width('90%').height('30%') }
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { })
Canvas(this.context) }.width('90%').height('30%')
.width('100%') Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
.height('100%') Canvas(this.context)
.backgroundColor('#ffffffff') .width('100%')
.onReady(() =>{ .height('100%')
this.context.lineWidth = 2; .backgroundColor('#ffffffff')
this.context.moveTo(250, 10); .onReady(() =>{
this.context.lineTo(250, 310); this.context.lineWidth = 2;
this.context.stroke(); this.context.moveTo(250, 10);
}) this.context.lineTo(250, 310);
}.width('100%').height('70%') this.context.stroke();
})
}.width('100%').height('70%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -34,6 +34,8 @@ struct SetCircle { ...@@ -34,6 +34,8 @@ struct SetCircle {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Scroll() {
Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){ Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('Top').fontSize(13).border({width:2}).size({width:'18%',height:'20%'}) Text('Top').fontSize(13).border({width:2}).size({width:'18%',height:'20%'})
.onClick(()=>{ .onClick(()=>{
...@@ -125,6 +127,8 @@ struct SetCircle { ...@@ -125,6 +127,8 @@ struct SetCircle {
this.context.stroke(); this.context.stroke();
}) })
}.width('100%').height('70%') }.width('100%').height('70%')
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -27,10 +27,12 @@ struct LongPressGestureExample { ...@@ -27,10 +27,12 @@ struct LongPressGestureExample {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Scroll() {
Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Image($r("app.media.flower")).height('60%').width('70%') Image($r("app.media.img")).height('60%').width('60%')
} }
.height('250vp').width('350vp').padding(20) .height('350vp').width('350vp').padding(20)
.gesture( .gesture(
LongPressGesture({ repeat: true }) LongPressGesture({ repeat: true })
.onAction((event: GestureEvent) => { .onAction((event: GestureEvent) => {
...@@ -46,6 +48,8 @@ struct LongPressGestureExample { ...@@ -46,6 +48,8 @@ struct LongPressGestureExample {
}) })
) )
Text('长按动作连续触发:' + this.X).fontColor(Color.Black) Text('长按动作连续触发:' + this.X).fontColor(Color.Black)
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
.justifyContent(FlexAlign.SpaceEvenly) .justifyContent(FlexAlign.SpaceEvenly)
} }
......
...@@ -28,10 +28,12 @@ struct PanGestureExample { ...@@ -28,10 +28,12 @@ struct PanGestureExample {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Scroll(){
Column(){
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Image($r("app.media.flower")).height('60%').width('70%') Image($r("app.media.img")).height('60%').width('60%')
} }
.height('250vp').width('350vp').padding(20) .height('350vp').width('350vp').padding(20)
.margin(80).translate({ x: this.X, y: this.Y, z: 5 }) .margin(80).translate({ x: this.X, y: this.Y, z: 5 })
.gesture( .gesture(
PanGesture({}) PanGesture({})
...@@ -48,6 +50,8 @@ struct PanGestureExample { ...@@ -48,6 +50,8 @@ struct PanGestureExample {
}) })
) )
Text('偏移坐标x: ' + this.X + '\n' + '偏移坐标y: ' + this.Y) Text('偏移坐标x: ' + this.X + '\n' + '偏移坐标y: ' + this.Y)
}
}
}.width('100%').height('80%').backgroundColor(Color.White) }.width('100%').height('80%').backgroundColor(Color.White)
.justifyContent(FlexAlign.SpaceEvenly) .justifyContent(FlexAlign.SpaceEvenly)
} }
......
...@@ -27,10 +27,12 @@ struct PinchGuestureTest { ...@@ -27,10 +27,12 @@ struct PinchGuestureTest {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column(){ Column(){
Scroll() {
Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Image($r("app.media.flower")).height('60%').width('70%') Image($r("app.media.img")).height('60%').width('60%')
} }
.height('250vp').width('350vp').padding(20) .height('350vp').width('350vp').padding(20)
.scale({ x: this.X, y: this.X, z: this.X }) .scale({ x: this.X, y: this.X, z: this.X })
.gesture( .gesture(
PinchGesture() PinchGesture()
...@@ -40,6 +42,8 @@ struct PinchGuestureTest { ...@@ -40,6 +42,8 @@ struct PinchGuestureTest {
}) })
) )
Text('捏合放缩比例:'+this.X).fontColor(Color.Black) Text('捏合放缩比例:'+this.X).fontColor(Color.Black)
}
}
} .width('100%').height('80%').backgroundColor(Color.White) } .width('100%').height('80%').backgroundColor(Color.White)
.justifyContent(FlexAlign.SpaceEvenly) .justifyContent(FlexAlign.SpaceEvenly)
} }
......
...@@ -27,10 +27,12 @@ struct RotationGuestureTest { ...@@ -27,10 +27,12 @@ struct RotationGuestureTest {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column(){ Column(){
Scroll() {
Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Image($r("app.media.flower")).height('60%').width('70%') Image($r("app.media.img")).height('60%').width('60%')
} }
.height('250vp').width('350vp').padding(20) .height('350vp').width('350vp').padding(20)
.rotate({ x:1, y:1, z:1, angle: this.X }) .rotate({ x:1, y:1, z:1, angle: this.X })
.margin(80) .margin(80)
.gesture( .gesture(
...@@ -41,6 +43,8 @@ struct RotationGuestureTest { ...@@ -41,6 +43,8 @@ struct RotationGuestureTest {
}) })
) )
Text('旋转角度:' + this.X) Text('旋转角度:' + this.X)
}
}
}.height('80%').width('100%').backgroundColor(Color.White) }.height('80%').width('100%').backgroundColor(Color.White)
} }
build() { build() {
......
...@@ -29,9 +29,9 @@ struct SwipeGestureTest { ...@@ -29,9 +29,9 @@ struct SwipeGestureTest {
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Image($r("app.media.flower")).height('60%').width('70%') Image($r("app.media.img")).height('60%').width('60%')
} }
.height('250vp').width('350vp').padding(20) .height('350vp').width('350vp').padding(20)
.rotate({x: 0, y: 0, z: 1, angle: this.X}) .rotate({x: 0, y: 0, z: 1, angle: this.X})
.gesture( .gesture(
SwipeGesture({fingers: 1, direction: SwipeDirection.Vertical}) SwipeGesture({fingers: 1, direction: SwipeDirection.Vertical})
......
...@@ -27,18 +27,22 @@ struct TapGestureExample { ...@@ -27,18 +27,22 @@ struct TapGestureExample {
} }
@Builder specificNoParam() { @Builder specificNoParam() {
Column() { Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Scroll() {
Image($r("app.media.flower")).height('60%').width('70%') Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Image($r("app.media.img")).height('60%').width('60%')
}
.height('350vp').width('350vp').padding(20)
.gesture(
TapGesture({ count: 2 })
.onAction(() => {
this.value = 'TapGesture onAction';
this.Vue = true;
})
)
Text(this.value)
}
} }
.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) }.width('100%').height('80%').backgroundColor(Color.White)
.justifyContent(FlexAlign.SpaceEvenly) .justifyContent(FlexAlign.SpaceEvenly)
} }
......
...@@ -98,81 +98,83 @@ struct audioInputRouting { ...@@ -98,81 +98,83 @@ struct audioInputRouting {
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Column() { Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Column(){ Scroll() {
Row(){ Column(){
Text(`是否设备支持TypeC耳机?`).fontColor(Color.White).fontSize('18fp') Row(){
} Text(`是否设备支持TypeC耳机?`).fontColor(Color.White).fontSize('18fp')
Row(){
Column(){
Button(`不支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(!this.yesEnable)
.opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
} }
Column(){ Row(){
Button(`支持`) Column(){
.borderRadius(8) Button(`不支持`)
.backgroundColor(0x317aff) .borderRadius(8)
.width('30%') .backgroundColor(0x317aff)
.onClick(async () => { .width('30%')
this.yesEnable = true .enabled(!this.yesEnable)
this.recorderEnable = true .opacity(!this.yesEnable? 1 : 0.4)
}) .onClick(async () => {
this.Vue = true
})
}
Column(){
Button(`支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.onClick(async () => {
this.yesEnable = true
this.recorderEnable = true
})
}
} }
} Row(){
Row(){ Text('测试目的:\n当设备连接TypeC耳机时,是否音频输入路由正确切换\n测试准备\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持TypeC耳机\n2. 连接TypeC耳机\n3. 按下录制按钮\n4. 对着耳机mic讲话\n5. 按下停止按钮\n6. 按下播放按钮\n测试标准:\n如果设备不支持TypeC耳机输入或者接收到输入路由通知、路由显示为TypeC耳机,通过TypeC可正常录制和播放,则用例pass').fontColor(Color.White).fontSize('18fp')
Text('测试目的:\n当设备连接TypeC耳机时,是否音频输入路由正确切换\n测试准备\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持TypeC耳机\n2. 连接TypeC耳机\n3. 按下录制按钮\n4. 对着耳机mic讲话\n5. 按下停止按钮\n6. 按下播放按钮\n测试标准:\n如果设备不支持TypeC耳机输入或者接收到输入路由通知、路由显示为TypeC耳机,通过TypeC可正常录制和播放,则用例pass').fontColor(Color.White).fontSize('18fp')
}
Row(){
Text(`Audio输入路由:${this.inputDevice}`).fontColor(Color.White).fontSize('18fp')
}
Row(){
Column(){
Button(`录制`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.recorderEnable)
.opacity(this.recorderEnable ? 1 : 0.4)
.onClick(async () => {
this.stopEnable = true
this.recorderEnable = false
await AudioCapturer.createAudioCapturer()
await AudioCapturer.startCapturer()
})
} }
Column(){ Row(){
Button(`停止`) Text(`Audio输入路由:${this.inputDevice}`).fontColor(Color.White).fontSize('18fp')
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.stopEnable)
.opacity(this.stopEnable ? 1 : 0.4)
.onClick(async () => {
this.recorderEnable = true
this.stopEnable = false
this.playEnable = true
await AudioCapturer.stopCapturer()
await AudioCapturer.releaseCapturer()
})
} }
Column(){ Row(){
Button(`播放`) Column(){
.borderRadius(8) Button(`录制`)
.backgroundColor(0x317aff) .borderRadius(8)
.width('30%') .backgroundColor(0x317aff)
.enabled(this.playEnable) .width('30%')
.opacity(this.playEnable ? 1 : 0.4) .enabled(this.recorderEnable)
.onClick(async () => { .opacity(this.recorderEnable ? 1 : 0.4)
this.playEnable = false .onClick(async () => {
await mediaPlay.init() this.stopEnable = true
this.Vue = true this.recorderEnable = false
}) await AudioCapturer.createAudioCapturer()
await AudioCapturer.startCapturer()
})
}
Column(){
Button(`停止`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.stopEnable)
.opacity(this.stopEnable ? 1 : 0.4)
.onClick(async () => {
this.recorderEnable = true
this.stopEnable = false
this.playEnable = true
await AudioCapturer.stopCapturer()
await AudioCapturer.releaseCapturer()
})
}
Column(){
Button(`播放`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.playEnable)
.opacity(this.playEnable ? 1 : 0.4)
.onClick(async () => {
this.playEnable = false
await mediaPlay.init()
this.Vue = true
})
}
} }
} }
} }
......
...@@ -98,81 +98,83 @@ struct audioInputRouting { ...@@ -98,81 +98,83 @@ struct audioInputRouting {
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Column() { Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Column(){ Scroll() {
Row(){ Column(){
Text(`是否设备支持3.5mm耳机?`).fontColor(Color.White).fontSize('18fp') Row(){
} Text(`是否设备支持3.5mm耳机?`).fontColor(Color.White).fontSize('18fp')
Row(){
Column(){
Button(`不支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(!this.yesEnable)
.opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
} }
Column(){ Row(){
Button(`支持`) Column(){
.borderRadius(8) Button(`不支持`)
.backgroundColor(0x317aff) .borderRadius(8)
.width('30%') .backgroundColor(0x317aff)
.onClick(async () => { .width('30%')
this.yesEnable = true .enabled(!this.yesEnable)
this.recorderEnable = true .opacity(!this.yesEnable? 1 : 0.4)
}) .onClick(async () => {
this.Vue = true
})
}
Column(){
Button(`支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.onClick(async () => {
this.yesEnable = true
this.recorderEnable = true
})
}
} }
} Row(){
Row(){ Text('测试目的:\n当设备连接3.5mm有线耳机时,是否音频输入路由正确切换\n测试准备\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持3.5mm有线耳机\n2. 连接3.5mm有线耳机\n3. 按下录制按钮\n4. 对着耳机mic讲话\n5. 按下停止按钮\n6. 按下播放按钮\n测试标准:\n如果设备不支持3.5mm有线耳机输入或者接收到路由通知、路由显示为3.5mm耳机,通过3.5mm耳机可正常录制和播放,则用例pass').fontColor(Color.White).fontSize('18fp')
Text('测试目的:\n当设备连接3.5mm有线耳机时,是否音频输入路由正确切换\n测试准备\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持3.5mm有线耳机\n2. 连接3.5mm有线耳机\n3. 按下录制按钮\n4. 对着耳机mic讲话\n5. 按下停止按钮\n6. 按下播放按钮\n测试标准:\n如果设备不支持3.5mm有线耳机输入或者接收到路由通知、路由显示为3.5mm耳机,通过3.5mm耳机可正常录制和播放,则用例pass').fontColor(Color.White).fontSize('18fp')
}
Row(){
Text(`Audio输入路由:${this.inputDevice}`).fontColor(Color.White).fontSize('18fp')
}
Row(){
Column(){
Button(`录制`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.recorderEnable)
.opacity(this.recorderEnable ? 1 : 0.4)
.onClick(async () => {
this.stopEnable = true
this.recorderEnable = false
await AudioCapturer.createAudioCapturer()
await AudioCapturer.startCapturer()
})
} }
Column(){ Row(){
Button(`停止`) Text(`Audio输入路由:${this.inputDevice}`).fontColor(Color.White).fontSize('18fp')
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.stopEnable)
.opacity(this.stopEnable ? 1 : 0.4)
.onClick(async () => {
this.recorderEnable = true
this.stopEnable = false
this.playEnable = true
await AudioCapturer.stopCapturer()
await AudioCapturer.releaseCapturer()
})
} }
Column(){ Row(){
Button(`播放`) Column(){
.borderRadius(8) Button(`录制`)
.backgroundColor(0x317aff) .borderRadius(8)
.width('30%') .backgroundColor(0x317aff)
.enabled(this.playEnable) .width('30%')
.opacity(this.playEnable ? 1 : 0.4) .enabled(this.recorderEnable)
.onClick(async () => { .opacity(this.recorderEnable ? 1 : 0.4)
this.playEnable = false .onClick(async () => {
await mediaPlay.init() this.stopEnable = true
this.Vue = true this.recorderEnable = false
}) await AudioCapturer.createAudioCapturer()
await AudioCapturer.startCapturer()
})
}
Column(){
Button(`停止`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.stopEnable)
.opacity(this.stopEnable ? 1 : 0.4)
.onClick(async () => {
this.recorderEnable = true
this.stopEnable = false
this.playEnable = true
await AudioCapturer.stopCapturer()
await AudioCapturer.releaseCapturer()
})
}
Column(){
Button(`播放`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.playEnable)
.opacity(this.playEnable ? 1 : 0.4)
.onClick(async () => {
this.playEnable = false
await mediaPlay.init()
this.Vue = true
})
}
} }
} }
} }
......
...@@ -88,71 +88,73 @@ struct audioOutputRouting { ...@@ -88,71 +88,73 @@ struct audioOutputRouting {
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Column() { Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Column(){ Scroll() {
Row(){ Column(){
Text(`是否设备支持蓝牙耳机?`).fontColor(Color.White).fontSize('18fp') Row(){
} Text(`是否设备支持蓝牙耳机?`).fontColor(Color.White).fontSize('18fp')
Row(){
Column(){
Button(`不支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(!this.yesEnable)
.opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
} }
Column(){ Row(){
Button(`支持`) Column(){
.borderRadius(8) Button(`不支持`)
.backgroundColor(0x317aff) .borderRadius(8)
.width('30%') .backgroundColor(0x317aff)
.onClick(async () => { .width('30%')
this.yesEnable = true .enabled(!this.yesEnable)
this.playEnable = true .opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
}
Column(){
Button(`支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.onClick(async () => {
this.yesEnable = true
this.playEnable = true
}) })
}
} }
} Row(){
Row(){ Text('测试目的:\n当设备连接蓝牙耳机时,音频路由是否正确切换\n测试准备:\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持蓝牙外设\n2. 按下播放按钮\n3. 连接蓝牙耳机\n4. 拔出蓝牙耳机\n5. 按下停止按钮\n测试标准:\n如果设备不支持蓝牙耳机连接或者插拔蓝牙耳机后接收到路由通知、路由显示正确,且连接蓝牙后音频通过蓝牙耳机播放,则用例pass').fontColor(Color.White).fontSize('18fp')
Text('测试目的:\n当设备连接蓝牙耳机时,音频路由是否正确切换\n测试准备:\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持蓝牙外设\n2. 按下播放按钮\n3. 连接蓝牙耳机\n4. 拔出蓝牙耳机\n5. 按下停止按钮\n测试标准:\n如果设备不支持蓝牙耳机连接或者插拔蓝牙耳机后接收到路由通知、路由显示正确,且连接蓝牙后音频通过蓝牙耳机播放,则用例pass').fontColor(Color.White).fontSize('18fp')
}
Row(){
Text(`Audio输出路由:${this.outputDevice}`).fontColor(Color.White).fontSize('18fp')
}
Row(){
Column(){
Button(`播放`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.playEnable)
.opacity(this.playEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
this.stopEnable = true
this.playEnable = false
await AudioRenderer.createAudioRenderer()
await AudioRenderer.startRenderer()
})
} }
Column(){ Row(){
Button(`停止`) Text(`Audio输出路由:${this.outputDevice}`).fontColor(Color.White).fontSize('18fp')
.borderRadius(8) }
.backgroundColor(0x317aff) Row(){
.width('30%') Column(){
.enabled(this.stopEnable) Button(`播放`)
.opacity(this.stopEnable? 1 : 0.4) .borderRadius(8)
.onClick(async () => { .backgroundColor(0x317aff)
await AudioRenderer.stopRenderer() .width('30%')
await AudioRenderer.releaseRenderer() .enabled(this.playEnable)
this.playEnable = true .opacity(this.playEnable? 1 : 0.4)
this.stopEnable = false .onClick(async () => {
}) this.Vue = true
this.stopEnable = true
this.playEnable = false
await AudioRenderer.createAudioRenderer()
await AudioRenderer.startRenderer()
})
}
Column(){
Button(`停止`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.stopEnable)
.opacity(this.stopEnable? 1 : 0.4)
.onClick(async () => {
await AudioRenderer.stopRenderer()
await AudioRenderer.releaseRenderer()
this.playEnable = true
this.stopEnable = false
})
}
} }
} }
} }
......
...@@ -88,71 +88,73 @@ struct audioOutputRouting { ...@@ -88,71 +88,73 @@ struct audioOutputRouting {
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Column() { Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Column(){ Scroll() {
Row(){ Column(){
Text(`是否设备支持TypeC耳机?`).fontColor(Color.White).fontSize('18fp') Row(){
} Text(`是否设备支持TypeC耳机?`).fontColor(Color.White).fontSize('18fp')
Row(){
Column(){
Button(`不支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(!this.yesEnable)
.opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
} }
Column(){ Row(){
Button(`支持`) Column(){
.borderRadius(8) Button(`不支持`)
.backgroundColor(0x317aff) .borderRadius(8)
.width('30%') .backgroundColor(0x317aff)
.onClick(async () => { .width('30%')
this.yesEnable = true .enabled(!this.yesEnable)
this.playEnable = true .opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
}
Column(){
Button(`支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.onClick(async () => {
this.yesEnable = true
this.playEnable = true
}) })
}
} }
} Row(){
Row(){ Text('测试目的:\n当设备连接TypeC耳机时,音频路由是否正确切换\n测试准备:\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持TypeC外设\n2. 按下播放按钮\n3. 连接TypeC耳机\n4. 拔出TypeC耳机\n5. 按下停止按钮\n测试标准:\n如果设备不支持TypeC耳机连接或者插拔TypeC耳机后接收到路由通知、路由显示正确,且连接TypeC后音频通过TypeC耳机播放,则用例pass').fontColor(Color.White).fontSize('18fp')
Text('测试目的:\n当设备连接TypeC耳机时,音频路由是否正确切换\n测试准备:\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持TypeC外设\n2. 按下播放按钮\n3. 连接TypeC耳机\n4. 拔出TypeC耳机\n5. 按下停止按钮\n测试标准:\n如果设备不支持TypeC耳机连接或者插拔TypeC耳机后接收到路由通知、路由显示正确,且连接TypeC后音频通过TypeC耳机播放,则用例pass').fontColor(Color.White).fontSize('18fp')
}
Row(){
Text(`Audio输出路由:${this.outputDevice}`).fontColor(Color.White).fontSize('18fp')
}
Row(){
Column(){
Button(`播放`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.playEnable)
.opacity(this.playEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
this.stopEnable = true
this.playEnable = false
await AudioRenderer.createAudioRenderer()
await AudioRenderer.startRenderer()
})
} }
Column(){ Row(){
Button(`停止`) Text(`Audio输出路由:${this.outputDevice}`).fontColor(Color.White).fontSize('18fp')
.borderRadius(8) }
.backgroundColor(0x317aff) Row(){
.width('30%') Column(){
.enabled(this.stopEnable) Button(`播放`)
.opacity(this.stopEnable? 1 : 0.4) .borderRadius(8)
.onClick(async () => { .backgroundColor(0x317aff)
await AudioRenderer.stopRenderer() .width('30%')
await AudioRenderer.releaseRenderer() .enabled(this.playEnable)
this.playEnable = true .opacity(this.playEnable? 1 : 0.4)
this.stopEnable = false .onClick(async () => {
}) this.Vue = true
this.stopEnable = true
this.playEnable = false
await AudioRenderer.createAudioRenderer()
await AudioRenderer.startRenderer()
})
}
Column(){
Button(`停止`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.stopEnable)
.opacity(this.stopEnable? 1 : 0.4)
.onClick(async () => {
await AudioRenderer.stopRenderer()
await AudioRenderer.releaseRenderer()
this.playEnable = true
this.stopEnable = false
})
}
} }
} }
} }
......
...@@ -88,71 +88,73 @@ struct audioOutputRouting { ...@@ -88,71 +88,73 @@ struct audioOutputRouting {
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Column() { Column() {
Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Flex({direction:FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Column(){ Scroll() {
Row(){ Column(){
Text(`是否设备支持3.5mm有线耳机?`).fontColor(Color.White).fontSize('18fp') Row(){
} Text(`是否设备支持3.5mm有线耳机?`).fontColor(Color.White).fontSize('18fp')
Row(){
Column(){
Button(`不支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(!this.yesEnable)
.opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
} }
Column(){ Row(){
Button(`支持`) Column(){
.borderRadius(8) Button(`不支持`)
.backgroundColor(0x317aff) .borderRadius(8)
.width('30%') .backgroundColor(0x317aff)
.onClick(async () => { .width('30%')
this.yesEnable = true .enabled(!this.yesEnable)
this.playEnable = true .opacity(!this.yesEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
})
}
Column(){
Button(`支持`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.onClick(async () => {
this.yesEnable = true
this.playEnable = true
}) })
}
} }
} Row(){
Row(){ Text('测试目的:\n当设备连接3.5mm有线耳机时,音频路由是否正确切换\n测试准备:\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持3.5mm耳机外设\n2. 按下播放按钮\n3. 连接3.5mm有线耳机\n4. 拔出3.5mm有线耳机\n5. 按下停止按钮\n测试标准:\n如果设备不支持有线耳机输入或者插入和拔出有线耳机后接收到路由通知,路由显示正确,且连接外设后音频通过外设播放,则用例pass').fontColor(Color.White).fontSize('18fp')
Text('测试目的:\n当设备连接3.5mm有线耳机时,音频路由是否正确切换\n测试准备:\n断连任何外设,保持设备常亮\n测试步骤:\n1. 验证设备是否支持3.5mm耳机外设\n2. 按下播放按钮\n3. 连接3.5mm有线耳机\n4. 拔出3.5mm有线耳机\n5. 按下停止按钮\n测试标准:\n如果设备不支持有线耳机输入或者插入和拔出有线耳机后接收到路由通知,路由显示正确,且连接外设后音频通过外设播放,则用例pass').fontColor(Color.White).fontSize('18fp')
}
Row(){
Text(`Audio输出路由:${this.outputDevice}`).fontColor(Color.White).fontSize('18fp')
}
Row(){
Column(){
Button(`播放`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.playEnable)
.opacity(this.playEnable? 1 : 0.4)
.onClick(async () => {
this.Vue = true
this.stopEnable = true
this.playEnable = false
await AudioRenderer.createAudioRenderer()
await AudioRenderer.startRenderer()
})
} }
Column(){ Row(){
Button(`停止`) Text(`Audio输出路由:${this.outputDevice}`).fontColor(Color.White).fontSize('18fp')
.borderRadius(8) }
.backgroundColor(0x317aff) Row(){
.width('30%') Column(){
.enabled(this.stopEnable) Button(`播放`)
.opacity(this.stopEnable? 1 : 0.4) .borderRadius(8)
.onClick(async () => { .backgroundColor(0x317aff)
await AudioRenderer.stopRenderer() .width('30%')
await AudioRenderer.releaseRenderer() .enabled(this.playEnable)
this.playEnable = true .opacity(this.playEnable? 1 : 0.4)
this.stopEnable = false .onClick(async () => {
}) this.Vue = true
this.stopEnable = true
this.playEnable = false
await AudioRenderer.createAudioRenderer()
await AudioRenderer.startRenderer()
})
}
Column(){
Button(`停止`)
.borderRadius(8)
.backgroundColor(0x317aff)
.width('30%')
.enabled(this.stopEnable)
.opacity(this.stopEnable? 1 : 0.4)
.onClick(async () => {
await AudioRenderer.stopRenderer()
await AudioRenderer.releaseRenderer()
this.playEnable = true
this.stopEnable = false
})
}
} }
} }
} }
......
...@@ -45,7 +45,9 @@ struct IndexPage { ...@@ -45,7 +45,9 @@ struct IndexPage {
{title:'AudioOutputRoutingTest(TypeC)',uri:'pages/Audio/AudioOutputRoutingTypeC'}, {title:'AudioOutputRoutingTest(TypeC)',uri:'pages/Audio/AudioOutputRoutingTypeC'},
{title:'AudioOutputRoutingTest(BT)',uri:'pages/Audio/AudioOutputRoutingBT'}, {title:'AudioOutputRoutingTest(BT)',uri:'pages/Audio/AudioOutputRoutingBT'},
] ]
@State ColorObject : string[] = VarColor; @State ColorObject : Object[] = VarColor;
@State ColorTrue : Object[] = [];
@State ColorTrue2 : Object[] = [];
async onPageShow(){ async onPageShow(){
let Test = null; let Test = null;
let context =null; let context =null;
...@@ -65,7 +67,7 @@ struct IndexPage { ...@@ -65,7 +67,7 @@ struct IndexPage {
if(Test != 1) { if(Test != 1) {
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) { for(let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); let log = (this.TestCaseList[i].title+';'+'none '+';').toString();
fileio.writeSync(fd,log); fileio.writeSync(fd,log);
} }
fileio.closeSync(fd); fileio.closeSync(fd);
...@@ -96,12 +98,12 @@ struct IndexPage { ...@@ -96,12 +98,12 @@ struct IndexPage {
let name1 = '刚刚点进了哪个用例:'+ titles; let name1 = '刚刚点进了哪个用例:'+ titles;
let results = this.result; let results = this.result;
let WriteTitle = (titles).toString(); let WriteTitle = (titles).toString();
let number = WriteTitle.length + 11; let number = WriteTitle.length + 7;
let Index = ColorBack.indexOf(WriteTitle); let Index = ColorBack.indexOf(WriteTitle);
if (this.result === 'true '){ if (this.result === 'true '){
this.ColorObject[this.current] = '#ff008000'; this.ColorObject[this.current] = 'true ';
let Log = (titles+';'+'#ff008000'+';'); let Log = (titles+';'+'true '+';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key,Log);
...@@ -114,8 +116,8 @@ struct IndexPage { ...@@ -114,8 +116,8 @@ struct IndexPage {
filewrite(name1,results,titles) filewrite(name1,results,titles)
} }
else if (this.result === 'false'){ else if (this.result === 'false'){
this.ColorObject[this.current] = '#ffff0000'; this.ColorObject[this.current] = 'false';
let Log = (titles+';'+'#ffff0000'+';'); let Log = (titles+';'+'false'+';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key,Log);
...@@ -127,10 +129,25 @@ struct IndexPage { ...@@ -127,10 +129,25 @@ struct IndexPage {
fileio.writeSync(Fd,Report); fileio.writeSync(Fd,Report);
filewrite(name1,results,titles); filewrite(name1,results,titles);
} }
else if (this.result === 'None'){ else {
this.ColorObject[this.current] = this.ColorObject[this.current]; this.ColorObject[this.current] = this.ColorObject[this.current];
} }
} }
for (let i = 0; i < TestList.length; i++){
if (this.ColorObject[i] === 'true '){
this.ColorTrue[i] = 0x263526
this.ColorTrue2[i] = 0x0CB60C
}
else if (this.ColorObject[i] === 'false'){
this.ColorTrue[i] = 0x380303
this.ColorTrue2[i] = 0xd60a0a
}
else {
this.ColorTrue[i] = 0x000000
this.ColorTrue2[i] = 0x000000
}
}
} }
build(){ build(){
Column(){ Column(){
...@@ -161,7 +178,7 @@ struct IndexPage { ...@@ -161,7 +178,7 @@ struct IndexPage {
action: () => { action: () => {
this.ClearAll = true; this.ClearAll = true;
this.ColorObject.forEach((value, index) => { this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080'; this.ColorObject[index] = 'none ';
}); });
this.ClearText(); this.ClearText();
prompt.showToast({ prompt.showToast({
...@@ -208,12 +225,13 @@ struct IndexPage { ...@@ -208,12 +225,13 @@ struct IndexPage {
}) })
} }
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black)
List({space:5}){ List({}){
ForEach(this.TestCaseList,(item,index) => { ForEach(this.TestCaseList,(item,index) => {
ListItem(){ ListItem(){
Row(){ Row(){
Text(item.title).fontSize(16).fontColor(Color.Black) Text(item.title).fontSize(20).fontColor(Color.White)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) }.width('100%').height(50).alignItems(VerticalAlign.Center)
.linearGradient(this.count===0&&this.TEST===0?{angle: 90,colors: [[0x000000, 0.0],[0x000000, 1.0]]}:{ angle: 90,colors: [[this.ColorTrue[index], 0.0], [this.ColorTrue2[index], 0.618]]})
.onClick(( )=>{ .onClick(( )=>{
this.count = 1; this.count = 1;
this.ClearAll=false; this.ClearAll=false;
...@@ -224,7 +242,7 @@ struct IndexPage { ...@@ -224,7 +242,7 @@ struct IndexPage {
}) })
} }
},item => item.title) },item => item.title)
}.width('100%').height('92%') }.width('100%').height('92%').divider({strokeWidth:1,color:Color.Grey})
}.width('100%').height('100%').backgroundColor(Color.Black) }.width('100%').height('100%').backgroundColor(Color.Black)
} }
ClearText(){ ClearText(){
......
...@@ -104,17 +104,21 @@ struct cameraOrientation { ...@@ -104,17 +104,21 @@ struct cameraOrientation {
}.size({ width: '10%', height: '30%' }) }.size({ width: '10%', height: '30%' })
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start, direction: FlexDirection.Column }) { Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Start, direction: FlexDirection.Column }) {
// Text(`提示:` + this.isFlash).fontSize('16fp').fontColor(Color.White) Scroll() {
Text(`提示:如果设备存在闪光灯,选择开启,否则选择无闪光灯`) Column() {
.fontSize('16fp').fontColor(Color.White).margin('20fp') // Text(`提示:` + this.isFlash).fontSize('16fp').fontColor(Color.White)
Row() { Text(`提示:如果设备存在闪光灯,选择开启,否则选择无闪光灯`)
Button(this.flashChange ? '关闭' : '开启').onClick(() => { .fontSize('16fp').fontColor(Color.White).margin('20fp')
this.openFlash() Row() {
}) Button(this.flashChange ? '关闭' : '开启').onClick(() => {
Button('无闪光灯').onClick(() => { this.openFlash()
this.Vue = true })
}) Button('无闪光灯').onClick(() => {
}.justifyContent(FlexAlign.SpaceEvenly).width('100%').margin('20fp') this.Vue = true
})
}.justifyContent(FlexAlign.SpaceEvenly).width('100%').margin('20fp')
}
}
}.width('80%').height('50%') }.width('80%').height('50%')
......
...@@ -118,50 +118,55 @@ struct cameraOrientation { ...@@ -118,50 +118,55 @@ struct cameraOrientation {
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { Scroll() {
Column() { Column() {
XComponent({ Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) {
id: 'componentId', Column() {
type: 'surface', XComponent({
controller: this.mXComponentController id: 'componentId',
}) type: 'surface',
.onLoad(async () => { controller: this.mXComponentController
Logger.info(this.tag, 'onLoad is called')
// @ts-ignore
this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => {
this.cameraListFn()
}) })
.onLoad(async () => {
Logger.info(this.tag, 'onLoad is called')
// @ts-ignore
this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => {
this.cameraListFn()
})
})
.size({ width: '100%', height: '100%' })
Text('预览').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '65%' })
Column() {
Image(this.assetUri || '').size({ width: '100%', height: '100%' }).border({ width: 1 })
Text('带旋转角度的图片').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '65%' })
}.width('100%').height('60%')
Flex({ direction: FlexDirection.Column }) {
Text(`Camera: ${this.cameraDeviceIndex}`).fontSize('16fp').fontColor(Color.White)
Text(`Orientation: ${this.imageRotation}°`).fontSize('16fp').fontColor(Color.White)
Text(`顺时针`).fontSize('16fp').fontColor(Color.White)
Text(`提示:`).fontSize('16fp').fontColor(Color.White)
Text(`如果左边预览窗口顺时针旋转后与右边窗口相同,选择pass,否则选择fail`)
.fontSize('16fp').fontColor(Color.White)
}.size({ width: '80%', height: '25%' })
Button(this.takeFlag ? '拍照' : '下一个')
.enabled(this.isEnabled)
.opacity(this.isEnabled ? 1 : 0.4)
.width('50%')
.height('5%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.onChangeTake()
}) })
.size({ width: '100%', height: '100%' }) }
Text('预览').fontSize('20fp').fontColor(Color.White) }.height('80%')
}.size({ width: '40%', height: '60%' })
Column() {
Image(this.assetUri || '').size({ width: '100%', height: '100%' }).border({ width: 1 })
Text('带旋转角度的图片').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '60%' })
}.width('100%').height('50%')
Flex({ direction: FlexDirection.Column }) {
Text(`Camera: ${this.cameraDeviceIndex}`).fontSize('16fp').fontColor(Color.White)
Text(`Orientation: ${this.imageRotation}°`).fontSize('16fp').fontColor(Color.White)
Text(`顺时针`).fontSize('16fp').fontColor(Color.White)
Text(`提示:`).fontSize('16fp').fontColor(Color.White)
Text(`如果左边预览窗口顺时针旋转后与右边窗口相同,选择pass,否则选择fail`)
.fontSize('16fp').fontColor(Color.White)
}.size({ width: '80%', height: '25%' })
Button(this.takeFlag ? '拍照' : '下一个')
.enabled(this.isEnabled)
.opacity(this.isEnabled ? 1 : 0.4)
.width('50%')
.height('5%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.onChangeTake()
})
CustomContainer({ CustomContainer({
title: this.name, title: this.name,
......
...@@ -125,130 +125,137 @@ struct cameraOrientation { ...@@ -125,130 +125,137 @@ struct cameraOrientation {
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { Scroll() {
Column() { Column() {
XComponent({ Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) {
id: 'componentId', Column() {
type: 'surface', XComponent({
controller: this.mXComponentController id: 'componentId',
}) type: 'surface',
.onLoad(async () => { controller: this.mXComponentController
Logger.info(this.tag, 'onLoad is called')
// @ts-ignore
this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
this.cameraInit()
})
.size({ width: '100%', height: '100%' })
Text('预览').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '60%' })
Column() {
Image(this.assetUri || '').size({ width: '100%', height: '100%' }).border({ width: 1 })
Text('图片').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '60%' })
}.width('100%').height('50%')
Flex({ direction: FlexDirection.Column }) {
Row() {
Select(this.resolution)
.selected(this.clickFrequency)
.value(this.resolutionSelectVal)
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number, value) => {
let indexOf = value.indexOf('x')
let objW = Number(value.slice(0, indexOf))
let objH = Number(value.slice(indexOf + 1))
let obj = {
format: 2000,
size: {
"width": objW,
"height": objH
}
}
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, obj)
Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`)
})
.backgroundColor(Color.Black)
Select(this.cameraList)
.selected(this.cameraDeviceIndex)
.value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
this.cameraDeviceIndex = index
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => {
this.cameraListFn()
}) })
}) .onLoad(async () => {
.backgroundColor(Color.Black) Logger.info(this.tag, 'onLoad is called')
}.justifyContent(FlexAlign.SpaceEvenly) // @ts-ignore
this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
this.cameraInit()
})
.size({ width: '100%', height: '100%' })
Text('预览').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '65%' })
Text(`提示:不同拍照分辨率下进行拍摄,图片拍摄成功且与预览画面一致则选择pass,否则选择fail`) Column() {
.fontSize('16fp').fontColor(Color.White).margin({ top: 20 }) Image(this.assetUri || '').size({ width: '100%', height: '100%' }).border({ width: 1 })
}.size({ width: '80%', height: '20%' }) Text('图片').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '65%' })
}.width('100%').height('60%')
Row() {
Button('拍照')
.enabled(this.isEnabled)
.opacity(this.isEnabled ? 1 : 0.4)
.width('40%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.isEnabled = false
this.isNextEnabled = false
CameraService.takePicture()
})
Button('下一个')
.enabled(!this.isNextEnabled)
.opacity(!this.isNextEnabled ? 1 : 0.4)
.width('40%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.clickFrequency++
Logger.info(this.tag, `nextClickFn new clickFrequency: ${this.clickFrequency}`)
if (this.resolution.length == this.clickFrequency || this.resolution.length < this.clickFrequency){ Flex({ direction: FlexDirection.Column }) {
if (this.isCameraChange){ Row() {
this.Vue = true Select(this.resolution)
this.isEnabled = false .selected(this.clickFrequency)
this.isNextEnabled = true .value(this.resolutionSelectVal)
return .font({ size: 16, weight: 500 })
} .fontColor(Color.White)
this.clickFrequency = 0 .selectedOptionBgColor(Color.Black)
if (this.cameraListLength > 1) { .optionBgColor(Color.Black)
this.cameraDeviceIndex = Number(!this.cameraDeviceIndex) .selectedOptionFont({ size: 16, weight: 400 })
await this.cameraInit().then(() => { .optionFont({ size: 16, weight: 400 })
this.isCameraChange = true .onSelect((index: number, value) => {
let indexOf = value.indexOf('x')
let objW = Number(value.slice(0, indexOf))
let objH = Number(value.slice(indexOf + 1))
let obj = {
format: 2000,
size: {
"width": objW,
"height": objH
}
}
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, obj)
Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`)
})
.backgroundColor(Color.Black)
Select(this.cameraList)
.selected(this.cameraDeviceIndex)
.value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
this.cameraDeviceIndex = index
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => {
this.cameraListFn()
})
}) })
} else { .backgroundColor(Color.Black)
this.Vue = true }.justifyContent(FlexAlign.SpaceEvenly)
Text(`提示:不同拍照分辨率下进行拍摄,图片拍摄成功且与预览画面一致则选择pass,否则选择fail`)
.fontSize('16fp').fontColor(Color.White).margin({ top: 20 })
}.size({ width: '80%', height: '25%' })
Row() {
Button('拍照')
.enabled(this.isEnabled)
.opacity(this.isEnabled ? 1 : 0.4)
.width('40%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.isEnabled = false this.isEnabled = false
this.isNextEnabled = false
CameraService.takePicture()
})
Button('下一个')
.enabled(!this.isNextEnabled)
.opacity(!this.isNextEnabled ? 1 : 0.4)
.width('40%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.clickFrequency++
Logger.info(this.tag, `nextClickFn new clickFrequency: ${this.clickFrequency}`)
if (this.resolution.length == this.clickFrequency || this.resolution.length < this.clickFrequency){
if (this.isCameraChange){
this.Vue = true
this.isEnabled = false
this.isNextEnabled = true
return
}
this.clickFrequency = 0
if (this.cameraListLength > 1) {
this.cameraDeviceIndex = Number(!this.cameraDeviceIndex)
await this.cameraInit().then(() => {
this.isCameraChange = true
})
} else {
this.Vue = true
this.isEnabled = false
this.isNextEnabled = true
return
}
}
this.isEnabled = true
this.isNextEnabled = true this.isNextEnabled = true
return if (this.clickFrequency){
} let newResolution = this.dealWithResolutionFn(this.resolution)
} Logger.info(this.tag, `nextClickFn new Resolution: ${newResolution}`)
this.isEnabled = true this.cameraInit(newResolution[this.clickFrequency])
this.isNextEnabled = true this.resolutionSelectVal = String(this.resolution[this.clickFrequency].value)
if (this.clickFrequency){ }
let newResolution = this.dealWithResolutionFn(this.resolution)
Logger.info(this.tag, `nextClickFn new Resolution: ${newResolution}`) })
this.cameraInit(newResolution[this.clickFrequency]) }.width('100%').justifyContent(FlexAlign.SpaceEvenly)
this.resolutionSelectVal = String(this.resolution[this.clickFrequency].value) .height('10%')
} }
}.height('80%')
})
}.width('100%').justifyContent(FlexAlign.SpaceEvenly)
.height('10%')
CustomContainer({ CustomContainer({
title: this.name, title: this.name,
......
...@@ -131,90 +131,94 @@ struct cameraFormat { ...@@ -131,90 +131,94 @@ struct cameraFormat {
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround, direction: FlexDirection.Column }) { Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround, direction: FlexDirection.Column }) {
Column() { Scroll() {
XComponent({ Column() {
id: 'componentId', Column() {
type: 'surface', XComponent({
controller: this.mXComponentController id: 'componentId',
}) type: 'surface',
.onLoad(async () => { controller: this.mXComponentController
Logger.info(this.tag, 'onLoad is called')
// @ts-ignore
this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
this.cameraInit()
})
.size({ width: '100%', height: '100%' })
Text('预览').fontSize('20fp').fontColor(Color.White)
}.size({ width: '80%', height: '70%' })
Column() {
Row() {
Select(this.resolution)
.selected(this.clickFrequency)
.value(this.resolutionSelectVal)
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number, value) => {
let indexOf = value.indexOf('x')
let objW = Number(value.slice(0, indexOf))
let objH = Number(value.slice(indexOf + 1))
let obj = {
format: 1003,
size: {
"width": objW,
"height": objH
}
}
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, undefined, undefined, obj)
Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`)
})
.backgroundColor(Color.Black)
Select(this.cameraList)
.selected(this.cameraDeviceIndex)
.value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
this.cameraDeviceIndex = index
this.cameraInit()
})
.backgroundColor(Color.Black)
}.size({ width: '100%', height: '50%' }).justifyContent(FlexAlign.SpaceEvenly)
Row() {
Select([{ value: 'YUV' }])
.selected(0)
.value('YUV')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number, value) => {
Logger.info(this.tag, `onSelect format index: ${index}, value: ${value}`)
}) })
.backgroundColor(Color.Black) .onLoad(async () => {
Button('下一个') Logger.info(this.tag, 'onLoad is called')
.borderRadius(8) // @ts-ignore
.backgroundColor(0x317aff) this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
.enabled(this.nextEnabled) Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
.opacity(this.nextEnabled ? 1 : 0.4) this.cameraInit()
.width('20%') })
.onClick(async () => { .size({ width: '100%', height: '70%' })
this.nextClickFn() Text('预览').fontSize('20fp').fontColor(Color.White)
}) }.size({ width: '80%' })
}.size({ width: '100%', height: '50%' }).justifyContent(FlexAlign.SpaceEvenly) Column() {
}.size({ width: '100%', height: '20%' }) Row() {
Select(this.resolution)
.selected(this.clickFrequency)
.value(this.resolutionSelectVal)
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number, value) => {
let indexOf = value.indexOf('x')
let objW = Number(value.slice(0, indexOf))
let objH = Number(value.slice(indexOf + 1))
let obj = {
format: 1003,
size: {
"width": objW,
"height": objH
}
}
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, undefined, undefined, obj)
Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`)
})
.backgroundColor(Color.Black)
Select(this.cameraList)
.selected(this.cameraDeviceIndex)
.value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
this.cameraDeviceIndex = index
this.cameraInit()
})
.backgroundColor(Color.Black)
}.size({ width: '100%', height: '50%' }).justifyContent(FlexAlign.SpaceEvenly)
Row() {
Select([{ value: 'YUV' }])
.selected(0)
.value('YUV')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number, value) => {
Logger.info(this.tag, `onSelect format index: ${index}, value: ${value}`)
})
.backgroundColor(Color.Black)
Button('下一个')
.borderRadius(8)
.backgroundColor(0x317aff)
.enabled(this.nextEnabled)
.opacity(this.nextEnabled ? 1 : 0.4)
.width('20%')
.onClick(async () => {
this.nextClickFn()
})
}.size({ width: '100%', height: '50%' }).justifyContent(FlexAlign.SpaceEvenly)
}.size({ width: '100%', height: '20%' })
}
}
}.height('80%').width('100%') }.height('80%').width('100%')
CustomContainer({ CustomContainer({
......
...@@ -116,66 +116,72 @@ struct cameraOrientation { ...@@ -116,66 +116,72 @@ struct cameraOrientation {
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { Scroll() {
Column() { Column() {
XComponent({ Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) {
id: 'componentId', Column() {
type: 'surface', XComponent({
controller: this.mXComponentController id: 'componentId',
}) type: 'surface',
.onLoad(async () => { controller: this.mXComponentController
Logger.info(this.tag, 'onLoad is called') })
// @ts-ignore .onLoad(async () => {
this.surfaceId = this.mXComponentController.getXComponentSurfaceId() Logger.info(this.tag, 'onLoad is called')
Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`) // @ts-ignore
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => { this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
this.cameraListFn() Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => {
this.cameraListFn()
})
})
.size({ width: '100%', height: '100%' })
Text('预览').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '65%' })
Column() {
Image(this.assetUri || '').size({ width: '100%', height: '100%' }).border({ width: 1 })
Text('图片').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '65%' })
}.width('100%').height('60%')
Flex({ direction: FlexDirection.Column }) {
Select(this.cameraList)
.selected(this.cameraDeviceIndex)
.value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
this.cameraDeviceIndex = index
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => {
this.cameraListFn()
})
}) })
.backgroundColor(Color.Black)
Text(`提示:`).fontSize('16fp').fontColor(Color.White)
Text(`期望拍摄${this.cameraListLength*10}张照片,实际拍摄${this.clickSerialPhotoVal}张,如果一致请选择pass,否则选择fail`)
.fontSize('16fp').fontColor(Color.White)
}.size({ width: '80%', height: '25%' })
Button('拍照')
.enabled(this.isEnabled)
.opacity(this.isEnabled ? 1 : 0.4)
.width('50%')
.height('5%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.isEnabled = false
this.timer = setInterval(() => {
this.clickSerialPhotoVal++
}, 1000)
}) })
.size({ width: '100%', height: '100%' }) }
Text('预览').fontSize('20fp').fontColor(Color.White) }.height('80%')
}.size({ width: '40%', height: '60%' })
Column() {
Image(this.assetUri || '').size({ width: '100%', height: '100%' }).border({ width: 1 })
Text('图片').fontSize('20fp').fontColor(Color.White)
}.size({ width: '40%', height: '60%' })
}.width('100%').height('50%')
Flex({ direction: FlexDirection.Column }) {
Select(this.cameraList)
.selected(this.cameraDeviceIndex)
.value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
this.cameraDeviceIndex = index
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => {
this.cameraListFn()
})
})
.backgroundColor(Color.Black)
Text(`提示:`).fontSize('16fp').fontColor(Color.White)
Text(`期望拍摄${this.cameraListLength*10}张照片,实际拍摄${this.clickSerialPhotoVal}张,如果一致请选择pass,否则选择fail`)
.fontSize('16fp').fontColor(Color.White)
}.size({ width: '80%', height: '25%' })
Button('拍照')
.enabled(this.isEnabled)
.opacity(this.isEnabled ? 1 : 0.4)
.width('50%')
.height('5%')
.backgroundColor(0x317aff)
.onClick(async () => {
this.isEnabled = false
this.timer = setInterval(() => {
this.clickSerialPhotoVal++
}, 1000)
})
CustomContainer({ CustomContainer({
title: this.name, title: this.name,
......
...@@ -141,135 +141,140 @@ struct cameraOrientation { ...@@ -141,135 +141,140 @@ struct cameraOrientation {
Text('hello').fontColor(Color.White).visibility(Visibility.Hidden) Text('hello').fontColor(Color.White).visibility(Visibility.Hidden)
}.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween) }.backgroundColor(Color.Black).height('10%').width('100%').justifyContent(FlexAlign.SpaceBetween)
Flex({ justifyContent: FlexAlign.SpaceEvenly }) { Scroll() {
Column() { Column() {
XComponent({ Flex({ justifyContent: FlexAlign.SpaceEvenly }) {
id: 'componentId',
type: 'surface',
controller: this.mXComponentController
})
.onLoad(async () => {
Logger.info(this.tag, 'onLoad is called')
// @ts-ignore
this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
this.cameraInit()
})
.size({ width: '100%', height: '100%' })
Text('视频录制').fontSize('20fp').fontColor(Color.White)
}.size({ width: '45%', height: '100%' })
Column() { Column() {
if(!this.isVideoPlayback){ XComponent({
XComponent({ id: 'componentId',
id: '', type: 'surface',
type: 'surface', controller: this.mXComponentController
controller: this.mXComponentController1 })
}) .onLoad(async () => {
.onLoad(() => { Logger.info(this.tag, 'onLoad is called')
}) // @ts-ignore
.size({ width: '100%', height: '100%' }) this.surfaceId = this.mXComponentController.getXComponentSurfaceId()
Text('视频回放').fontSize('20fp').fontColor(Color.White) Logger.info(this.tag, `onLoad surfaceId: ${this.surfaceId}`)
} this.cameraInit()
}.size({ width: '45%', height: '100%' }) })
.size({ width: '100%', height: '100%' })
}.size({ width: '100%', height: '50%' }) Text('视频录制').fontSize('20fp').fontColor(Color.White)
}.size({ width: '45%', height: '100%' })
Column() { Column() {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceEvenly }) { if(!this.isVideoPlayback){
Select(this.resolution) XComponent({
.selected(this.clickFrequency) id: '',
.value(this.resolutionSelectVal) type: 'surface',
.font({ size: 16, weight: 500 }) controller: this.mXComponentController1
.fontColor(Color.White) })
.margin({ top: 50 }) .onLoad(() => {
.selectedOptionBgColor(Color.Black) })
.optionBgColor(Color.Black) .size({ width: '100%', height: '100%' })
.selectedOptionFont({ size: 16, weight: 400 }) Text('视频回放').fontSize('20fp').fontColor(Color.White)
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number, value) => {
let indexOf = value.indexOf('x')
let objW = Number(value.slice(0, indexOf))
let objH = Number(value.slice(indexOf + 1))
let obj = {
format: 1003,
size: {
"width": objW,
"height": objH
}
} }
CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) }.size({ width: '45%', height: '100%' })
Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`)
}) }.size({ width: '100%', height: '60%' })
.backgroundColor(Color.Black)
Select(this.cameraList) Column() {
.selected(this.cameraDeviceIndex) Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceEvenly }) {
.value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0') Select(this.resolution)
.font({ size: 16, weight: 500 }) .selected(this.clickFrequency)
.fontColor(Color.White) .value(this.resolutionSelectVal)
.margin({ top: 50 }) .font({ size: 16, weight: 500 })
.selectedOptionBgColor(Color.Black) .fontColor(Color.White)
.optionBgColor(Color.Black) .margin({ top: 50 })
.selectedOptionFont({ size: 16, weight: 400 }) .selectedOptionBgColor(Color.Black)
.optionFont({ size: 16, weight: 400 }) .optionBgColor(Color.Black)
.onSelect((index: number) => { .selectedOptionFont({ size: 16, weight: 400 })
this.cameraDeviceIndex = index .optionFont({ size: 16, weight: 400 })
this.cameraInit() .onSelect((index: number, value) => {
}) let indexOf = value.indexOf('x')
.backgroundColor(Color.Black) let objW = Number(value.slice(0, indexOf))
Select([{ value: 'YUV' }]) let objH = Number(value.slice(indexOf + 1))
.selected(0) let obj = {
.value('YUV') format: 1003,
.font({ size: 16, weight: 500 }) size: {
.fontColor(Color.White) "width": objW,
.margin({ top: 50 }) "height": objH
.selectedOptionBgColor(Color.Black) }
.optionBgColor(Color.Black) }
.selectedOptionFont({ size: 16, weight: 400 }) CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex)
.optionFont({ size: 16, weight: 400 }) Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`)
.onSelect((index: number, value) => { })
Logger.info(this.tag, `onSelect format index: ${index}, value: ${value}`) .backgroundColor(Color.Black)
}) Select(this.cameraList)
.backgroundColor(Color.Black) .selected(this.cameraDeviceIndex)
}.size({ width: '100%', height: '50%' }) .value(this.cameraDeviceIndex ? 'Camera 1' : 'Camera 0')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.margin({ top: 50 })
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
this.cameraDeviceIndex = index
this.cameraInit()
})
.backgroundColor(Color.Black)
Select([{ value: 'YUV' }])
.selected(0)
.value('YUV')
.font({ size: 16, weight: 500 })
.fontColor(Color.White)
.margin({ top: 50 })
.selectedOptionBgColor(Color.Black)
.optionBgColor(Color.Black)
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number, value) => {
Logger.info(this.tag, `onSelect format index: ${index}, value: ${value}`)
})
.backgroundColor(Color.Black)
}.size({ width: '100%', height: '50%' })
Row() {
Button('录制')
.borderRadius(8)
.backgroundColor(0x317aff)
.margin(15)
.enabled(this.testEnabled)
.opacity(this.testEnabled ? 1 : 0.4)
.size({ width: '30%', height: '40%' })
.onClick(async () => {
this.testEnabled = false
this.nextEnabled = true
prompt.showToast({
message: '录制中,请等待三秒', duration: 1000
});
CameraService.startVideo().then(() => {
setTimeout(() => {
// @ts-ignore
let sufferID = this.mXComponentController1.getXComponentSurfaceId()
Logger.info(this.tag, `onSelect format sufferID: ${sufferID}`)
mediaPlay.init(sufferID)
}, 4000)
})
})
Button('下一个')
.borderRadius(8)
.backgroundColor(0x317aff)
.margin(15)
.enabled(this.nextEnabled)
.opacity(this.nextEnabled ? 1 : 0.4)
.size({ width: '30%', height: '40%' })
.onClick(async () => {
this.testEnabled = true
this.nextClickFn()
})
}.size({ width: '100%', height: '50%' }).justifyContent(FlexAlign.SpaceEvenly)
}.size({ width: '100%', height: '30%' })
}
}.height('80%')
Row() {
Button('录制')
.borderRadius(8)
.backgroundColor(0x317aff)
.margin(15)
.enabled(this.testEnabled)
.opacity(this.testEnabled ? 1 : 0.4)
.size({ width: '30%', height: '40%' })
.onClick(async () => {
this.testEnabled = false
this.nextEnabled = true
prompt.showToast({
message: '录制中,请等待三秒', duration: 1000
});
CameraService.startVideo().then(() => {
setTimeout(() => {
// @ts-ignore
let sufferID = this.mXComponentController1.getXComponentSurfaceId()
Logger.info(this.tag, `onSelect format sufferID: ${sufferID}`)
mediaPlay.init(sufferID)
}, 4000)
})
})
Button('下一个')
.borderRadius(8)
.backgroundColor(0x317aff)
.margin(15)
.enabled(this.nextEnabled)
.opacity(this.nextEnabled ? 1 : 0.4)
.size({ width: '30%', height: '40%' })
.onClick(async () => {
this.testEnabled = true
this.nextClickFn()
})
}.size({ width: '100%', height: '50%' }).justifyContent(FlexAlign.SpaceEvenly)
}.size({ width: '100%', height: '30%' })
CustomContainer({ CustomContainer({
title: this.name, title: this.name,
......
...@@ -46,7 +46,9 @@ struct IndexPage { ...@@ -46,7 +46,9 @@ struct IndexPage {
{ title: 'CameraVideo', uri: 'pages/Camera/CameraVideo' }, { title: 'CameraVideo', uri: 'pages/Camera/CameraVideo' },
{ title: 'CameraFlash', uri: 'pages/Camera/CameraFlash' }, { title: 'CameraFlash', uri: 'pages/Camera/CameraFlash' },
] ]
@State ColorObject : string[] = VarColor; @State ColorObject : Object[] = VarColor;
@State ColorTrue : Object[] = [];
@State ColorTrue2 : Object[] = [];
async onPageShow(){ async onPageShow(){
let Test = null; let Test = null;
let context =null; let context =null;
...@@ -66,7 +68,7 @@ struct IndexPage { ...@@ -66,7 +68,7 @@ struct IndexPage {
if(Test != 1) { if(Test != 1) {
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) { for(let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); let log = (this.TestCaseList[i].title+';'+'none '+';').toString();
fileio.writeSync(fd,log); fileio.writeSync(fd,log);
} }
fileio.closeSync(fd); fileio.closeSync(fd);
...@@ -97,12 +99,12 @@ struct IndexPage { ...@@ -97,12 +99,12 @@ struct IndexPage {
let name1 = '刚刚点进了哪个用例:'+ titles; let name1 = '刚刚点进了哪个用例:'+ titles;
let results = this.result; let results = this.result;
let WriteTitle = (titles).toString(); let WriteTitle = (titles).toString();
let number = WriteTitle.length + 11; let number = WriteTitle.length + 7;
let Index = ColorBack.indexOf(WriteTitle); let Index = ColorBack.indexOf(WriteTitle);
if (this.result === 'true '){ if (this.result === 'true '){
this.ColorObject[this.current] = '#ff008000'; this.ColorObject[this.current] = 'true ';
let Log = (titles+';'+'#ff008000'+';'); let Log = (titles+';'+'true '+';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key,Log);
...@@ -115,8 +117,8 @@ struct IndexPage { ...@@ -115,8 +117,8 @@ struct IndexPage {
filewrite(name1,results,titles) filewrite(name1,results,titles)
} }
else if (this.result === 'false'){ else if (this.result === 'false'){
this.ColorObject[this.current] = '#ffff0000'; this.ColorObject[this.current] = 'false';
let Log = (titles+';'+'#ffff0000'+';'); let Log = (titles+';'+'false'+';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key,Log);
...@@ -128,10 +130,25 @@ struct IndexPage { ...@@ -128,10 +130,25 @@ struct IndexPage {
fileio.writeSync(Fd,Report); fileio.writeSync(Fd,Report);
filewrite(name1,results,titles); filewrite(name1,results,titles);
} }
else if (this.result === 'None'){ else {
this.ColorObject[this.current] = this.ColorObject[this.current]; this.ColorObject[this.current] = this.ColorObject[this.current];
} }
} }
for (let i = 0; i < TestList.length; i++){
if (this.ColorObject[i] === 'true '){
this.ColorTrue[i] = 0x263526
this.ColorTrue2[i] = 0x0CB60C
}
else if (this.ColorObject[i] === 'false'){
this.ColorTrue[i] = 0x380303
this.ColorTrue2[i] = 0xd60a0a
}
else {
this.ColorTrue[i] = 0x000000
this.ColorTrue2[i] = 0x000000
}
}
} }
build(){ build(){
Column(){ Column(){
...@@ -143,9 +160,9 @@ struct IndexPage { ...@@ -143,9 +160,9 @@ struct IndexPage {
router.back(); router.back();
}) })
Row(){ Row(){
Text('Camera') Text('Camera SubSystem')
.fontColor(Color.White) .fontColor(Color.White)
.fontSize('20fp') .fontSize('22fp')
}.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black)
Row() { Row() {
Button(){ Button(){
...@@ -162,7 +179,7 @@ struct IndexPage { ...@@ -162,7 +179,7 @@ struct IndexPage {
action: () => { action: () => {
this.ClearAll = true; this.ClearAll = true;
this.ColorObject.forEach((value, index) => { this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080'; this.ColorObject[index] = 'none ';
}); });
this.ClearText(); this.ClearText();
prompt.showToast({ prompt.showToast({
...@@ -209,12 +226,13 @@ struct IndexPage { ...@@ -209,12 +226,13 @@ struct IndexPage {
}) })
} }
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black)
List({space:5}){ List({}){
ForEach(this.TestCaseList,(item,index) => { ForEach(this.TestCaseList,(item,index) => {
ListItem(){ ListItem(){
Row(){ Row(){
Text(item.title).fontSize(16).fontColor(Color.Black) Text(item.title).fontSize(20).fontColor(Color.White)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) }.width('100%').height(50).alignItems(VerticalAlign.Center)
.linearGradient(this.count===0&&this.TEST===0?{angle: 90,colors: [[0x000000, 0.0],[0x000000, 1.0]]}:{ angle: 90,colors: [[this.ColorTrue[index], 0.0], [this.ColorTrue2[index], 0.618]]})
.onClick(( )=>{ .onClick(( )=>{
this.count = 1; this.count = 1;
this.ClearAll=false; this.ClearAll=false;
...@@ -225,7 +243,7 @@ struct IndexPage { ...@@ -225,7 +243,7 @@ struct IndexPage {
}) })
} }
},item => item.title) },item => item.title)
}.width('100%').height('92%') }.width('100%').height('92%').divider({strokeWidth:1,color:Color.Grey})
}.width('100%').height('100%').backgroundColor(Color.Black) }.width('100%').height('100%').backgroundColor(Color.Black)
} }
ClearText(){ ClearText(){
...@@ -233,7 +251,7 @@ struct IndexPage { ...@@ -233,7 +251,7 @@ struct IndexPage {
fileio.mkdirSync(path1); fileio.mkdirSync(path1);
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) { for(let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); let log = (this.TestCaseList[i].title+';'+'none '+';').toString();
fileio.writeSync(fd,log); fileio.writeSync(fd,log);
} }
} }
......
...@@ -13,20 +13,18 @@ ...@@ -13,20 +13,18 @@
* limitations under the License. * limitations under the License.
*/ */
import router from '@ohos.router'; import router from '@ohos.router';
import fileio from '@ohos.fileio';
import {CustomContainer} from '../common/StartExperienceCustomContainer'; import {CustomContainer} from '../common/StartExperienceCustomContainer';
import FirstDialog from '../model/FirstDialog'; import FirstDialog from '../model/FirstDialog';
import context from '@ohos.app.ability.common'; import context from '@ohos.app.ability.common';
let abilityContext = getContext(this) as context.UIAbilityContext; let abilityContext = getContext(this) as context.UIAbilityContext;
let path = globalThis.dir;
let path1 = path + '/ExperienceData';
let CameraColdPath = path1 + '/ColdStartCamera.log';
@Entry @Entry
@Component @Component
struct CustomContainerUser { struct CustomContainerUser {
@State name: string = 'CameraColdStart'; @State name: string = 'CameraColdStart';
@State StepTips: string = '操作步骤:根据操作提示运行脚本文件,启动应用'+'\n'+'预期结果:所有应用冷启动时延小于2300ms则测试通过'; @State StepTips: string = '操作步骤:根据操作提示运行脚本文件,启动应用'+'\n'+'预期结果:所有应用冷启动时延小于2300ms则测试通过';
@State toSP_daemon: string = 'SP_daemon -editor coldStartHM com.ohos.camera 相机 ohtest';
@State Vue: boolean = false; @State Vue: boolean = false;
@State StartEnable: boolean = true; @State StartEnable: boolean = true;
@State num: number = 0; @State num: number = 0;
...@@ -39,6 +37,8 @@ struct CustomContainerUser { ...@@ -39,6 +37,8 @@ struct CustomContainerUser {
async aboutToAppear(){ async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name); await FirstDialog.ChooseDialog(this.StepTips,this.name);
this.Vue = false; this.Vue = false;
globalThis.SendMessage = this.toSP_daemon;
globalThis.HideFloatingWindow();
} }
@Builder specificNoParam() { @Builder specificNoParam() {
...@@ -51,10 +51,10 @@ struct CustomContainerUser { ...@@ -51,10 +51,10 @@ struct CustomContainerUser {
.fontColor(Color.White).fontSize('24fp') .fontColor(Color.White).fontSize('24fp')
} }
Row(){ Row(){
Text(`测试步骤:`+ '\n' + '\n' + '1.测试设备通过USB连接工作台' + '\n' + '\n' + `2.点击开始键进入系统桌面` + '\n' + '\n' Text(`测试步骤:`+ '\n' + '\n' + '\n' + '\n' + `1.点击开始键进入系统桌面` + '\n' + '\n'
+ `3.清空后台应用,将底层任务栏中应用拖至桌面` + '\n' + '\n' + `4.工作台运行‘点击启动测试.bat’选择冷启动>相机测试,回车执行` + `2.清空后台应用` + '\n' + '\n' + `3.快速点击桌面相机应用` + '\n' + '\n' +`4.测试应用拉起后手动返回validator界面`
+ '\n' + '\n' +`5.测试应用自动执行冷启动后手动返回validator界面` + '\n' + '\n' + '6.点击结束键观察测试结果' + '\n' + '\n' + '5.点击结束键观察测试结果' + '\n' + '\n' + `6.若冷启动测试在规定时延内完成则通过测试`
+ '\n' + '\n' + `7.若冷启动测试在规定时延内完成则通过测试` + '\n' + '\n' ) + '\n' + '\n' + 'PS:双击悬浮球中断测试,长按悬浮球快速结束测试')
.fontColor(Color.White).fontSize('20fp') .fontColor(Color.White).fontSize('20fp')
} }
Row(){ Row(){
...@@ -66,6 +66,7 @@ struct CustomContainerUser { ...@@ -66,6 +66,7 @@ struct CustomContainerUser {
.enabled(this.StartEnable) .enabled(this.StartEnable)
.opacity(this.StartEnable? 1 : 0.4) .opacity(this.StartEnable? 1 : 0.4)
.onClick(async () => { .onClick(async () => {
globalThis.ShowFloatingWindow();
this.num = 0; this.num = 0;
this.StartEnable = !this.StartEnable; this.StartEnable = !this.StartEnable;
let str = { let str = {
...@@ -87,23 +88,25 @@ struct CustomContainerUser { ...@@ -87,23 +88,25 @@ struct CustomContainerUser {
.enabled(!this.StartEnable) .enabled(!this.StartEnable)
.opacity(!this.StartEnable? 1 : 0.4) .opacity(!this.StartEnable? 1 : 0.4)
.onClick(() => { .onClick(() => {
this.StartEnable = !this.StartEnable
this.StartEnable = !this.StartEnable;
/* /*
camera camera
*/ */
let CameraFd = fileio.openSync(CameraColdPath, 0o100 | 0o2002, 0o664); console.log('result num: ' + globalThis.resultNum);
let CameraBuf = new ArrayBuffer(4096); let CameraReport = globalThis.resultNum;
fileio.readSync(CameraFd,CameraBuf);
let CameraReport = String.fromCharCode.apply(null,new Uint8Array(CameraBuf));
let CameraHead = CameraReport.indexOf('time:'); let CameraHead = CameraReport.indexOf('time:');
let CameraTime = CameraReport.substring(CameraHead+5); let CameraTime = CameraReport.substring(CameraHead+5);
this.cameraNum = parseFloat(CameraTime); this.cameraNum = parseFloat(CameraTime);
if( 0 < this.cameraNum && this.cameraNum < 2300 ) { if( 0 < this.cameraNum && this.cameraNum < 2300 ) {
this.num++ this.num++
} else if ( isNaN(this.cameraNum )){
this.cameraNum = -1000;
} }
if( this.num === 1 ) { if( this.num === 1 ) {
this.Vue = true; this.Vue = true;
} }
globalThis.HideFloatingWindow();
}) })
} }
} }
......
...@@ -65,7 +65,7 @@ struct IndexPage { ...@@ -65,7 +65,7 @@ struct IndexPage {
{title:'Player',uri:'pages/Player/Player_index'}, {title:'Player',uri:'pages/Player/Player_index'},
{title:'Experience',uri:'pages/Experience/Experience_index'}, {title:'Experience',uri:'pages/Experience/Experience_index'},
] ]
@State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080'] @State ColorObject : string[] = ['#ff000000','#ff000000','#ff000000','#ff000000','#ff000000']
async onPageShow(){ async onPageShow(){
let Test = null; let Test = null;
let context =null; let context =null;
...@@ -173,11 +173,11 @@ struct IndexPage { ...@@ -173,11 +173,11 @@ struct IndexPage {
}) })
} }
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%') }.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%')
List({space:5}){ List({}){
ForEach(this.TestCaseList,(item,index) => { ForEach(this.TestCaseList,(item,index) => {
ListItem(){ ListItem(){
Row(){ Row(){
Text(item.title).fontSize(16).fontColor(Color.Black) Text(item.title).fontSize(20).fontColor(Color.White)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index]) }.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.ColorObject[index])
.onClick(()=>{ .onClick(()=>{
router.push({ router.push({
...@@ -194,7 +194,7 @@ struct IndexPage { ...@@ -194,7 +194,7 @@ struct IndexPage {
}) })
} }
},item => item.title) },item => item.title)
}.width('100%').height('92%') }.width('100%').height('92%').divider({strokeWidth:1,color:Color.Grey})
}.width('100%').height('100%').backgroundColor(Color.Black) }.width('100%').height('100%').backgroundColor(Color.Black)
} }
ClearText(){ ClearText(){
......
...@@ -59,6 +59,9 @@ ...@@ -59,6 +59,9 @@
}, },
{ {
"name": "ohos.permission.START_INVISIBLE_ABILITY" "name": "ohos.permission.START_INVISIBLE_ABILITY"
},
{
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW"
} }
] ]
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册