提交 19efddd4 编写于 作者: T tianwenzhe

add player and experience

Signed-off-by: Ntian-wenzhe411 <tianwenzhe2@huawei.com>
上级 9c1cf240
......@@ -61,7 +61,6 @@ struct IndexPage {
{title:'CanvasShadowColor',uri:'pages/ArkUI/CanvasShadowColor'},
{title:'CanvasShadowOffsetX',uri:'pages/ArkUI/CanvasShadowOffsetX'},
{title:'CanvasShadowOffsetY',uri:'pages/ArkUI/CanvasShadowOffsetY'},
{title:'CanvasImageSmoothingEnabled',uri:'pages/ArkUI/CanvasImageSmoothingEnabled'},
]
@State ColorObject : string[] = VarColor;
async onPageShow(){
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {CustomContainer} from '../common/CanvasCustomContainer2';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
private settings: RenderingContextSettings = new RenderingContextSettings(true);
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings);
private img:ImageBitmap = new ImageBitmap("src/main/resources/base/media/flower.jpg");
@State FillColor: string = '#FF000000';
@State X: number = 0;
@State name: string = 'CanvasImageSmoothingEnabled';
@State StepTips: string = '操作步骤:点击不同的控件'+'\n'+'预期结果:切换平滑过渡效果';
@State Vue: boolean = false;
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }){
Text('True').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(10, 100, 400, 300);
this.context.imageSmoothingEnabled = true;
this.context.drawImage( this.img,0,0,400,200);
this.Vue = true;
})
Text('False').fontSize(16).border({width:2}).size({width:'25%',height:'20%'})
.onClick(()=>{
this.context.clearRect(10, 100, 400, 300);
this.context.imageSmoothingEnabled = false;
this.context.drawImage( this.img,0,0,400,200);
this.Vue = true;
})
}.width('70%').height('30%')
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Canvas(this.context)
.width('100%')
.height('100%')
.backgroundColor('#ffffffff')
.onReady(() =>{
this.context.imageSmoothingEnabled = false;
this.context.drawImage( this.img,0,0,200,200);
})
}.width('100%').height('60%')
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url: 'pages/ArkUI/ArkUI_index',
StepTips: this.StepTips,
content: this.specificNoParam,
FillColor: $FillColor,
X: $X,
name: $name,
Vue: $Vue,
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import camera from '@ohos.multimedia.camera'
import Logger from '../model/Logger'
import CameraService from '../model/CameraService'
......@@ -55,7 +40,7 @@ struct SetCircle {
Column() {
CustomContainer({
title: this.name,
Url:'pages/CameraOrientation/Camera_Orientation_index',
Url:'pages/Camera/Camera_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import camera from '@ohos.multimedia.camera'
import Logger from '../model/Logger'
import CameraService from '../model/CameraService'
......@@ -54,7 +39,7 @@ struct SetCircle {
Column() {
CustomContainer({
title: this.name,
Url:'pages/CameraOrientation/Camera_Orientation_index',
Url:'pages/Camera/Camera_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import camera from '@ohos.multimedia.camera'
import Logger from '../model/Logger'
import CameraService from '../model/CameraService'
......@@ -53,7 +38,7 @@ struct SetCircle {
Column() {
CustomContainer({
title: this.name,
Url:'pages/CameraOrientation/Camera_Orientation_index',
Url:'pages/Camera/Camera_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import camera from '@ohos.multimedia.camera'
import Logger from '../model/Logger'
import CameraService from '../model/CameraService'
......@@ -53,7 +38,7 @@ struct SetCircle {
Column() {
CustomContainer({
title: this.name,
Url:'pages/CameraOrientation/Camera_Orientation_index',
Url:'pages/Camera/Camera_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import camera from '@ohos.multimedia.camera'
import Logger from '../model/Logger'
import CameraService from '../model/CameraService'
......@@ -53,7 +38,7 @@ struct SetCircle {
Column() {
CustomContainer({
title: this.name,
Url:'pages/CameraOrientation/Camera_Orientation_index',
Url:'pages/Camera/Camera_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import camera from '@ohos.multimedia.camera'
import Logger from '../model/Logger'
import CameraService from '../model/CameraService'
......@@ -55,7 +40,7 @@ struct SetCircle {
Column() {
CustomContainer({
title: this.name,
Url:'pages/CameraOrientation/Camera_Orientation_index',
Url:'pages/Camera/Camera_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import prompt from '@ohos.prompt';
import router from '@ohos.router';
import fileio from '@ohos.fileio';
......@@ -39,12 +24,12 @@ struct IndexPage {
@State result : string = '';
@State TEST : number = 0;
private TestCaseList = [
{title:'CameraOrientation0',uri:'pages/CameraOrientation/CameraOrientation0'},
{title:'CameraOrientation90',uri:'pages/CameraOrientation/CameraOrientation90'},
{title:'CameraOrientation180',uri:'pages/CameraOrientation/CameraOrientation180'},
{title:'CameraOrientation270',uri:'pages/CameraOrientation/CameraOrientation270'},
{title:'CameraFormat',uri:'pages/CameraOrientation/CameraFormat'},
{title:'CameraVideo',uri:'pages/CameraOrientation/CameraVideo'},
{title:'CameraOrientation0',uri:'pages/Camera/CameraOrientation0'},
{title:'CameraOrientation90',uri:'pages/Camera/CameraOrientation90'},
{title:'CameraOrientation180',uri:'pages/Camera/CameraOrientation180'},
{title:'CameraOrientation270',uri:'pages/Camera/CameraOrientation270'},
{title:'CameraFormat',uri:'pages/Camera/CameraFormat'},
{title:'CameraVideo',uri:'pages/Camera/CameraVideo'},
]
@State ColorObject : string[] = VarColor;
async onPageShow(){
......@@ -143,7 +128,7 @@ struct IndexPage {
router.back();
})
Row(){
Text('Camera Oritentation')
Text('Camera')
.fontColor(Color.White)
.fontSize('20fp')
}.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black)
......
import {CustomContainer} from '../common/CustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct CustomContainerUser {
private listArr: number[] = Array.from(new Array(50).keys());
@State name: string = 'ScrollingList';
@State StepTips: string = '操作步骤:滑动列表观察是否能正常滑动'+'\n'+'预期结果:列表滑动正常';
@State Vue: boolean = false;
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
this.Vue = true;
}
@Builder specificNoParam() {
Column() {
List() {
ForEach(this.listArr,(item:any,index:number) => {
ListItem() {
Text('Item #' + (index + 1)).width('100%').height(50).fontSize(16).fontColor(Color.White).margin({left:'10vp'})
}
},index => index)
}.height('100%').width('100%').divider({strokeWidth:1,color:Color.Grey})
}.height('83%').width('100%')
}
build() {
Column() {
CustomContainer({
title: this.name,
Url: 'pages/Experience/Experience_index',
StepTips: this.StepTips,
content: this.specificNoParam.bind(this),
name: $name,
Vue: $Vue,
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewCallback1';
@State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:可以预览到一张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewCallback1';
let images = [
"datashare:///media/image/3",
];
let index = 1;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => {
if (err) {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
return;
}
console.log(TAG + "Succeeded in previewing the images.");
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewCallback2';
@State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:起始图片为第一张图片,一共可以预览到两张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewCallback2';
let images = [
"datashare:///media/image/3",
"datashare:///media/image/4",
];
let index = 1;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => {
if (err) {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
return;
}
console.log(TAG + "Succeeded in previewing the images.");
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewCallback3';
@State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:起始图片为第三张图片,一共可以预览到四张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewCallback3';
let images = [
"datashare:///media/image/3",
"datashare:///media/image/4",
"datashare:///media/image/5",
"datashare:///media/image/6",
];
let index = 2;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => {
if (err) {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
return;
}
console.log(TAG + "Succeeded in previewing the images.");
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewCallback4';
@State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:预览图片失败';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewCallback4';
let images = [
"datashare:///media/image/9999",
"datashare:///media/image/9998",
"datashare:///media/image/9997",
"datashare:///media/image/9996",
];
let index = 2;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index, (err) => {
if (err) {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
return;
}
console.log(TAG + "Succeeded in previewing the images.");
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewCallback5';
@State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:成功预览一张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewCallback5';
let images = [
"datashare:///media/image/3",
];
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => {
if (err) {
console.log(TAG + "startImagePreview_One An error occurred when previewing the images." + JSON.stringify(err));
return;
}
console.log(TAG + "startImagePreview_One Succeeded in previewing the images.");
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewCallback6';
@State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:成功预览五张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewCallback6';
let images = [
"datashare:///media/image/3",
"datashare:///media/image/4",
"datashare:///media/image/5",
"datashare:///media/image/6",
"datashare:///media/image/2",
];
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => {
if (err) {
console.log(TAG + "startImagePreview_MultiPle An error occurred when previewing the images." + JSON.stringify(err));
return;
}
console.log(TAG + "startImagePreview_MultiPle Succeeded in previewing the images.");
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewCallback7';
@State StepTips: string = '测试步骤:点击“点击预览”按钮'+'\n'+'预期结果:预览图片失败';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewCallback7';
let images = [
"datashare:///media/image/9999",
];
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, (err) => {
if (err) {
console.log(TAG + "startImagePreview_One An error occurred when previewing the images." + JSON.stringify(err));
return;
}
console.log(TAG + "startImagePreview_One Succeeded in previewing the images.");
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewPromise1';
@State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:可以成功预览到一张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewPromise1';
let images = [
"datashare:///media/image/3",
];
let index = 1;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => {
console.log(TAG + "Succeeded in previewing the images.");
}).catch((err) => {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url: 'pages/MediaLibrary/MediaLibrary_index',
StepTips: this.StepTips,
content: this.specificNoParam,
FillColor: $FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewPromise2';
@State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:起始图片为第一张图片,一共可以预览到两张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewPromise2';
let images = [
"datashare:///media/image/3",
"datashare:///media/image/4",
];
let index = 1;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => {
console.log(TAG + "Succeeded in previewing the images.");
}).catch((err) => {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url: 'pages/MediaLibrary/MediaLibrary_index',
StepTips: this.StepTips,
content: this.specificNoParam,
FillColor: $FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewPromise3';
@State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:起始图片为第二张图片,一共可以预览到三张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewPromise3';
let images = [
"datashare:///media/image/3",
"datashare:///media/image/4",
"datashare:///media/image/5",
];
let index = 1;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => {
console.log(TAG + "Succeeded in previewing the images.");
}).catch((err) => {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url: 'pages/MediaLibrary/MediaLibrary_index',
StepTips: this.StepTips,
content: this.specificNoParam,
FillColor: $FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startImagePreviewPromise4';
@State StepTips: string = '测试步骤:点击“点击预览”按钮' + '\n' + '预期结果:预览图片失败';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击预览').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startImagePreviewPromise4';
let images = [
"datashare:///media/image/9999",
"datashare:///media/image/9998",
"datashare:///media/image/9997",
];
let index = 1;
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startImagePreview(images, index).then(() => {
console.log(TAG + "Succeeded in previewing the images.");
}).catch((err) => {
console.log(TAG + "An error occurred when previewing the images." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url: 'pages/MediaLibrary/MediaLibrary_index',
StepTips: this.StepTips,
content: this.specificNoParam,
FillColor: $FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectCallback1';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择一张图片(单选)';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelectCallback1';
let option : mediaLibrary.MediaSelectOption = {
type : "image",
count : 1
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => {
if (err) {
console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err));
return;
}
console.log(TAG + "image resources selected." + JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor, name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectCallback2';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多张图片(多选)';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelectCallback2';
let option : mediaLibrary.MediaSelectOption = {
type : "image",
count : 2
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => {
if (err) {
console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err));
return;
}
console.log(TAG + "image resources selected." + JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectCallback3';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个图片、视频文件';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelectCallback3';
let option : mediaLibrary.MediaSelectOption = {
type : "media",
count : 2
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => {
if (err) {
console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err));
return;
}
console.log(TAG + "image resources selected." + JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectCallback4';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个视频资源';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelectCallback4';
let option : mediaLibrary.MediaSelectOption = {
type : "video",
count : 2
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option, (err, value) => {
if (err) {
console.log(TAG + "An error occurred when selecting image resources." + JSON.stringify(err));
return;
}
console.log(TAG + "image resources selected." + JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectPromise1';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择单张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelectPromise1';
let option : mediaLibrary.MediaSelectOption = {
type : "image",
count : 1
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => {
console.log(TAG + "Media resources selected." + JSON.stringify(value));
}).catch((err) => {
console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectPromise2';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多张图片';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelectPromise2';
let option : mediaLibrary.MediaSelectOption = {
type : "image",
count : 2
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => {
console.log(TAG + "Media resources selected." + JSON.stringify(value));
}).catch((err) => {
console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectPromise3';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择多个图片、视频资源';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelect5_media2';
let option : mediaLibrary.MediaSelectOption = {
type : "media",
count : 2
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => {
console.log(TAG + "Media resources selected." + JSON.stringify(value));
}).catch((err) => {
console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'startMediaSelectPromise4';
@State StepTips: string = '测试步骤:点击“点击选择”按钮'+'\n'+'预期结果:可以选择单个视频';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击选择').margin('5%').fontSize(20).border({ width: 1 }).size({ width: '75%', height: '30%' })
.onClick(() => {
let TAG = 'startMediaSelect5_video2';
let option : mediaLibrary.MediaSelectOption = {
type : "video",
count : -1
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).startMediaSelect(option).then((value) => {
console.log(TAG + "Media resources selected." + JSON.stringify(value));
}).catch((err) => {
console.log(TAG + "An error occurred when selecting media resources." + JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetCallback1';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存一张图片,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam(){
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetCallback1';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let JpgPath = data + "/files/"+time + ".jpg";
let srcFd =await fileio.open(JpgPath,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : JpgPath,
mimeType : "image/*",
relativePath : "Pictures/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => {
if (err) {
console.log(TAG +"An error occurred when storing image resources." + JSON.stringify(err));
return;
}
AlertDialog.show(
{
title: '保存成功',
message: '查询到Pictures路径下新增一个.jpg格式的图片资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + 'Closed callbacks')
}
}
)
console.log(TAG + "image resources stored. "+ JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetCallback2';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存音频,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam(){
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetCallback2';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let PathMp3 = data + "/files/"+time + ".mp3";
let srcFd =await fileio.open(PathMp3,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : PathMp3,
mimeType : "audio/mp3",
relativePath : "Audios/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => {
if (err) {
console.log(TAG + "An error occurred when storing audios resources."+ JSON.stringify(err));
return;
}
AlertDialog.show(
{
title: '保存成功',
message: '查询到Audios路径下新增一个.mp3格式的音频资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + 'Closed callbacks')
}
}
)
console.log(TAG + "audios resources stored. "+ JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetCallback3';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存视频,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam(){
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetCallback3';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let PathMp4 = data + "/files/"+time + ".mp4";
let srcFd =await fileio.open(PathMp4,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : PathMp4,
mimeType : "video/mp4",
relativePath : "Videos/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => {
if (err) {
console.log(TAG + "An error occurred when storing videos resources."+ JSON.stringify(err));
return;
}
AlertDialog.show(
{
title: '保存成功',
message: '查询到Videos路径下新增一个.mp4格式的视频资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + 'Closed callbacks')
}
}
)
console.log(TAG + "videos resources stored. "+ JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetCallback4';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存文件,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam(){
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetCallback4';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let PathPdf = data + "/files/"+time + ".Pdf";
let srcFd =await fileio.open(PathPdf,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : PathPdf,
mimeType : "file/pdf",
relativePath : "Documents/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option, (err, value) => {
if (err) {
console.log(TAG + "An error occurred when storing files resources."+ JSON.stringify(err));
return;
}
AlertDialog.show(
{
title: '保存成功',
message: '查询到Documents路径下新增一个.Pdf格式的文件资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking1 callback')
}
},
cancel: () => {
console.info(TAG + 'Closed1 callbacks')
}
}
)
console.log(TAG + "files resources stored. "+ JSON.stringify(value));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetPromise1';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存图片,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetPromise1';
let context0 = featureAbility.getContext();
let data = await context0.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let JpgPath = data + "/files/"+time + ".jpg";
let srcFd =await fileio.open(JpgPath,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : JpgPath,
mimeType : "image/*",
relativePath : "Pictures/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => {
AlertDialog.show(
{
title: '保存成功',
message: '查询到Pictures路径下新增一个.jpg格式的图片资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + 'Closed callbacks')
}
}
)
console.log(TAG + "image resources stored. "+ JSON.stringify(value));
}).catch((err) => {
console.log(TAG + "An error occurred when storing image resources."+ JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetPromise2';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存音频,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetPromise2';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let PathMp3 = data + "/files/"+time + ".mp3";
let srcFd =await fileio.open(PathMp3,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : PathMp3,
mimeType : "audio/mp3",
relativePath : "Audios/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => {
AlertDialog.show(
{
title: '保存成功',
message: '查询到Audios路径下新增一个.mp3格式的音频资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + 'Closed callbacks')
}
}
)
console.log(TAG + "audios resources stored. "+ JSON.stringify(value));
}).catch((err) => {
console.log(TAG + "An error occurred when storing audios resources."+ JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetPromise3';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存视频,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetPromise3';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let PathMp4 = data + "/files/"+time + ".mp4";
let srcFd =await fileio.open(PathMp4,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : PathMp4,
mimeType : "video/mp4",
relativePath : "Videos/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => {
AlertDialog.show(
{
title: '保存成功',
message: '查询到Videos路径下新增一个.mp4格式的视频资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + ' Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + ' Closed callbacks')
}
}
)
console.log(TAG + " videos resources stored. "+ JSON.stringify(value));
}).catch((err) => {
console.log(TAG + " An error occurred when storing videos resources."+ JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetPromise4';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:成功保存文件,资源内容为“hello world”';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetPromise4';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let PathPdf = data + "/files/"+time + ".Pdf";
let srcFd =await fileio.open(PathPdf,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : PathPdf,
mimeType : "file/pdf",
relativePath : "Documents/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => {
AlertDialog.show(
{
title: '保存成功',
message: '查询到Documents路径下新增一个.Pdf格式的文件资源,资源内容为“hello world”',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + 'Closed callbacks')
}
}
)
console.log(TAG + "files resources stored. "+ JSON.stringify(value));
}).catch((err) => {
console.log(TAG + "An error occurred when storing files resources."+ JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import {CustomContainer} from '../common/MediaCustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct SetCircle {
@State FillColor: string = '#FF000000';
@State name: string = 'storeMediaAssetPromise5';
@State StepTips: string = '操作步骤:点击“点击保存”按钮'+'\n'+'预期结果:保存图片失败';
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
}
@Builder specificNoParam() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('点击保存').margin('2%').backgroundColor('#FFDDDDF8').fontSize(20).border({ width: 1 }).size({ width: '70%', height: '20%' })
.onClick(async () => {
let TAG = 'storeMediaAssetPromise5';
let data = await globalThis.abilityContext.getFilesDir();
let time = new Date().getTime();
console.log("data is"+ JSON.stringify(data));
data = 'data/storage/el2/base/haps/entry';
let JpgPath = data + "/files/"+time + ".jpg";
let srcFd =await fileio.open(JpgPath,0o102,0o0600);
await fileio.write(srcFd,"hello world");
await fileio.close(srcFd);
let option = {
src : JpgPath,
mimeType : "123",
relativePath : "Pictures/"
};
mediaLibrary.getMediaLibrary(globalThis.abilityContext).storeMediaAsset(option).then((value) => {
console.log(TAG + "image resources stored. "+ JSON.stringify(value));
}).catch((err) => {
AlertDialog.show(
{
title: '保存失败',
message: '媒体MIME类型错误',
confirm: {
value: 'OK',
action: () => {
console.info(TAG + 'Button-clicking callback')
}
},
cancel: () => {
console.info(TAG + 'Closed callbacks')
}
}
)
console.log(TAG + "An error occurred when storing image resources."+ JSON.stringify(err));
});
})
}
}.width('100%').height('80%').backgroundColor(Color.White)
}
build() {
Column() {
CustomContainer({
title: this.name,
Url:'pages/MediaLibrary/MediaLibrary_index',
StepTips:this.StepTips,
content: this.specificNoParam,
FillColor:$FillColor,
name:$name
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
\ No newline at end of file
import prompt from '@ohos.prompt';
import router from '@ohos.router';
import fileio from '@ohos.fileio';
import xml from '@ohos.xml';
import fileIO from '@ohos.fileio';
import util from '@ohos.util';
import data_preferences from '@ohos.data.preferences';
const TAG = 'ParseXML';
let path = globalThis.dir;
let path1 = path + '/Player';
let VarColor = [];
let ColorBackPath = path + '/PlayerColorBack.txt';
let txtPath = path1 + 'PlayerReport.txt';
let xmlPath =path1 + 'PlayerTest.xml';
@Entry
@Component
struct IndexPage {
@State ClearAll : boolean = false;
private current : number = undefined;
@State count : number = 0;
@State result : string = '';
@State TEST : number = 0;
private TestCaseList = [
{title:'ScrollingList',uri:'pages/Player/ScrollListTest'},
]
@State ColorObject : string[] = VarColor;
async onPageShow(){
let Test = null;
let context =null;
context = globalThis.getContext();
let preferences;
let promise = data_preferences.getPreferences(context,'mystore');
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('Player', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'Player'. Data: " + data);
});
if(Test != 1) {
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString();
fileio.writeSync(fd,log);
}
fileio.closeSync(fd);
}
promise = preferences.put('Player', 1);
promise.then(() => {
console.info("Succeeded in putting value of 'Player'.");
});
promise = preferences.flush();
promise.then(() => {
console.info("Succeeded in flushing.");
});
this.TEST = Test;
let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664);
let buff = new ArrayBuffer(40960);
fileio.readSync(opt,buff);
let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff));
let TestList = ColorBack.split(';');
for (let i = 0; i < Math.floor(TestList.length / 2); i++) {
VarColor[i] = TestList[i*2+1];
}
fileio.closeSync(opt);
if (this.count === 1){
this.result = router.getParams()['result'];
let titles = router.getParams()['title'];
let name1 = '刚刚点进了哪个用例:'+ titles;
let results = this.result;
let WriteTitle = (titles).toString();
let number = WriteTitle.length + 11;
let Index = ColorBack.indexOf(WriteTitle);
if (this.result === 'Pass'){
this.ColorObject[this.current] = '#ff008000';
let Log = (titles+';'+'#ff008000'+';');
let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD,buffer);
let Report = ColorBack.substring(0,rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd,Report);
filewrite(name1,results,titles)
}
else if (this.result === 'Fail'){
this.ColorObject[this.current] = '#ffff0000';
let Log = (titles+';'+'#ffff0000'+';');
let key = ColorBack.substring(Index,Index+number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD,buffer);
let Report = ColorBack.substring(0,rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd,Report);
filewrite(name1,results,titles);
}
else if (this.result === 'None'){
this.ColorObject[this.current] = this.ColorObject[this.current];
}
}
}
build(){
Column(){
Row() {
Button() {
Image($r('app.media.ic_public_back')).width('20vp').height('18vp')
}.backgroundColor(Color.Black)
.onClick(() => {
router.back();
})
Row(){
Text('Player SubSystem')
.fontColor(Color.White)
.fontSize('22fp')
}.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black)
Row() {
Button(){
Image($r('app.media.ic_public_delete'))
.width('30vp')
.height('30vp')
}.backgroundColor(Color.Black)
.onClick(() => {
AlertDialog.show(
{
message: "是否删除所有记录",
primaryButton: {
value: 'Yes',
action: () => {
this.ClearAll = true;
this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080';
});
this.ClearText();
prompt.showToast({
message: '结果已删除', duration: 1000
});
}
},
secondaryButton: {
value: 'No',
action: () => {
}
},
cancel: () => {
}
}
)
})
Button(){
Image($r('app.media.ic_public_save'))
.width('30vp')
.height('30vp')
.margin({ left: 30 })
}.backgroundColor(Color.Black)
.onClick(() => {
this.ReadTextParseXml();
AlertDialog.show({
message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/Player/PlayerTest.xml -本地路径'",
confirm:{
value:'OK',
action:()=>{
prompt.showToast({
message: '报告已生成', duration: 1000
})
}
},
cancel: () => {
prompt.showToast({
message: '报告已生成', duration: 1000
});
}
})
})
}
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black)
List({space:5}){
ForEach(this.TestCaseList,(item,index) => {
ListItem(){
Row(){
Text(item.title).fontSize(16).fontColor(Color.Black)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index])
.onClick(( )=>{
this.count = 1;
this.ClearAll=false;
this.current = index;
router.push({
url: item.uri,
})
})
}
},item => item.title)
}.width('100%').height('92%')
}.width('100%').height('100%').backgroundColor(Color.Black)
}
ClearText(){
fileio.rmdirSync(path1);
fileio.mkdirSync(path1);
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString();
fileio.writeSync(fd,log);
}
}
ReadTextParseXml(){
let ReportPath = path1 + '/PlayerReport.txt';
let dir = fileio.opendirSync(path1);
console.info("ssssss"+dir);
while (dir) {
let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664);
let buf = new ArrayBuffer(40960);
let RD = fileio.readSync(OP,buf);
console.info("ddddd"+RD);
let report;
function ab2str(buf) {
return report = String.fromCharCode.apply(null,new Uint8Array(buf));
}
ab2str(buf);
let str1 = report.split(";");
let title = [];
let result = [];
for(let i=0; i<Math.floor(str1.length/2); i++){
title[i] = str1[i*2];
result[i] = str1[i*2+1];
}
let FailIndex = report.indexOf('Fail');
let FailNum = 0;
while (FailIndex != -1) {
console.log(FailIndex);
FailNum++;
FailIndex = report.indexOf('Fail',FailIndex + 1);
}
let failNum = (FailNum).toString();
let PassIndex = report.indexOf('Pass');
let PassNum = 0;
while (PassIndex != -1) {
console.log(PassIndex);
PassNum++;
PassIndex = report.indexOf('Pass',PassIndex + 1);
}
let TestNum = FailNum + PassNum;
let testNum = (TestNum).toString();
let ignoreNum = (24-TestNum).toString();
let arrayBuffer = new ArrayBuffer(40960);
let bufView = new DataView(arrayBuffer);
let serializer = new xml.XmlSerializer(bufView);
serializer.setDeclaration();
serializer.startElement("testsuite");
serializer.setAttributes("name","ActsPlayerTest");
serializer.setAttributes("time", " ");
serializer.setAttributes("errors", "0");
serializer.setAttributes("disabled", "0");
serializer.setAttributes("failures", failNum);
serializer.setAttributes("ignored", ignoreNum);
serializer.setAttributes("tests", testNum);
serializer.setAttributes("message", " ");
serializer.setAttributes("modulename", "ActsPlayerTest");
for (let i = 0; i < title.length; i++) {
serializer.startElement("testcase");
serializer.setAttributes("name", String(title[i]));
serializer.setAttributes("status", " ");
serializer.setAttributes("time", " ");
serializer.setAttributes("classname", " ");
serializer.setAttributes("result", String(result[i]));
serializer.setAttributes("level", " ");
serializer.setAttributes("message", " ");
serializer.endElement();
}
serializer.endElement();
let that = new util.TextDecoder('utf-8');
let array = new Uint8Array(arrayBuffer);
let serializerStr = that.decode(array);
console.info(xmlPath);
try{
console.error(TAG,"write xmlPath =" +xmlPath);
var xmlfd = fileIO.openSync(xmlPath, 0o102, 0o666);
fileIO.writeSync(xmlfd,serializerStr);
}catch(err){
console.error(TAG,"read xmlPath =" + xmlPath + "error:" + err);
}finally{
fileIO.closeSync(xmlfd);
}
return;
}
}
}
function filewrite(name1,results,titles){
let fd = fileio.openSync(txtPath, 0o100 | 0o2002, 0o664);
let buf = new ArrayBuffer(4096);
let RD = fileio.readSync(fd,buf);
console.info("RRRRRRRRRRd"+RD);
let report = String.fromCharCode.apply(null,new Uint8Array(buf));
let WriteTitle = (titles).toString();
let number = WriteTitle.length + 6;
let Index = report.indexOf(WriteTitle);
let Log = (titles+";"+results+";").toString();
if (Index == -1){
fileio.writeSync(fd,Log);
}
else if (Index != -1){
let key = report.substring(Index,Index+number);
let FD = fileio.openSync(txtPath, 0o102, 0o666);
report = report.replace(key,Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD,buffer);
let Report = report.substring(0,rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(txtPath, 0o102, 0o666);
fileio.writeSync(Fd,Report);
}
}
\ No newline at end of file
import {CustomContainer} from '../common/CustomContainer';
import FirstDialog from '../model/FirstDialog';
@Entry
@Component
struct CustomContainerUser {
private listArr: number[] = Array.from(new Array(50).keys());
@State name: string = 'ScrollingList';
@State StepTips: string = '操作步骤:滑动列表观察是否能正常滑动'+'\n'+'预期结果:列表滑动正常';
@State Vue: boolean = false;
async aboutToAppear(){
await FirstDialog.ChooseDialog(this.StepTips,this.name);
this.Vue = true;
}
@Builder specificNoParam() {
Column() {
List() {
ForEach(this.listArr,(item:any,index:number) => {
ListItem() {
Text('Item #' + (index + 1)).width('100%').height(50).fontSize(16).fontColor(Color.White).margin({left:'10vp'})
}
},index => index)
}.height('100%').width('100%').divider({strokeWidth:1,color:Color.Grey})
}.height('83%').width('100%')
}
build() {
Column() {
CustomContainer({
title: this.name,
Url: 'pages/Player/Player_index',
StepTips: this.StepTips,
content: this.specificNoParam.bind(this),
name: $name,
Vue: $Vue,
})
}.width('100%').height('100%').backgroundColor(Color.Black)
}
}
......@@ -25,34 +25,39 @@ import FlushData from '../pages/model/FlushData'
const TAG = 'ParseXML';
let path=globalThis.dir;
let path1 = path + '/ArkUI';
let path2 = path + '/MediaLibrary';
let path2 = path + '/Audio';
let path3 = path + '/Camera';
let path4 = path + '/Audio';
let path4 = path + '/Player';
let path5 = path + '/Experience';
let ArkUIColorBackPath = path + '/ArkUIColorBack.txt';
let MediaColorBackPath = path + '/MediaColorBack.txt';
let CameraColorBackPath = path + '/CameraColorBack.txt';
let AudioColorBackPath = path + '/AudioColorBack.txt';
let CameraColorBackPath = path + '/CameraColorBack.txt';
let PlayerColorBackPath = path + '/PlayerColorBack.txt';
let ExperienceColorBackPath = path + '/ExperienceColorBack.txt';
fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(MediaColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(ExperienceColorBackPath, 0o100 | 0o2002, 0o664);
let TimePath = path + '/Time.txt';
fileio.openSync(TimePath, 0o100 | 0o2002, 0o664);
let xmlPath = path + '/Test.xml';
fileio.openSync(xmlPath, 0o100 | 0o2002, 0o664);
let path11 = path1 + '/ArkUIReport.txt';
let path22 = path2 + '/MediaReport.txt';
let path22 = path2 + '/AudioReport.txt';
let path33 = path3 + '/CameraReport.txt';
let path44 = path4 + '/AudioReport.txt';
let path44 = path4 + '/PlayerReport.txt';
let path55 = path5 + '/ExperienceReport.txt';
@Entry
@Component
struct IndexPage {
private TestCaseList = [
{title:'ArkUI',uri:'pages/ArkUI/ArkUI_index'},
{title:'MediaLibrary',uri:'pages/MediaLibrary/MediaLibrary_index'},
{title:'Camera',uri:'pages/CameraOrientation/Camera_Orientation_index'},
{title:'Audio',uri:'pages/Audio/Audio_index'},
{title:'Camera',uri:'pages/Camera/Camera_index'},
{title:'Player',uri:'pages/Player/Player_index'},
{title:'Experience',uri:'pages/Experience/Experience_index'},
]
@State ColorObject : string[] = ['#ff808080','#ff808080','#ff808080','#ff808080','#ff808080']
async onPageShow(){
......@@ -75,6 +80,7 @@ struct IndexPage {
fileio.mkdirSync(path2);
fileio.mkdirSync(path3);
fileio.mkdirSync(path4);
fileio.mkdirSync(path5);
let promise = preferences.put('index', 1);
promise.then(() => {
......@@ -89,11 +95,12 @@ struct IndexPage {
fileio.openSync(path22, 0o100 | 0o2002, 0o664);
fileio.openSync(path33, 0o100 | 0o2002, 0o664);
fileio.openSync(path44, 0o100 | 0o2002, 0o664);
fileio.openSync(path55, 0o100 | 0o2002, 0o664);
}
build(){
Column(){
Row() {
Text('ActValidator')
Text('ActsValidator')
.fontColor(Color.White)
.fontSize('22fp')
Row() {
......@@ -185,23 +192,29 @@ struct IndexPage {
fileio.unlinkSync(path22);
fileio.unlinkSync(path33);
fileio.unlinkSync(path44);
fileio.unlinkSync(path55);
fileio.unlinkSync(ArkUIColorBackPath);
fileio.unlinkSync(MediaColorBackPath);
fileio.unlinkSync(AudioColorBackPath);
fileio.unlinkSync(CameraColorBackPath);
fileio.unlinkSync(PlayerColorBackPath);
fileio.unlinkSync(ExperienceColorBackPath);
fileio.openSync(TimePath, 0o100 | 0o2002, 0o664);
fileio.openSync(xmlPath, 0o100 | 0o2002, 0o664);
fileio.openSync(path11, 0o100 | 0o2002, 0o664);
fileio.openSync(path22, 0o100 | 0o2002, 0o664);
fileio.openSync(path33, 0o100 | 0o2002, 0o664);
fileio.openSync(path44, 0o100 | 0o2002, 0o664);
fileio.openSync(path55, 0o100 | 0o2002, 0o664);
fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(MediaColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(ExperienceColorBackPath, 0o100 | 0o2002, 0o664);
FlushData.ResetArkUI();
FlushData.ResetMedia();
FlushData.ResetCamera();
FlushData.ResetAudio();
FlushData.ResetCamera();
FlushData.ResetPlayer();
FlushData.ResetExperience();
}
SaveXml() {
let dateTimeUtil = new DateTimeUtil();
......@@ -212,17 +225,18 @@ struct IndexPage {
let StartTime = String.fromCharCode.apply(null, new Uint8Array(buf));
let Index = StartTime.indexOf(';');
let starttime = StartTime.substring(0,Index);
let ArkUIReport;
let AudioReport;
let CameraReport;
let PlayerReport;
let ExperienceReport;
/*
* ArkUI
*/
let OP1 = fileio.openSync(path11, 0o100 | 0o2002, 0o664);
let buf1 = new ArrayBuffer(40960);
fileio.readSync(OP1,buf1);
let ArkUIReport;
let MediaLibraryReport;
function ab2str1(buf1) {
return ArkUIReport = String.fromCharCode.apply(null, new Uint8Array(buf1));
}
ab2str1(buf1);
ArkUIReport = String.fromCharCode.apply(null, new Uint8Array(buf1));
let str1 = ArkUIReport.split(";");
let title1 = [];
let result1 = [];
......@@ -230,23 +244,64 @@ struct IndexPage {
title1[i] = str1[i * 2];
result1[i] = str1[i * 2 + 1];
}
/*
* Audio
*/
let OP2 = fileio.openSync(path22, 0o100 | 0o2002, 0o664);
let buf2 = new ArrayBuffer(40960);
fileio.readSync(OP2,buf2);
function ab2str2(buf2) {
return MediaLibraryReport = String.fromCharCode.apply(null, new Uint8Array(buf2));
}
ab2str2(buf2);
let str2 = MediaLibraryReport.split(";");
AudioReport = String.fromCharCode.apply(null, new Uint8Array(buf2));
let str2 = AudioReport.split(";");
let title2 = [];
let result2 = [];
for (let i = 0; i < Math.floor(str2.length / 2); i++) {
title2[i] = str2[i * 2];
result2[i] = str2[i * 2 + 1];
}
/*
* Camera
*/
let OP3 = fileio.openSync(path33, 0o100 | 0o2002, 0o664);
let buf3 = new ArrayBuffer(40960);
fileio.readSync(OP3,buf3);
CameraReport = String.fromCharCode.apply(null, new Uint8Array(buf3));
let str3 = CameraReport.split(";");
let title3 = [];
let result3 = [];
for (let i = 0; i < Math.floor(str3.length / 2); i++) {
title3[i] = str3[i * 2];
result3[i] = str3[i * 2 + 1];
}
/*
* Player
*/
let OP4 = fileio.openSync(path44, 0o100 | 0o2002, 0o664);
let buf4 = new ArrayBuffer(40960);
fileio.readSync(OP4,buf4);
PlayerReport = String.fromCharCode.apply(null, new Uint8Array(buf4));
let str4 = PlayerReport.split(";");
let title4 = [];
let result4 = [];
for (let i = 0; i < Math.floor(str4.length / 2); i++) {
title4[i] = str4[i * 2];
result4[i] = str4[i * 2 + 1];
}
/*
* Experience
*/
let OP5 = fileio.openSync(path55, 0o100 | 0o2002, 0o664);
let buf5 = new ArrayBuffer(40960);
fileio.readSync(OP5,buf5);
ExperienceReport = String.fromCharCode.apply(null, new Uint8Array(buf5));
let str5 = ExperienceReport.split(";");
let title5 = [];
let result5 = [];
for (let i = 0; i < Math.floor(str5.length / 2); i++) {
title5[i] = str5[i * 2];
result5[i] = str5[i * 2 + 1];
}
let report = ArkUIReport + MediaLibraryReport;
let report = ArkUIReport + AudioReport + CameraReport + PlayerReport + ExperienceReport;
let FailIndex = report.indexOf('Fail');
let FailNum = 0;
while(FailIndex != -1) {
......@@ -264,8 +319,10 @@ struct IndexPage {
}
let TestNum = FailNum + PassNum;
let testNum = (TestNum).toString();
let ignoreNum = (52-TestNum).toString();
let ignoreNum = (54-TestNum).toString();
/*
* ArkUI
*/
let ArkUIFailIndex = ArkUIReport.indexOf('Fail');
let ArkUIFailNum = 0;
while (ArkUIFailIndex != -1) {
......@@ -283,26 +340,91 @@ struct IndexPage {
}
let ArkUITestNum = ArkUIFailNum + ArkUIPassNum;
let ArkuiTestNum = (ArkUIPassNum).toString();
let ArkUIIgnoreNum = (24-ArkUITestNum).toString();
let MediaLibraryFailIndex = MediaLibraryReport.indexOf('Fail');
let MediaLibraryFailNum = 0;
while (MediaLibraryFailIndex != -1) {
console.log(MediaLibraryFailIndex);
MediaLibraryFailNum++;
MediaLibraryFailIndex = MediaLibraryReport.indexOf('Fail',MediaLibraryFailIndex + 1);
let ArkUIIgnoreNum = (23-ArkUITestNum).toString();
/*
* Audio
*/
let AudioFailIndex = AudioReport.indexOf('Fail');
let AudioFailNum = 0;
while (AudioFailIndex != -1) {
console.log(AudioFailIndex);
AudioFailNum++;
AudioFailIndex = AudioReport.indexOf('Fail',AudioFailIndex + 1);
}
let audioFailNum = (AudioFailNum).toString();
let AudioPassIndex = AudioReport.indexOf('Pass');
let AudioPassNum = 0;
while (AudioPassIndex != -1) {
console.log(AudioPassIndex);
AudioPassNum++;
AudioPassIndex = AudioReport.indexOf('Pass',AudioPassIndex + 1);
}
let AudioTestNum = AudioFailNum + AudioPassNum;
let audioTestNum = (AudioPassNum).toString();
let AudioIgnoreNum = (28-AudioTestNum).toString();
/*
* Camera
*/
let CameraFailIndex = CameraReport.indexOf('Fail');
let CameraFailNum = 0;
while (CameraFailIndex != -1) {
console.log(CameraFailIndex);
CameraFailNum++;
CameraFailIndex = CameraReport.indexOf('Fail',CameraFailIndex + 1);
}
let cameraFailNum = (CameraFailNum).toString();
let CameraPassIndex = CameraReport.indexOf('Pass');
let CameraPassNum = 0;
while (CameraPassIndex != -1) {
console.log(CameraPassIndex);
CameraPassNum++;
CameraPassIndex = CameraReport.indexOf('Pass',CameraPassIndex + 1);
}
let CameraTestNum = CameraFailNum + CameraPassNum;
let cameraTestNum = (CameraPassNum).toString();
let CameraIgnoreNum = (28-CameraTestNum).toString();
/*
* Player
*/
let PlayerFailIndex = PlayerReport.indexOf('Fail');
let PlayerFailNum = 0;
while (PlayerFailIndex != -1) {
console.log(PlayerFailIndex);
PlayerFailNum++;
PlayerFailIndex = PlayerReport.indexOf('Fail',PlayerFailIndex + 1);
}
let playerFailNum = (PlayerFailNum).toString();
let PlayerPassIndex = PlayerReport.indexOf('Pass');
let PlayerPassNum = 0;
while (PlayerPassIndex != -1) {
console.log(PlayerPassIndex);
PlayerPassNum++;
PlayerPassIndex = PlayerReport.indexOf('Pass',PlayerPassIndex + 1);
}
let PlayerTestNum = PlayerFailNum + PlayerPassNum;
let playerTestNum = (PlayerPassNum).toString();
let PlayerIgnoreNum = (28-PlayerTestNum).toString();
/*
* Experience
*/
let ExperienceFailIndex = ExperienceReport.indexOf('Fail');
let ExperienceFailNum = 0;
while (ExperienceFailIndex != -1) {
console.log(ExperienceFailIndex);
ExperienceFailNum++;
ExperienceFailIndex = ExperienceReport.indexOf('Fail',ExperienceFailIndex + 1);
}
let medialibraryFailNum = (MediaLibraryFailNum).toString();
let MediaLibraryPassIndex = MediaLibraryReport.indexOf('Pass');
let MediaLibraryPassNum = 0;
while (MediaLibraryPassIndex != -1) {
console.log(MediaLibraryPassIndex);
MediaLibraryPassNum++;
MediaLibraryPassIndex = MediaLibraryReport.indexOf('Pass',MediaLibraryPassIndex + 1);
let experienceFailNum = (ExperienceFailNum).toString();
let ExperiencePassIndex = ExperienceReport.indexOf('Pass');
let ExperiencePassNum = 0;
while (ExperiencePassIndex != -1) {
console.log(ExperiencePassIndex);
ExperiencePassNum++;
ExperiencePassIndex = ExperienceReport.indexOf('Pass',ExperiencePassIndex + 1);
}
let MediaLibraryTestNum = MediaLibraryFailNum + MediaLibraryPassNum;
let medialibraryTestNum = (MediaLibraryPassNum).toString();
let MediaLibraryIgnoreNum = (28-MediaLibraryTestNum).toString();
let ExperienceTestNum = ExperienceFailNum + ExperiencePassNum;
let experienceTestNum = (ExperiencePassNum).toString();
let ExperienceIgnoreNum = (28-ExperienceTestNum).toString();
let arrayBuffer = new ArrayBuffer(40960);
let bufView = new DataView(arrayBuffer);
......@@ -321,6 +443,9 @@ struct IndexPage {
serializer.setAttributes("productinfo", "{ }");
serializer.setAttributes("modules", " ");
serializer.setAttributes("runmodules", " ");
/*
* ArkUI
*/
serializer.startElement("testsuite");
serializer.setAttributes("name", "ActsArkUITest");
serializer.setAttributes("time", " ");
......@@ -343,17 +468,19 @@ struct IndexPage {
serializer.endElement();
}
serializer.endElement();
/*
* Audio
*/
serializer.startElement("testsuite");
serializer.setAttributes("name", "ActsMediaLibraryTest");
serializer.setAttributes("name", "ActsAudioTest");
serializer.setAttributes("time", " ");
serializer.setAttributes("errors", "0");
serializer.setAttributes("disabled", "0");
serializer.setAttributes("failures", medialibraryFailNum);
serializer.setAttributes("ignored", MediaLibraryIgnoreNum);
serializer.setAttributes("tests", medialibraryTestNum);
serializer.setAttributes("failures", audioFailNum);
serializer.setAttributes("ignored", AudioIgnoreNum);
serializer.setAttributes("tests", audioTestNum);
serializer.setAttributes("message", " ");
serializer.setAttributes("modulename", "ActsMediaLibraryTest");
serializer.setAttributes("modulename", "ActsAudioTest");
for (let i = 0; i < title2.length; i++) {
serializer.startElement("testcase");
serializer.setAttributes("name", String(title2[i]));
......@@ -366,6 +493,81 @@ struct IndexPage {
serializer.endElement();
}
serializer.endElement();
/*
* Camera
*/
serializer.startElement("testsuite");
serializer.setAttributes("name", "ActsCameraTest");
serializer.setAttributes("time", " ");
serializer.setAttributes("errors", "0");
serializer.setAttributes("disabled", "0");
serializer.setAttributes("failures", cameraFailNum);
serializer.setAttributes("ignored", CameraIgnoreNum);
serializer.setAttributes("tests", cameraTestNum);
serializer.setAttributes("message", " ");
serializer.setAttributes("modulename", "ActsCameraTest");
for (let i = 0; i < title2.length; i++) {
serializer.startElement("testcase");
serializer.setAttributes("name", String(title3[i]));
serializer.setAttributes("status", " ");
serializer.setAttributes("time", " ");
serializer.setAttributes("classname", " ");
serializer.setAttributes("result", String(result3[i]));
serializer.setAttributes("level", " ");
serializer.setAttributes("message", " ");
serializer.endElement();
}
serializer.endElement();
/*
* Player
*/
serializer.startElement("testsuite");
serializer.setAttributes("name", "ActsPlayerTest");
serializer.setAttributes("time", " ");
serializer.setAttributes("errors", "0");
serializer.setAttributes("disabled", "0");
serializer.setAttributes("failures", playerFailNum);
serializer.setAttributes("ignored", PlayerIgnoreNum);
serializer.setAttributes("tests", playerTestNum);
serializer.setAttributes("message", " ");
serializer.setAttributes("modulename", "ActsPlayerTest");
for (let i = 0; i < title2.length; i++) {
serializer.startElement("testcase");
serializer.setAttributes("name", String(title4[i]));
serializer.setAttributes("status", " ");
serializer.setAttributes("time", " ");
serializer.setAttributes("classname", " ");
serializer.setAttributes("result", String(result4[i]));
serializer.setAttributes("level", " ");
serializer.setAttributes("message", " ");
serializer.endElement();
}
serializer.endElement();
/*
* Experience
*/
serializer.startElement("testsuite");
serializer.setAttributes("name", "ActsExperienceTest");
serializer.setAttributes("time", " ");
serializer.setAttributes("errors", "0");
serializer.setAttributes("disabled", "0");
serializer.setAttributes("failures", experienceFailNum);
serializer.setAttributes("ignored", ExperienceIgnoreNum);
serializer.setAttributes("tests", experienceTestNum);
serializer.setAttributes("message", " ");
serializer.setAttributes("modulename", "ActsExperienceTest");
for (let i = 0; i < title2.length; i++) {
serializer.startElement("testcase");
serializer.setAttributes("name", String(title5[i]));
serializer.setAttributes("status", " ");
serializer.setAttributes("time", " ");
serializer.setAttributes("classname", " ");
serializer.setAttributes("result", String(result5[i]));
serializer.setAttributes("level", " ");
serializer.setAttributes("message", " ");
serializer.endElement();
}
serializer.endElement();
serializer.endElement();
let that = new util.TextDecoder('utf-8');
......
......@@ -40,7 +40,7 @@ export default class FlushData{
console.info("Succeeded in flushing.");
});
}
static ResetMedia = async ()=>{
static ResetAudio = async ()=>{
let Test = null;
let context =null;
context = globalThis.getContext();
......@@ -50,14 +50,14 @@ export default class FlushData{
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('Media', 0);
promise = preferences.get('Audio', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'startup'. Data: " + data);
console.info("Succeeded in getting value of 'Audio'. Data: " + data);
});
promise = preferences.put('Media', 0);
promise = preferences.put('Audio', 0);
promise.then(() => {
console.info("Succeeded in putting value of 'test'.");
console.info("Succeeded in putting value of 'Audio'.");
});
promise = preferences.flush();
promise.then(() => {
......@@ -88,7 +88,7 @@ export default class FlushData{
console.info("Succeeded in flushing.");
});
}
static ResetAudio = async ()=>{
static ResetPlayer = async ()=>{
let Test = null;
let context =null;
context = globalThis.getContext();
......@@ -98,14 +98,38 @@ export default class FlushData{
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('Camera', 0);
promise = preferences.get('Player', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'startup'. Data: " + data);
console.info("Succeeded in getting value of 'Player'. Data: " + data);
});
promise = preferences.put('Camera', 0);
promise = preferences.put('Player', 0);
promise.then(() => {
console.info("Succeeded in putting value of 'test'.");
console.info("Succeeded in putting value of 'Player'.");
});
promise = preferences.flush();
promise.then(() => {
console.info("Succeeded in flushing.");
});
}
static ResetExperience = async ()=>{
let Test = null;
let context =null;
context = globalThis.getContext();
let preferences;
let promise = data_preferences.getPreferences(context,'mystore');
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('Experience', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'Experience'. Data: " + data);
});
promise = preferences.put('Experience', 0);
promise.then(() => {
console.info("Succeeded in putting value of 'Experience'.");
});
promise = preferences.flush();
promise.then(() => {
......
......@@ -23,47 +23,21 @@
"pages/ArkUI/CanvasShadowBlur",
"pages/ArkUI/CanvasShadowColor",
"pages/ArkUI/CanvasShadowOffsetX",
"pages/ArkUI/CanvasImageSmoothingEnabled",
"pages/ArkUI/CanvasGlobalAlpha",
"pages/ArkUI/CanvasLineDashOffset",
"pages/ArkUI/CanvasShadowOffsetY",
"pages/MediaLibrary/MediaLibrary_index",
"pages/MediaLibrary/startImagePreviewCallback1",
"pages/MediaLibrary/startImagePreviewCallback2",
"pages/MediaLibrary/startImagePreviewCallback3",
"pages/MediaLibrary/startImagePreviewCallback4",
"pages/MediaLibrary/startImagePreviewCallback5",
"pages/MediaLibrary/startImagePreviewCallback6",
"pages/MediaLibrary/startImagePreviewCallback7",
"pages/MediaLibrary/startImagePreviewPromise1",
"pages/MediaLibrary/startImagePreviewPromise2",
"pages/MediaLibrary/startImagePreviewPromise3",
"pages/MediaLibrary/startImagePreviewPromise4",
"pages/MediaLibrary/startMediaSelectCallback1",
"pages/MediaLibrary/startMediaSelectCallback2",
"pages/MediaLibrary/startMediaSelectCallback3",
"pages/MediaLibrary/startMediaSelectCallback4",
"pages/MediaLibrary/startMediaSelectPromise1",
"pages/MediaLibrary/startMediaSelectPromise2",
"pages/MediaLibrary/startMediaSelectPromise3",
"pages/MediaLibrary/startMediaSelectPromise4",
"pages/MediaLibrary/storeMediaAssetCallback1",
"pages/MediaLibrary/storeMediaAssetCallback2",
"pages/MediaLibrary/storeMediaAssetCallback3",
"pages/MediaLibrary/storeMediaAssetCallback4",
"pages/MediaLibrary/storeMediaAssetPromise1",
"pages/MediaLibrary/storeMediaAssetPromise2",
"pages/MediaLibrary/storeMediaAssetPromise3",
"pages/MediaLibrary/storeMediaAssetPromise4",
"pages/MediaLibrary/storeMediaAssetPromise5",
"pages/CameraOrientation/Camera_Orientation_index",
"pages/CameraOrientation/CameraOrientation0",
"pages/CameraOrientation/CameraOrientation90",
"pages/CameraOrientation/CameraOrientation180",
"pages/CameraOrientation/CameraOrientation270",
"pages/CameraOrientation/CameraFormat",
"pages/CameraOrientation/CameraVideo",
"pages/Camera/Camera_index",
"pages/Camera/CameraOrientation0",
"pages/Camera/CameraOrientation90",
"pages/Camera/CameraOrientation180",
"pages/Camera/CameraOrientation270",
"pages/Camera/CameraFormat",
"pages/Camera/CameraVideo",
"pages/Audio/Audio_index",
"pages/Audio/ScrollListTest"
"pages/Audio/ScrollListTest",
"pages/Player/Player_index",
"pages/Player/ScrollListTest",
"pages/Experience/Experience_index",
"pages/Experience/ScrollListTest"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册