From 9043229debba45ebe5eb24ceacf5f2f7761cd328 Mon Sep 17 00:00:00 2001 From: sunjiakun Date: Mon, 26 Jun 2023 10:44:17 +0800 Subject: [PATCH] 0626 datepicker Signed-off-by: sunjiakun --- .../src/main/ets/TestAbility/pages/Index.ets | 22 ++++++ .../src/main/ets/test/DatePicker.ets | 72 ++++++++++++++++--- 2 files changed, 84 insertions(+), 10 deletions(-) diff --git a/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/TestAbility/pages/Index.ets b/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/TestAbility/pages/Index.ets index a292ff8fd..072d2b93e 100644 --- a/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/TestAbility/pages/Index.ets +++ b/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/TestAbility/pages/Index.ets @@ -91,6 +91,28 @@ struct DatePickerExample { .onChange((date: DatePickerResult) => { console.info( 'select current date is: ' + JSON.stringify(date)) }) + + Button('Dialog') + .fontColor('black') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin(10) + .backgroundColor('#0D9FFB') + .width('40%') + .height(40) + .key("Dialog") + .onClick(() => { + DatePickerDialog.show({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.selectedDate, + lunar:true, + showTime:true, + disappearTextStyle:this.disappearTextStyle, + textStyle: this.textStyle, + selectedTextStyle: this.selectedTextStyle, + }) + }) } } } \ No newline at end of file diff --git a/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/test/DatePicker.ets b/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/test/DatePicker.ets index 7f011f621..507eec035 100644 --- a/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/test/DatePicker.ets +++ b/arkui/ace_ets_components_ux/ace_ets_component_datepicker/src/main/ets/test/DatePicker.ets @@ -484,7 +484,7 @@ export default function datepicker() { eventId: 185, priority: events_emitter.EventPriority.LOW } - console.info("[ArkUI_Stage_timepicker_textStyle_0600] start to publish emit"); + console.info("[ArkUI_Stage_datepicker_textStyle_0600] start to publish emit"); events_emitter.emit(innerEvent, eventData); } catch (err) { console.log("[ArkUI_Stage_datePicker_textStyle_0600] change component data error: " + err.message); @@ -809,7 +809,7 @@ export default function datepicker() { let strJsonDefault = getInspectorByKey('datePickerDefault'); let objDefault = JSON.parse(strJsonDefault); - console.info("[ArkUI_Stage_timepicker_selectedTextStyle_0700] disappearColor:" + obj.$attrs.selectedTextStyle.color); + console.info("[ArkUI_Stage_datepicker_selectedTextStyle_0700] disappearColor:" + obj.$attrs.selectedTextStyle.color); expect(obj.$attrs.selectedTextStyle.color).assertEqual(objDefault.$attrs.selectedTextStyle.color); expect(obj.$attrs.selectedTextStyle.font.size).assertEqual(objDefault.$attrs.selectedTextStyle.font.size); expect(obj.$attrs.selectedTextStyle.font.weight).assertEqual('FontWeight.Lighter'); @@ -817,11 +817,11 @@ export default function datepicker() { }); /* - * @tc.number ArkUI_Stage_timepicker_selectedTextStyle_0800 + * @tc.number ArkUI_Stage_datepicker_selectedTextStyle_0800 * @tc.name Tests the selectedTextStyle property of the picker component * @tc.desc set selectedTextStyle then get the value */ - it('ArkUI_Stage_timepicker_selectedTextStyle_0800', 0, async function (done) { + it('ArkUI_Stage_datepicker_selectedTextStyle_0800', 0, async function (done) { let value = {color:'rgb(138,43,226)',font:{size:'20vp',weight:900}} try { var eventData = { @@ -833,10 +833,10 @@ export default function datepicker() { eventId: 185, priority: events_emitter.EventPriority.LOW } - console.info("[ArkUI_Stage_timepicker_selectedTextStyle_0800] start to publish emit"); + console.info("[ArkUI_Stage_datepicker_selectedTextStyle_0800] start to publish emit"); events_emitter.emit(innerEvent, eventData); } catch (err) { - console.log("[ArkUI_Stage_timepicker_selectedTextStyle_0800] change component data error: " + err.message); + console.log("[ArkUI_Stage_datepicker_selectedTextStyle_0800] change component data error: " + err.message); } await Utils.sleep(3000); let strJson = getInspectorByKey('datePicker'); @@ -848,11 +848,11 @@ export default function datepicker() { }); /* - * @tc.number ArkUI_Stage_timepicker_selectedTextStyle_0900 + * @tc.number ArkUI_Stage_datepicker_selectedTextStyle_0900 * @tc.name Tests the selectedTextStyle property of the picker component * @tc.desc set selectedTextStyle then get the value */ - it('ArkUI_Stage_timepicker_selectedTextStyle_0900', 0, async function (done) { + it('ArkUI_Stage_datepicker_selectedTextStyle_0900', 0, async function (done) { let value = {color:'rgb(138,43,226)',font:{size:'15lpx',weight:90}} try { var eventData = { @@ -864,10 +864,10 @@ export default function datepicker() { eventId: 185, priority: events_emitter.EventPriority.LOW } - console.info("[ArkUI_Stage_timepicker_selectedTextStyle_0900] start to publish emit"); + console.info("[ArkUI_Stage_datepicker_selectedTextStyle_0900] start to publish emit"); events_emitter.emit(innerEvent, eventData); } catch (err) { - console.log("[ArkUI_Stage_timepicker_selectedTextStyle_0900] change component data error: " + err.message); + console.log("[ArkUI_Stage_datepicker_selectedTextStyle_0900] change component data error: " + err.message); } await Utils.sleep(3000); let strJson = getInspectorByKey('datePicker'); @@ -877,6 +877,58 @@ export default function datepicker() { expect(obj.$attrs.selectedTextStyle.font.weight).assertEqual('FontWeight.Normal'); done(); }); + + /* + * @tc.number ArkUI_Stage_datepicker_selectedTextStyle_0900 + * @tc.name Tests the selectedTextStyle property of the picker component + * @tc.desc set selectedTextStyle then get the value + */ + it('ArkUI_Stage_datepicker_selectedTextStyle_0900', 0, async function (done) { + let value = {color:'rgb(138,43,226)',font:{size:'15lpx',weight:90}} + try { + var eventData = { + data: { + "selectedTextStyle": JSON.stringify(value) + } + } + var innerEvent = { + eventId: 185, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_Stage_datepicker_selectedTextStyle_0900] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_Stage_datepicker_selectedTextStyle_0900] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('datePicker'); + let obj = JSON.parse(strJson); + expect(obj.$attrs.selectedTextStyle.color).assertEqual('#FF8A2BE2'); + expect(obj.$attrs.selectedTextStyle.font.size).assertEqual('15.00lpx'); + expect(obj.$attrs.selectedTextStyle.font.weight).assertEqual('FontWeight.Normal'); + done(); + }); + + /* + * @tc.number ArkUI_Stage_datepicker_Dialog_0100 + * @tc.name Tests the property of the Dialog + * @tc.desc get the property of the Dialog + */ + it('ArkUI_Stage_datepicker_dialog_0100', 0, async function (done) { + console.info('testDialog START'); + await Utils.sleep(3000); + try { + var innerEvent = { + eventId: 185, + priority: events_emitter.EventPriority.LOW + } + console.info("[ArkUI_Stage_datepicker_dialog_0100] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[ArkUI_Stage_datepicker_dialog_0100] change component data error: " + err.message); + } + done(); + }); }) } -- GitLab