您的位置:首页 > 移动开发 > Android开发

Android自动测试之MonkeyRunner之MonkeyImage

2011-10-24 10:32 330 查看
monkeyrunner类可以保存设备或模拟器的截图。MonkeyImage提供了图像转换、图像存储、复制部分图像能方法。这样可以把通过截图显性的观察问题。

MonkeyImage创建对象的方法如下:

newimage =MonkeyDevice.takeSnapshot()

MonkeyImage提供了如下方法:



Methods
stringconvertToBytes (string format)
Converts the current image to a particular format and returns it as a string that you can then access as an
iterable of binary bytes.
tuplegetRawPixel (integer x, integer
y)
Returns the single pixel at the image location (x,y), as an atuple of
integer, in the form (a,r,g,b).
integergetRawPixelInt (integer x, integer
y)
Returns the single pixel at the image location (x,y), as a 32-bitinteger.

MonkeyImage
getSubImage (tuple rect)
Creates a new
MonkeyImage
object from a rectangular selection of the current image.
booleansameAs (
MonkeyImage

other, float percent)
Compares this
MonkeyImage
object to another and returns the result of the comparison. The
percent
argument specifies the percentage difference that is allowed for
the two images to be "equal".
voidwriteToFile (string path, string
format)
Writes the current image to the file specified by
filename
, in the format specified by
format
.
http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html




/**

* @author 张兴业

* 邮箱:xy-zhang@163.com

* qq:363302850

*

*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: