public class RobotiumTestRunner extends AbstractTestRunner
This is the InstrumentationTestRunner that is considered the test package usually associated with a very specific target Package to be tested. However, in the case of SAFS we want to make a completely reusable test package that is NOT built with a specific target Package association. We want this general-purpose test framework to be usable to test all Android Applications via the data-driven SAFS framework.
The initial implementation, however, is not necessarily SAFS-specific.
How the remote control mechanism works:
The test package AdroidManifest.xml does need to have the Instrumentation tags set for the target
Application to be tested. There is no getting around this:
<instrumentation android:name="com.jayway.android.robotium.remotecontrol.client.RobotiumTestRunner"
android:targetPackage="com.android.example.spinner"
android:label="General-Purpose SAFS Droid Automation Framework"/>
The AndroidManifest.xml then simply needs to be repackaged into a working test APK in order to test
the target application.
The test consists of the following on-device assets:
1. TCP Messenger Service,
2. Robotium Remote Solo APK,
3. Target Application APK.
The remote control assets are simply:
1. Remote Controller implementing a TCP SocketServerListener,
2. TCP SocketServer binding to the on-device TCP Messenger Service for two-way communication.
There is a predefined TCP Protocol the remote TCP SocketServer and the on-device TCP Messenger Service must adhere to for proper signalling and synchronization.
When using the Droid Emulator, the remote controller must ensure the proper emulator port forwarding is set in order for the TCP Messenger Service to be able to communicate with the outside world.
MessengerService,
AbstractTestRunner| Modifier and Type | Field and Description |
|---|---|
(package private) RobotiumTestCase |
activityrunner |
(package private) int |
ALL_APPLICATION_INFO
Flags OR'd together to retrieve all available information on an Application.
|
(package private) int |
ALL_PACKAGE_INFO
Flags OR'd together to retrieve all available information on an installed Package.
|
(package private) android.app.Activity |
mainApp |
(package private) android.content.pm.InstrumentationInfo |
myInstrumentInfo |
(package private) android.content.pm.PackageInfo |
myPackageInfo |
(package private) android.content.pm.PackageManager |
myPackageManager |
(package private) RCSolo |
solo |
static java.lang.String |
TAG |
(package private) android.content.pm.ActivityInfo[] |
targetActivityInfo |
(package private) java.lang.String |
targetApplicationClassName |
(package private) android.content.Intent |
targetLaunchIntent |
(package private) android.content.pm.PackageInfo |
targetPackageInfo |
(package private) java.lang.String |
targetPackageString |
lock, messageRunner, mIsBound, processorsMap, resource_bind_service, resource_service_attached, resource_service_disconnect, resource_service_release, runnerStopped| Constructor and Description |
|---|
RobotiumTestRunner() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterStart()
Called as part of the
AbstractTestRunner.onCreate(Bundle) initialization after Instrumentation.start(). |
boolean |
beforeStart()
Called as part of the
AbstractTestRunner.onCreate(Bundle) initialization after AbstractTestRunner.doBindService()
immediately before Instrumentation.start(). |
void |
closeApplication()
Force a shutdown of ANY running test Activities.
|
(package private) boolean |
createRobotiumTestCase()
Instantiate the RobotiumTestCase.
|
RobotiumTestCase |
getActivityrunner() |
java.lang.String |
getListenerName()
Unique name to identify the listener.
|
RCSolo |
getSolo()
The returned
RCSolo is probably a null.The RCSolo object will be initialized after calling launchApplication() |
(package private) boolean |
getTargetPackageInfo()
Attempt to extract all pertinent information for launching/driving the package we are testing.
|
MessageResult |
handleDispatchFile(java.lang.String filename)
===========================================================================================
Following are the call-back methods inheritated from CommandListener
===========================================================================================
|
MessageResult |
handleMessage(java.lang.String message) |
MessageResult |
handleRemoteShutdown() |
MessageResult |
handleServerConnected() |
MessageResult |
handleServerDisconnected() |
MessageResult |
handleServerShutdown() |
(package private) boolean |
initializeInstrumentation()
Attempt to initialize the RobotiumTestCase with Intent and Instrumentation.
|
SoloProcessor |
initializeSoloProcessor()
Subclasses will want to override to instantiate their own SoloProcessor subclass.
This Processor will be add to processors-cache with key Message.target_solo |
void |
launchApplication()
Launches the main Application Activity and initializes the Robotium Solo object.
|
addProcessor, debug, doBindService, doUnbindService, finishInstrumentation, getProcessors, handleDispatchProps, handleEngineShutdown, isDebugEnabled, messengerRunnerStopped, onCreate, onReceiveDebug, onStart, removeProcessor, removeProcessors, removeProcessors, sendServiceResult, setDebugEnabledgetAllTests, getAndroidTestRunner, getArguments, getLoader, getTestSuiteaddMonitor, addMonitor, addMonitor, callActivityOnCreate, callActivityOnCreate, callActivityOnDestroy, callActivityOnNewIntent, callActivityOnPause, callActivityOnPostCreate, callActivityOnPostCreate, callActivityOnRestart, callActivityOnRestoreInstanceState, callActivityOnRestoreInstanceState, callActivityOnResume, callActivityOnSaveInstanceState, callActivityOnSaveInstanceState, callActivityOnStart, callActivityOnStop, callActivityOnUserLeaving, callApplicationOnCreate, checkMonitorHit, endPerformanceSnapshot, finish, getAllocCounts, getBinderCounts, getComponentName, getContext, getTargetContext, getUiAutomation, getUiAutomation, invokeContextMenuAction, invokeMenuActionSync, isProfiling, newActivity, newActivity, newApplication, newApplication, onDestroy, onException, removeMonitor, runOnMainSync, sendCharacterSync, sendKeyDownUpSync, sendKeySync, sendPointerSync, sendStatus, sendStringSync, sendTrackballEventSync, setAutomaticPerformanceSnapshots, setInTouchMode, start, startActivitySync, startAllocCounting, startPerformanceSnapshot, startProfiling, stopAllocCounting, stopProfiling, waitForIdle, waitForIdleSync, waitForMonitor, waitForMonitorWithTimeoutpublic static java.lang.String TAG
android.content.pm.PackageManager myPackageManager
int ALL_PACKAGE_INFO
int ALL_APPLICATION_INFO
android.content.pm.PackageInfo myPackageInfo
android.content.pm.InstrumentationInfo myInstrumentInfo
java.lang.String targetPackageString
android.content.Intent targetLaunchIntent
java.lang.String targetApplicationClassName
android.content.pm.PackageInfo targetPackageInfo
android.content.pm.ActivityInfo[] targetActivityInfo
RobotiumTestCase activityrunner
android.app.Activity mainApp
RCSolo solo
public SoloProcessor initializeSoloProcessor()
Message.target_solorunner - Message.target_solopublic RobotiumTestCase getActivityrunner()
public RCSolo getSolo()
RCSolo is probably a null.RCSolo object will be initialized after calling launchApplication()We CANNOT automatically call launchApplication as part of this method because there are cases--especially during initialization--when the call to launchApplication will most definitely fail.
RCSolo or null if the application
has not yet been launched by the test/user at an appropriate time.public java.lang.String getListenerName()
NamedListenergetListenerName in interface NamedListenergetListenerName in class AbstractTestRunnerboolean createRobotiumTestCase()
RobotiumTestCase,
beforeStart(),
getTargetPackageInfo()boolean initializeInstrumentation()
ActivityInstrumentationTestCase2.setActivityIntent(Intent),
InstrumentationTestCase.injectInstrumentation(android.app.Instrumentation)boolean getTargetPackageInfo()
PackageManager.getPackageInfo(String, int),
PackageInfo.instrumentation,
InstrumentationInfo.targetPackage,
PackageManager.getLaunchIntentForPackage(String)public boolean beforeStart()
AbstractTestRunnerAbstractTestRunner.onCreate(Bundle) initialization after AbstractTestRunner.doBindService()
immediately before Instrumentation.start().
Allows subclasses to do any additional setup prior to starting the Instrumentation Thread as part of the onCreate call.
beforeStart in class AbstractTestRunnerpublic void afterStart()
AbstractTestRunnerAbstractTestRunner.onCreate(Bundle) initialization after Instrumentation.start().
Allows subclasses to do any additional setup after the Instrumentation Thread has been started as part of the onCreate call.
afterStart in class AbstractTestRunnerpublic void launchApplication()
public void closeApplication()
public MessageResult handleDispatchFile(java.lang.String filename)
public MessageResult handleMessage(java.lang.String message)
public MessageResult handleServerConnected()
public MessageResult handleServerDisconnected()
public MessageResult handleServerShutdown()
public MessageResult handleRemoteShutdown()
Copyright © SAS Institute. All Rights Reserved.