`
jinvasshole
  • 浏览: 771523 次
文章分类
社区版块
存档分类
最新评论

Android自动测试之MonkeyRunner之MonkeyImage

 
阅读更多

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

MonkeyImage创建对象的方法如下:

newimage =MonkeyDevice.takeSnapshot()

MonkeyImage提供了如下方法:

Methods
<nobr><em>string</em></nobr> <nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html#convertToBytes" target="_blank">convertToBytes</a></span> (<em>string</em> format)</nobr>
Converts the current image to a particular format and returns it as astring that you can then access as an iterable of binary bytes.
<nobr><em>tuple</em></nobr> <nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html#getRawPixel" target="_blank">getRawPixel</a></span> (<em>integer</em> x,<em>integer</em> y) </nobr>
Returns the single pixel at the image location (x,y), as an atuple of integer, in the form (a,r,g,b).
<nobr><em>integer</em></nobr> <nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html#getRawPixelInt" target="_blank">getRawPixelInt</a></span> (<em>integer</em> x,<em>integer</em> y) </nobr>
Returns the single pixel at the image location (x,y), as a 32-bitinteger.
<nobr><code><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html" target="_blank">MonkeyImage</a></code></nobr> <nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html#getSubImage" target="_blank">getSubImage</a></span> (<em>tuple</em> rect)</nobr>
Creates a new MonkeyImage object from a rectangular selection of the current image.
<nobr><em>boolean</em></nobr> <nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html#sameAs" target="_blank">sameAs</a></span> (<code><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html" target="_blank">MonkeyImage</a></code> other, <em>float</em> percent) </nobr>
Compares this MonkeyImage object to another and returns the result of the comparison. Thepercent argument specifies the percentage difference that is allowed for the two images to be "equal".
<nobr><em>void</em></nobr> <nobr><span class="sympad"><a href="http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyImage.html#writeToFile" target="_blank">writeToFile</a></span> (<em>string</em> path,<em>string</em> format) </nobr>
Writes the current image to the file specified byfilename, in the format specified by format.

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

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics