public class DJavaHook extends JavaSocketsHook implements LogsInterface
The STAF name predefined for this Droid Engine is "SAFS/DROID".
As of this writing, this hook uses standard org.safs.LogUtilities.
The SAFS/DROID engine does require Droid-specific implementations of
If the engine is being launched manually or via a batch file or script then the following Java System property MUST be set on the Java command line:
testpath is the file path to the test configuration INI file,
projectpath is the file path to the project configuration INI file,
driverpath is the file path to the SAFS driver configuration INI file.
-Dsafs.config.paths=<testpath>;<projectpath>;<driverpath> Example: -Dsafs.config.paths=C:\safs\samples\Droid\droidtest.ini;C:\safs\samples\Droid\safstid.ini;C:\safs\safstid.ini
At least one INI file path must be specified or the engine will abort due to insufficient configuration information being provided.
The configuration file(s) must minimally provide the following information:
The configuration file(s) can also provide the following:
The configuration file(s) can optionally also contain other relevant information as described in the SAFSDROID Java Engine. Also see SAFSTID Config Files for more information.
Assuming everything is properly CLASSPATHed and the config file(s) have proper settings then the Engine can then be launched with:
java -Dsafs.config.paths=<paths> org.safs.android.DJavaHook
Modifier and Type | Field and Description |
---|---|
protected boolean |
_forceClear |
protected boolean |
_forceStop |
protected boolean |
_unlockEmulatorScreen |
protected boolean |
_weSetTargetAPP |
protected boolean |
_weSetTargetPackage |
static java.lang.String |
DEFAULT_SAFS_SERVICE_APP |
static java.lang.String |
DEFAULT_SAFS_SERVICE_PACKAGE |
static java.lang.String |
DEFAULT_TEST_RUNNER_APP |
static java.lang.String |
DEFAULT_TEST_RUNNER_INSTRUMENT |
static java.lang.String |
DEFAULT_TEST_RUNNER_PACKAGE |
static java.lang.String |
DEFAULT_TEST_RUNNER_SOURCE |
static java.lang.String |
DROID_COMMANDS
Our predefined STAF process name: "SAFS/DROID"
|
protected boolean |
persistEmulators |
protected boolean |
persistJVM |
protected boolean |
portForwarding |
protected java.lang.String |
remoteComment |
protected java.lang.String |
remoteDetail |
protected int |
remoteLogtype |
protected boolean |
weLaunchedEmulator |
remoteConnectionTimeout, remoteReadyTimeout, remoteRunningTimeout, socketdata, tcpServer
data, DEBUG_MESSAGE, errorText, FAILED_MESSAGE, FAILED_OK_MESSAGE, GENERIC_ERROR, GENERIC_MESSAGE, helper, hookconfig, log, PASSED_MESSAGE, PAUSE_EXECUTION, PAUSE_SWITCH_OFF, PAUSE_SWITCH_ON, process_name, processor, REQUEST_PROCEED_TESTING, REQUEST_USER_STOPPED_SCRIPT_REQUEST, RUNNING_EXECUTION, semaphore_name, SHUTDOWN_RECORD, STAF_ERROR, STEP_EXECUTION, STEP_RETRY_EXECUTION, STEPPING_EXECUTION, STEPPING_RETRY_EXECUTION, trd_name, utils, WARNING_MESSAGE, WARNING_OK_MESSAGE
Constructor and Description |
---|
DJavaHook()
No-arg constructor for DJavaHook
Simply calls the super()
|
DJavaHook(java.lang.String process_name)
Constructor for DJavaHook
Simply calls super(process_name)
|
DJavaHook(java.lang.String process_name,
LogUtilities logs)
Constructor for DJavaHook
Simply calls super(process_name, logs)
|
DJavaHook(java.lang.String process_name,
java.lang.String trd_name)
Constructor for DJavaHook
Simply calls super(process_name, trd_name)
|
DJavaHook(java.lang.String process_name,
java.lang.String trd_name,
LogUtilities logs)
Constructor for DJavaHook
Simply calls super(process_name, trd_name, logs)
|
DJavaHook(java.lang.String process_name,
java.lang.String trd_name,
LogUtilities logs,
SocketTestRecordHelper trd_data,
DDGUIUtilities gui_utils,
ProcessRequest aprocessor)
Advanced Constructor for DJavaHook.
|
Modifier and Type | Method and Description |
---|---|
boolean |
afterLaunchRemoteEngine()
Minimally, forward TCP Port if we launched an Emulator.
|
boolean |
beforeLaunchRemoteEngine()
Perform some initial validation of SAFS_DROID project settings and availability of
test assets defined there.
|
protected boolean |
createProtocolRunner()
Invoked during start loop initialization.
|
void |
debug(java.lang.String message)
Solo Remote control LogsInterface implementation.
|
void |
enableDebug(boolean enabled)
Solo Remote control LogsInterface implementation.
|
void |
enableSoloLogs(boolean enabled)
Enable/Disable log output from the Solo LogsInterface methods pass, fail, warn.
|
void |
fail(java.lang.String action,
java.lang.String message)
Solo Remote control LogsInterface implementation.
|
static CaseInsensitiveFile |
getAbsoluteFile(java.lang.String dir,
java.lang.String file)
Get an CaseInsensitiveFile
|
DDGUIUtilities |
getGUIUtilities()
Use this method to retrieve/create the current/default DDGUIUtilities instance.
|
LogUtilities |
getLogUtilities()
Use this method to retrieve/create the current/default LogUtilities instance.
|
ProcessRequest |
getRequestProcessor()
Use this method to retrieve/create the current/default ProcessRequest instance.
|
TestRecordHelper |
getTRDData()
Use this method to retrieve/create the current/default TestRecordHelper instance.
|
protected boolean |
hook_shutdown()
Perform final hook shutdown activities--such as killing emulators, if needed.
|
void |
info(java.lang.String message)
Solo Remote control LogsInterface implementation.
|
protected void |
interpretResultProperties(java.util.Properties remoteResultProperties)
Called by the running loop to extract whatever remoteResultProperties were received.
|
boolean |
isDebugEnabled()
Solo Remote control LogsInterface implementation.
|
boolean |
isSoloLogsEnabled() |
boolean |
launchRemoteEngine()
If no devices/emulators are running, then we will launch one based on DEFAULT or INI settings.
|
protected void |
logResultsMessage()
Called by the running loop when it is time to log the results of the executed command.
|
static void |
main(java.lang.String[] args)
Launches a default instance of the SAFS/DROID engine.
|
void |
pass(java.lang.String action,
java.lang.String message)
Solo Remote control LogsInterface implementation.
|
boolean |
startProtocolRunner()
Performs the normal startProtocolRunner of the superclass.
|
void |
warn(java.lang.String action,
java.lang.String message)
Solo Remote control LogsInterface implementation.
|
disconnectSocketServer, getListenerName, onReceiveDebug, setTRDData, start
allowSystemExit, checkConfiguration, driverShutdownRequest, evaluateRuntimeException, getHelper, getProcessName, getSemaphoreName, getTRDName, initConfigPaths, instantiateHookConfig, setGUIUtilities, setHelper, setLogUtilities, setProcessName, setRequestProcessor, setSemaphoreName, setTRDName
public static final java.lang.String DROID_COMMANDS
public static final java.lang.String DEFAULT_SAFS_SERVICE_APP
public static final java.lang.String DEFAULT_SAFS_SERVICE_PACKAGE
public static final java.lang.String DEFAULT_TEST_RUNNER_APP
public static final java.lang.String DEFAULT_TEST_RUNNER_PACKAGE
public static final java.lang.String DEFAULT_TEST_RUNNER_SOURCE
public static final java.lang.String DEFAULT_TEST_RUNNER_INSTRUMENT
protected java.lang.String remoteComment
protected java.lang.String remoteDetail
protected int remoteLogtype
protected boolean weLaunchedEmulator
protected boolean persistEmulators
protected boolean persistJVM
protected boolean _unlockEmulatorScreen
protected boolean _forceStop
protected boolean _forceClear
protected boolean _weSetTargetAPP
protected boolean _weSetTargetPackage
protected boolean portForwarding
public DJavaHook()
public DJavaHook(java.lang.String process_name)
process_name
- the ID to use when registering with STAF.
Normally this would be our predefined name "SAFS/DROID".public DJavaHook(java.lang.String process_name, LogUtilities logs)
process_name
- the ID to use when registering with STAF.
Normally this would be our predefined name "SAFS/DROID".logs
- the LogUtilities to be used by the Engine. Currently we can
use the default org.safs.LogUtilitiesorg.safs.LogUtilites
public DJavaHook(java.lang.String process_name, java.lang.String trd_name)
process_name
- the ID to use when registering with STAF.
Normally this would be our predefined name "SAFS/DROID".trd_name
- -- The root name for specific TestRecordData to reference
in STAF. This should typically be STAFHelper.SAFS_HOOK_TRD which is used
by default.STAFHelper.SAFS_HOOK_TRD
public DJavaHook(java.lang.String process_name, java.lang.String trd_name, LogUtilities logs)
process_name
- the ID to use when registering with STAF.
Normally this would be our predefined name "SAFS/DROID".trd_name
- -- The root name for specific TestRecordData to reference
in STAF. This should typically be STAFHelper.SAFS_HOOK_TRD which is used
by default.logs
- the LogUtilities to be used by the Engine. Currently we can
use the default org.safs.LogUtilitiesSTAFHelper.SAFS_HOOK_TRD
,
org.safs.LogUtilites
public DJavaHook(java.lang.String process_name, java.lang.String trd_name, LogUtilities logs, SocketTestRecordHelper trd_data, DDGUIUtilities gui_utils, ProcessRequest aprocessor)
process_name
- the ID to use when registering with STAF.
Normally this would be our predefined name "SAFS/DROID".trd_name
- -- The root name for specific TestRecordData to reference
in STAF. This should typically be STAFHelper.SAFS_HOOK_TRD which is used
by default.logs
- the LogUtilities to be used by the Engine.trd_data
- -- DTestRecordHelper to hold TestRecordData.
The Droid engine expects an instance of SocketTestRecordHelper.gui_utils
- -- DGUIUtilities the hook will use for handling components.
The Droid engine expects an instance of DGUIUtilities.aprocessor
- -- ProcessRequest object the hook will use for routing records.
The Droid engine uses the standard ProcessRequest class and a standard TestStepProcessor.STAFHelper.SAFS_HOOK_TRD
,
org.safs.LogUtilites
,
DTestRecordHelper
,
DGUIUtilities
,
ProcessRequest
,
TestStepProcessor
public TestRecordHelper getTRDData()
Note that there is a known circular execution between getTRDData and getGUIUtilities if neither was previously set. Each routine calls the other which may result in a second call to the other. This has not been a problem.
getTRDData
in class JavaSocketsHook
DTestRecordHelper
,
JavaHook.getHelper()
,
getGUIUtilities()
,
JavaHook.getTRDData()
public DDGUIUtilities getGUIUtilities()
Note that there is a known circular execution between getTRDData and getGUIUtilities if neither was previously set. Each routine calls the other which may result in a second call to the other. This has not been a problem.
getGUIUtilities
in class JavaHook
JavaHook.getGUIUtilities()
,
JavaHook.getHelper()
,
getTRDData()
,
DGUIUtilities
public LogUtilities getLogUtilities()
getLogUtilities
in class JavaHook
JavaHook.getLogUtilities()
,
org.safs.LogUtilities
public ProcessRequest getRequestProcessor()
Note that the call to getTRDData() may force the instantiation of the default DTestRecordHelper if one has not already been set. A call to getLogUtilities() may also force the instantiation of the default LogUtilities if one has not already been set.
getRequestProcessor
in class JavaHook
JavaHook.getRequestProcessor()
,
ProcessRequest
,
DTestRecordHelper
,
getTRDData()
,
getLogUtilities()
,
org.safs.LogUtilities
,
DDriverCommand
,
DTestStepProcessor
protected boolean createProtocolRunner()
createProtocolRunner()
beforeLaunchRemoteEngine()
launchRemoteEngine()
afterLaunchRemoteEngine()
startProtocolRunner()
#waitForRemoteConnection(int)
createProtocolRunner
in class JavaSocketsHook
public boolean beforeLaunchRemoteEngine()
createProtocolRunner()
beforeLaunchRemoteEngine()
launchRemoteEngine()
afterLaunchRemoteEngine()
startProtocolRunner()
#waitForRemoteConnection(int)
beforeLaunchRemoteEngine
in class JavaSocketsHook
public static CaseInsensitiveFile getAbsoluteFile(java.lang.String dir, java.lang.String file)
dir
- String, the directory where the file is storedfile
- String, the file relative/absolute namepublic boolean launchRemoteEngine()
We include the loading of required Android packages as part of the launch. We also start the instrumentation runner on the device which starts the TCP Messenger service so that we can start 2-way communication. Invoked during start loop initialization.
createProtocolRunner()
beforeLaunchRemoteEngine()
launchRemoteEngine()
afterLaunchRemoteEngine()
startProtocolRunner()
#waitForRemoteConnection(int)
launchRemoteEngine
in class JavaSocketsHook
public boolean afterLaunchRemoteEngine()
Check/Install SAFSDroidAutomation Engine on device/emulator.
Note: The engine has to be repackaged with specific AdroidManifest entries
for the target AUT package. We can make the users do this manually, or we
may be able to find a way to do this on-the-fly based on INI settings.
Check/Install target AUT package on device/emulator.
Invoked during start loop initialization.
createProtocolRunner()
beforeLaunchRemoteEngine()
launchRemoteEngine()
afterLaunchRemoteEngine()
startProtocolRunner()
#waitForRemoteConnection(int)
afterLaunchRemoteEngine
in class JavaSocketsHook
public boolean startProtocolRunner()
startProtocolRunner
in class JavaSocketsHook
protected void interpretResultProperties(java.util.Properties remoteResultProperties)
JavaSocketsHook
interpretResultProperties
in class JavaSocketsHook
protected void logResultsMessage()
JavaSocketsHook
LogUtilities.logMessage(String, String, int, String)
logResultsMessage
in class JavaSocketsHook
protected boolean hook_shutdown()
hook_shutdown
in class JavaSocketsHook
JavaHook.hook_shutdown()
,
JavaHook.allowSystemExit()
,
DUtilities.shutdownLaunchedEmulators(boolean)
public void pass(java.lang.String action, java.lang.String message)
pass
in interface LogsInterface
public void fail(java.lang.String action, java.lang.String message)
fail
in interface LogsInterface
public void warn(java.lang.String action, java.lang.String message)
warn
in interface LogsInterface
public void info(java.lang.String message)
info
in interface LogsInterface
enableDebug(boolean)
public void debug(java.lang.String message)
debug
in interface LogsInterface
enableDebug(boolean)
public void enableDebug(boolean enabled)
enableDebug
in interface LogsInterface
public boolean isDebugEnabled()
isDebugEnabled
in interface LogsInterface
public void enableSoloLogs(boolean enabled)
public boolean isSoloLogsEnabled()
public static void main(java.lang.String[] args)
Assuming everything is properly CLASSPATHed, the default SAFS/Droid Engine can be launched simply with:
java -Dsafs.config.paths=<paths> org.safs.android.DJavaHook
Copyright © SAS Institute. All Rights Reserved.