From f02ac81e47c8630c91f103397faac97d0c8b46b9 Mon Sep 17 00:00:00 2001 From: wang-xupeng2 Date: Mon, 31 Jul 2023 22:49:33 +0800 Subject: [PATCH] fixed 0956d50 from https://gitee.com/wang-xupeng2/xts_acts_9/pulls/9631 add matrix4 testcase Signed-off-by: wang-xupeng2 --- .../ets/TestAbility/pages/getcomponent.ets | 63 ++++++++++++++----- .../src/main/ets/test/getcomponent.test.ets | 28 ++++++--- 2 files changed, 69 insertions(+), 22 deletions(-) diff --git a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/TestAbility/pages/getcomponent.ets b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/TestAbility/pages/getcomponent.ets index 1b43d2360..f8617796c 100644 --- a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/TestAbility/pages/getcomponent.ets +++ b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/TestAbility/pages/getcomponent.ets @@ -12,25 +12,60 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import componentUtils from '@ohos.componentUtils'; + @Entry @Component struct getcomponent { - @State message: string = 'Hello World' + + getcomponentRect(key){ + let modePosition = componentUtils.getRectangleById(key) + let widthSize = modePosition.size.width + let heightSize = modePosition.size.height + let localOffsetX = modePosition.localOffset.x + let localOffsetY = modePosition.localOffset.y + let windowOffsetX = modePosition.windowOffset.x + let windowOffsetY = modePosition.windowOffset.y + let screenOffsetX = modePosition.screenOffset.x + let screenOffsetY = modePosition.screenOffset.y + let Matrix4Result1 = modePosition.transform + return { + "sizeWidth": widthSize, + "sizeHeight": heightSize, + "localOffsetX": localOffsetX, + "localOffsetY": localOffsetY, + "windowOffsetX": windowOffsetX, + "windowOffsetY": windowOffsetY, + "screenOffsetX": screenOffsetX, + "screenOffsetY": screenOffsetY, + "Matrix4Result1": Matrix4Result1 + } + } + build() { Column() { - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .key('ArkUX_Get_component_0010') - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('50%') - .height('50%') - }.width(200).height(200) + Button('next page') + .size({ width: 90, height: 90 }) + .fontWeight(FontWeight.Bold) + .id('ArkUX_Get_component_0010') + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + + Button("返回值").margin(30) + .onClick(()=>{ + let Rectangle = this.getcomponentRect("ArkUX_Get_component_0010") + this.message = "sizeWidth: " + Rectangle.sizeWidth + "\n sizeHeight: " + Rectangle.sizeHeight + + "\n localOffsetX: " + Rectangle.localOffsetX + "\n localOffsetY: " + Rectangle.localOffsetY + + "\n windowOffsetX: " + Rectangle.windowOffsetX + "\n windowOffsetY: " + Rectangle.windowOffsetY + + "\n screenOffsetX: " + Rectangle.screenOffsetX + "\n screenOffsetY: " + Rectangle.screenOffsetY + + "\n Matrix4Result: " + Rectangle.Matrix4Result1.toString() + }) + + Text(this.message).fontSize(25).padding(15).fontWeight(FontWeight.Bold).margin(10) + }.width("100%").height("100%") } } \ No newline at end of file diff --git a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/getcomponent.test.ets b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/getcomponent.test.ets index 2eb73ffe9..b4301330c 100644 --- a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/getcomponent.test.ets +++ b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/getcomponent.test.ets @@ -58,14 +58,26 @@ export default function ActsgetcomponentTest() { console.info('ArkUX_Get_component_0010 START'); setTimeout(()=>{ try{ - let strJson = Utils.getComponentRect('ArkUX_Get_component_0010'); - expect(parseInt(strJson.width)).assertEqual(vp2px(100)); - expect(parseInt(strJson.height)).assertEqual(vp2px(100)); - expect(parseInt(strJson.localOffsetY)).assertEqual(30); - expect(parseInt(strJson.windowOffsetX)).assertEqual(234); - expect(parseInt(strJson.windowOffsetY)).assertEqual(102); - expect(parseInt(strJson.screenOffsetX)).assertEqual(234); - expect(parseInt(strJson.screenOffsetY)).assertEqual(234); + let strJson = getInspectorByKey('ArkUX_Get_component_0010'); + let obj = JSON.parse(strJson); + console.info('ArkUX_Get_component_0010 width: '+ JSON.stringify(obj.width)); + console.info('ArkUX_Get_component_0010 height: '+ JSON.stringify(obj.height)); + console.info('ArkUX_Get_component_0010 localOffsetX: '+ JSON.stringify(obj.localOffsetX)); + console.info('ArkUX_Get_component_0010 localOffsetY: '+ JSON.stringify(obj.localOffsetY)); + console.info('ArkUX_Get_component_0010 windowOffsetX: '+ JSON.stringify(obj.windowOffsetX)); + console.info('ArkUX_Get_component_0010 windowOffsetY: '+ JSON.stringify(obj.windowOffsetY)); + console.info('ArkUX_Get_component_0010 screenOffsetX: '+ JSON.stringify(obj.screenOffsetX)); + console.info('ArkUX_Get_component_0010 screenOffsetY: '+ JSON.stringify(obj.screenOffsetY)); + console.info('ArkUX_Get_component_0010 transform: '+ JSON.stringify(obj.transform)); + expect(parseInt(obj.width)).assertEqual(vp2px(90)); + expect(parseInt(obj.height)).assertEqual(vp2px(90)); + expect(parseInt(obj.localOffsetX)).assertEqual(293); + expect(parseInt(obj.localOffsetY)).assertEqual(30); + expect(parseInt(obj.windowOffsetX)).assertEqual(293); + expect(parseInt(obj.windowOffsetY)).assertEqual(102); + expect(parseInt(obj.screenOffsetX)).assertEqual(293); + expect(parseInt(obj.screenOffsetY)).assertEqual(102); + expect(obj.transform).assertEqual('[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]'); console.info('ArkUX_Get_component_0010 END '); } catch(err) { expect().assertFail() -- GitLab