Android自动测试之MonkeyRunner之MonkeyDevice

MonkeyDevice是 用来控制 Android设备 或模拟器, 发送 UI事件 的 方法 , 检索信息 , 安装和 删除应用程序, 并可以运行应用程序 。

       通常 , 不必使用newdevice = MonkeyDevice()来 创建 MonkeyDevice 的 一个 实例 。 相反的经常 使用 MonkeyRunner.waitForConnection ()来创建 一个新的MonkeyDevice对象 。

MonkeyDevice的常用方法:

Summary

Constants
string        DOWN                  Use this with the type argument of               press() ortouch()                to send a DOWN event.           
stringUP                  Use this with the type argument of               press() ortouch()                to send an UP event.           
stringDOWN_AND_UP                  Use this with the type argument of               press() ortouch()                to send a DOWN event    immediately followed by an UP event.           
Methods
                void            broadcastIntent                (string uri,               string action,                string data,                string mimetype,               iterable categories                dictionary extras,               component component,                iterable flags)           
                Broadcasts an Intent to this device, as if the Intent were coming from an                application.           
                void            drag                (tuple start,               tuple end,                float duration,                integer steps)           
                Simulates a drag gesture (touch, hold, and move) on this device's screen.           
objectgetProperty                (string key)           
                Given the name of a system environment variable, returns its value for this device.                The available variable names are listed in the                 detailed description of this method.           
objectgetSystemProperty                (string key)           
.               The API equivalent of adb shell getprop <key>. This is provided for use                by platform developers.           
                void            installPackage                (string path)           
                Installs the Android application or test package contained in packageFile onto this                device. If the application or test package is already installed, it is replaced.           
dictionaryinstrument                (string className,               dictionary args)           
                Runs the specified component under Android instrumentation, and returns the results                in a dictionary whose exact format is dictated by the component being run. The                component must already be present on this device.           
                void            press                (string name,               dictionary type)           
                Sends the key event specified by type to the key specified by                keycode.           
                void            reboot                (string into)           
                Reboots this device into the bootloader specified by bootloadType.           
                void            removePackage                (string package)           
                Deletes the specified package from this device, including its data and cache.           
objectshell                (string cmd)           
                Executes an adb shell command and returns the result, if any.           
                void            startActivity                (string uri,               string action,                string data,                string mimetype,               iterable categories                dictionary extras,               component component,                flags)           
                Starts an Activity on this device by sending an Intent constructed from the                supplied arguments.           
                        MonkeyImage                   takeSnapshot()               
                Captures the entire screen buffer of this device, yielding a                                        MonkeyImage               object containing a screen capture of the current display.           
                void            touch               (integer x,                integer y,                 integer type)           
                Sends a touch event specified by type to the screen location specified                by x and y.           
                void            type                   (string message)           
                Sends the characters contained in message to this device, as if they                had been typed on the device's keyboard. This is equivalent to calling                press() for each keycode in message                using the key event type DOWN_AND_UP.           
                void            wake                   ()           
                Wakes the screen of this device.           

http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html

 

/**
* @author 张兴业
* 邮箱:xy-zhang@163.com
* qq:363302850
*
*/

 

转载于:https://www.cnblogs.com/xyzlmn/archive/2011/10/24/3168415.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值