未验证 提交 29995ca9 编写于 作者: O openharmony_ci 提交者: Gitee

!9895 modified Jsunit add ets

Merge pull request !9895 from liuzixuan/cherry-pick-1693043145
/**
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct ActionSheetExample {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button('Click to Show ActionSheet')
.onClick(() => {
ActionSheet.show({
title: 'ActionSheet title',
subtitle: 'ActionSheet subtitle',
message: 'message',
alignment: DialogAlignment.TopStart,
offset: { dx: 10, dy: 100 },
maskRect: { x: 0, y: 90, width: 1000, height: 250 },
confirm: {
value: 'Confirm button',
action: () => {
console.log('Get Alert Dialog handled')
}
},
sheets: [
{
title: 'apples',
action: () => {
console.log('apples')
}
},
{
title: 'bananas',
action: () => {
console.log('bananas')
}
},
{
title: 'pears',
action: () => {
console.log('pears')
}
}
]
}).key('ActionSheet')
})
}.width('100%')
.height('100%')
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct AlertDialogExample {
build() {
Column({ space: 5 }) {
Button('one button dialog')
.onClick(() => {
AlertDialog.show(
{
title: 'title',
subtitle: 'subtitle',
message: 'text',
alignment: DialogAlignment.TopStart,
offset: { dx: 10, dy: 100 },
maskRect: { x: 0, y: 90, width: 1000, height: 250 },
buttonDirection:DialogButtonDirection.AUTO,
confirm: {
value: 'button',
action: () => {
console.info('Button-clicking callback')
}
},
cancel: () => {
console.info('Closed callbacks')
}
}
).key('AlertDialog')
})
.backgroundColor(0x317aff)
Button('two button dialog')
.onClick(() => {
AlertDialog.show(
{
title: 'title',
subtitle: 'subtitle',
message: 'text',
primaryButton: {
value: 'cancel',
action: () => {
console.info('Callback when the first button is clicked')
}
},
secondaryButton: {
value: 'ok',
action: () => {
console.info('Callback when the second button is clicked')
}
},
cancel: () => {
console.info('Closed callbacks')
}
}
)
}).backgroundColor(0x317aff)
}.width('100%').margin({ top: 5 })
}
}
\ No newline at end of file
......@@ -90,9 +90,10 @@ struct CustomDialogUser {
}
}),
cancel: this.existApp,
autoCancel: true,
alignment: DialogAlignment.Default,
offset: { dx: 0, dy: -20 },
alignment: DialogAlignment.Top,
offset: { dx: 10, dy: 100 },
maskRect: { x: 0, y: 100, width: '100%', height: '80%' },
cornerRadius: "5vp",
gridCount: 4,
customStyle: false
})
......@@ -117,7 +118,7 @@ struct CustomDialogUser {
build() {
Column() {
Button(this.inputValue)
Button(this.inputValue).key('CustomDialog')
.onClick(() => {
if (this.dialogController != undefined) {
this.dialogController.open()
......
......@@ -16,6 +16,8 @@
@Entry
@Component
struct DatePickerDialogOptions0 {
@State isLunar: boolean = false
selectedDate: Date = new Date("2023-7-24")
build() {
Column() {
......@@ -23,11 +25,26 @@ struct DatePickerDialogOptions0 {
.margin(20)
.onClick(() => {
DatePickerDialog.show({
alignment: DialogAlignment.TopStart,
offset: { dx: 10, dy: 100 },
maskRect: { x: 0, y: 90, width: 1000, height: 250 },
start: new Date("2000-1-1"),
end: new Date("2100-12-31"),
selected: new Date("2023-7-24"),
lunarSwitch: true
}).id("DatePickerDialogOptions0")
selected: this.selectedDate,
lunar: this.isLunar,
showTime:true,
useMilitaryTime:false,
onDateAccept: (value: Date)=> {
this.selectedDate = value
console.info("DatePickerDialog:onDateAccept()" + value.toString())
},
onCancel:()=> {
console.info("DatePickerDialog: onCancel()")
},
onDateChange: (value: Date)=> {
console.info("DatePickerDialog: onChange()" + value.toString())
}
}).key('DatePickerDialog')
})
}.width('100%')
}
......
/**
* 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.
*/
@Entry
@Component
struct PanelExample {
@State show: boolean = false;
private des: Dimension;
build() {
Column() {
Text('2021-09-30 Today Calendar: 1.afternoon......Click for details')
.width('90%').height(50).borderRadius(10)
.backgroundColor(0xFFFFFF).padding({ left: 20 })
.onClick(() => {
this.show = !this.show
})
Panel(this.show) { // Display the agenda
Column() {
Text('Today Calendar')
Divider()
Text('1. afternoon 4:00 The project meeting')
}
}
.key('PanelText')
.type(PanelType.CUSTOM)
.customHeight(PanelHeight.WRAP_CONTENT)
.dragBar(true) // The drag bar is enabled by default
.onChange((width: number, height: number, mode: PanelMode) => {
console.info(`width:${width},height:${height},mode:${mode}`)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 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 promptAction from '@ohos.promptAction'
@Entry
@Component
struct PromptActionOptions {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button('PromptActionDialog')
.key('ShowDialog')
.onClick(() => {
promptAction.showDialog({
title: 'Title Info',
message: 'Message Info',
alignment: DialogAlignment.TopStart,
offset: { dx: 10, dy: 100 },
maskRect: { x: 0, y: 100, width: '100%', height: '80%' },
buttons: [
{
text: 'button1',
color: '#000000'
},
{
text: 'button2',
color: '#000000'
}
]
})
.then(data=>{
console.info('showDialog success,click button:'+ data.index);
}).catch(error=>{
console.info('showDialog error:'+ error);
})
})
}.width('100%')
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct TextPickerDialogExample {
private select: number | number[] = 2
private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5']
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button('TextPickerDialog')
.margin(20)
.onClick(() => {
TextPickerDialog.show({
range: this.fruits,
selected: this.select,
alignment: DialogAlignment.TopStart,
offset: { dx: 10, dy: 100 },
maskRect: { x: 0, y: 90, width: 1000, height: 250 },
onAccept: (value: TextPickerResult)=> {
this.select = value.index
console.info("TextPickerDialog: onAccept()" + JSON.stringify(value))
},
onCancel:()=> {
console.info("TextPickerDialog: onCancel()")
},
onChange: (value: TextPickerResult)=> {
console.info("TextPickerDialog: onChange()" + JSON.stringify(value))
}
}).key('TextPickerDialog')
})
}.width('100%')
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct TimePickerDialogExample {
private selectTime: Date = new Date('2020-12-25T08:30:00')
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button('TimePickerDialog')
.margin(20)
.onClick(() => {
TimePickerDialog.show({
selected: this.selectTime,
alignment: DialogAlignment.TopStart,
offset: { dx: 10, dy: 100 },
maskRect: { x: 0, y: 90, width: 1000, height: 250 },
onAccept: (value: TimePickerResult)=> {
this.selectTime.setHours(value.hour, value.minute)
console.info("TimePickerDialog: onAccept()" + JSON.stringify(value))
},
onCancel:()=> {
console.info("TimePickerDialog: onCancel()")
},
onChange: (value: TimePickerResult)=> {
console.info("TimePickerDialog: onChange()" + JSON.stringify(value))
}
}).key('TimePickerDialog')
})
}.width('100%')
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 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 events_emitter from '@ohos.events.emitter'
@Entry
@Component
struct OverlayExample {
@State title: string = 'old title'
@State x: number = 0
@State y: number = -15
@State alignment: Alignment = Alignment.Bottom
onPageShow() {
console.info('[overlay] page show called ');
let stateChangeEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
let stateChangeEvent2 = {
eventId: 1110,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent2, this.stateChangCallBack);
}
private stateChangCallBack = (eventData) => {
console.info("[stateChangCallBack] stateChangCallBack ");
if (eventData != null) {
console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData));
if (eventData.data.align != null) {
this.alignment = eventData.data.align
}
if (eventData.data.title != null) {
this.title = eventData.data.title
}
if (eventData.data.x != null) {
this.x = eventData.data.x
}
if (eventData.data.y != null) {
this.y = eventData.data.y
}
}
}
build() {
Column() {
Column() {
Text('floating layer')
.fontSize(12).fontColor(0xCCCCCC).maxLines(1)
Column() {
Image('/images/img.jpeg')
.width(340).height(240)
.key('overlay')
.overlay(this.title,
{ align: this.alignment, offset: { x: this.x, y: this.y } })
}.border({ color: Color.Black, width: 2 })
}.width('100%')
}.padding({ top: 20 })
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function ActionSheetJsunit() {
describe('ActionSheetJsunit', function () {
beforeEach(async function (done) {
console.info("ActionSheetJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/ActionSheetOptions',
}
try {
router.clear();
let pages = router.getState();
console.info("get ActionSheetJsunit state pages: " + JSON.stringify(pages));
if (!("ActionSheetOptions" == pages.name)) {
console.info("get ActionSheetJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push ActionSheetJsunit success " + JSON.stringify(result));
}
} catch (err) {
console.error("push ActionSheetJsunit page error: " + err);
expect().assertFail();
}
done()
});
it('ActionSheetJsunit_0100', 0, async function (done) {
console.info('ActionSheetJsunit_0100 START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('ActionSheet');
let obj = JSON.parse(strJson);
console.info("[ActionSheetJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[ActionSheetJsunit_0100] subtitle:" + JSON.stringify(obj.$attrs.subtitle));
console.info("[ActionSheetJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment));
console.info("[ActionSheetJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset));
console.info("[ActionSheetJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
expect(obj.$attrs.maskRect.x).assertEqual('0.00vp');
expect(obj.$attrs.maskRect.y).assertEqual('90.00vp');
expect(obj.$attrs.maskRect.width).assertEqual('80%');
expect(obj.$attrs.maskRect.height).assertEqual('60%');
expect(obj.$attrs.subtitle).assertEqual("ActionSheet subtitle");
console.info('[ActionSheetJsunit_0100] END');
done();
});
})
}
/**
* Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function AlertDialogJsunit() {
describe('AlertDialogJsunit', function () {
beforeEach(async function (done) {
console.info("AlertDialogJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/AlertDialogParam',
}
try {
router.clear();
let pages = router.getState();
console.info("get AlertDialogJsunit state pages: " + JSON.stringify(pages));
if (!("AlertDialogParam" == pages.name)) {
console.info("get AlertDialogJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push AlertDialogJsunit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push AlertDialogJsunit page error: " + err);
expect().assertFail();
}
done()
});
it('AlertDialogJsunit_0100', 0, async function (done) {
console.info('AlertDialogJsunit_0100 START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('AlertDialog');
let obj = JSON.parse(strJson);
console.info("[AlertDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[AlertDialogJsunit_0100] subtitle:" + JSON.stringify(obj.$attrs.subtitle));
console.info("[AlertDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment));
console.info("[AlertDialogJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset));
console.info("[AlertDialogJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
expect(obj.$attrs.subtitle).assertEqual("subtitle");
console.info('[AlertDialogJsunit_0100] END');
done();
});
it('AlertDialogJsunit_0200', 0, async function (done) {
console.info('AlertDialogJsunit_0200 START');
await CommonFunc.sleep(1000);
let driver = await UiDriver.create();
let btn = await driver.findComponent(BY.key('AlertDialog'));
await btn.click();
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('AlertDialog');
let obj = JSON.parse(strJson);
console.info("[AlertDialogJsunit_0200] component strJson:" + JSON.stringify(obj.$attrs.buttonDirection));
expect(obj.$attrs.buttonDirection).assertEqual("DialogButtonDirection.AUTO");
console.info('[AlertDialogJsunit_0200] END');
done();
});
it('AlertDialogJsunit_0300', 0, async function (done) {
console.info('AlertDialogJsunit_0300 START');
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'buttonDirection',value:'DialogButtonDirection.HORIZONTAL'})
let driver = await UiDriver.create();
let btn = await driver.findComponent(BY.key('AlertDialog'));
await btn.click();
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('AlertDialog');
let obj = JSON.parse(strJson);
console.info("[AlertDialogJsunit_0300] component strJson:" + JSON.stringify(obj.$attrs.buttonDirection));
expect(obj.$attrs.buttonDirection).assertEqual("DialogButtonDirection.HORIZONTAL ");
console.info('[AlertDialogJsunit_0300] END');
done();
});
it('AlertDialogJsunit_0400', 0, async function (done) {
console.info('AlertDialogJsunit_0400 START');
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'buttonDirection',value:'DialogButtonDirection.VERTICAL'})
let driver = await UiDriver.create();
let btn = await driver.findComponent(BY.key('AlertDialog'));
await btn.click();
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('AlertDialog');
let obj = JSON.parse(strJson);
console.info("[AlertDialogJsunit_0400] component strJson:" + JSON.stringify(obj.$attrs.buttonDirection));
expect(obj.$attrs.buttonDirection).assertEqual("DialogButtonDirection.VERTICAL");
console.info('[AlertDialogJsunit_0400] END');
done();
});
})
}
/**
* Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function CustomDialogJsunit() {
describe('CustomDialogJsunit', function () {
beforeEach(async function (done) {
console.info("CustomDialogJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/CustomDialogControllerOptions',
}
try {
router.clear();
let pages = router.getState();
console.info("get CustomDialogJsunit state pages: " + JSON.stringify(pages));
if (!("CustomDialogControllerOptions" == pages.name)) {
console.info("get CustomDialogJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push CustomDialogJsunit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push CustomDialogJsunit page error: " + err);
expect().assertFail();
}
done()
});
it('CustomDialogJsunit_0100', 0, async function (done) {
console.info('CustomDialogJsunit_0100 START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('CustomDialog');
let obj = JSON.parse(strJson);
console.info("[CustomDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[CustomDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment));
console.info("[CustomDialogJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset));
console.info("[CustomDialogJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
console.info("[CustomDialogJsunit_0100] cornerRadius:" + JSON.stringify(obj.$attrs.cornerRadius));
expect(obj.$attrs.cornerRadius).assertEqual("5vp");
console.info('[CustomDialogJsunit_0100] END');
done();
});
})
}
/**
* Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function DatePickerDialogJsunit() {
describe('DatePickerDialogJsunit', function () {
beforeEach(async function (done) {
console.info("DatePickerDialogJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/DatePickerDialogOptions',
}
try {
router.clear();
let pages = router.getState();
console.info("get DatePickerDialogJsunit state pages: " + JSON.stringify(pages));
if (!("DatePickerDialogOptions" == pages.name)) {
console.info("get DatePickerDialogJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push DatePickerDialogJsunit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push DatePickerDialogJsunit page error: " + err);
expect().assertFail();
}
done()
});
it('DatePickerDialogJsunit_0100', 0, async function (done) {
console.info('DatePickerDialogJsunit_0100 START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('DatePickerDialog');
let obj = JSON.parse(strJson);
console.info("[DatePickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[DatePickerDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment));
console.info("[DatePickerDialogJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset));
console.info("[DatePickerDialogJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
console.info("[DatePickerDialogJsunit_0100] selected:" + JSON.stringify(obj.$attrs.selected));
console.info("[DatePickerDialogJsunit_0100] showTime:" + JSON.stringify(obj.$attrs.showTime));
expect(obj.$attrs.selected).assertEqual("2023-7-24");
expect(obj.$attrs.showTime).assertEqual(true);
console.info('[DatePickerDialogJsunit_0100] END');
done();
});
})
}
......@@ -61,6 +61,15 @@ import fontJsunit from './fontJsunit.test.ets';
import PanGestureEventJsunit from './PanGestureEventJsunit.test.ets';
import RenderFitJsunit from './RenderFitJsunit.test.ets';
import DialogJsunit from './DialogJsunit.test.ets';
import ActionSheetJsunit from './ActionSheetJsunit.test.ets';
import AlertDialogJsunit from './AlertDialogJsunit.test.ets';
import CustomDialogJsunit from './CustomDialogJsunit.test.ets';
import DatePickerDialogJsunit from './DatePickerDialogJsunit.test.ets';
import ShowDialogJsunit from './ShowDialogJsunit.test.ets';
import TextPickerDialogJsunit from './TextPickerDialogJsunit.test.ets';
import TimePickerDialogJsunit from './TimePickerDialogJsunit.test.ets';
import OverlayJsunit from './OverlayJsunit.test.ets';
import PanelJsunit from './PanelJsunit.test.ets';
export default function testsuite() {
DialogJsunit();
......@@ -111,4 +120,13 @@ export default function testsuite() {
ApiCommponentAddJsunit();
PanGestureEventJsunit();
RenderFitJsunit();
ActionSheetJsunit();
AlertDialogJsunit();
CustomDialogJsunit();
DatePickerDialogJsunit();
ShowDialogJsunit();
TextPickerDialogJsunit();
TimePickerDialogJsunit();
OverlayJsunit();
PanelJsunit();
}
\ No newline at end of file
/**
* Copyright (c) 2023 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
import events_emitter from '@ohos.events.emitter'
export default function overLayJsunit() {
describe('overLayJsunit', function () {
beforeEach(async function (done) {
console.info("overLayJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/overlay',
}
try {
router.clear();
let pages = router.getState();
console.info("get overLayJsunit state pages: " + JSON.stringify(pages));
if (!("overlay" == pages.name)) {
console.info("get overLayJsunit state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push overLayJsunit page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push overLayJsunit page error:" + err);
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("overlay after each called");
});
it('overLayJsunit_0100', 0, async function (done) {
console.info('[overLayJsunit_0100] START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0100] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.title).assertEqual("old title");
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Bottom");
expect(obj.$attrs.overlay.options.offset.x).assertEqual('0.00vp');
expect(obj.$attrs.overlay.options.offset.y).assertEqual('-15.00vp');
console.info('[overLayJsunit_0100] END');
done();
});
it('overLayJsunit_0200', 0, async function (done) {
console.info('[overLayJsunit_0200] START');
try {
var eventData = {
data: {
"title": "new title"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0200] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0200] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0200] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.title).assertEqual("new title");
console.info('overLayJsunit_0200 END');
done();
});
it('overLayJsunit_0300', 0, async function (done) {
console.info('[overLayJsunit_0300] START');
try {
var eventData = {
data: {
"align": "Alignment.TopStart",
"x": 30,
"y": -30
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0300] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0300] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0300] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
expect(obj.$attrs.overlay.options.offset.x).assertEqual('30.00vp');
expect(obj.$attrs.overlay.options.offset.y).assertEqual('-30.00vp');
console.info('overLayJsunit_0300 END');
done();
});
it('overLayJsunit_0400', 0, async function (done) {
console.info('[overLayJsunit_0400] START');
await CommonFunc.sleep(1000);
try {
var eventData = {
data: {
"align": "Alignment.Center"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0400] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0400] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0400] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('overLayJsunit_0400 END');
done();
});
it('overLayJsunit_0500', 0, async function (done) {
console.info('[overLayJsunit_0500] START');
try {
var eventData = {
data: {
"align":'-1'
}
}
var innerEvent = {
eventId: 1110,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0500] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0500] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0500] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Center");
console.info('overLayJsunit_0500 END');
done();
});
it('overLayJsunit_0600', 0, async function (done) {
console.info('[overLayJsunit_0600] START');
try {
var eventData = {
data: {
"x": -30,
"y": 30
}
}
var innerEvent = {
eventId: 1110,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0600] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0600] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0600] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.offset.x).assertEqual('-30.00vp');
expect(obj.$attrs.overlay.options.offset.y).assertEqual('30.00vp');
console.info('overLayJsunit_0600 END');
done();
});
it('overLayJsunit_0700', 0, async function (done) {
console.info('[overLayJsunit_0700] START');
try {
var eventData = {
data: {
"x": 1111111111
}
}
var innerEvent = {
eventId: 1110,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0700] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0700] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0700] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.offset.x).assertEqual('1111111111.00vp');
console.info('overLayJsunit_0700 END');
done();
});
it('overLayJsunit_0800', 0, async function (done) {
console.info('[overLayJsunit_0800] START');
try {
var eventData = {
data: {
"y": 1111111111
}
}
var innerEvent = {
eventId: 1110,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0800] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0800] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0800] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.offset.x).assertEqual('1111111111.00vp');
console.info('overLayJsunit_0800 END');
done();
});
it('overLayJsunit_0900', 0, async function (done) {
console.info('[overLayJsunit_0900] START');
await CommonFunc.sleep(1000);
try {
var eventData = {
data: {
"align": "Alignment.Top"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_0900] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_0900] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0900] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Top");
console.info('overLayJsunit_0900 END');
done();
});
it('overLayJsunit_1000', 0, async function (done) {
console.info('[overLayJsunit_1000] START');
await CommonFunc.sleep(1000);
try {
var eventData = {
data: {
"align": "Alignment.TopEnd"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_1000] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_1000] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1000] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopEnd");
console.info('overLayJsunit_1000 END');
done();
});
it('overLayJsunit_1100', 0, async function (done) {
console.info('[overLayJsunit_1100] START');
await CommonFunc.sleep(1000);
try {
var eventData = {
data: {
"align": "Alignment.Start"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_1100] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_1100] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1100] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Start");
console.info('overLayJsunit_1100 END');
done();
});
it('overLayJsunit_1200', 0, async function (done) {
console.info('[overLayJsunit_1200] START');
await CommonFunc.sleep(1000);
try {
var eventData = {
data: {
"align": "Alignment.End"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_1200] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_1200] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1200] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.End");
console.info('overLayJsunit_1200 END');
done();
});
it('overLayJsunit_1300', 0, async function (done) {
console.info('[overLayJsunit_1300] START');
await CommonFunc.sleep(1000);
try {
var eventData = {
data: {
"align": "Alignment.BottomEnd"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_1300] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_1300] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1300] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.BottomEnd");
console.info('overLayJsunit_1300 END');
done();
});
it('overLayJsunit_1400', 0, async function (done) {
console.info('[overLayJsunit_1400] START');
await CommonFunc.sleep(1000);
try {
var eventData = {
data: {
"align": "Alignment.BottomStart"
}
}
var innerEvent = {
eventId: 143,
priority: events_emitter.EventPriority.LOW
}
console.info("[overLayJsunit_1400] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[overLayJsunit_1400] change component data error: " + err.message);
}
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1400] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.BottomStart");
console.info('overLayJsunit_1400 END');
done();
});
})
}
/**
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function PanelJsunit() {
describe('PanelJsunit', function () {
beforeEach(async function (done) {
console.info("Panel beforeEach start");
let options = {
uri: 'MainAbility/pages/Panel',
}
try {
router.clear();
let pages = router.getState();
console.info("get Panel state pages: " + JSON.stringify(pages));
if (!("Panel" == pages.name)) {
console.info("get Panel state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Panel page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Panel page error:" + err);
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Panel after each called");
});
it('PanelJsunit_0100', 0, async function (done) {
console.info('[PanelJsunit_0100] START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('PanelText');
let obj = JSON.parse(strJson);
console.info("[PanelJsunit_0100] obj is: " + JSON.stringify(obj.$attrs.customHeight));
expect(obj.$attrs.customHeight).assertEqual("PanelHeight.WRAP_CONTENT");
console.info('[PanelJsunit_0100] END');
done();
});
})
}
/**
* Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function ShowDialogJsunit() {
describe('ShowDialogJsunit', function () {
beforeEach(async function (done) {
console.info("ShowDialogJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/ShowDialogOptions',
}
try {
router.clear();
let pages = router.getState();
console.info("get ShowDialogJsunit state pages: " + JSON.stringify(pages));
if (!("ShowDialogOptions" == pages.name)) {
console.info("get ShowDialogJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push ShowDialogJsunit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push ShowDialogJsunit page error: " + err);
expect().assertFail();
}
done()
});
it('ShowDialogJsunit_0100', 0, async function (done) {
console.info('ShowDialogJsunit_0100 START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('ShowDialog');
let obj = JSON.parse(strJson);
console.info("[ShowDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[ShowDialogJsunit_0100] title:" + JSON.stringify(obj.$attrs.title));
console.info("[ShowDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment));
console.info("[ShowDialogJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset));
console.info("[ShowDialogJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
expect(obj.$attrs.title).assertEqual("Title Info");
console.info('[ShowDialogJsunit_0100] END');
done();
});
})
}
/**
* Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function TextPickerDialogJsunit() {
describe('TextPickerDialogJsunit', function () {
beforeEach(async function (done) {
console.info("TextPickerDialogJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/TextPickerDialogOptions',
}
try {
router.clear();
let pages = router.getState();
console.info("get TextPickerDialogJsunit state pages: " + JSON.stringify(pages));
if (!("TextPickerDialogOptions" == pages.name)) {
console.info("get TextPickerDialogJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push TextPickerDialogJsunit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push TextPickerDialogJsunit page error: " + err);
expect().assertFail();
}
done()
});
it('TextPickerDialogJsunit_0100', 0, async function (done) {
console.info('TextPickerDialogJsunit_0100 START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('TextPickerDialog');
let obj = JSON.parse(strJson);
console.info("[TextPickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[TextPickerDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment));
console.info("[TextPickerDialogJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset));
console.info("[TextPickerDialogJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
expect(obj.$attrs.alignment).assertEqual("DialogAlignment.TopStart");
console.info('[TextPickerDialogJsunit_0100] END');
done();
});
})
}
/**
* Copyright (c) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function TimePickerDialogJsunit() {
describe('TimePickerDialogJsunit', function () {
beforeEach(async function (done) {
console.info("TimePickerDialogJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/TimePickerDialogOptions',
}
try {
router.clear();
let pages = router.getState();
console.info("get TimePickerDialogJsunit state pages: " + JSON.stringify(pages));
if (!("TimePickerDialogOptions" == pages.name)) {
console.info("get TimePickerDialogJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push TimePickerDialogJsunit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push TimePickerDialogJsunit page error: " + err);
expect().assertFail();
}
done()
});
it('TimePickerDialogJsunit_0100', 0, async function (done) {
console.info('TimePickerDialogJsunit_0100 START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('TimePickerDialog');
let obj = JSON.parse(strJson);
console.info("[TimePickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[TimePickerDialogJsunit_0100] selected:" + JSON.stringify(obj.$attrs.selected));
console.info("[TimePickerDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment));
console.info("[TimePickerDialogJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset));
console.info("[TimePickerDialogJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
expect(obj.$attrs.selected).assertEqual("2020-12-25T08:30:00");
console.info('[TimePickerDialogJsunit_0100] END');
done();
});
})
}
......@@ -94,6 +94,13 @@
"MainAbility/pages/DragController",
"MainAbility/pages/richEditor",
"MainAbility/pages/richEditorCustomKeyBoard",
"MainAbility/pages/DialogPage"
"MainAbility/pages/DialogPage",
"MainAbility/pages/ActionSheetOptions",
"MainAbility/pages/AlertDialogParam",
"MainAbility/pages/ShowDialogOptions",
"MainAbility/pages/TextPickerDialogOptions",
"MainAbility/pages/TimePickerDialogOptions",
"MainAbility/pages/overlay",
"MainAbility/pages/Panel"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册