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