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 9a0706e7b72c1f9d25d1f43e83b7c65c0be6e324..b1bdaaf0a503b9ce510cf33f9267deb6cbd10a80 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 6caa340f8b09789c649377e0e483c4033fb82814..b51162a1b994f23e52c73647ffcb7a162fe501a0 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 7ca79a21dd3065bd1503f7c8b9d89319ea253ffb..6a1e9c844453dbc81d14e671fcb1276ec28c8d06 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 ad2339564d52faa01614375f6487a294c65d6daf..cea06d4089968cb89dab00ed7ebcb7686f258394 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(); });