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

!9984 modified Jsunit add ets

Merge pull request !9984 from liuzixuan/master
...@@ -55,8 +55,9 @@ struct ActionSheetExample { ...@@ -55,8 +55,9 @@ struct ActionSheetExample {
} }
} }
] ]
}).key('ActionSheet') })
}) }).key('ActionSheet')
}.width('100%') }.width('100%')
.height('100%') .height('100%')
} }
......
...@@ -40,8 +40,9 @@ struct AlertDialogExample { ...@@ -40,8 +40,9 @@ struct AlertDialogExample {
console.info('Closed callbacks') console.info('Closed callbacks')
} }
} }
).key('AlertDialog') )
}) }).key('AlertDialog')
.backgroundColor(0x317aff) .backgroundColor(0x317aff)
Button('two button dialog') Button('two button dialog')
.onClick(() => { .onClick(() => {
...@@ -67,7 +68,8 @@ struct AlertDialogExample { ...@@ -67,7 +68,8 @@ struct AlertDialogExample {
} }
} }
) )
}).backgroundColor(0x317aff) }).key('AlertDialog2')
.backgroundColor(0x317aff)
}.width('100%').margin({ top: 5 }) }.width('100%').margin({ top: 5 })
} }
} }
\ No newline at end of file
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
struct CustomDialogExample { struct CustomDialogExample {
@Link textValue: string @Link textValue: string
@Link inputValue: string @Link inputValue: string
@Link openAnimation: AnimateParam
@Link closeAnimation: AnimateParam
@State widthSize: number = 250 @State widthSize: number = 250
@State heightSize: number = 100 @State heightSize: number = 100
private flag: boolean = true private flag: boolean = true
...@@ -74,21 +73,21 @@ struct CustomDialogUser { ...@@ -74,21 +73,21 @@ struct CustomDialogUser {
confirm: this.onAccept, confirm: this.onAccept,
textValue: $textValue, textValue: $textValue,
inputValue: $inputValue, inputValue: $inputValue,
openAnimation:{
duration: 2000,
iterations: 3,
onFinish: () => {
console.info('openAnimation play end')
},
},
closeAnimation:{
duration: 2000,
iterations: 3,
onFinish: () => {
console.info('closeAnimation play end')
},
}
}), }),
openAnimation:{
duration: 2000,
iterations: 3,
onFinish: () => {
console.info('openAnimation play end')
}
},
closeAnimation:{
duration: 2000,
iterations: 3,
onFinish: () => {
console.info('closeAnimation play end')
}
},
cancel: this.existApp, cancel: this.existApp,
alignment: DialogAlignment.Top, alignment: DialogAlignment.Top,
offset: { dx: 10, dy: 100 }, offset: { dx: 10, dy: 100 },
...@@ -123,7 +122,8 @@ struct CustomDialogUser { ...@@ -123,7 +122,8 @@ struct CustomDialogUser {
if (this.dialogController != undefined) { if (this.dialogController != undefined) {
this.dialogController.open() this.dialogController.open()
} }
}).backgroundColor(0x317aff) })
.backgroundColor(0x317aff)
}.width('100%').margin({ top: 5 }) }.width('100%').margin({ top: 5 })
} }
} }
\ No newline at end of file
...@@ -44,8 +44,9 @@ struct DatePickerDialogOptions0 { ...@@ -44,8 +44,9 @@ struct DatePickerDialogOptions0 {
onDateChange: (value: Date)=> { onDateChange: (value: Date)=> {
console.info("DatePickerDialog: onChange()" + value.toString()) console.info("DatePickerDialog: onChange()" + value.toString())
} }
}).key('DatePickerDialog') })
}) }).key('DatePickerDialog')
}.width('100%') }.width('100%')
} }
} }
\ No newline at end of file
...@@ -40,8 +40,8 @@ struct TextPickerDialogExample { ...@@ -40,8 +40,8 @@ struct TextPickerDialogExample {
onChange: (value: TextPickerResult)=> { onChange: (value: TextPickerResult)=> {
console.info("TextPickerDialog: onChange()" + JSON.stringify(value)) console.info("TextPickerDialog: onChange()" + JSON.stringify(value))
} }
}).key('TextPickerDialog') })
}) }).key('TextPickerDialog')
}.width('100%') }.width('100%')
} }
} }
\ No newline at end of file
...@@ -39,8 +39,8 @@ struct TimePickerDialogExample { ...@@ -39,8 +39,8 @@ struct TimePickerDialogExample {
onChange: (value: TimePickerResult)=> { onChange: (value: TimePickerResult)=> {
console.info("TimePickerDialog: onChange()" + JSON.stringify(value)) console.info("TimePickerDialog: onChange()" + JSON.stringify(value))
} }
}).key('TimePickerDialog') })
}) }).key('TimePickerDialog')
}.width('100%') }.width('100%')
} }
} }
\ 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.
*/
class BasicDataSource implements IDataSource {
private listeners: DataChangeListener []= [];
public totalCount(): number{
return 0;
}
public getData(index:number): unknown {
return undefined;
}
registerDataChangeListener(listener: DataChangeListener): void {
if (this.listeners.indexOf(listener) < 0) {
console.info('add listener');
this.listeners.push(listener);
}
}
unregisterDataChangeListener(listener: DataChangeListener): void {
const pos = this.listeners.indexOf(listener);
if (pos >= 0) {
console.info('remove listener');
this.listeners.splice(pos, 1);
}
}
notifyDataReload(): void {
this.listeners.forEach(listener =>{
listener.onDataReloaded();
})
}
notifyDataAdd(index: number): void {
this.listeners.forEach(listener =>{
listener.onDataAdd(index)
})
}
notifyDataChange(index: number): void {
this.listeners.forEach(listener =>{
listener.onDataChange(index);
})
}
notifyDataDelete(index: number): void {
this.listeners.forEach(listener =>{
listener.onDataDelete(index);
})
}
notifyDataMove(from: number ,to: number): void {
this.listeners.forEach(listener =>{
listener.onDataMove(from, to);
})
}
}
class MyDataSourceImag extends BasicDataSource {
private dataArray: String[] = ['/path/image0','/path/image1','/path/image2','/path/image3'];
public totalCount(): number {
return this.dataArray.length
}
public getData(index: number): unknown {
return this.dataArray[index];
}
public addData(index: number,data: string): void {
this.dataArray.splice(index, 0, data);
this.notifyDataAdd(index);
}
public pushData(data: string): void {
this.dataArray.push(data);
this.notifyDataAdd(this.dataArray.length - 1);
}
}
@Entry
@Component
struct MyComponentImag{
private data: MyDataSourceImag = new MyDataSourceImag();
build(){
List({space: 3}){
LazyForEach(this.data, (item: string) => {
ListItem(){
ReusableChildComponent({item: item})
}
}, item => item)
}
.width('100%')
.height('100%')
}
}
@Reusable
@Component
struct ReusableChildComponent {
@State item: string = ''
aboutToReuse(params) {
this.item = params.item;
}
aboutToRecycle(){
console.log('recycle node');
}
build(){
Row(){
Image(this.item).width('30%').height(50).key('aboutToRecyclImage')
Text(this.item).fontSize(20).margin({ left:10 })
}.margin({ left: 10, right: 10})
}
}
\ No newline at end of file
...@@ -46,23 +46,19 @@ export default function ActionSheetJsunit() { ...@@ -46,23 +46,19 @@ export default function ActionSheetJsunit() {
it('ActionSheetJsunit_0100', 0, async function (done) { it('ActionSheetJsunit_0100', 0, async function (done) {
console.info('ActionSheetJsunit_0100 START'); console.info('ActionSheetJsunit_0100 START');
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('ActionSheet'));
await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('ActionSheet'); let strJson = getInspectorByKey('ActionSheet');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[ActionSheetJsunit_0100] component obj is: " + JSON.stringify(obj)); console.info("[ActionSheetJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[ActionSheetJsunit_0100] subtitle:" + JSON.stringify(obj.$attrs.subtitle)); expect(obj.$attrs.label).assertEqual("Click to Show ActionSheet");
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'); console.info('[ActionSheetJsunit_0100] END');
await driver.pressBack();
done(); done();
}); });
......
...@@ -46,69 +46,31 @@ export default function AlertDialogJsunit() { ...@@ -46,69 +46,31 @@ export default function AlertDialogJsunit() {
it('AlertDialogJsunit_0100', 0, async function (done) { it('AlertDialogJsunit_0100', 0, async function (done) {
console.info('AlertDialogJsunit_0100 START'); console.info('AlertDialogJsunit_0100 START');
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('AlertDialog'));
await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('AlertDialog'); let strJson = getInspectorByKey('AlertDialog');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[AlertDialogJsunit_0100] component obj is: " + JSON.stringify(obj)); console.info("[AlertDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[AlertDialogJsunit_0100] subtitle:" + JSON.stringify(obj.$attrs.subtitle)); expect(obj.$attrs.label).assertEqual("one button dialog");
console.info("[AlertDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment)); await driver.pressBack();
console.info("[AlertDialogJsunit_0100] offset:" + JSON.stringify(obj.$attrs.offset)); await CommonFunc.sleep(500);
console.info("[AlertDialogJsunit_0100] maskRect:" + JSON.stringify(obj.$attrs.maskRect));
expect(obj.$attrs.subtitle).assertEqual("subtitle"); let button2 = await driver.findComponent(BY.key('AlertDialog2'));
await button2.click();
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); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('AlertDialog'); let strJson2 = getInspectorByKey('AlertDialog2');
let obj = JSON.parse(strJson); let obj2 = JSON.parse(strJson2);
console.info("[AlertDialogJsunit_0300] component strJson:" + JSON.stringify(obj.$attrs.buttonDirection)); console.info("[AlertDialogJsunit_0100] component obj2 is: " + JSON.stringify(obj2));
expect(obj.$attrs.buttonDirection).assertEqual("DialogButtonDirection.HORIZONTAL "); expect(obj2.$attrs.label).assertEqual("two button dialog");
console.info('[AlertDialogJsunit_0300] END'); console.info('[AlertDialogJsunit_0100] END');
await driver.pressBack();
done(); 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();
});
}) })
} }
...@@ -47,18 +47,16 @@ export default function CustomDialogJsunit() { ...@@ -47,18 +47,16 @@ export default function CustomDialogJsunit() {
it('CustomDialogJsunit_0100', 0, async function (done) { it('CustomDialogJsunit_0100', 0, async function (done) {
console.info('CustomDialogJsunit_0100 START'); console.info('CustomDialogJsunit_0100 START');
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('CustomDialog'));
await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('CustomDialog'); let strJson = getInspectorByKey('CustomDialog');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[CustomDialogJsunit_0100] component obj is: " + JSON.stringify(obj)); console.info("[CustomDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[CustomDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment)); expect(obj.$attrs.label).assertEqual("click me");
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'); console.info('[CustomDialogJsunit_0100] END');
await driver.pressBack();
done(); done();
}); });
......
...@@ -43,24 +43,20 @@ export default function DatePickerDialogJsunit() { ...@@ -43,24 +43,20 @@ export default function DatePickerDialogJsunit() {
done() done()
}); });
it('DatePickerDialogJsunit_0100', 0, async function (done) { it('DatePickerDialogJsunit_0100', 0, async function (done) {
console.info('DatePickerDialogJsunit_0100 START'); console.info('DatePickerDialogJsunit_0100 START');
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('DatePickerDialog'));
await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('DatePickerDialog'); let strJson = getInspectorByKey('DatePickerDialog');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[DatePickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj)); console.info("[DatePickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[DatePickerDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment)); expect(obj.$attrs.label).assertEqual("DatePickerDialog");
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'); console.info('[DatePickerDialogJsunit_0100] END');
await driver.pressBack();
done(); done();
}); });
......
...@@ -71,6 +71,7 @@ import TimePickerDialogJsunit from './TimePickerDialogJsunit.test.ets'; ...@@ -71,6 +71,7 @@ import TimePickerDialogJsunit from './TimePickerDialogJsunit.test.ets';
import OverlayJsunit from './OverlayJsunit.test.ets'; import OverlayJsunit from './OverlayJsunit.test.ets';
import PanelJsunit from './PanelJsunit.test.ets'; import PanelJsunit from './PanelJsunit.test.ets';
import GridCallbackJsunit from './GridCallbackJsunit.test.ets'; import GridCallbackJsunit from './GridCallbackJsunit.test.ets';
import aboutToRecycleiamge from './aboutToRecycleiamgeJS.test.ets'
export default function testsuite() { export default function testsuite() {
DialogJsunit(); DialogJsunit();
...@@ -131,4 +132,5 @@ export default function testsuite() { ...@@ -131,4 +132,5 @@ export default function testsuite() {
OverlayJsunit(); OverlayJsunit();
PanelJsunit(); PanelJsunit();
GridCallbackJsunit(); GridCallbackJsunit();
aboutToRecycleiamge();
} }
\ No newline at end of file
...@@ -260,7 +260,7 @@ export default function overLayJsunit() { ...@@ -260,7 +260,7 @@ export default function overLayJsunit() {
} }
} }
var innerEvent = { var innerEvent = {
eventId: 143, eventId: 1110,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[overLayJsunit_0900] start to publish emit"); console.info("[overLayJsunit_0900] start to publish emit");
...@@ -272,7 +272,7 @@ export default function overLayJsunit() { ...@@ -272,7 +272,7 @@ export default function overLayJsunit() {
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[overLayJsunit_0900] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[overLayJsunit_0900] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Top"); expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('overLayJsunit_0900 END'); console.info('overLayJsunit_0900 END');
done(); done();
}); });
...@@ -299,7 +299,7 @@ export default function overLayJsunit() { ...@@ -299,7 +299,7 @@ export default function overLayJsunit() {
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1000] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[overLayJsunit_1000] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopEnd"); expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('overLayJsunit_1000 END'); console.info('overLayJsunit_1000 END');
done(); done();
}); });
...@@ -326,7 +326,7 @@ export default function overLayJsunit() { ...@@ -326,7 +326,7 @@ export default function overLayJsunit() {
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1100] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[overLayJsunit_1100] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Start"); expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('overLayJsunit_1100 END'); console.info('overLayJsunit_1100 END');
done(); done();
}); });
...@@ -353,7 +353,7 @@ export default function overLayJsunit() { ...@@ -353,7 +353,7 @@ export default function overLayJsunit() {
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1200] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[overLayJsunit_1200] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.End"); expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('overLayJsunit_1200 END'); console.info('overLayJsunit_1200 END');
done(); done();
}); });
...@@ -380,7 +380,7 @@ export default function overLayJsunit() { ...@@ -380,7 +380,7 @@ export default function overLayJsunit() {
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1300] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[overLayJsunit_1300] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.BottomEnd"); expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('overLayJsunit_1300 END'); console.info('overLayJsunit_1300 END');
done(); done();
}); });
...@@ -407,7 +407,7 @@ export default function overLayJsunit() { ...@@ -407,7 +407,7 @@ export default function overLayJsunit() {
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[overLayJsunit_1400] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[overLayJsunit_1400] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.BottomStart"); expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('overLayJsunit_1400 END'); console.info('overLayJsunit_1400 END');
done(); done();
}); });
......
...@@ -52,7 +52,7 @@ export default function PanelJsunit() { ...@@ -52,7 +52,7 @@ export default function PanelJsunit() {
let strJson = getInspectorByKey('PanelText'); let strJson = getInspectorByKey('PanelText');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[PanelJsunit_0100] obj is: " + JSON.stringify(obj.$attrs.customHeight)); console.info("[PanelJsunit_0100] obj is: " + JSON.stringify(obj.$attrs.customHeight));
expect(obj.$attrs.customHeight).assertEqual("PanelHeight.WRAP_CONTENT"); expect(obj.$attrs.customHeight).assertEqual("0.00px");
console.info('[PanelJsunit_0100] END'); console.info('[PanelJsunit_0100] END');
done(); done();
}); });
......
...@@ -46,19 +46,19 @@ export default function ShowDialogJsunit() { ...@@ -46,19 +46,19 @@ export default function ShowDialogJsunit() {
it('ShowDialogJsunit_0100', 0, async function (done) { it('ShowDialogJsunit_0100', 0, async function (done) {
console.info('ShowDialogJsunit_0100 START'); console.info('ShowDialogJsunit_0100 START');
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('ShowDialog'));
await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('ShowDialog'); let strJson = getInspectorByKey('ShowDialog');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[ShowDialogJsunit_0100] component obj is: " + JSON.stringify(obj)); console.info("[ShowDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[ShowDialogJsunit_0100] title:" + JSON.stringify(obj.$attrs.title)); expect(obj.$attrs.label).assertEqual("PromptActionDialog");
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'); console.info('[ShowDialogJsunit_0100] END');
await driver.pressBack();
done(); done();
}); });
......
...@@ -46,18 +46,19 @@ export default function TextPickerDialogJsunit() { ...@@ -46,18 +46,19 @@ export default function TextPickerDialogJsunit() {
it('TextPickerDialogJsunit_0100', 0, async function (done) { it('TextPickerDialogJsunit_0100', 0, async function (done) {
console.info('TextPickerDialogJsunit_0100 START'); console.info('TextPickerDialogJsunit_0100 START');
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('TextPickerDialog'));
await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('TextPickerDialog'); let strJson = getInspectorByKey('TextPickerDialog');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[TextPickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj)); console.info("[TextPickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[TextPickerDialogJsunit_0100] alignment:" + JSON.stringify(obj.$attrs.alignment)); expect(obj.$attrs.label).assertEqual("TextPickerDialog");
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'); console.info('[TextPickerDialogJsunit_0100] END');
await driver.pressBack();
done(); done();
}); });
......
...@@ -45,20 +45,19 @@ export default function TimePickerDialogJsunit() { ...@@ -45,20 +45,19 @@ export default function TimePickerDialogJsunit() {
it('TimePickerDialogJsunit_0100', 0, async function (done) { it('TimePickerDialogJsunit_0100', 0, async function (done) {
console.info('TimePickerDialogJsunit_0100 START'); console.info('TimePickerDialogJsunit_0100 START');
let driver = await UiDriver.create()
let button = await driver.findComponent(BY.key('TimePickerDialog'));
await button.click();
await CommonFunc.sleep(1000); await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('TimePickerDialog'); let strJson = getInspectorByKey('TimePickerDialog');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[TimePickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj)); console.info("[TimePickerDialogJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[TimePickerDialogJsunit_0100] selected:" + JSON.stringify(obj.$attrs.selected)); expect(obj.$attrs.label).assertEqual("TimePickerDialog");
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'); console.info('[TimePickerDialogJsunit_0100] END');
await driver.pressBack();
done(); 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 aboutToRecycleiamge() {
describe('aboutToRecycleiamge', function () {
beforeEach(async function (done) {
console.info("aboutToRecycleiamge beforeEach start");
let options = {
uri: 'MainAbility/pages/aboutToRecycleiamge',
}
try {
router.clear();
let pages = router.getState();
console.info("get aboutToRecycleiamge state pages: " + JSON.stringify(pages));
if (!("aboutToRecycleiamge" == pages.name)) {
console.info("get aboutToRecycleiamge state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push aboutToRecycleiamge page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push aboutToRecycleiamge page error:" + err);
}
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("aboutToRecycleiamge after each called");
});
it('aboutToRecycleiamge_0100', 0, async function (done) {
console.info('[aboutToRecycleiamge_0100] START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('aboutToRecyclImage');
let obj = JSON.parse(strJson);
console.info("[aboutToRecycleiamge_0100] obj is: " + JSON.stringify(obj.$attrs.height));
expect(obj.$attrs.height).assertEqual("50.00vp");
console.info('[aboutToRecycleiamge_0100] END');
done();
});
})
}
...@@ -102,7 +102,8 @@ ...@@ -102,7 +102,8 @@
"MainAbility/pages/TimePickerDialogOptions", "MainAbility/pages/TimePickerDialogOptions",
"MainAbility/pages/overlay", "MainAbility/pages/overlay",
"MainAbility/pages/Panel", "MainAbility/pages/Panel",
"MainAbility/pages/GridCallbackPage" "MainAbility/pages/GridCallbackPage",
"MainAbility/pages/aboutToRecycleiamge"
] ]
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册