|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.app.Instrumentation
com.googlecode.autoandroid.positron.Positron
public class Positron
The positron instrumentation. This class implements the PositronAPI and exposes it over http for use as a simple service.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class android.app.Instrumentation |
---|
Instrumentation.ActivityMonitor, Instrumentation.ActivityResult |
Nested classes/interfaces inherited from interface com.googlecode.autoandroid.positron.PositronAPI |
---|
PositronAPI.Intents, PositronAPI.Key, PositronAPI.Menu, PositronAPI.Motion |
Field Summary | |
---|---|
static String |
TAG
|
Fields inherited from class android.app.Instrumentation |
---|
REPORT_KEY_IDENTIFIER, REPORT_KEY_STREAMRESULT |
Constructor Summary | |
---|---|
Positron()
|
Method Summary | ||
---|---|---|
protected List<Activity> |
activities()
Get a snapshot of the known activity stack. |
|
protected Activity |
activity()
|
|
protected
|
at(Class<T> asA,
Object from,
String path)
Evaluate the ViewShorthand path starting from the given point. |
|
protected
|
at(Class<T> asA,
String path)
Evaluate the ViewShorthand path starting from the current activity. |
|
void |
backup()
Backup all databases in the tested application. |
|
void |
backup(String database)
Backup the given database. |
|
boolean |
booleanAt(int depth,
String path)
Evaluate the ViewShorthand path starting from the activity at the given depth. |
|
boolean |
booleanAt(String path)
Evaluate the ViewShorthand path starting from the current activity. |
|
void |
callActivityOnResume(Activity activity)
|
|
void |
click()
sendKeyDownUp(KEYCODE_DPAD_CENTER) |
|
boolean |
contextMenu(int id)
invokeContextMenuActionSync with the current activity. |
|
boolean |
contextMenu(int id,
int flag)
invokeContextMenuActionSync with the current activity. |
|
boolean |
contextMenu(int depth,
int id,
int flag)
invokeContextMenuActionSync with the activity at the given depth on the stack, resuming momentarily if necessary. |
|
double |
doubleAt(int depth,
String path)
Evaluate the ViewShorthand path starting from the activity at the given depth. |
|
double |
doubleAt(String path)
Evaluate the ViewShorthand path starting from the current activity. |
|
void |
drag(float startX,
float startY,
float endX,
float endY)
Drag from one point on the screen to another. |
|
void |
drag(String start,
String end)
Drag from the center of one view to the center of another. |
|
void |
finish()
Finish the current activity. |
|
void |
finish(int depth)
Activity.finish() the activity with the given depth on the stack. |
|
void |
finishAll()
Finish all detected activities on the stack. |
|
void |
flick(float x,
float y)
Flick the trackball in the given direction. |
|
float |
floatAt(int depth,
String path)
Evaluate the ViewShorthand path starting from the current activity. |
|
float |
floatAt(String path)
Evaluate the ViewShorthand path starting from the current activity. |
|
int |
intAt(int depth,
String path)
Evaluate the ViewShorthand path starting from the activity at the given depth. |
|
int |
intAt(String path)
Evaluate the ViewShorthand path starting from the current activity. |
|
boolean |
invokeContextMenuAction(Activity targetActivity,
int id,
int flag)
invokeContextMenuAction, resuming momentarily if necessary. |
|
protected boolean |
invokeMenuAction(Activity targetActivity,
int id,
int flag)
invokeMenuActionSync, resuming momentarily if necessary. |
|
boolean |
invokeMenuActionSync(Activity targetActivity,
int id,
int flag)
|
|
boolean |
menu(int id)
invokeMenuAction with the current activity. |
|
boolean |
menu(int id,
int flag)
invokeMenuAction with the current activity. |
|
boolean |
menu(int depth,
int id,
int flag)
invokeMenuActionSync with the activity at the given depth on the stack, resuming momentarily if necessary. |
|
void |
onCreate(Bundle arguments)
|
|
void |
onStart()
|
|
void |
pause()
Pause execution of the target package. |
|
boolean |
paused()
Is the target package paused? |
|
void |
press(Object... keys)
sendKeyDownUpSync on all keys in order, resuming momentarily if necessary. |
|
void |
quit()
Stop the positron instrumentation and cleanup. |
|
void |
restore()
Restore all databases in the tested application that have backups. |
|
void |
restore(String database)
Restore the given database from a previous backup call. |
|
void |
resume()
Resume executing the target package if it has been paused. |
|
protected void |
route(String pattern,
String method)
|
|
void |
sendCharacter(int keyCode)
sendCharacterSync, resuming momentarily if necessary. |
|
void |
sendCharacterSync(int keyCode)
|
|
void |
sendKey(int action,
int code)
sendKeySync, resuming momentarily if necessary. |
|
protected void |
sendKey(KeyEvent event)
sendKeySync, resuming momentarily if necessary. |
|
void |
sendKey(long eventTimeAfterDown,
int action,
int code,
int repeat)
sendKeySync, resuming momentarily if necessary. |
|
void |
sendKey(long eventTimeAfterDown,
int action,
int code,
int repeat,
int metaState)
sendKeySync, resuming momentarily if necessary. |
|
void |
sendKey(long eventTimeAfterDown,
int action,
int code,
int repeat,
int metaState,
int device,
int scancode)
sendKeySync, resuming momentarily if necessary. |
|
void |
sendKey(long eventTimeAfterDown,
int action,
int code,
int repeat,
int metaState,
int device,
int scancode,
int flags)
sendKeySync, resuming momentarily if necessary. |
|
void |
sendKeyDownUp(int key)
sendKeyDownUpSync, resuming momentarily if necessary. |
|
void |
sendKeyDownUpSync(int key)
|
|
void |
sendKeySync(KeyEvent event)
|
|
void |
sendPointer(int action,
float x,
float y)
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. |
|
void |
sendPointer(int action,
float x,
float y,
int metaState)
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. |
|
void |
sendPointer(long eventTimeAfterDown,
int action,
float x,
float y,
float pressure,
float size,
int metaState,
float xPrecision,
float yPrecision,
int deviceId,
int edgeFlags)
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. |
|
void |
sendPointer(long eventTimeAfterDown,
int action,
float x,
float y,
int metaState)
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. |
|
protected void |
sendPointer(MotionEvent event)
|
|
void |
sendPointerSync(MotionEvent event)
|
|
void |
sendString(String text)
sendStringSync, resuming momentarily if necessary. |
|
void |
sendStringSync(String text)
|
|
void |
sendTrackball(int action,
float x,
float y)
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. |
|
void |
sendTrackball(int action,
float x,
float y,
int metaState)
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. |
|
void |
sendTrackball(long eventTimeAfterDown,
int action,
float x,
float y,
float pressure,
float size,
int metaState,
float xPrecision,
float yPrecision,
int deviceId,
int edgeFlags)
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. |
|
void |
sendTrackball(long eventTimeAfterDown,
int action,
float x,
float y,
int metaState)
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. |
|
protected void |
sendTrackball(MotionEvent event)
|
|
void |
sendTrackballEventSync(MotionEvent event)
|
|
void |
servePress(String remainder)
|
|
String |
serveRoot()
|
|
void |
serveSql(String database,
Properties parameters)
|
|
void |
serveStart(Properties parameters)
|
|
protected void |
sql(String database,
int scriptsAsRawResources)
Execute the given Sql scripts (as raw resources in the target context.) |
|
void |
sql(String database,
String script)
Execute the given Sql script. |
|
protected void |
startActivity(Intent intent)
startActivitySync, resuming momentarily if necessary. |
|
void |
startActivity(String action)
startActivitySync, resuming momentarily if necessary. |
|
void |
startActivity(String packageName,
String className)
startActivitySync, resuming momentarily if necessary. |
|
void |
startActivity(String action,
String[] categories)
startActivitySync, resuming momentarily if necessary. |
|
void |
startActivity(String action,
String[] categories,
int[] flags)
startActivitySync, resuming momentarily if necessary. |
|
void |
startActivity(String action,
String data,
String type)
startActivitySync, resuming momentarily if necessary. |
|
void |
startActivity(String action,
String data,
String type,
String[] categories,
int[] flags)
startActivitySync, resuming momentarily if necessary. |
|
Activity |
startActivitySync(Intent intent)
|
|
String |
stringAt(int depth,
String path)
Evaluate the ViewShorthand path starting from the activity at the given depth. |
|
String |
stringAt(String path)
Evaluate the ViewShorthand path starting from the current activity. |
|
void |
touch(float x,
float y)
Touch the screen (or click the pointer) at the given location. |
|
void |
touch(String path)
Touch the screen (or click the pointer) at the center of the view with the given path. |
|
boolean |
waitFor(int depth,
String path,
String value,
long timeout)
Wait until value.equals(stringAt(depth, path)) or the given timeout expires, then pause(). |
|
boolean |
waitFor(String path,
String value,
long timeout)
Wait until value.equals(stringAt(path)) or the given timeout expires, then pause(). |
|
void |
waitForIdleSync()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TAG
Constructor Detail |
---|
public Positron()
Method Detail |
---|
public void onStart()
onStart
in class Instrumentation
protected void route(String pattern, String method)
public String serveRoot()
public void serveSql(String database, Properties parameters)
public void servePress(String remainder)
public void serveStart(Properties parameters)
public void onCreate(Bundle arguments)
onCreate
in class Instrumentation
public void callActivityOnResume(Activity activity)
callActivityOnResume
in class Instrumentation
protected List<Activity> activities()
protected Activity activity()
public void finish()
PositronAPI
finish
in interface PositronAPI
public void finishAll()
PositronAPI
finishAll
in interface PositronAPI
public void pause()
pause
in interface PositronAPI
public void resume()
resume
in interface PositronAPI
public boolean paused()
paused
in interface PositronAPI
public void backup()
backup
in interface PositronAPI
public void backup(String database)
backup
in interface PositronAPI
protected void sql(String database, int scriptsAsRawResources)
public void sql(String database, String script)
sql
in interface PositronAPI
public void restore()
restore
in interface PositronAPI
public void quit()
quit
in interface PositronAPI
public void restore(String database)
restore
in interface PositronAPI
protected boolean invokeMenuAction(Activity targetActivity, int id, int flag)
public boolean invokeContextMenuAction(Activity targetActivity, int id, int flag)
invokeContextMenuAction
in class Instrumentation
public void sendCharacter(int keyCode)
sendCharacter
in interface PositronAPI
public void sendKeyDownUp(int key)
sendKeyDownUp
in interface PositronAPI
public void click()
click
in interface PositronAPI
public void press(Object... keys)
press
in interface PositronAPI
keys
- A mixture of ints and Strings. ints are sent with sendKeyDownUpSync,
Strings are send with sendStringSync.
IllegalArgumentException
- if something other than an int or String was passed.protected <T> T at(Class<T> asA, Object from, String path)
protected <T> T at(Class<T> asA, String path)
public String stringAt(String path)
stringAt
in interface PositronAPI
public float floatAt(int depth, String path)
floatAt
in interface PositronAPI
public float floatAt(String path)
floatAt
in interface PositronAPI
public int intAt(String path)
intAt
in interface PositronAPI
public boolean booleanAt(String path)
booleanAt
in interface PositronAPI
public double doubleAt(String path)
doubleAt
in interface PositronAPI
protected void sendKey(KeyEvent event)
public void sendKey(int action, int code)
sendKey
in interface PositronAPI
public void sendKey(long eventTimeAfterDown, int action, int code, int repeat)
sendKey
in interface PositronAPI
public void sendKey(long eventTimeAfterDown, int action, int code, int repeat, int metaState)
sendKey
in interface PositronAPI
public void sendKey(long eventTimeAfterDown, int action, int code, int repeat, int metaState, int device, int scancode)
sendKey
in interface PositronAPI
public void sendKey(long eventTimeAfterDown, int action, int code, int repeat, int metaState, int device, int scancode, int flags)
sendKey
in interface PositronAPI
public void sendString(String text)
sendString
in interface PositronAPI
protected void startActivity(Intent intent)
public boolean invokeMenuActionSync(Activity targetActivity, int id, int flag)
invokeMenuActionSync
in class Instrumentation
public void sendCharacterSync(int keyCode)
sendCharacterSync
in class Instrumentation
public void sendKeyDownUpSync(int key)
sendKeyDownUpSync
in class Instrumentation
public void sendKeySync(KeyEvent event)
sendKeySync
in class Instrumentation
public void sendStringSync(String text)
sendStringSync
in class Instrumentation
public Activity startActivitySync(Intent intent)
startActivitySync
in class Instrumentation
public void waitForIdleSync()
waitForIdleSync
in class Instrumentation
public void finish(int depth)
PositronAPI
finish
in interface PositronAPI
public boolean menu(int id)
PositronAPI
menu
in interface PositronAPI
public boolean menu(int id, int flag)
PositronAPI
menu
in interface PositronAPI
public boolean menu(int depth, int id, int flag)
PositronAPI
menu
in interface PositronAPI
public boolean contextMenu(int id)
PositronAPI
contextMenu
in interface PositronAPI
public boolean contextMenu(int id, int flag)
PositronAPI
contextMenu
in interface PositronAPI
public boolean contextMenu(int depth, int id, int flag)
PositronAPI
contextMenu
in interface PositronAPI
public void startActivity(String action)
PositronAPI
startActivity
in interface PositronAPI
public void startActivity(String packageName, String className)
PositronAPI
startActivity
in interface PositronAPI
public void startActivity(String action, String data, String type)
PositronAPI
startActivity
in interface PositronAPI
public void startActivity(String action, String[] categories)
PositronAPI
startActivity
in interface PositronAPI
public void startActivity(String action, String[] categories, int[] flags)
PositronAPI
startActivity
in interface PositronAPI
public void startActivity(String action, String data, String type, String[] categories, int[] flags)
PositronAPI
startActivity
in interface PositronAPI
public boolean booleanAt(int depth, String path)
PositronAPI
booleanAt
in interface PositronAPI
public double doubleAt(int depth, String path)
PositronAPI
doubleAt
in interface PositronAPI
public int intAt(int depth, String path)
PositronAPI
intAt
in interface PositronAPI
public String stringAt(int depth, String path)
PositronAPI
stringAt
in interface PositronAPI
public void touch(float x, float y)
PositronAPI
touch
in interface PositronAPI
public void touch(String path)
PositronAPI
touch
in interface PositronAPI
public void drag(float startX, float startY, float endX, float endY)
PositronAPI
drag
in interface PositronAPI
public void drag(String start, String end)
PositronAPI
drag
in interface PositronAPI
public void sendPointer(int action, float x, float y)
PositronAPI
sendPointer
in interface PositronAPI
public void sendPointer(int action, float x, float y, int metaState)
PositronAPI
sendPointer
in interface PositronAPI
public void sendPointer(long eventTimeAfterDown, int action, float x, float y, int metaState)
PositronAPI
sendPointer
in interface PositronAPI
eventTimeAfterDown
- Time in milliseconds since the initial down event.action
- One of the MotionEvent action constants.x
- The x coordinate.y
- The y coordinate.metaState
- Any meta / modifier keys to hold while the sending the event.public void sendPointer(long eventTimeAfterDown, int action, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int deviceId, int edgeFlags)
PositronAPI
sendPointer
in interface PositronAPI
protected void sendPointer(MotionEvent event)
public void sendPointerSync(MotionEvent event)
sendPointerSync
in class Instrumentation
public void flick(float x, float y)
PositronAPI
flick
in interface PositronAPI
public void sendTrackball(int action, float x, float y)
PositronAPI
sendTrackball
in interface PositronAPI
public void sendTrackball(int action, float x, float y, int metaState)
PositronAPI
sendTrackball
in interface PositronAPI
public void sendTrackball(long eventTimeAfterDown, int action, float x, float y, int metaState)
PositronAPI
sendTrackball
in interface PositronAPI
eventTimeAfterDown
- Time in milliseconds since the initial down event.action
- One of the MotionEvent action constants.x
- The x coordinate.y
- The y coordinate.metaState
- Any meta / modifier keys to hold while the sending the event.public void sendTrackball(long eventTimeAfterDown, int action, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int deviceId, int edgeFlags)
PositronAPI
sendTrackball
in interface PositronAPI
protected void sendTrackball(MotionEvent event)
public void sendTrackballEventSync(MotionEvent event)
sendTrackballEventSync
in class Instrumentation
public boolean waitFor(String path, String value, long timeout)
PositronAPI
waitFor
in interface PositronAPI
path
- The view shorthand expression to watch.value
- The value to wait for.timeout
- Time in milliseconds to wait before giving up and pausing anyway.
public boolean waitFor(int depth, String path, String value, long timeout)
PositronAPI
waitFor
in interface PositronAPI
depth
- The depth down the activity stackpath
- The view shorthand expression to watch.value
- The value to wait for.timeout
- Time in milliseconds to wait before giving up and pausing anyway.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |