提交 7eddc4d2 编写于 作者: W wang-xupeng2

update Ui testcases

Signed-off-by: Nwang-xupeng2 <wangxupeng2@huawei.com>
上级 817001f1
...@@ -50,7 +50,7 @@ struct CheckboxExample { ...@@ -50,7 +50,7 @@ struct CheckboxExample {
} else { } else {
this.selectedColor = "#000000" this.selectedColor = "#000000"
} }
}).key("check1").id('chek1') }).key('chek1')
Checkbox({name: 'checkbox2', group: 'checkboxGroup'}) Checkbox({name: 'checkbox2', group: 'checkboxGroup'})
.select(false) .select(false)
.selectedColor(0x39a2db) .selectedColor(0x39a2db)
......
...@@ -44,7 +44,7 @@ struct ImageAnimatorExample { ...@@ -44,7 +44,7 @@ struct ImageAnimatorExample {
} }
let callback:Callback = (message:any) => { let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value) console.error('message = ' + message.name + "--" + message.value)
if (message.name == 'type') { if (message.name == 'state') {
this.state = message.value this.state = message.value
} }
if (message.name == 'reverse') { if (message.name == 'reverse') {
...@@ -99,7 +99,7 @@ struct ImageAnimatorExample { ...@@ -99,7 +99,7 @@ struct ImageAnimatorExample {
.margin({ top: 100 }) .margin({ top: 100 })
.key('imageAnimator') .key('imageAnimator')
.onStart(() => { .onStart(() => {
console.info('Start') console.info('Start123456')
this.message1 = 'start' this.message1 = 'start'
}) })
.onPause(() => { .onPause(() => {
......
...@@ -61,10 +61,10 @@ export default function TextPickerJsunit() { ...@@ -61,10 +61,10 @@ export default function TextPickerJsunit() {
// Get the content of Initial value // Get the content of Initial value
let driver = await UiDriver.create() let driver = await UiDriver.create()
let change = await driver.findComponent(BY.key('text')); let strJson1 = getInspectorByKey('text');
let textChange = await change.getText(); let obj1 = JSON.parse(strJson1);
console.info("[TextPickerJsunit_0100] textChange: " + JSON.stringify(textChange)); console.info("[TextPickerJsunit_0100] obj1: " + JSON.stringify(obj1));
expect(textChange).assertEqual('value: 0'); expect(obj1.$attrs.content).assertEqual('value: 0');
console.info('[TextPickerJsunit_0100] END'); console.info('[TextPickerJsunit_0100] END');
done(); done();
}); });
...@@ -110,10 +110,10 @@ export default function TextPickerJsunit() { ...@@ -110,10 +110,10 @@ export default function TextPickerJsunit() {
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let driver = await UiDriver.create() let driver = await UiDriver.create()
await driver.swipe(Math.round(right / 2), Math.round(bottom * 2 / 3), Math.round(right / 2), Math.round(bottom / 3)); await driver.swipe(Math.round(right / 2), Math.round(bottom * 2 / 3), Math.round(right / 2), Math.round(bottom / 3));
let change = await driver.findComponent(BY.key('text')); let strJson = getInspectorByKey('text');
let textChange = await change.getText(); let obj = JSON.parse(strJson);
console.info("[TextPickerJsunit_0300] textChange: " + JSON.stringify(textChange)); console.info("[TextPickerJsunit_0300] obj: " + JSON.stringify(obj));
expect(textChange == 'value: 0').assertFalse(); expect(obj.$attrs.content == 'value: 0').assertFalse();
done(); done();
}); });
......
...@@ -76,19 +76,21 @@ export default function imageAniamtorJsunit() { ...@@ -76,19 +76,21 @@ export default function imageAniamtorJsunit() {
let strJson = getInspectorByKey('imageAnimator'); let strJson = getInspectorByKey('imageAnimator');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info('[imageAniamtorJsunit_0200] component obj is: ' + obj.$attrs.state); console.info('[imageAniamtorJsunit_0200] component obj is: ' + obj.$attrs.state);
//expect(obj.$attrs.state).assertEqual('AnimationStatus.Running'); expect(obj.$attrs.state).assertEqual('AnimationStatus.Running');
globalThis.value.message.notify({name:'state',value:AnimationStatus.Paused}) globalThis.value.message.notify({name:'state',value:AnimationStatus.Paused})
await CommonFunc.sleep(5000); await CommonFunc.sleep(1000);
let strJson2 = getInspectorByKey('imageAnimator'); let strJson2 = getInspectorByKey('imageAnimator');
let obj2 = JSON.parse(strJson2); let obj2 = JSON.parse(strJson2);
console.info('[imageAniamtorJsunit_0200] component obj2 is: ' + obj2.$attrs.state); console.info('[imageAniamtorJsunit_0200] component obj2 is: ' + obj2.$attrs.state);
//expect(obj2.$attrs.state).assertEqual('AnimationStatus.Paused'); expect(obj2.$attrs.state).assertEqual('AnimationStatus.Paused');
globalThis.value.message.notify({name:'state',value:AnimationStatus.Stopped}) globalThis.value.message.notify({name:'state',value:AnimationStatus.Stopped})
await CommonFunc.sleep(5000); await CommonFunc.sleep(1000);
let strJson3 = getInspectorByKey('imageAnimator'); let strJson3 = getInspectorByKey('imageAnimator');
let obj3 = JSON.parse(strJson3); let obj3 = JSON.parse(strJson3);
console.info('[imageAniamtorJsunit_0200] component obj3 is: ' + obj3.$attrs.state); console.info('[imageAniamtorJsunit_0200] component obj3 is: ' + obj3.$attrs.state);
//expect(obj3.$attrs.state).assertEqual('AnimationStatus.Stopped'); expect(obj3.$attrs.state).assertEqual('AnimationStatus.Stopped');
console.info('[imageAniamtorJsunit_0200] END'); console.info('[imageAniamtorJsunit_0200] END');
done(); done();
}); });
...@@ -178,13 +180,15 @@ export default function imageAniamtorJsunit() { ...@@ -178,13 +180,15 @@ export default function imageAniamtorJsunit() {
expect(btn != null).assertTrue(); expect(btn != null).assertTrue();
await btn.click(); await btn.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let textComponent = await driver.findComponent(BY.key('t1')); let strJson = getInspectorByKey('t1');
let text = await textComponent.getText(); let obj = JSON.parse(strJson);
expect(text).assertEqual('start'); console.info("[imageAniamtorJsunit_0700] obj: " + JSON.stringify(obj));
expect(obj.$attrs.content).assertEqual('start');
await CommonFunc.sleep(3000); await CommonFunc.sleep(3000);
let textComponent1 = await driver.findComponent(BY.key('t5')); let strJson1 = getInspectorByKey('t5');
let text1 = await textComponent1.getText(); let obj1 = JSON.parse(strJson1);
expect(text1).assertEqual('onFinish'); console.info("[imageAniamtorJsunit_0700] obj1: " + JSON.stringify(obj1));
expect(obj1.$attrs.content).assertEqual('onFinish');
console.info('imageAniamtorJsunit_0700 END'); console.info('imageAniamtorJsunit_0700 END');
done(); done();
}); });
...@@ -201,7 +205,7 @@ export default function imageAniamtorJsunit() { ...@@ -201,7 +205,7 @@ export default function imageAniamtorJsunit() {
let btn2 = await driver.findComponent(ON.id('start')); let btn2 = await driver.findComponent(ON.id('start'));
expect(btn2 != null).assertTrue(); expect(btn2 != null).assertTrue();
await btn2.click(); await btn2.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('t3'); let strJson = getInspectorByKey('t3');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info('imageAnimatorJsunit_0800 component obj is: '+ obj.$attrs.content); console.info('imageAnimatorJsunit_0800 component obj is: '+ obj.$attrs.content);
......
...@@ -182,9 +182,34 @@ export default function sliderJsunit() { ...@@ -182,9 +182,34 @@ export default function sliderJsunit() {
expect(obj.$attrs.constructor.value).assertEqual('30.000000'); expect(obj.$attrs.constructor.value).assertEqual('30.000000');
done(); done();
}); });
it('sliderJsunit_0800', 0, async function (done) { it('sliderJsunit_0800', 0, async function (done) {
// Verify the swipe function of slider component
console.info('sliderJsunit_0800 START'); console.info('sliderJsunit_0800 START');
await CommonFunc.sleep(1000);
let sliderT = CommonFunc.getComponentRect('sliderConstructor');
let top = sliderT.top
let bottom = sliderT.bottom
let left = sliderT.left
let right = sliderT.right
let x = Math.round(left + (right - left) / 2)
let driver = await Driver.create();
await driver.delayMs(waitUiReadyMs);
await driver.swipe(x, Math.round(bottom - 20), x, Math.round(top + 50));
await driver.delayMs(waitUiReadyMs);
let strJson = getInspectorByKey('tex');
let obj = JSON.parse(strJson);
console.info("[sliderJsunit_0800] obj: " + JSON.stringify(obj));
expect(obj.$attrs.content).assertEqual('30');
let strJson1 = getInspectorByKey('modeT');
let obj1 = JSON.parse(strJson1);
console.info("[sliderJsunit_0800] obj1: " + JSON.stringify(obj1));
expect(obj1.$attrs.content).assertEqual('mode');
done();
});
it('sliderJsunit_0900', 0, async function (done) {
console.info('[sliderJsunit_0800] START');
// modify the constructor attribute of slider dynamically // modify the constructor attribute of slider dynamically
globalThis.value.message.notify({name:'vInSetValueOne',value:-30}) globalThis.value.message.notify({name:'vInSetValueOne',value:-30})
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
...@@ -203,7 +228,7 @@ export default function sliderJsunit() { ...@@ -203,7 +228,7 @@ export default function sliderJsunit() {
// check the value of changed parameter // check the value of changed parameter
let strJson = getInspectorByKey('sliderConstructor'); let strJson = getInspectorByKey('sliderConstructor');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info('sliderJsunit_0200 component obj is: ' + obj.$attrs.style + "---" + obj.$attrs.constructor.direction + "--" + obj.$attrs.constructor.value console.info('[sliderJsunit_0900] component obj is: ' + obj.$attrs.style + "---" + obj.$attrs.constructor.direction + "--" + obj.$attrs.constructor.value
+ "---" + obj.$attrs.constructor.reverse + "----" + obj.$attrs.constructor.min + "----" + obj.$attrs.constructor.max + "---" + obj.$attrs.constructor.step); + "---" + obj.$attrs.constructor.reverse + "----" + obj.$attrs.constructor.min + "----" + obj.$attrs.constructor.max + "---" + obj.$attrs.constructor.step);
expect(obj.$attrs.style).assertEqual('SliderStyle.OutSet'); expect(obj.$attrs.style).assertEqual('SliderStyle.OutSet');
expect(obj.$attrs.constructor.direction).assertEqual('Axis.Horizontal'); expect(obj.$attrs.constructor.direction).assertEqual('Axis.Horizontal');
...@@ -212,33 +237,7 @@ export default function sliderJsunit() { ...@@ -212,33 +237,7 @@ export default function sliderJsunit() {
expect(obj.$attrs.constructor.min).assertEqual('-20.000000'); expect(obj.$attrs.constructor.min).assertEqual('-20.000000');
expect(obj.$attrs.constructor.max).assertEqual('1000.000000'); expect(obj.$attrs.constructor.max).assertEqual('1000.000000');
expect(obj.$attrs.constructor.step).assertEqual('1.000000'); expect(obj.$attrs.constructor.step).assertEqual('1.000000');
done(); console.info('[sliderJsunit_0900] END');
});
it('sliderJsunit_0900', 0, async function (done) {
// Verify the swipe function of slider component
console.info('sliderJsunit_0900 START');
await CommonFunc.sleep(1000);
let sliderT = CommonFunc.getComponentRect('sliderConstructor2');
let top = sliderT.top
let sliderB = CommonFunc.getComponentRect('sliderConstructor2');
let bottom = sliderB.bottom
let sliderL = CommonFunc.getComponentRect('sliderConstructor2');
let left = sliderL.left
let sliderR = CommonFunc.getComponentRect('sliderConstructor2');
let right = sliderR.right
let driver = await Driver.create();
await driver.delayMs(waitUiReadyMs);
await driver.swipe(Math.round((right - left) / 2), Math.round(bottom - 10), Math.round((right - left) / 2), Math.round(top + 10));
await driver.delayMs(waitUiReadyMs);
let textIn = await driver.findComponent(ON.id('tex'));
let txt = await textIn.getText();
console.info('sliderJsunit_0900 component textIn obj is: ' + txt);
expect(txt).assertEqual('20');
let modeT = await driver.findComponent(ON.id('modeT'));
let txtt = await modeT.getText();
console.info('sliderJsunit_0900 modeT component obj is: ' + txtt);
expect(txtt).assertEqual('mode');
done(); done();
}); });
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册