device.touch()不为Gallery应用程序正常工作 [英] device.touch() is not working properly for Gallery application

查看:289
本文介绍了device.touch()不为Gallery应用程序正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个脚本来测试安卓4.0.4库的应用程序。使用monkeyrunner。但是,当我送触摸事件的任何专辑它会选择专辑,而不是打开它。
低于code是Andorid的View客户端:

I am creating a script to test gallery app of android 4.0.4. using monkeyrunner. But when I am sending touch event to any album it gets selects the album instead opening it. below code is for Andorid View client :

vc=ViewClient(device,serialNo)
firstAlbum = vc.findViewById('id/no_id/1')
firstAlbum.touch(MonkeyDevice.DOWN_AND_UP)

低于code为实现使用monkeydevice触摸事件。

below code is implement using monkeydevice touch event.

device.touch(x,y,MonkeyDevice.DOWN_AND_UP)


推荐答案

MonkeyRunner的这个限制,它不能处理非交互式项目。对于这个问题的错误已被记录在谷歌群体的http:/ /$c$c.google.com/p/android/issues/detail?id=19452

this the limitation of the MonkeyRunner , that it can not handle non interactive items. For this issue bug has been logged in the google groups http://code.google.com/p/android/issues/detail?id=19452

我可以通过其中包含以下命令的脚本打开相册:

I am able to open the album by making a script which contains the following commands:

adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 2 0 -1000
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 2 1 -1000
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 2 0 500
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 2 1 500
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 2 0 80
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 2 1 80
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 1 272 1
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 1 272 0
adb shell sendevent /dev/input/event2 0 0 0

您monkeyrunner应该脚本中包含运行您的画廊活动后以下行:

your monkeyrunner script should contains the following lines after running your gallery activity:

try:
    subprocess.Popen(['bash', '-c', '. .Script_name.sh'])     
except:
    raise Exception('Could not open the File: script_name.sh')

这篇关于device.touch()不为Gallery应用程序正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆