From 514cae712e5694e6e242196e1428453e11d85cd8 Mon Sep 17 00:00:00 2001 From: lixiteng Date: Mon, 20 Mar 2023 17:06:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0shadow=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lixiteng --- .../ets/MainAbility/pages/imageEffects.ets | 17 ++ .../main/ets/test/ImageEffectsJsunit.test.ets | 179 ++++++++++++++++++ 2 files changed, 196 insertions(+) diff --git a/arkui/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets b/arkui/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets index ab4a6a832..885387c89 100644 --- a/arkui/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets +++ b/arkui/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets @@ -22,6 +22,7 @@ struct ImageEffectsExample { @State blurValue: string = 100; @State backdropBlueValue: string= 30; @State shadowValue: object= { radius: 10, color: Color.Gray, offsetX: 5, offsetY: 5 } + @State shadowStyleValue: ShadowStyle = ShadowStyle.OuterDefaultXS; @State grayscaleValue: string= 10; @State brightnessValue: string= 20; @State saturateValue: string= 50; @@ -37,6 +38,9 @@ struct ImageEffectsExample { if (eventData.data.shadowValue != null) { this.shadowValue = JSON.parse(eventData.data.shadowValue); } + if (eventData.data.shadowStyleValue != null) { + this.shadowStyleValue = eventData.data.shadowStyleValue; + } if (eventData.data.grayscaleValue != null) { this.grayscaleValue = eventData.data.grayscaleValue; } @@ -107,6 +111,12 @@ struct ImageEffectsExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent8, this.stateChangCallBack); + + var stateChangeEvent9 = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent9, this.stateChangCallBack); } build() { @@ -138,6 +148,13 @@ struct ImageEffectsExample { .shadow(this.shadowValue) .key('centerRow3') + Text('shadow--枚举类型').fontSize(15).fontColor(0xCCCCCC).width('90%') + Image('/images/download.png') + .width('90%') + .height(40) + .shadow(this.shadowStyleValue) + .key('shadowDefaultShadow') + Text('grayscale').fontSize(15).fontColor(0xCCCCCC).width('90%') Image('/images/download.png') .width('90%') diff --git a/arkui/ace_ets_component/entry/src/main/ets/test/ImageEffectsJsunit.test.ets b/arkui/ace_ets_component/entry/src/main/ets/test/ImageEffectsJsunit.test.ets index d143fe132..5aa3be362 100644 --- a/arkui/ace_ets_component/entry/src/main/ets/test/ImageEffectsJsunit.test.ets +++ b/arkui/ace_ets_component/entry/src/main/ets/test/ImageEffectsJsunit.test.ets @@ -866,6 +866,185 @@ export default function imageEffectsJsunit() { expect(objNew.$attrs.hueRotate).assertEqual(0); done(); }); + + it('testImageEffects036', 0, async function (done) { + console.info('[testImageEffects036] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "shadowStyleValue": ShadowStyle.OuterDefaultXS + } + } + var innerEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects036] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects036] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('shadowDefaultShadow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects036] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#32000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("0.000000"); + done(); + }); + + it('testImageEffects037', 0, async function (done) { + console.info('[testImageEffects037] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "shadowStyleValue": ShadowStyle.OuterDefaultSM + } + } + var innerEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects037] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects037] change component data error: " + err.message); + } + await Utils.sleep(2000); + + let strJsonNew = getInspectorByKey('shadowDefaultShadow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects037] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#0B000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("0.000000"); + done(); + }); + + it('testImageEffects038', 0, async function (done) { + console.info('[testImageEffects038] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "shadowStyleValue": ShadowStyle.OuterDefaultMD + } + } + var innerEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects038] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects038] change component data error: " + err.message); + } + await Utils.sleep(2000); + + let strJsonNew = getInspectorByKey('shadowDefaultShadow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects038] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#28000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("60.000000"); + done(); + }); + + it('testImageEffects039', 0, async function (done) { + console.info('[testImageEffects039] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "shadowStyleValue": ShadowStyle.OuterDefaultLG + } + } + var innerEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects039] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects039] change component data error: " + err.message); + } + await Utils.sleep(2000); + + let strJsonNew = getInspectorByKey('shadowDefaultShadow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects039] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#26000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("10.000000"); + done(); + }); + + it('testImageEffects040', 0, async function (done) { + console.info('[testImageEffects040] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "shadowStyleValue": ShadowStyle.OuterFloatingSM + } + } + var innerEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects040] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects040] change component data error: " + err.message); + } + await Utils.sleep(2000); + + let strJsonNew = getInspectorByKey('shadowDefaultShadow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects040] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#15000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("50.000000"); + done(); + }); + + it('testImageEffects041', 0, async function (done) { + console.info('[testImageEffects041] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "shadowStyleValue": ShadowStyle.OuterFloatingMD + } + } + var innerEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects041] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects041] change component data error: " + err.message); + } + await Utils.sleep(2000); + + let strJsonNew = getInspectorByKey('shadowDefaultShadow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects041] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#31000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("30.000000"); + done(); + }); }) } -- GitLab