DO NOT MERGE: Doc Change: Documentation for MonkeyRunner tool
Change-Id: I049c5f70c47077c51fefbae32633592e80068df2
This commit is contained in:
1353
docs/html/guide/developing/tools/MonkeyDevice.jd
Normal file
1353
docs/html/guide/developing/tools/MonkeyDevice.jd
Normal file
File diff suppressed because it is too large
Load Diff
435
docs/html/guide/developing/tools/MonkeyImage.jd
Normal file
435
docs/html/guide/developing/tools/MonkeyImage.jd
Normal file
@ -0,0 +1,435 @@
|
||||
page.title=MonkeyImage
|
||||
@jd:body
|
||||
<style>
|
||||
h4.jd-details-title {background-color: #DEE8F1;}
|
||||
</style>
|
||||
|
||||
<p>
|
||||
A monkeyrunner class to hold an image of the device or emulator's screen. The image is
|
||||
copied from the screen buffer during a screenshot. This object's methods allow you to
|
||||
convert the image into various storage formats, write the image to a file, copy parts of
|
||||
the image, and compare this object to other <code>MonkeyImage</code> objects.
|
||||
</p>
|
||||
<p>
|
||||
You do not need to create new instances of <code>MonkeyImage</code>. Instead, use
|
||||
<code><a href="{@docRoot}guide/developing/tools/MonkeyDevice.html#takeSnapshot">
|
||||
MonkeyDevice.takeSnapshot()</a></code> to create a new instance from a screenshot. For example, use:
|
||||
</p>
|
||||
<pre>
|
||||
newimage = MonkeyDevice.takeSnapshot()
|
||||
</pre>
|
||||
<h2>Summary</h2>
|
||||
<table id="pubmethods" class="jd-sumtable">
|
||||
<tr>
|
||||
<th colspan="12" style="background-color: #E2E2E2">Methods</th>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<em>string</em>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#convertToBytes">convertToBytes</a>
|
||||
</span>
|
||||
(<em>string</em> format)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Converts the current image to a particular format and returns it as a
|
||||
<em>string</em> that you can then access as an <em>iterable</em> of binary bytes.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<em>tuple</em>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#getRawPixel">getRawPixel</a>
|
||||
</span>
|
||||
(<em>integer</em> x,
|
||||
<em>integer</em> y)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Returns the single pixel at the image location (x,y), as an
|
||||
a <em>tuple</em> of <em>integer</em>, in the form (a,r,g,b).
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<em>integer</em>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#getRawPixelInt">getRawPixelInt</a>
|
||||
</span>
|
||||
(<em>integer</em> x,
|
||||
<em>integer</em> y)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Returns the single pixel at the image location (x,y), as
|
||||
a 32-bit <em>integer</em>.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<code>
|
||||
<a href="{@docRoot}guide/developing/tools/MonkeyImage.html">MonkeyImage</a>
|
||||
</code>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#getSubImage">getSubImage</a>
|
||||
</span>
|
||||
(<em>tuple</em> rect)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Creates a new <code>MonkeyImage</code> object from a rectangular selection of the
|
||||
current image.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<em>boolean</em>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#sameAs">sameAs</a>
|
||||
</span>
|
||||
(<code><a href="{@docRoot}guide/developing/tools/MonkeyImage.html">MonkeyImage</a></code>
|
||||
other,
|
||||
<em>float</em> percent)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Compares this <code>MonkeyImage</code> object to another and returns the result of
|
||||
the comparison. The <code>percent</code> argument specifies the percentage
|
||||
difference that is allowed for the two images to be "equal".
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<em>void</em>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#writeToFile">writeToFile</a>
|
||||
</span>
|
||||
(<em>string</em> path,
|
||||
<em>string</em> format)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Writes the current image to the file specified by <code>filename</code>, in the
|
||||
format specified by <code>format</code>.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- ========= METHOD DETAIL ======== -->
|
||||
<!-- Public methods -->
|
||||
<h2>Public Methods</h2>
|
||||
<A NAME="convertToBytes"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<em>string</em>
|
||||
</span>
|
||||
<span class="sympad">convertToBytes</span>
|
||||
<span class="normal">
|
||||
(
|
||||
<em>string</em> format)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Converts the current image to a particular format and returns it as a <em>string</em>
|
||||
that you can then access as an <em>iterable</em> of binary bytes.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>format</th>
|
||||
<td>
|
||||
The desired output format. All of the common raster output formats are supported.
|
||||
The default value is "png" (Portable Network Graphics).
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="getRawPixel"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<em>tuple</em>
|
||||
</span>
|
||||
<span class="sympad">getRawPixel</span>
|
||||
<span class="normal">
|
||||
(<em>integer</em> x,
|
||||
<em>integer</em> y)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Returns the single pixel at the image location (x,y), as an
|
||||
a <em>tuple</em> of <em>integer</em>, in the form (a,r,g,b).
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>x</th>
|
||||
<td>
|
||||
The horizontal position of the pixel, starting with 0 at the left of the screen in the
|
||||
orientation it had when the screenshot was taken.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>y</th>
|
||||
<td>
|
||||
The vertical position of the pixel, starting with 0 at the top of the screen in the
|
||||
orientation it had when the screenshot was taken.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Returns</h5>
|
||||
<ul class="nolist">
|
||||
<li>
|
||||
A tuple of integers representing the pixel, in the form (a,r,g,b) where
|
||||
a is the alpha channel value, and r, g, and b are the red, green, and blue values,
|
||||
respectively.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="getRawPixelInt"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<em>tuple</em>
|
||||
</span>
|
||||
<span class="sympad">getRawPixelInt</span>
|
||||
<span class="normal">
|
||||
(<em>integer</em> x,
|
||||
<em>integer</em> y)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Returns the single pixel at the image location (x,y), as an
|
||||
an <em>integer</em>. Use this method to economize on memory.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>x</th>
|
||||
<td>
|
||||
The horizontal position of the pixel, starting with 0 at the left of the screen in the
|
||||
orientation it had when the screenshot was taken.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>y</th>
|
||||
<td>
|
||||
The vertical position of the pixel, starting with 0 at the top of the screen in the
|
||||
orientation it had when the screenshot was taken.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Returns</h5>
|
||||
<ul class="nolist">
|
||||
<li>
|
||||
The a,r,g, and b values of the pixel as 8-bit values combined into a 32-bit
|
||||
integer, with a as the leftmost 8 bits, r the next rightmost, and so forth.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="getSubImage"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<code>
|
||||
<a href="{@docRoot}guide/developing/tools/MonkeyImage.html">MonkeyImage</a>
|
||||
</code>
|
||||
</span>
|
||||
<span class="sympad">getSubImage</span>
|
||||
<span class="normal">
|
||||
(<em>tuple</em> rect)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Creates a new <code>MonkeyImage</code> object from a rectangular selection of the
|
||||
current image.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>rect</th>
|
||||
<td>
|
||||
A tuple (x, y, w, h) specifying the selection. x and y specify the 0-based pixel
|
||||
position of the upper left-hand corner of the selection. w specifies the width of the
|
||||
region, and h specifies its height, both in units of pixels.
|
||||
<p>
|
||||
The image's orientation is the same as the screen orientation at the time the
|
||||
screenshot was made.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Returns</h5>
|
||||
<ul class="nolist">
|
||||
<li>
|
||||
A new <code>MonkeyImage</code> object containing the selection.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="sameAs"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<em>boolean</em>
|
||||
</span>
|
||||
<span class="sympad">sameAs</span>
|
||||
<span class="normal">
|
||||
(
|
||||
<code>
|
||||
<a href="{@docRoot}guide/developing/tools/MonkeyImage.html">MonkeyImage</a>
|
||||
</code> otherImage,
|
||||
<em>float</em> percent
|
||||
)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Compares this <code>MonkeyImage</code> object to another and returns the result of
|
||||
the comparison. The <code>percent</code> argument specifies the percentage
|
||||
difference that is allowed for the two images to be "equal".
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>other</th>
|
||||
<td>
|
||||
Another <code>MonkeyImage</code> object to compare to this one.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
percent
|
||||
</th>
|
||||
<td>
|
||||
A float in the range 0.0 to 1.0, inclusive, indicating
|
||||
the percentage of pixels that need to be the same for the method to return
|
||||
<code>true</code>. The default is 1.0, indicating that all the pixels
|
||||
must match.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Returns</h5>
|
||||
<ul class="nolist">
|
||||
<li>
|
||||
Boolean <code>true</code> if the images match, or boolean <code>false</code> otherwise.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="writeToFile"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
void
|
||||
</span>
|
||||
<span class="sympad">writeToFile</span>
|
||||
<span class="normal">
|
||||
(<em>string</em> filename,
|
||||
<em>string</em> format)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Writes the current image to the file specified by <code>filename</code>, in the
|
||||
format specified by <code>format</code>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>path</th>
|
||||
<td>
|
||||
The fully-qualified filename and extension of the output file.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
format
|
||||
</th>
|
||||
<td>
|
||||
The output format to use for the file. If no format is provided, then the
|
||||
method tries to guess the format from the filename's extension. If no
|
||||
extension is provided and no format is specified, then the default format of
|
||||
"png" (Portable Network Graphics) is used.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
445
docs/html/guide/developing/tools/MonkeyRunner.jd
Normal file
445
docs/html/guide/developing/tools/MonkeyRunner.jd
Normal file
@ -0,0 +1,445 @@
|
||||
page.title=MonkeyRunner
|
||||
@jd:body
|
||||
<style>
|
||||
h4.jd-details-title {background-color: #DEE8F1;}
|
||||
</style>
|
||||
<p>
|
||||
A monkeyrunner class that contains static utility methods.
|
||||
</p>
|
||||
<h2>Summary</h2>
|
||||
<table id="pubmethods" class="jd-sumtable">
|
||||
<tr>
|
||||
<th colspan="12" style="background-color: #E2E2E2">Methods</th>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
void
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#alert">alert</a>
|
||||
</span>
|
||||
(<em>string</em> message,
|
||||
<em>string</em> title,
|
||||
<em>string</em> okTitle)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Displays an alert dialog to the process running the current
|
||||
program.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<em>integer</em>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#choice">choice</a>
|
||||
</span>
|
||||
(<em>string</em> message,
|
||||
<em>iterable</em> choices,
|
||||
<em>string</em> title)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Displays a dialog with a list of choices to the process running the current program.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
void
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#help">help</a>
|
||||
</span>
|
||||
(<em>string</em> format)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Displays the monkeyrunner API reference in a style similar to that of Python's
|
||||
<code>pydoc</code> tool, using the specified format.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<em>string</em>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#input">input</a>
|
||||
</span>
|
||||
(<em>string</em> message,
|
||||
<em>string</em> initialValue,
|
||||
<em>string</em> title,
|
||||
<em>string</em> okTitle,
|
||||
<em>string</em> cancelTitle)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Displays a dialog that accepts input.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
void
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#sleep">sleep</a>
|
||||
</span>
|
||||
(<em>float</em> seconds)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Pauses the current program for the specified number of seconds.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="api" >
|
||||
<td class="jd-typecol">
|
||||
<nobr>
|
||||
<code>
|
||||
<a href="{@docRoot}guide/developing/tools/MonkeyDevice.html">MonkeyDevice</a>
|
||||
</code>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class="jd-linkcol" width="100%">
|
||||
<nobr>
|
||||
<span class="sympad">
|
||||
<a href="#waitForConnection">waitForConnection</a>
|
||||
</span>
|
||||
(<em>float</em> timeout,
|
||||
<em>string</em> deviceId)
|
||||
</nobr>
|
||||
<div class="jd-descrdiv">
|
||||
Tries to make a connection between the <code>monkeyrunner</code> backend and the
|
||||
specified device or emulator.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- ========= METHOD DETAIL ======== -->
|
||||
<!-- Public methods -->
|
||||
<h2>Public Methods</h2>
|
||||
<A NAME="alert"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<em>string</em>
|
||||
</span>
|
||||
<span class="sympad">alert</span>
|
||||
<span class="normal">
|
||||
(
|
||||
<em>string</em> message,
|
||||
<em>string</em> title,
|
||||
<em>string</em> okTitle)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Displays an alert dialog to the process running the current
|
||||
program. The dialog is modal, so the program pauses until the user clicks the dialog's
|
||||
button.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>message</th>
|
||||
<td>
|
||||
The message to display in the dialog.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>title</th>
|
||||
<td>
|
||||
The dialog's title. The default value is "Alert".
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>okTitle</th>
|
||||
<td>
|
||||
The text displayed in the dialog button. The default value is "OK".
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="choice"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<em>integer</em>
|
||||
</span>
|
||||
<span class="sympad">choice</span>
|
||||
<span class="normal">
|
||||
(<em>string</em> message,
|
||||
<em>iterable</em> choices,
|
||||
<em>string</em> title)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Displays a dialog with a list of choices to the process running the current program. The
|
||||
dialog is modal, so the program pauses until the user clicks one of the dialog's
|
||||
buttons.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>message</th>
|
||||
<td>
|
||||
The prompt message displayed in the dialog.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>choices</th>
|
||||
<td>
|
||||
A Python iterable containing one or more objects that are displayed as strings. The
|
||||
recommended form is an array of strings.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
title
|
||||
</th>
|
||||
<td>
|
||||
The dialog's title. The default is "Input".
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Returns</h5>
|
||||
<ul class="nolist">
|
||||
<li>
|
||||
If the user makes a selection and clicks the "OK" button, the method returns
|
||||
the 0-based index of the selection within the iterable.
|
||||
If the user clicks the "Cancel" button, the method returns -1.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="help"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
void
|
||||
</span>
|
||||
<span class="sympad">help</span>
|
||||
<span class="normal">
|
||||
(<em>string</em> format)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Displays the monkeyrunner API reference in a style similar to that of Python's
|
||||
<code>pydoc</code> tool, using the specified format.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>format</th>
|
||||
<td>
|
||||
The markup format to use in the output. The possible values are "text" for plain text
|
||||
or "html" for HTML.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="input"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<em>string</em>
|
||||
</span>
|
||||
<span class="sympad">input</span>
|
||||
<span class="normal">
|
||||
(<em>string</em> message
|
||||
<em>string</em> initialValue,
|
||||
<em>string</em> title,
|
||||
<em>string</em> okTitle,
|
||||
<em>string</em> cancelTitle)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Displays a dialog that accepts input and returns it to the program. The dialog is
|
||||
modal, so the program pauses until the user clicks one of the dialog's buttons.
|
||||
</p>
|
||||
<p>
|
||||
The dialog contains two buttons, one of which displays the okTitle value
|
||||
and the other the cancelTitle value. If the user clicks the okTitle button,
|
||||
the current value of the input box is returned. If the user clicks the cancelTitle
|
||||
button, an empty string is returned.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>message</th>
|
||||
<td>
|
||||
The prompt message displayed in the dialog.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>initialValue</th>
|
||||
<td>
|
||||
The initial value to display in the dialog. The default is an empty string.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>title</th>
|
||||
<td>
|
||||
The dialog's title. The default is "Input".
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>okTitle</th>
|
||||
<td>
|
||||
The text displayed in the okTitle button. The default is "OK".
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>cancelTitle</th>
|
||||
<td>
|
||||
The text displayed in the cancelTitle button. The default is "Cancel".
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Returns</h5>
|
||||
<ul class="nolist">
|
||||
<li>
|
||||
If the user clicks the okTitle button, then the method returns the current value of
|
||||
the dialog's input box. If the user clicks the cancelTitle button, the method returns
|
||||
an empty string.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="sleep"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
void
|
||||
</span>
|
||||
<span class="sympad">sleep</span>
|
||||
<span class="normal">
|
||||
(
|
||||
<em>float</em> seconds
|
||||
)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Pauses the current program for the specified number of seconds.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>seconds</th>
|
||||
<td>
|
||||
The number of seconds to pause.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A NAME="waitForConnection"></A>
|
||||
<div class="jd-details api ">
|
||||
<h4 class="jd-details-title">
|
||||
<span class="normal">
|
||||
<code>
|
||||
<a href="{@docRoot}guide/developing/tools/MonkeyDevice.html">MonkeyDevice</a>
|
||||
</code>
|
||||
</span>
|
||||
<span class="sympad">waitForConnection</span>
|
||||
<span class="normal">
|
||||
(<em>float</em> timeout,
|
||||
<em>string</em> deviceId)
|
||||
</span>
|
||||
</h4>
|
||||
<div class="jd-details-descr">
|
||||
|
||||
<div class="jd-tagdata jd-tagdescr">
|
||||
<p>
|
||||
Tries to make a connection between the <code>monkeyrunner</code> backend and the
|
||||
specified device or emulator.
|
||||
</p>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Arguments</h5>
|
||||
<table class="jd-tagtable">
|
||||
<tr>
|
||||
<th>timeout</th>
|
||||
<td>
|
||||
The number of seconds to wait for a connection. The default is to wait forever.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
deviceId
|
||||
</th>
|
||||
<td>
|
||||
A regular expression that specifies the serial number of the device or emulator. See
|
||||
the topic
|
||||
<a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a>
|
||||
for a description of device and emulator serial numbers.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="jd-tagdata">
|
||||
<h5 class="jd-tagtitle">Returns</h5>
|
||||
<ul class="nolist">
|
||||
<li>
|
||||
A <code><a href="{@docRoot}guide/developing/tools/MonkeyDevice.html">MonkeyDevice</a></code>
|
||||
instance for the device or emulator. Use this object to control and communicate with the
|
||||
device or emulator.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -3,27 +3,27 @@ page.title=Tools Overview
|
||||
|
||||
<img src="{@docRoot}assets/images/android_wrench.png" alt="" align="right">
|
||||
|
||||
<p>The Android SDK includes a variety of custom tools that help you develop mobile
|
||||
applications on the Android platform. The most important of these are the Android
|
||||
Emulator and the Android Development Tools plugin for Eclipse, but the SDK also
|
||||
includes a variety of other tools for debugging, packaging, and installing your
|
||||
<p>The Android SDK includes a variety of custom tools that help you develop mobile
|
||||
applications on the Android platform. The most important of these are the Android
|
||||
Emulator and the Android Development Tools plugin for Eclipse, but the SDK also
|
||||
includes a variety of other tools for debugging, packaging, and installing your
|
||||
applications on the emulator. </p>
|
||||
|
||||
|
||||
<dl>
|
||||
<dt><a href="adt.html">Android Development Tools Plugin</a> (for the Eclipse IDE)</dt>
|
||||
<dd>The ADT plugin adds powerful extensions to the Eclipse integrated environment,
|
||||
making creating and debugging your Android applications easier and faster. If you
|
||||
use Eclipse, the ADT plugin gives you an incredible boost in developing Android
|
||||
<dd>The ADT plugin adds powerful extensions to the Eclipse integrated environment,
|
||||
making creating and debugging your Android applications easier and faster. If you
|
||||
use Eclipse, the ADT plugin gives you an incredible boost in developing Android
|
||||
applications.</dd>
|
||||
<dt><a href="emulator.html">Android Emulator</a></dt>
|
||||
<dd>A QEMU-based device-emulation tool that you can use to design,
|
||||
<dd>A QEMU-based device-emulation tool that you can use to design,
|
||||
debug, and test your applications in an actual Android run-time environment. </dd>
|
||||
|
||||
<dt><a href="avd.html">Android Virtual Devices (AVDs)</a></dt>
|
||||
<dd>Virtual device configurations that you create, to model device
|
||||
characteristics in the Android Emulator. In each configuration, you can
|
||||
specify the Android platform to run, the hardware options, and the
|
||||
emulator skin to use. Each AVD functions as an independent device with
|
||||
emulator skin to use. Each AVD functions as an independent device with
|
||||
it's own storage for user data, SD card, and so on. </dd>
|
||||
|
||||
<dt><a href="hierarchy-viewer.html">Hierarchy Viewer</a></dt>
|
||||
@ -37,53 +37,53 @@ applications on the emulator. </p>
|
||||
efficiency.
|
||||
</dd>
|
||||
|
||||
<dt><a href="draw9patch.html">Draw 9-patch</a></dt>
|
||||
<dd>The Draw 9-patch tool allows you to easily create a
|
||||
{@link android.graphics.NinePatch} graphic using a WYSIWYG editor. It also previews stretched
|
||||
versions of the image, and highlights the area in which content is allowed.
|
||||
</dd>
|
||||
<dt><a href="draw9patch.html">Draw 9-patch</a></dt>
|
||||
<dd>The Draw 9-patch tool allows you to easily create a
|
||||
{@link android.graphics.NinePatch} graphic using a WYSIWYG editor. It also previews stretched
|
||||
versions of the image, and highlights the area in which content is allowed.
|
||||
</dd>
|
||||
|
||||
<dt><a href="ddms.html" >Dalvik Debug Monitor
|
||||
<dt><a href="ddms.html" >Dalvik Debug Monitor
|
||||
Service</a> (ddms)</dt>
|
||||
<dd>Integrated with Dalvik, the Android platform's custom VM, this tool
|
||||
lets you manage processes on an emulator or device and assists in debugging.
|
||||
You can use it to kill processes, select a specific process to debug,
|
||||
generate trace data, view heap and thread information, take screenshots
|
||||
of the emulator or device, and more. </dd>
|
||||
|
||||
<dd>Integrated with Dalvik, the Android platform's custom VM, this tool
|
||||
lets you manage processes on an emulator or device and assists in debugging.
|
||||
You can use it to kill processes, select a specific process to debug,
|
||||
generate trace data, view heap and thread information, take screenshots
|
||||
of the emulator or device, and more. </dd>
|
||||
|
||||
<dt><a href="adb.html" >Android Debug Bridge</a> (adb)</dt>
|
||||
<dd>The adb tool lets you install your application's .apk files on an
|
||||
emulator or device and access the emulator or device from a command line.
|
||||
You can also use it to link a standard debugger to application code running
|
||||
<dd>The adb tool lets you install your application's .apk files on an
|
||||
emulator or device and access the emulator or device from a command line.
|
||||
You can also use it to link a standard debugger to application code running
|
||||
on an Android emulator or device.</dd>
|
||||
|
||||
<dt><a href="aapt.html">Android Asset
|
||||
<dt><a href="aapt.html">Android Asset
|
||||
Packaging Tool</a> (aapt)</dt>
|
||||
<dd>The aapt tool lets you create .apk files containing the binaries and
|
||||
<dd>The aapt tool lets you create .apk files containing the binaries and
|
||||
resources of Android applications.</dd>
|
||||
|
||||
<dt><a href="aidl.html" >Android Interface
|
||||
<dt><a href="aidl.html" >Android Interface
|
||||
Description Language</a> (aidl)</dt>
|
||||
<dd>Lets you generate code for an interprocess interface, such as what
|
||||
a service might use.</dd>
|
||||
|
||||
<dt><a href="adb.html#sqlite">sqlite3</a></dt>
|
||||
<dd>Included as a convenience, this tool lets you access the SQLite data
|
||||
<dd>Included as a convenience, this tool lets you access the SQLite data
|
||||
files created and used by Android applications.</dd>
|
||||
|
||||
<dt><a href="traceview.html" >Traceview</a></dt>
|
||||
<dd> This tool produces graphical analysis views of trace log data that you
|
||||
<dd> This tool produces graphical analysis views of trace log data that you
|
||||
can generate from your Android application. </dd>
|
||||
|
||||
<dt><a href="othertools.html#mksdcard">mksdcard</a></dt>
|
||||
<dd>Helps you create a disk image that you can use with the emulator,
|
||||
<dd>Helps you create a disk image that you can use with the emulator,
|
||||
to simulate the presence of an external storage card (such as an SD card).</dd>
|
||||
|
||||
<dt><a href="othertools.html#dx">dx</a></dt>
|
||||
<dd>The dx tool rewrites .class bytecode into Android bytecode
|
||||
<dd>The dx tool rewrites .class bytecode into Android bytecode
|
||||
(stored in .dex files.)</dd>
|
||||
|
||||
<dt><a href="monkey.html">UI/Application
|
||||
<dt><a href="monkey.html">UI/Application
|
||||
Exerciser Monkey</a></dt>
|
||||
<dd>The Monkey is a program that runs on your emulator or device and generates pseudo-random
|
||||
streams of user events such as clicks, touches, or gestures, as well as a number of system-
|
||||
@ -92,9 +92,9 @@ efficiency.
|
||||
|
||||
<dt><a href="othertools.html#android">android</a></dt>
|
||||
<dd>A script that lets you manage AVDs and generate <a
|
||||
href="http://ant.apache.org/" title="Ant">Ant</a> build files that
|
||||
href="http://ant.apache.org/" title="Ant">Ant</a> build files that
|
||||
you can use to compile your Android applications. </dd>
|
||||
|
||||
|
||||
<dt><a href="zipalign.html">zipalign</a></dt>
|
||||
<dd>An important .apk optimization tool. This tool ensures that all uncompressed data starts
|
||||
with a particular alignment relative to the start of the file. This should always be used
|
||||
|
308
docs/html/guide/developing/tools/monkeyrunner_concepts.jd
Normal file
308
docs/html/guide/developing/tools/monkeyrunner_concepts.jd
Normal file
@ -0,0 +1,308 @@
|
||||
page.title=monkeyrunner
|
||||
@jd:body
|
||||
|
||||
<div id="qv-wrapper">
|
||||
<div id="qv">
|
||||
<h2>In this document</h2>
|
||||
<ol>
|
||||
<li>
|
||||
<a href="#SampleProgram">A Simple monkeyrunner Program</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#APIClasses">The monkeyrunner API</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#RunningMonkeyRunner">Running monkeyrunner</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#Help">monkeyrunner Built-in Help</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#Plugins">Extending monkeyrunner with Plugins</a>
|
||||
</li>
|
||||
</ol>
|
||||
<h2>See Also</h2>
|
||||
<ol>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/testing/testing_android.html">Testing Fundamentals</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
The monkeyrunner tool provides an API for writing programs that control an Android device
|
||||
or emulator from outside of Android code. With monkeyrunner, you can write a Python program
|
||||
that installs an Android application or test package, runs it, sends keystrokes to it,
|
||||
takes screenshots of its user interface, and stores screenshots on the workstation. The
|
||||
monkeyrunner tool is primarily designed to test applications and devices at the
|
||||
functional/framework level and for running unit test suites, but you are free to use it for
|
||||
other purposes.
|
||||
</p>
|
||||
<p>
|
||||
The monkeyrunner tool is not related to the
|
||||
<a href="{@docRoot}guide/developing/tools/monkey.html">UI/Application Exerciser Monkey</a>,
|
||||
also known as the <code>monkey</code> tool. The <code>monkey</code> tool runs in an
|
||||
<code><a href="{@docRoot}guide/developing/tools/adb.html">adb</a></code> shell directly on the
|
||||
device or emulator and generates pseudo-random streams of user and system events. In comparison,
|
||||
the monkeyrunner tool controls devices and emulators from a workstation by sending specific
|
||||
commands and events from an API.
|
||||
</p>
|
||||
<p>
|
||||
The monkeyrunner tool provides these unique features for Android testing:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Multiple device control: The monkeyrunner API can apply one or more
|
||||
test suites across multiple devices or emulators. You can physically attach all the devices
|
||||
or start up all the emulators (or both) at once, connect to each one in turn
|
||||
programmatically, and then run one or more tests. You can also start up an emulator
|
||||
configuration programmatically, run one or more tests, and then shut down the emulator.
|
||||
</li>
|
||||
<li>
|
||||
Functional testing: monkeyrunner can run an automated start-to-finish test of an Android
|
||||
application. You provide input values with keystrokes or touch events, and view the results
|
||||
as screenshots.
|
||||
</li>
|
||||
<li>
|
||||
Regression testing - monkeyrunner can test application stability by running an application
|
||||
and comparing its output screenshots to a set of screenshots that are known to be correct.
|
||||
</li>
|
||||
<li>
|
||||
Extensible automation - Since monkeyrunner is an API toolkit, you can develop an entire
|
||||
system of Python-based modules and programs for controlling Android devices. Besides using
|
||||
the monkeyrunner API itself, you can use the standard Python
|
||||
<code><a href="http://docs.python.org/library/os.html">os</a></code> and
|
||||
<code><a href="http://docs.python.org/library/subprocess.html">subprocess</a></code>
|
||||
modules to call Android tools such as
|
||||
<a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a>.
|
||||
<p>
|
||||
You can also add your own classes to the monkeyrunner API. This is described
|
||||
in more detail in the section
|
||||
<a href="#Plugins">Extending monkeyrunner with plugins</a>.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
The monkeyrunner tool uses <a href="http://www.jython.org/">Jython</a>, a
|
||||
implementation of Python that uses the Java programming language. Jython allows the
|
||||
monkeyrunner API to interact easily with the Android framework. With Jython you can
|
||||
use Python syntax to access the constants, classes, and methods of the API.
|
||||
</p>
|
||||
|
||||
<h2 id="SampleProgram">A Simple monkeyrunner Program</h2>
|
||||
<p>
|
||||
Here is a simple monkeyrunner program that connects to a device, creating a
|
||||
<code><a href="{@docRoot}guide/developing/tools/MonkeyDevice.html">MonkeyDevice</a></code>
|
||||
object. Using the <code>MonkeyDevice</code> object, the program installs an Android application
|
||||
package, runs one of its activities, and sends key events to the activity.
|
||||
The program then takes a screenshot of the result, creating a
|
||||
<code><a href="{@docRoot}guide/developing/tools/MonkeyImage.html">MonkeyImage</a></code> object.
|
||||
From this object, the program writes out a <code>.png</code> file containing the screenshot.
|
||||
</p>
|
||||
<pre>
|
||||
# Imports the monkeyrunner modules used by this program
|
||||
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
|
||||
|
||||
# Connects to the current device, returning a MonkeyDevice object
|
||||
device = MonkeyRunner.waitForConnection()
|
||||
|
||||
# Installs the Android package. Notice that this method returns a boolean, so you can test
|
||||
# to see if the installation worked.
|
||||
device.installPackage('myproject/bin/MyApplication.apk')
|
||||
|
||||
# Runs an activity in the application
|
||||
device.startActivity(component='com.example.android.myapplication.MainActivity')
|
||||
|
||||
# Presses the Menu button
|
||||
device.press('KEYCODE_MENU','DOWN_AND_UP')
|
||||
|
||||
# Takes a screenshot
|
||||
result = device.takeSnapShot
|
||||
|
||||
# Writes the screenshot to a file
|
||||
result.writeToFile('myproject/shot1.png','png')
|
||||
</pre>
|
||||
|
||||
<h2 id="APIClasses">The monkeyrunner API</h2>
|
||||
<p>
|
||||
The monkeyrunner API is contained in three modules in the package
|
||||
<code>com.android.monkeyrunner</code>:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code><a href="{@docRoot}guide/developing/tools/MonkeyRunner.html">MonkeyRunner</a></code>:
|
||||
A class of utility methods for monkeyrunner programs. This class provides a method for
|
||||
connecting monkeyrunner to a device or emulator. It also provides methods for
|
||||
creating UIs for a monkeyrunner program and for displaying the built-in help.
|
||||
</li>
|
||||
<li>
|
||||
<code><a href="{@docRoot}guide/developing/tools/MonkeyDevice.html">MonkeyDevice</a></code>:
|
||||
Represents a device or emulator. This class provides methods for installing and
|
||||
uninstalling packages, starting an Activity, and sending keyboard or touch events to an
|
||||
application. You also use this class to run test packages.
|
||||
</li>
|
||||
<li>
|
||||
<code><a href="{@docRoot}guide/developing/tools/MonkeyImage.html">MonkeyImage</a></code>:
|
||||
Represents a screen capture image. This class provides methods for capturing screens,
|
||||
converting bitmap images to various formats, comparing two MonkeyImage objects, and
|
||||
writing an image to a file.
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
In a Python program, you access each class as a Python module. The monkeyrunner tool
|
||||
does not import these modules automatically. To import a module, use the
|
||||
Python <code>from</code> statement:
|
||||
</p>
|
||||
<pre>
|
||||
from com.android.monkeyrunner import <module>
|
||||
</pre>
|
||||
<p>
|
||||
where <code><module></code> is the class name you want to import. You can import more
|
||||
than one module in the same <code>from</code> statement by separating the module names with
|
||||
commas.
|
||||
</p>
|
||||
<h2 id="RunningMonkeyRunner">Running monkeyrunner</h2>
|
||||
<p>
|
||||
You can either run monkeyrunner programs from a file, or enter monkeyrunner statements in
|
||||
an interactive session. You do both by invoking the <code>monkeyrunner</code> command
|
||||
which is found in the <code>tools/</code> subdirectory of your SDK directory.
|
||||
If you provide a filename as an argument, the <code>monkeyrunner</code> command
|
||||
runs the file's contents as a Python program; otherwise, it starts an interactive session.
|
||||
</p>
|
||||
<p>
|
||||
The syntax of the <code>monkeyrunner</code> command is
|
||||
</p>
|
||||
<pre>
|
||||
monkeyrunner -plugin <plugin_jar> <program_filename> <program_options>
|
||||
</pre>
|
||||
<p>
|
||||
Table 1 explains the flags and arguments.
|
||||
</p>
|
||||
<p class="table-caption" id="table1">
|
||||
<strong>Table 1.</strong> <code>monkeyrunner</code> flags and arguments.</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Argument</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<nobr>
|
||||
<code>-plugin <plugin_jar></code>
|
||||
</nobr>
|
||||
</td>
|
||||
<td>
|
||||
(Optional) Specifies a <code>.jar</code> file containing a plugin for monkeyrunner.
|
||||
To learn more about monkeyrunner plugins, see
|
||||
<a href="#Plugins">Extending monkeyrunner with plugins</a>. To specify more than one
|
||||
file, include the argument multiple times.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<nobr>
|
||||
<code><program_filename></code>
|
||||
</nobr>
|
||||
</td>
|
||||
<td>
|
||||
If you provide this argument, the <code>monkeyrunner</code> command runs the contents
|
||||
of the file as a Python program. If the argument is not provided, the command starts an
|
||||
interactive session.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><program_options></code>
|
||||
</td>
|
||||
<td>
|
||||
(Optional) Flags and arguments for the program in <program_file>.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2 id="Help">monkeyrunner Built-in Help</h2>
|
||||
<p>
|
||||
You can generate an API reference for monkeyrunner by running:
|
||||
</p>
|
||||
<pre>
|
||||
monkeyrunner <format> help.py <outfile>
|
||||
</pre>
|
||||
<p>
|
||||
The arguments are:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code><format></code> is either <code>text</code> for plain text output
|
||||
or <code>html</code> for HTML output.
|
||||
</li>
|
||||
<li>
|
||||
<code><outfile></code> is a path-qualified name for the output file.
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="Plugins">Extending monkeyrunner with Plugins</h2>
|
||||
<p>
|
||||
You can extend the monkeyrunner API with classes you write in the Java programming language
|
||||
and build into one or more <code>.jar</code> files. You can use this feature to extend the
|
||||
monkeyrunner API with your own classes or to extend the existing classes. You can also use this
|
||||
feature to initialize the monkeyrunner environment.
|
||||
</p>
|
||||
<p>
|
||||
To provide a plugin to monkeyrunner, invoke the <code>monkeyrunner</code> command with the
|
||||
<code>-plugin <plugin_jar></code> argument described in
|
||||
<a href="#table1">table 1</a>.
|
||||
</p>
|
||||
<p>
|
||||
In your plugin code, you can import and extend the the main monkeyrunner classes
|
||||
<code>MonkeyDevice</code>, <code>MonkeyImage</code>, and <code>MonkeyRunner</code> in
|
||||
<code>com.android.monkeyrunner</code> (see <a href="#APIClasses">The monkeyrunner API</a>).
|
||||
</p>
|
||||
<p>
|
||||
Note that plugins do not give you access to the Android SDK. You can't import packages
|
||||
such as <code>com.android.app</code>. This is because monkeyrunner interacts with the
|
||||
device or emulator below the level of the framework APIs.
|
||||
</p>
|
||||
<h3>The plugin startup class</h3>
|
||||
<p>
|
||||
The <code>.jar</code> file for a plugin can specify a class that is instantiated before
|
||||
script processing starts. To specify this class, add the key
|
||||
<code>MonkeyRunnerStartupRunner</code> to the <code>.jar</code> file's
|
||||
manifest. The value should be the name of the class to run at startup. The following
|
||||
snippet shows how you would do this within an <code>ant</code> build script:
|
||||
</p>
|
||||
<pre>
|
||||
<jar jarfile="myplugin" basedir="${build.dir}">
|
||||
<manifest>
|
||||
<attribute name="MonkeyRunnerStartupRunner" value="com.myapp.myplugin"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
|
||||
|
||||
</pre>
|
||||
<p>
|
||||
To get access to monkeyrunner's runtime environment, the startup class can implement
|
||||
<code>com.google.common.base.Predicate<PythonInterpreter></code>. For example, this
|
||||
class sets up some variables in the default namespace:
|
||||
</p>
|
||||
<pre>
|
||||
package com.android.example;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import org.python.util.PythonInterpreter;
|
||||
|
||||
public class Main implements Predicate<PythonInterpreter> {
|
||||
@Override
|
||||
public boolean apply(PythonInterpreter anInterpreter) {
|
||||
|
||||
/*
|
||||
* Examples of creating and initializing variables in the monkeyrunner environment's
|
||||
* namespace. During execution, the monkeyrunner program can refer to the variables "newtest"
|
||||
* and "use_emulator"
|
||||
*
|
||||
*/
|
||||
anInterpreter.set("newtest", "enabled");
|
||||
anInterpreter.set("use_emulator", 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
</pre>
|
@ -254,34 +254,45 @@
|
||||
<li><a href="<?cs var:toroot?>guide/topics/search/searchable-config.html">Searchable Configuration</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toggle-list">
|
||||
<div>
|
||||
<a href="<?cs var:toroot ?>guide/topics/testing/index.html">
|
||||
<span class="en">Testing</span>
|
||||
</a> <span class="new">new!</span>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="<?cs var:toroot?>guide/topics/testing/testing_android.html">
|
||||
<span class="en">Testing Fundamentals</span></a>
|
||||
</li>
|
||||
<li><a href="<?cs var:toroot?>guide/topics/testing/activity_testing.html">
|
||||
<span class="en">Activity Testing</span></a>
|
||||
</li>
|
||||
<li><a href="<?cs var:toroot ?>guide/topics/testing/contentprovider_testing.html">
|
||||
<span class="en">Content Provider Testing</span></a>
|
||||
</li>
|
||||
<li><a href="<?cs var:toroot ?>guide/topics/testing/service_testing.html">
|
||||
<span class="en">Service Testing</span></a>
|
||||
</li>
|
||||
<li><a href="<?cs var:toroot ?>guide/topics/testing/what_to_test.html">
|
||||
<span class="en">What To Test</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="<?cs var:toroot?>guide/topics/admin/device-admin.html">
|
||||
<li><a href="<?cs var:toroot?>guide/topics/admin/device-admin.html">
|
||||
<span class="en">Device Administration</span>
|
||||
</a> <span class="new">new!</span>
|
||||
</li>
|
||||
</li>
|
||||
<li class="toggle-list">
|
||||
<div>
|
||||
<a href="<?cs var:toroot?>guide/topics/testing/index.html">
|
||||
<span class="en">Testing</span>
|
||||
</a>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?cs var:toroot?>guide/topics/testing/testing_android.html">
|
||||
<span class="en">Testing Fundamentals</span></a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?cs var:toroot?>guide/topics/testing/activity_testing.html">
|
||||
<span class="en">Activity Testing</span></a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?cs var:toroot?>guide/topics/testing/contentprovider_testing.html">
|
||||
<span class="en">Content Provider Testing</span></a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?cs var:toroot?>guide/topics/testing/service_testing.html">
|
||||
<span class="en">Service Testing</span></a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?cs var:toroot ?>guide/topics/testing/what_to_test.html">
|
||||
<span class="en">What To Test</span></a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@ -336,6 +347,7 @@
|
||||
<span class="en">Testing in Eclipse, with ADT</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="<?cs var:toroot ?>guide/developing/testing/testing_otheride.html">
|
||||
<span class="en">Testing in Other IDEs</span>
|
||||
@ -363,6 +375,34 @@
|
||||
<li><a href="<?cs var:toroot ?>guide/developing/tools/layoutopt.html">layoutopt</a></li>
|
||||
<li><a href="<?cs var:toroot ?>guide/developing/tools/othertools.html#mksdcard">mksdcard</a></li>
|
||||
<li><a href="<?cs var:toroot ?>guide/developing/tools/monkey.html">Monkey</a></li>
|
||||
<li class="toggle-list">
|
||||
<div>
|
||||
<a href="<?cs var:toroot?>guide/developing/tools/monkeyrunner_concepts.html">
|
||||
<span class="en">monkeyrunner</span>
|
||||
</a>
|
||||
<span class="new">new!</span>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?cs var:toroot?>guide/developing/tools/MonkeyDevice.html">
|
||||
<span class="en">MonkeyDevice</span>
|
||||
</a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?cs var:toroot?>guide/developing/tools/MonkeyImage.html">
|
||||
<span class="en">MonkeyImage</span>
|
||||
</a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?cs var:toroot?>guide/developing/tools/MonkeyRunner.html">
|
||||
<span class="en">MonkeyRunner</span>
|
||||
</a>
|
||||
<span class="new">new!</span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="<?cs var:toroot ?>guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
|
||||
<li><a href="<?cs var:toroot ?>guide/developing/tools/traceview.html" >Traceview</a></li>
|
||||
<li><a href="<?cs var:toroot ?>guide/developing/tools/zipalign.html" >zipalign</a></li>
|
||||
|
@ -59,6 +59,20 @@ page.title=Testing
|
||||
which guides you through a more complex testing scenario.
|
||||
</li>
|
||||
</ul>
|
||||
<h4>Tools</h4>
|
||||
<ul>
|
||||
<li>
|
||||
The
|
||||
<a href="{@docRoot}guide/developing/tools/monkey.html">UI/Application Exerciser Monkey</a>,
|
||||
usually called Monkey, is a command-line tool that sends pseudo-random
|
||||
streams of keystrokes, touches, and gestures to a device.
|
||||
</li>
|
||||
<li>
|
||||
The <a href="{@docRoot}guide/developing/tools/monkeyrunner_concepts.html">monkeyrunner</a> tool
|
||||
is an API and execution environment. You use monkeyrunner with Python programs
|
||||
to test applications and devices.
|
||||
</li>
|
||||
</ul>
|
||||
<h4>Samples</h4>
|
||||
<ul>
|
||||
<li>
|
||||
|
@ -38,7 +38,7 @@ page.title=Testing Fundamentals
|
||||
<a href="#TestResults">Seeing Test Results</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#Monkeys">Monkey and MonkeyRunner</a>
|
||||
<a href="#Monkeys">monkey and monkeyrunner</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#PackageNames">Working With Package Names</a>
|
||||
@ -77,6 +77,13 @@ page.title=Testing Fundamentals
|
||||
<a href="{@docRoot}guide/developing/testing/testing_otheride.html">
|
||||
Testing in Other IDEs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/developing/tools/monkeyrunner_concepts.html">
|
||||
monkeyrunner</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/developing/tools/monkey.html">UI/Application Exerciser Monkey</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
@ -112,10 +119,10 @@ page.title=Testing Fundamentals
|
||||
</li>
|
||||
<li>
|
||||
The SDK also provides
|
||||
<a href="{@docRoot}guide/topics/testing/monkeyrunner.html">MonkeyRunner</a>, an API for
|
||||
testing devices with Jython scripts, and <a
|
||||
href="{@docRoot}guide/developing/tools/monkey.html">Monkey</a>, a command-line tool for
|
||||
stress-testing UIs by sending pseudo-random events to a device.
|
||||
<a href="{@docRoot}guide/developing/tools/monkeyrunner_concepts.html">monkeyrunner</a>, an API
|
||||
testing devices with Python programs, and <a
|
||||
href="{@docRoot}guide/developing/tools/monkey.html">UI/Application Exerciser Monkey</a>,
|
||||
a command-line tool for stress-testing UIs by sending pseudo-random events to a device.
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
@ -540,25 +547,28 @@ page.title=Testing Fundamentals
|
||||
<a href="{@docRoot}guide/developing/testing/testing_otheride.html#RunTestsCommand">
|
||||
Testing in Other IDEs</a>.
|
||||
</p>
|
||||
<h2 id="Monkeys">Monkey and MonkeyRunner</h2>
|
||||
<h2 id="Monkeys">monkey and monkeyrunner</h2>
|
||||
<p>
|
||||
The SDK provides two tools for functional-level application testing:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/developing/tools/monkey.html">Monkey</a> is a command-line
|
||||
tool that sends pseudo-random streams of keystrokes, touches, and gestures to a
|
||||
device. You run it with the <a href="{@docRoot}guide/developing/tools/adb.html">
|
||||
Android Debug Bridge</a> (adb) tool. You use it to stress-test your application and
|
||||
report back errors that are encountered. You can repeat a stream of events by
|
||||
running the tool each time with the same random number seed.
|
||||
The <a href="{@docRoot}guide/developing/tools/monkey.html">UI/Application Exerciser Monkey</a>,
|
||||
usually called "monkey", is a command-line tool that sends pseudo-random streams of
|
||||
keystrokes, touches, and gestures to a device. You run it with the
|
||||
<a href="{@docRoot}guide/developing/tools/adb.html">Android Debug Bridge</a> (adb) tool.
|
||||
You use it to stress-test your application and report back errors that are encountered.
|
||||
You can repeat a stream of events by running the tool each time with the same random
|
||||
number seed.
|
||||
</li>
|
||||
<li>
|
||||
<a href="{@docRoot}guide/topics/testing/monkeyrunner.html">MonkeyRunner</a> is a
|
||||
Jython API that you use in test programs written in Python. The API includes functions
|
||||
for connecting to a device, installing and uninstalling packages, taking screenshots,
|
||||
comparing two images, and running a test package against an application. Using the API
|
||||
with Python, you can write a wide range of large, powerful, and complex tests.
|
||||
The <a href="{@docRoot}guide/developing/tools/monkeyrunner_concepts.html">monkeyrunner</a> tool
|
||||
is an API and execution environment for test programs written in Python. The API
|
||||
includes functions for connecting to a device, installing and uninstalling packages,
|
||||
taking screenshots, comparing two images, and running a test package against an
|
||||
application. Using the API, you can write a wide range of large, powerful, and complex
|
||||
tests. You run programs that use the API with the <code>monkeyrunner</code> command-line
|
||||
tool.
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="PackageNames">Working With Package names</h2>
|
||||
|
Reference in New Issue
Block a user