未验证 提交 ca3b452b 编写于 作者: O openharmony_ci 提交者: Gitee

!9633 【OpenHarmony 4.0.9.5】【master】【ArkUI子系统】【TOD】【rk3568】【必现】新增接口用例

Merge pull request !9633 from 王旭鹏/cherry-pick-1690854549
...@@ -12,25 +12,60 @@ ...@@ -12,25 +12,60 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import componentUtils from '@ohos.componentUtils';
@Entry @Entry
@Component @Component
struct getcomponent { struct getcomponent {
@State message: string = 'Hello World' @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() { build() {
Column() { Column() {
Button() { Button('next page')
Text('next page') .size({ width: 90, height: 90 })
.fontSize(20) .fontWeight(FontWeight.Bold)
.fontWeight(FontWeight.Bold) .id('ArkUX_Get_component_0010')
}.type(ButtonType.Capsule) .margin({
.key('ArkUX_Get_component_0010') top: 20
.margin({ })
top: 20 .backgroundColor('#0D9FFB')
})
.backgroundColor('#0D9FFB') Button("返回值").margin(30)
.width('50%') .onClick(()=>{
.height('50%') let Rectangle = this.getcomponentRect("ArkUX_Get_component_0010")
}.width(200).height(200) 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
...@@ -58,14 +58,26 @@ export default function ActsgetcomponentTest() { ...@@ -58,14 +58,26 @@ export default function ActsgetcomponentTest() {
console.info('ArkUX_Get_component_0010 START'); console.info('ArkUX_Get_component_0010 START');
setTimeout(()=>{ setTimeout(()=>{
try{ try{
let strJson = Utils.getComponentRect('ArkUX_Get_component_0010'); let strJson = getInspectorByKey('ArkUX_Get_component_0010');
expect(parseInt(strJson.width)).assertEqual(vp2px(100)); let obj = JSON.parse(strJson);
expect(parseInt(strJson.height)).assertEqual(vp2px(100)); console.info('ArkUX_Get_component_0010 width: '+ JSON.stringify(obj.width));
expect(parseInt(strJson.localOffsetY)).assertEqual(30); console.info('ArkUX_Get_component_0010 height: '+ JSON.stringify(obj.height));
expect(parseInt(strJson.windowOffsetX)).assertEqual(234); console.info('ArkUX_Get_component_0010 localOffsetX: '+ JSON.stringify(obj.localOffsetX));
expect(parseInt(strJson.windowOffsetY)).assertEqual(102); console.info('ArkUX_Get_component_0010 localOffsetY: '+ JSON.stringify(obj.localOffsetY));
expect(parseInt(strJson.screenOffsetX)).assertEqual(234); console.info('ArkUX_Get_component_0010 windowOffsetX: '+ JSON.stringify(obj.windowOffsetX));
expect(parseInt(strJson.screenOffsetY)).assertEqual(234); 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 '); console.info('ArkUX_Get_component_0010 END ');
} catch(err) { } catch(err) {
expect().assertFail() expect().assertFail()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册