com.googlecode.autoandroid.positron
Class Positron

java.lang.Object
  extended by android.app.Instrumentation
      extended by com.googlecode.autoandroid.positron.Positron
All Implemented Interfaces:
PositronAPI

public class Positron
extends Instrumentation
implements PositronAPI

The positron instrumentation. This class implements the PositronAPI and exposes it over http for use as a simple service.

Author:
philhsmith

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
<T> T
at(Class<T> asA, Object from, String path)
          Evaluate the ViewShorthand path starting from the given point.
protected
<T> T
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 android.app.Instrumentation
addMonitor, addMonitor, addMonitor, callActivityOnCreate, callActivityOnDestroy, callActivityOnNewIntent, callActivityOnPause, callActivityOnPostCreate, callActivityOnRestart, callActivityOnRestoreInstanceState, callActivityOnSaveInstanceState, callActivityOnStart, callActivityOnStop, callApplicationOnCreate, checkMonitorHit, endPerformanceSnapshot, finish, getAllocCounts, getBinderCounts, getComponentName, getContext, getTargetContext, isProfiling, newActivity, newActivity, newApplication, newApplication, onDestroy, onException, removeMonitor, runOnMainSync, sendStatus, setAutomaticPerformanceSnapshots, setInTouchMode, start, startAllocCounting, startPerformanceSnapshot, startProfiling, stopAllocCounting, stopProfiling, waitForIdle, waitForMonitor, waitForMonitorWithTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG

public static final String TAG
See Also:
Constant Field Values
Constructor Detail

Positron

public Positron()
Method Detail

onStart

public void onStart()
Overrides:
onStart in class Instrumentation

route

protected void route(String pattern,
                     String method)

serveRoot

public String serveRoot()

serveSql

public void serveSql(String database,
                     Properties parameters)

servePress

public void servePress(String remainder)

serveStart

public void serveStart(Properties parameters)

onCreate

public void onCreate(Bundle arguments)
Overrides:
onCreate in class Instrumentation

callActivityOnResume

public void callActivityOnResume(Activity activity)
Overrides:
callActivityOnResume in class Instrumentation

activities

protected List<Activity> activities()
Get a snapshot of the known activity stack.


activity

protected Activity activity()

finish

public void finish()
Description copied from interface: PositronAPI
Finish the current activity.

Specified by:
finish in interface PositronAPI

finishAll

public void finishAll()
Description copied from interface: PositronAPI
Finish all detected activities on the stack.

Specified by:
finishAll in interface PositronAPI

pause

public void pause()
Pause execution of the target package. This is useful for inspecting the view state of the target package, since doing so while it is running can create race conditions. Resume execution with resume(). Pausing an already-paused application is a safe no-op. Paused applications can't respond to events, nor execute synchronous commands such as sendStringSync (or any *Sync.) Keep this in mind when writing tests. Pausing is done by asynchronously calling Instrumentation.runOnMainSync on a blocking operation.

Specified by:
pause in interface PositronAPI

resume

public void resume()
Resume executing the target package if it has been paused. Resuming an unpaused package is a safe noop.

Specified by:
resume in interface PositronAPI

paused

public boolean paused()
Is the target package paused?

Specified by:
paused in interface PositronAPI

backup

public void backup()
Backup all databases in the tested application.

Specified by:
backup in interface PositronAPI

backup

public void backup(String database)
Backup the given database.

Specified by:
backup in interface PositronAPI

sql

protected void sql(String database,
                   int scriptsAsRawResources)
Execute the given Sql scripts (as raw resources in the target context.)


sql

public void sql(String database,
                String script)
Execute the given Sql script.

Specified by:
sql in interface PositronAPI

restore

public void restore()
Restore all databases in the tested application that have backups.

Specified by:
restore in interface PositronAPI

quit

public void quit()
Stop the positron instrumentation and cleanup.

Specified by:
quit in interface PositronAPI

restore

public void restore(String database)
Restore the given database from a previous backup call. This deletes the backup as well.

Specified by:
restore in interface PositronAPI

invokeMenuAction

protected boolean invokeMenuAction(Activity targetActivity,
                                   int id,
                                   int flag)
invokeMenuActionSync, resuming momentarily if necessary.


invokeContextMenuAction

public boolean invokeContextMenuAction(Activity targetActivity,
                                       int id,
                                       int flag)
invokeContextMenuAction, resuming momentarily if necessary.

Overrides:
invokeContextMenuAction in class Instrumentation

sendCharacter

public void sendCharacter(int keyCode)
sendCharacterSync, resuming momentarily if necessary.

Specified by:
sendCharacter in interface PositronAPI

sendKeyDownUp

public void sendKeyDownUp(int key)
sendKeyDownUpSync, resuming momentarily if necessary.

Specified by:
sendKeyDownUp in interface PositronAPI

click

public void click()
sendKeyDownUp(KEYCODE_DPAD_CENTER)

Specified by:
click in interface PositronAPI

press

public void press(Object... keys)
sendKeyDownUpSync on all keys in order, resuming momentarily if necessary.

Specified by:
press in interface PositronAPI
Parameters:
keys - A mixture of ints and Strings. ints are sent with sendKeyDownUpSync, Strings are send with sendStringSync.
Throws:
IllegalArgumentException - if something other than an int or String was passed.

at

protected <T> T at(Class<T> asA,
                   Object from,
                   String path)
Evaluate the ViewShorthand path starting from the given point.

Returns:
The result as the passed type.

at

protected <T> T at(Class<T> asA,
                   String path)
Evaluate the ViewShorthand path starting from the current activity.

Returns:
The result as the passed type.

stringAt

public String stringAt(String path)
Evaluate the ViewShorthand path starting from the current activity.

Specified by:
stringAt in interface PositronAPI
Returns:
The result as a String. If the result would be a CharSequence, call toString on it.

floatAt

public float floatAt(int depth,
                     String path)
Evaluate the ViewShorthand path starting from the current activity.

Specified by:
floatAt in interface PositronAPI
Returns:
The result as a float.

floatAt

public float floatAt(String path)
Evaluate the ViewShorthand path starting from the current activity.

Specified by:
floatAt in interface PositronAPI
Returns:
The result as a float.

intAt

public int intAt(String path)
Evaluate the ViewShorthand path starting from the current activity.

Specified by:
intAt in interface PositronAPI
Returns:
The result as an int.

booleanAt

public boolean booleanAt(String path)
Evaluate the ViewShorthand path starting from the current activity.

Specified by:
booleanAt in interface PositronAPI
Returns:
The result as a boolean.

doubleAt

public double doubleAt(String path)
Evaluate the ViewShorthand path starting from the current activity.

Specified by:
doubleAt in interface PositronAPI
Returns:
The result as a double.

sendKey

protected void sendKey(KeyEvent event)
sendKeySync, resuming momentarily if necessary.


sendKey

public void sendKey(int action,
                    int code)
sendKeySync, resuming momentarily if necessary.

Specified by:
sendKey in interface PositronAPI

sendKey

public void sendKey(long eventTimeAfterDown,
                    int action,
                    int code,
                    int repeat)
sendKeySync, resuming momentarily if necessary.

Specified by:
sendKey in interface PositronAPI

sendKey

public void sendKey(long eventTimeAfterDown,
                    int action,
                    int code,
                    int repeat,
                    int metaState)
sendKeySync, resuming momentarily if necessary.

Specified by:
sendKey in interface PositronAPI

sendKey

public void sendKey(long eventTimeAfterDown,
                    int action,
                    int code,
                    int repeat,
                    int metaState,
                    int device,
                    int scancode)
sendKeySync, resuming momentarily if necessary.

Specified by:
sendKey in interface PositronAPI

sendKey

public void sendKey(long eventTimeAfterDown,
                    int action,
                    int code,
                    int repeat,
                    int metaState,
                    int device,
                    int scancode,
                    int flags)
sendKeySync, resuming momentarily if necessary.

Specified by:
sendKey in interface PositronAPI

sendString

public void sendString(String text)
sendStringSync, resuming momentarily if necessary.

Specified by:
sendString in interface PositronAPI

startActivity

protected void startActivity(Intent intent)
startActivitySync, resuming momentarily if necessary.


invokeMenuActionSync

public boolean invokeMenuActionSync(Activity targetActivity,
                                    int id,
                                    int flag)
Overrides:
invokeMenuActionSync in class Instrumentation

sendCharacterSync

public void sendCharacterSync(int keyCode)
Overrides:
sendCharacterSync in class Instrumentation

sendKeyDownUpSync

public void sendKeyDownUpSync(int key)
Overrides:
sendKeyDownUpSync in class Instrumentation

sendKeySync

public void sendKeySync(KeyEvent event)
Overrides:
sendKeySync in class Instrumentation

sendStringSync

public void sendStringSync(String text)
Overrides:
sendStringSync in class Instrumentation

startActivitySync

public Activity startActivitySync(Intent intent)
Overrides:
startActivitySync in class Instrumentation

waitForIdleSync

public void waitForIdleSync()
Overrides:
waitForIdleSync in class Instrumentation

finish

public void finish(int depth)
Description copied from interface: PositronAPI
Activity.finish() the activity with the given depth on the stack.

Specified by:
finish in interface PositronAPI

menu

public boolean menu(int id)
Description copied from interface: PositronAPI
invokeMenuAction with the current activity.

Specified by:
menu in interface PositronAPI

menu

public boolean menu(int id,
                    int flag)
Description copied from interface: PositronAPI
invokeMenuAction with the current activity.

Specified by:
menu in interface PositronAPI

menu

public boolean menu(int depth,
                    int id,
                    int flag)
Description copied from interface: PositronAPI
invokeMenuActionSync with the activity at the given depth on the stack, resuming momentarily if necessary.

Specified by:
menu in interface PositronAPI

contextMenu

public boolean contextMenu(int id)
Description copied from interface: PositronAPI
invokeContextMenuActionSync with the current activity.

Specified by:
contextMenu in interface PositronAPI

contextMenu

public boolean contextMenu(int id,
                           int flag)
Description copied from interface: PositronAPI
invokeContextMenuActionSync with the current activity.

Specified by:
contextMenu in interface PositronAPI

contextMenu

public boolean contextMenu(int depth,
                           int id,
                           int flag)
Description copied from interface: PositronAPI
invokeContextMenuActionSync with the activity at the given depth on the stack, resuming momentarily if necessary.

Specified by:
contextMenu in interface PositronAPI

startActivity

public void startActivity(String action)
Description copied from interface: PositronAPI
startActivitySync, resuming momentarily if necessary.

Specified by:
startActivity in interface PositronAPI

startActivity

public void startActivity(String packageName,
                          String className)
Description copied from interface: PositronAPI
startActivitySync, resuming momentarily if necessary.

Specified by:
startActivity in interface PositronAPI

startActivity

public void startActivity(String action,
                          String data,
                          String type)
Description copied from interface: PositronAPI
startActivitySync, resuming momentarily if necessary.

Specified by:
startActivity in interface PositronAPI

startActivity

public void startActivity(String action,
                          String[] categories)
Description copied from interface: PositronAPI
startActivitySync, resuming momentarily if necessary.

Specified by:
startActivity in interface PositronAPI

startActivity

public void startActivity(String action,
                          String[] categories,
                          int[] flags)
Description copied from interface: PositronAPI
startActivitySync, resuming momentarily if necessary.

Specified by:
startActivity in interface PositronAPI

startActivity

public void startActivity(String action,
                          String data,
                          String type,
                          String[] categories,
                          int[] flags)
Description copied from interface: PositronAPI
startActivitySync, resuming momentarily if necessary.

Specified by:
startActivity in interface PositronAPI

booleanAt

public boolean booleanAt(int depth,
                         String path)
Description copied from interface: PositronAPI
Evaluate the ViewShorthand path starting from the activity at the given depth.

Specified by:
booleanAt in interface PositronAPI
Returns:
The result as a boolean.

doubleAt

public double doubleAt(int depth,
                       String path)
Description copied from interface: PositronAPI
Evaluate the ViewShorthand path starting from the activity at the given depth.

Specified by:
doubleAt in interface PositronAPI
Returns:
The result as a double.

intAt

public int intAt(int depth,
                 String path)
Description copied from interface: PositronAPI
Evaluate the ViewShorthand path starting from the activity at the given depth.

Specified by:
intAt in interface PositronAPI
Returns:
The result as an int.

stringAt

public String stringAt(int depth,
                       String path)
Description copied from interface: PositronAPI
Evaluate the ViewShorthand path starting from the activity at the given depth.

Specified by:
stringAt in interface PositronAPI
Returns:
The result as a String.

touch

public void touch(float x,
                  float y)
Description copied from interface: PositronAPI
Touch the screen (or click the pointer) at the given location. This uses sendPointer to send an ACTION_DOWN, and an ACTION_UP a little later.

Specified by:
touch in interface PositronAPI

touch

public void touch(String path)
Description copied from interface: PositronAPI
Touch the screen (or click the pointer) at the center of the view with the given path. Once the center of the view is found, this behaves as touch(float, float).

Specified by:
touch in interface PositronAPI

drag

public void drag(float startX,
                 float startY,
                 float endX,
                 float endY)
Description copied from interface: PositronAPI
Drag from one point on the screen to another. This uses sendPointer to send an ACTION_DOWN at (startX, startY), followed by an ACTION_MOVE to (endX, endY), and finally an ACTION_UP.

Specified by:
drag in interface PositronAPI

drag

public void drag(String start,
                 String end)
Description copied from interface: PositronAPI
Drag from the center of one view to the center of another. Once the centers have been found, this behaves as drag(float, float, float, float).

Specified by:
drag in interface PositronAPI

sendPointer

public void sendPointer(int action,
                        float x,
                        float y)
Description copied from interface: PositronAPI
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. The eventTimeAfterDown and metaState are both taken to be 0.

Specified by:
sendPointer in interface PositronAPI

sendPointer

public void sendPointer(int action,
                        float x,
                        float y,
                        int metaState)
Description copied from interface: PositronAPI
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. The eventTimeAfterDown is taken to be 0.

Specified by:
sendPointer in interface PositronAPI

sendPointer

public void sendPointer(long eventTimeAfterDown,
                        int action,
                        float x,
                        float y,
                        int metaState)
Description copied from interface: PositronAPI
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. MotionEvents (within the android api) take a downTime which needs to be given as milliseconds from system start, from the uptimeMillis() call. Since stories won't likely have that number around, positron uses the current uptimeMillis for the downTime. An eventTime may be given as milliseconds relative to downTime; the downTime will be added.

Specified by:
sendPointer in interface PositronAPI
Parameters:
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.

sendPointer

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)
Description copied from interface: PositronAPI
Send a MotionEvent via sendPointerSync, resuming momentarily if needed. MotionEvents (within the android api) take a downTime which needs to be given as milliseconds from system start, from the uptimeMillis() call. Since stories won't likely have that number around, positron uses the current uptimeMillis for the downTime. An eventTime may be given as milliseconds relative to downTime; the downTime will be added.

Specified by:
sendPointer in interface PositronAPI

sendPointer

protected void sendPointer(MotionEvent event)

sendPointerSync

public void sendPointerSync(MotionEvent event)
Overrides:
sendPointerSync in class Instrumentation

flick

public void flick(float x,
                  float y)
Description copied from interface: PositronAPI
Flick the trackball in the given direction.

Specified by:
flick in interface PositronAPI

sendTrackball

public void sendTrackball(int action,
                          float x,
                          float y)
Description copied from interface: PositronAPI
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. The eventTimeAfterDown and metaState are both taken to be 0.

Specified by:
sendTrackball in interface PositronAPI

sendTrackball

public void sendTrackball(int action,
                          float x,
                          float y,
                          int metaState)
Description copied from interface: PositronAPI
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. The eventTimeAfterDown is taken to be 0.

Specified by:
sendTrackball in interface PositronAPI

sendTrackball

public void sendTrackball(long eventTimeAfterDown,
                          int action,
                          float x,
                          float y,
                          int metaState)
Description copied from interface: PositronAPI
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. MotionEvents (within the android api) take a downTime which needs to be given as milliseconds from system start, from the uptimeMillis() call. Since stories won't likely have that number around, positron uses the current uptimeMillis for the downTime. An eventTime may be given as milliseconds relative to downTime; the downTime will be added.

Specified by:
sendTrackball in interface PositronAPI
Parameters:
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.

sendTrackball

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)
Description copied from interface: PositronAPI
Send a MotionEvent via sendTrackballEventSync, resuming momentarily if needed. MotionEvents (within the android api) take a downTime which needs to be given as milliseconds from system start, from the uptimeMillis() call. Since stories won't likely have that number around, positron uses the current uptimeMillis for the downTime. An eventTime may be given as milliseconds relative to downTime; the downTime will be added.

Specified by:
sendTrackball in interface PositronAPI

sendTrackball

protected void sendTrackball(MotionEvent event)

sendTrackballEventSync

public void sendTrackballEventSync(MotionEvent event)
Overrides:
sendTrackballEventSync in class Instrumentation

waitFor

public boolean waitFor(String path,
                       String value,
                       long timeout)
Description copied from interface: PositronAPI
Wait until value.equals(stringAt(path)) or the given timeout expires, then pause(). If paused() initially, resume() before waiting. Handy for events (like those from the touch screen) that continue to have side-effects even after the initial event has been processed. This method necessarily polls state in a pause() / resume() cycle. It is possible for the condition to be missed if it is only briefly or intermittently true.

Specified by:
waitFor in interface PositronAPI
Parameters:
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.
Returns:
True if the condition was met before the timeout expired.

waitFor

public boolean waitFor(int depth,
                       String path,
                       String value,
                       long timeout)
Description copied from interface: PositronAPI
Wait until value.equals(stringAt(depth, path)) or the given timeout expires, then pause(). If paused() initially, resume() before waiting. Handy for events (like those from the touch screen) that continue to have side-effects even after the initial event has been processed. This method necessarily polls state in a pause() / resume() cycle. It is possible for the condition to be missed if it is only briefly or intermittently true.

Specified by:
waitFor in interface PositronAPI
Parameters:
depth - The depth down the activity stack
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.
Returns:
True if the condition was met before the timeout expired.