未验证 提交 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 @@
* 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
......@@ -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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册