From b68127bc51f861271a4b5c17bddeac666d8ea3f5 Mon Sep 17 00:00:00 2001 From: tengfan Date: Tue, 18 Jul 2023 22:00:44 +0800 Subject: [PATCH] fixed 0b4e2f6 from https://gitee.com/tengfan66/xts_acts/pulls/9385 qrcode_xts_0718 Signed-off-by: tengfan --- .../entry/src/main/ets/MainAbility/pages/QrCode.ets | 6 ++++++ .../entry/src/main/ets/test/QrCodeJsunit.test.ets | 10 ++++++++-- .../src/main/ets/MainAbility/pages/QRCodePage.ets | 5 +++++ .../entry/src/main/ets/test/QRCodeJsunit.test.ets | 12 +++++++++--- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/arkui/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets b/arkui/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets index 9a0706e7b..b1bdaaf0a 100644 --- a/arkui/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets +++ b/arkui/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets @@ -114,6 +114,12 @@ struct QrCode { .width(197) .height(197) .key("QrCodeBackgroundColor") + QRCode(`${this.qrCodeValue}`) + .color($r('sys.color.ohos_id_color_foreground')) + .backgroundColor($r('sys.color.ohos_id_color_background')) + .width(197) + .height(197) + .key("QrCodeDefault") } .width('100%') .height('100%') diff --git a/arkui/ace_ets_component_three/entry/src/main/ets/test/QrCodeJsunit.test.ets b/arkui/ace_ets_component_three/entry/src/main/ets/test/QrCodeJsunit.test.ets index 6caa340f8..b51162a1b 100644 --- a/arkui/ace_ets_component_three/entry/src/main/ets/test/QrCodeJsunit.test.ets +++ b/arkui/ace_ets_component_three/entry/src/main/ets/test/QrCodeJsunit.test.ets @@ -129,9 +129,12 @@ export default function qrCodeJsunit() { } await Utils.sleep(2000); var strJson = getInspectorByKey('QrCodeColor'); + var strJsonDefault = getInspectorByKey('QrCodeDefault'); var obj = JSON.parse(strJson); + var objDefault = JSON.parse(strJsonDefault); console.info("[test_qrCode_004] component obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.color).assertEqual('#FF000000'); + console.info("[test_qrCode_004] component objDefault is: " + JSON.stringify(objDefault)); + expect(obj.$attrs.color).assertEqual(objDefault.$attrs.color); done(); }); @@ -181,10 +184,13 @@ export default function qrCodeJsunit() { } await Utils.sleep(2000); var strJson = getInspectorByKey('QrCodeColor'); + var strJsonDefault = getInspectorByKey('QrCodeDefault'); var obj = JSON.parse(strJson); + var objDefault = JSON.parse(strJsonDefault); console.info("[test_qrCode_006] component obj is: " + JSON.stringify(obj)); + console.info("[test_qrCode_006] component objDefault is: " + JSON.stringify(objDefault)); // 非法入参默认初始值 - expect(obj.$attrs.backgroundColor).assertEqual('#FFFFFFFF'); + expect(obj.$attrs.backgroundColor).assertEqual(objDefault.$attrs.backgroundColor); done(); }); diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/QRCodePage.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/QRCodePage.ets index 7ca79a21d..6a1e9c844 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/QRCodePage.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/MainAbility/pages/QRCodePage.ets @@ -60,6 +60,11 @@ struct QRCodePage { Text('backgroundColor').fontSize(9).width('90%').fontColor(0xCCCCCC).fontSize(30) QRCode(this.value).width(200).height(200).backgroundColor(this.backColor).key('qr2') Text(this.text).fontSize(20).margin(10).key('text') + + QRCode(this.value).width(200).height(200) + .color($r('sys.color.ohos_id_color_foreground')) + .backgroundColor($r('sys.color.ohos_id_color_background')) + .key('qrDefault') }.width('100%').margin({ top: 5 }) } } \ No newline at end of file diff --git a/arkui/ace_ets_component_ui/entry/src/main/ets/test/QRCodeJsunit.test.ets b/arkui/ace_ets_component_ui/entry/src/main/ets/test/QRCodeJsunit.test.ets index ad2339564..cea06d408 100644 --- a/arkui/ace_ets_component_ui/entry/src/main/ets/test/QRCodeJsunit.test.ets +++ b/arkui/ace_ets_component_ui/entry/src/main/ets/test/QRCodeJsunit.test.ets @@ -47,12 +47,15 @@ export default function QRCodeJsunit() { // Get the information of the QRCode component console.info('[QRCodeJsunit_0100] START'); let strJson = getInspectorByKey('qr'); + let strJsonDefault = getInspectorByKey('qrDefault'); let obj = JSON.parse(strJson); + let objDefault = JSON.parse(strJsonDefault); console.info("[QRCodeJsunit_0100] component obj is: " + JSON.stringify(obj)); + console.info("[QRCodeJsunit_0100] component objDefault is: " + JSON.stringify(objDefault)); await CommonFunc.sleep(1000); expect(obj.$attrs.value).assertEqual('normal'); - expect(obj.$attrs.color).assertEqual('#FF000000'); - expect(obj.$attrs.backgroundColor).assertEqual('#FFFFFFFF'); + expect(obj.$attrs.color).assertEqual(objDefault.$attrs.color); + expect(obj.$attrs.backgroundColor).assertEqual(objDefault.$attrs.backgroundColor); console.info('[QRCodeJsunit_0100] END'); done(); }); @@ -118,9 +121,12 @@ export default function QRCodeJsunit() { globalThis.value.message.notify({name:'backgroundColor',value:'test'}) await CommonFunc.sleep(2000); let strJson1 = getInspectorByKey('qr2'); + let strJsonDefault = getInspectorByKey('qrDefault'); let obj1 = JSON.parse(strJson1); + let objDefault = JSON.parse(strJsonDefault); console.info("[QRCodeJsunit_0500] component obj1 is: " + JSON.stringify(obj1)); - expect(obj1.$attrs.backgroundColor).assertEqual('#FFFFFFFF'); + console.info("[QRCodeJsunit_0500] component objDefault is: " + JSON.stringify(objDefault)); + expect(obj1.$attrs.backgroundColor).assertEqual(objDefault.$attrs.backgroundColor); console.info('[QRCodeJsunit_0500] END'); done(); }); -- GitLab