提交 7d0973dd 编写于 作者: W wangguan 提交者: 李鲲辉

fixed 7bc3d111 from https://gitee.com/kunge-hub/xts_acts/pulls/9875

弹窗扩展多个按钮属性XTS用例
Signed-off-by: Nwangguan <wangguan27@huawei.com>
上级 70b0b1b4
/**
* 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 {MessageManager,Callback} from '../utils/MessageManager';
@Entry
@Component
struct DialogPage {
@State title: string = 'title'
@State message: string = "This is the message of alertdialog"
@State autoCancel: boolean = true
@State buttonName: string = 'ButtonHORIZONTAL'
@State buttonName1: string = 'ButtonVERTICAL'
@State buttonName2: string = 'ButtonAuto'
messageManager: MessageManager = new MessageManager()
onPageShow() {
console.info('DialogPage onPageShow')
globalThis.value = {
name: 'messageManager', message: this.messageManager
}
let callback: Callback = (message: any) => {
console.error('message = ' + message.name + "--" + message.value)
if (message.name == 'autoCancel') {
this.autoCancel = message.value
}
}
this.messageManager.registerCallback(callback)
}
build() {
Column({ space: 40 }) {
Button(this.buttonName)
.key('button')
.onClick(() => {
this.buttonName = 'threeButtonHor:succ'
this.showThreeButtonHORIZONTAL()
}).backgroundColor(0x317aff)
Button(this.buttonName1)
.key('button1')
.onClick(() => {
this.buttonName1 = 'threeButtonVer:succ'
this.showThreeButtonVERTICAL()
}).backgroundColor(0x317aff)
Button(this.buttonName2)
.key('button2')
.onClick(() => {
this.buttonName2 = 'threeButtonAuto:succ'
this.showThreeButtonAUTO()
}).backgroundColor(0x317aff)
}.width("100%").margin({ top: 150 })
}
private showThreeButtonHORIZONTAL() {
AlertDialog.show(
{
title: this.title,
message: this.message,
autoCancel: this.autoCancel,
buttonDirection:DialogButtonDirection.HORIZONTAL,
buttons: [
{
value: this.buttonName,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
{
value: this.buttonName1,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName1 = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
{
value: this.buttonName2,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName2 = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
],
cancel: () => {
console.info('Closed callbacks')
}
}
)
}
private showThreeButtonVERTICAL() {
AlertDialog.show(
{
title: this.title,
message: this.message,
autoCancel: this.autoCancel,
buttonDirection:DialogButtonDirection.VERTICAL,
buttons: [
{
value: this.buttonName,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
{
value: this.buttonName1,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName1 = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
{
value: this.buttonName2,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName2 = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
],
cancel: () => {
console.info('Closed callbacks')
}
}
)
}
private showThreeButtonAUTO() {
AlertDialog.show(
{
title: this.title,
message: this.message,
autoCancel: this.autoCancel,
buttonDirection:DialogButtonDirection.AUTO,
buttons: [
{
value: this.buttonName,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
{
value: this.buttonName1,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName1 = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
{
value: this.buttonName2,
fontColor: 0xffffff,
backgroundColor: 0x317aff,
action: () => {
this.buttonName2 = "OneButton3:succ"
console.info("Button AlertDialog Button-Clicking callback")
}
},
],
cancel: () => {
console.info('Closed callbacks')
}
}
)
}
}
\ 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 DialogJsunit() {
describe('DialogJsunit', function () {
beforeEach(async function (done) {
console.info("DialogJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/DialogPage',
}
try {
router.clear();
let pages = router.getState();
console.info("get DialogJsunit state pages: " + JSON.stringify(pages));
if (!("DialogPage" == pages.name)) {
console.info("get DialogJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push DialogJsunit success: " + JSON.stringify(result));
}
} catch (err) {
console.error("push DialogJsunit page error: " + err);
expect().assertFail();
}
done();
});
it('DialogJsunit_0100', 0, async function (done) {
console.info('[DialogJsunit_0100] START');
await CommonFunc.sleep(1000);
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('button'));
await button.click();
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('button');
let obj = JSON.parse(strJson);
console.info('[DialogJsunit_0100] button component obj is: ' + obj.$attrs.label);
expect(obj.$attrs.label).assertEqual('threeButtonHor:succ');
await driver.pressBack();
await CommonFunc.sleep(500);
let button1 = await driver.findComponent(BY.key('button1'));
await button1.click();
await CommonFunc.sleep(1000);
let strJson1 = getInspectorByKey('button1');
let obj1 = JSON.parse(strJson1);
console.info('[DialogJsunit_0100] button1 component obj is: ' + obj1.$attrs.label);
expect(obj1.$attrs.label).assertEqual('threeButtonVer:succ');
await driver.pressBack();
await CommonFunc.sleep(500);
let button2 = await driver.findComponent(BY.key('button2'));
await button2.click();
await CommonFunc.sleep(1000);
let strJson2 = getInspectorByKey('button2');
let obj2 = JSON.parse(strJson2);
console.info('[DialogJsunit_0100] button2 component obj is: ' + obj2.$attrs.label);
expect(obj2.$attrs.label).assertEqual('threeButtonAuto:succ');
await driver.pressBack();
await CommonFunc.sleep(500);
console.info('[DialogJsunit_0100] END');
done();
});
})
}
\ No newline at end of file
......@@ -60,8 +60,10 @@ import ApiCommponentAddJsunit from './ApiCommponentAddJsunit.test.ets';
import fontJsunit from './fontJsunit.test.ets';
import PanGestureEventJsunit from './PanGestureEventJsunit.test.ets';
import RenderFitJsunit from './RenderFitJsunit.test.ets';
import DialogJsunit from './DialogJsunit.test.ets';
export default function testsuite() {
DialogJsunit();
blankJsunit();
buttonJsunit();
checkBoxGroupUIJsunit();
......
......@@ -93,6 +93,7 @@
"MainAbility/pages/navition3",
"MainAbility/pages/DragController",
"MainAbility/pages/richEditor",
"MainAbility/pages/richEditorCustomKeyBoard"
"MainAbility/pages/richEditorCustomKeyBoard",
"MainAbility/pages/DialogPage"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册