org.safs
Class ComponentFunction

java.lang.Object
  extended by org.safs.Processor
      extended by org.safs.ComponentFunction
Direct Known Subclasses:
CFComponent, CFComponent, CFComponent, CFComponent, CFComponentFunctions, CFDefaultComponent, CFEditBox, CFTIDComponent, CFWindow

public abstract class ComponentFunction
extends Processor


Purpose: abstract ComponentFunction, enforces that the 'process' method be implemented

Since:
JUN 04, 2003
JUN 04, 2003 (DBauman) Original Release
SEP 16, 2003 (CANAGL) Implemented use of new SAFSLOGS logging.
NOV 10, 2003 (CANAGL) Added isSupportedRecordType() implementation.
OCT 28, 2005 (CANAGL) Refactored to allow for override of convertCoords methods.
MAR 19, 2008 (LeiWang) Added componentSuccessMessage for common success message use.
MAR 25, 2008 (JuwnuMa) Added componentExecutedFailureMessage
DEC 03, 2008 (LeiWang) Modify method action_getGuiImage() and action_verifyGuiImageToFile(): Call ImageUtils.saveImageToFile() to save image, instead of ImageIO.write(); Because using ImageIO.write() will loss quality of jpg image. Now we use full quality to save jpg image, that is when call ImageUtils.saveImageToFile(), we set its third parameter to 1.0f
MAR 25, 2009 (CANAGL) Added issuePassedSuccessUsing
NOV 12, 2009 (CANAGL) Simple JavaDoc update
APR 14, 2010 (JunwuMa)Move TIDComponent.setRectVars() to ComponentFunction for sharing.

Field Summary
protected  java.lang.String action
           
protected  java.lang.String compName
           
protected  java.lang.String mapname
           
protected  DDGUIUtilities utils
           
protected  java.lang.String windowName
           
 
Fields inherited from class org.safs.Processor
breakpointsOn, CASE_INSENSITIVE_FLAG, CASEINSENSITIVE_FLAG, clearProxiesAlways, commandLineBreakpoint, customStr, customText, DEBUG_MESSAGE, debugStr, debugText, DEFAULT_CUSTOM_PROCESSOR_PACKAGE, DEFAULT_CUSTOM_PROCESSOR_SUBPACKAGE, DEFAULT_PROCESSOR_PACKAGE, FAILED_MESSAGE, FAILED_OK_MESSAGE, failedStr, failedText, FAILURE_DETAIL, GENERIC_MESSAGE, genericStr, genericText, LINE_FAILURE_4, log, myBreakpointsOn, otherStr, otherText, PARAM_SIZE_1, PARAM_SIZE_2, PARAM_SIZE_3, PARAM_SIZE_4, params, PASSED_MESSAGE, passedStr, passedText, PRE_TXT_SUCCESS_4, PRE_TXT_SUCCESS_5, processorConfigSet, processorMap, recordProcessed, RECTYPE_DRIVER_COMMAND, RECTYPE_DRIVER_COMMAND_F, RECTYPE_DRIVER_COMMAND_W, RECTYPE_TEST_STEP, RECTYPE_TEST_STEP_F, RECTYPE_TEST_STEP_W, RFSMCache, RFSMOnly, RFT_FIND_SEARCH_MODE_ALGORITHM, RFT_FIND_SEARCH_MODE_CACHE, SAFS_CLEARPROXIESALWAYS_ITEM, SAFS_COMMANDLINEBREAKPOINT_ITEM, SAFS_COMMANDLINEBREAKPOINT_VARIABLE, SAFS_PARAMS_FILE, SAFS_RESBUN_NAME, SAFS_SECSWAITFORCOMPONENT_ITEM, SAFS_SECSWAITFORCOMPONENT_VARIABLE, SAFS_SECSWAITFORWINDOW_ITEM, SAFS_SECSWAITFORWINDOW_VARIABLE, SAFS_TESTDOMAINS_ITEM, SAFS_TESTDOMAINS_VARIABLE, secsWaitForComponent, secsWaitForWindow, SENT_MSG_3, testDomains, testRecordData, TXT_FAILURE_1, TXT_FAILURE_2, TXT_FAILURE_3, TXT_FAILURE_4, TXT_FAILURE_5, TXT_SUCCESS_1, TXT_SUCCESS_2, TXT_SUCCESS_2a, TXT_SUCCESS_3, TXT_SUCCESS_3a, TXT_SUCCESS_4, TXT_SUCCESS_5, WARNING_MESSAGE, WARNING_OK_MESSAGE, warningStr, warningText
 
Constructor Summary
ComponentFunction()
          
Purpose: constructor
 
Method Summary
protected  void action_getGuiImage()
          Processes a Component Function Test Record to capture a screen GUI image to a file.
protected  void action_verifyGuiImageToFile()
          Processes a Component Function Test Record to verify a screen GUI image to a file.
protected  void componentExecutedFailureMessage(java.lang.String detail)
          "windowname compName action processed with a negative result." "[detail]"
Purpose: log a simple failure message when a test record got processed with negative result.
protected  void componentFailureMessage(java.lang.String detail)
          "Unable to perform action on compName in file line N." "[Detail]"
Purpose: log an "Unable to perform function" FAILED_MESSAGE with detail.
protected  void componentSuccessMessage(java.lang.String detail)
          "windowName compName action successful." "[detail]"
Purpose: Log a generic success message.
 java.awt.Point convertCoords(java.lang.String coords)
          Convert coordinates string of the formats: "x;y" "x,y" "x y" "Coords=x;y" "Coords=x,y" "Coords=x y" into a java.awt.Point object.
 java.awt.Polygon convertLine(java.lang.String coords)
          Convert 2-point Line coordinates string of the formats: "x1;y1;x2;y2" "x1,y1,x2,y2" "x1 y1 x2 y2" "Coords=x1;y1;x2;y2" "Coords=x1,y1,x2,y2" "Coords=x1 y1 x2 y2" into a java.awt.Polygon object.
 java.lang.Integer convertNum(java.lang.String num)
          
Purpose: convertNum: convert into a number
Assumptions: all exceptions are handled.
 java.util.Collection getAlternateParams()
          
Purpose: zero-based params with:
windowname compname +N additional parameters
protected  java.awt.Rectangle getComponentRectangle()
          Do nothing method returns null.
protected  void getHelpers()
          Simply calls getHelpersWorker.
protected  void getHelpersWorker()
          set instance variables from the current testRecordData: actionwindowNamecompNamemapnameutils Subclasses can override this for any additional setup beyond getHelpersWorker.
protected  void issueActionFailure(java.lang.String error)
          "Unable to perform action.
protected  void issueActionOnXFailure(java.lang.String x, java.lang.String error)
          "Unable to perform action on [x].
protected  void issueErrorPerformingAction(java.lang.String error)
          "Error performing action.
protected  void issueErrorPerformingActionOnX(java.lang.String x, java.lang.String error)
          Sets GENERAL_SCRIPT_FAILURE and issues a FAILED_MESSAGE: "Error performing action on [x].
protected  void issueFileErrorFailure(java.lang.String filename)
          Issue a file error and failure message Filename does not need to be localized.
protected  void issueInputRecordFailure(java.lang.String error)
          "Unable to perform action.
protected  void issueParameterCountFailure()
          Issue parameter count error and failure message
protected  void issueParameterCountFailure(java.lang.String detail)
          Issue parameter count error and failure message
protected  void issueParameterValueFailure(java.lang.String paramName)
          Issue parameter value error and failure message
protected  void issuePassedSuccess(java.lang.String comment)
          "windowName compName action successful.
protected  void issuePassedSuccessUsing(java.lang.String using)
          "windowName compName action successful using [using]" Sets status to OK and issues a PASSED message.
protected  void issueUnknownErrorFailure(java.lang.String cause)
          Issue a generic error and failure message The cause parameter is expected to already be localized.
 boolean isSupportedRecordType(java.lang.String recordType)
          Supports standard TEST STEP record types (T, TW, TF)
protected  java.awt.Point lookupAppMapCoordReference(java.lang.String referenceName)
          lookupAppMapCoordReference: uses 'convertCoords' after the call to 'lookupAppMapReference'.
protected  java.awt.Polygon lookupAppMapLineReference(java.lang.String referenceName)
          lookupAppMapLineReference: uses 'convertLine' after the call to 'lookupAppMapReference'.
protected  java.lang.Integer lookupAppMapNumReference(java.lang.String referenceName)
          
Purpose: lookupAppMapNumReference: uses 'convertNum' after the call to 'lookupAppMapReference'.
protected  java.lang.String lookupAppMapReference(java.lang.String referenceName)
          Looks up an item using the current appmapID=mapname, section=compName, item=referenceName.
protected  boolean setRectVars(java.awt.Rectangle rect, java.lang.String varname)
          Set the varname.x, varname.y, varname.w, and varname.h variables to the values retrieved from the rectangle.
protected  void updateFromTestRecordData()
          Updates our internal storage for action, windowName, compName, and mapname from the current TestRecordData.
 
Methods inherited from class org.safs.Processor
activateBreakpoint, checkBreakpoints, checkMyBreakpoints, delay, distributeConfigInformation, getAppMapItem, getChainedProcessor, getClassInstance, getClearProxiesAlways, getCustomProcClassNames, getCustomProcInstancePath, getLogUtilities, getParams, getProcClassNames, getProcInstance, getProcInstancePath, getRequiredField, getSecsWaitForComponent, getSecsWaitForWindow, getStandardErrorMessage, getTestRecordData, getVariable, hasChainedProcessor, initProcessorAndProcess, instanceProcessorAndProcess, isBreakpointsOn, isComponentFunctionRecord, isDriverCommandRecord, isEngineCommandRecord, isMyBreakpointsOn, isRecordProcessed, isRFSMCache, isRFSMOnly, paramsFailedMsg, paramsFailedMsg, process, processCustomProcessor, processSubclassProcessor, setBreakpointsOn, setChainedProcessor, setClearProxiesAlways, setCommandLineBreakpoint, setCustomProcInstancePath, setLogUtilities, setMyBreakpointsOn, setParams, setProcInstance, setProcInstancePath, setRecordProcessed, setRFSMCache, setRFSMOnly, setSecsWaitForComponent, setSecsWaitForWindow, setTestDomains, setTestRecordData, setVariable, standardFailureMessage, substituteVariable, validateParamSize, validProcessorClassName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected java.lang.String action

windowName

protected java.lang.String windowName

compName

protected java.lang.String compName

mapname

protected java.lang.String mapname

utils

protected DDGUIUtilities utils
Constructor Detail

ComponentFunction

public ComponentFunction()

Purpose: constructor

Method Detail

updateFromTestRecordData

protected void updateFromTestRecordData()
Updates our internal storage for action, windowName, compName, and mapname from the current TestRecordData. Missing items in the TestRecordData will update our storage with null.


isSupportedRecordType

public boolean isSupportedRecordType(java.lang.String recordType)
Supports standard TEST STEP record types (T, TW, TF)

Specified by:
isSupportedRecordType in class Processor
Parameters:
recordType - -- String text of record type to match (ignoring case).
Returns:
'true' if the provided recordType is one this Processor can execute. Note, that SAFS record types are normally not case-sensitive. So the comparison to match the provided recordType should ignore case.


getAlternateParams

public java.util.Collection getAlternateParams()

Purpose: zero-based params with:
  1. windowname
  2. compname
  3. +N additional parameters

Overrides:
getAlternateParams in class Processor
Returns:
Collection

getHelpersWorker

protected void getHelpersWorker()
                         throws SAFSException
set instance variables from the current testRecordData: Subclasses can override this for any additional setup beyond getHelpersWorker.

Throws:
SAFSException

getHelpers

protected void getHelpers()
                   throws SAFSException
Simply calls getHelpersWorker. Subclasses can override this for any additional setup beyond getHelpersWorker.

Throws:
SAFSException

convertNum

public java.lang.Integer convertNum(java.lang.String num)

Purpose: convertNum: convert into a number
Assumptions: all exceptions are handled.

Parameters:
numStr, - String (indexed from 1, 1 will be subtracted from the number before returned)
Returns:
Integer if successfull, null otherwise (if alpha chars instead of digits are encountered; or if number is less than one)

convertCoords

public java.awt.Point convertCoords(java.lang.String coords)
Convert coordinates string of the formats: into a java.awt.Point object.

Subclasses may override to convert alternative values, such as Row and Col values as is done in org.safs.rational.CFTable

Parameters:
coords, - String x;y or x,y or Coords=x;y or Coords=x,y
Returns:
Point if successfull, null otherwise

convertLine

public java.awt.Polygon convertLine(java.lang.String coords)
Convert 2-point Line coordinates string of the formats: into a java.awt.Polygon object.

Parameters:
coords, - String x1;y1;x2;y2 or x1,y1,x2,y2 or Coords=x1;y1;x2;y2 or Coords=x1,y1,x2,y2
Returns:
Polygon if successfull, null otherwise

lookupAppMapReference

protected java.lang.String lookupAppMapReference(java.lang.String referenceName)
Looks up an item using the current appmapID=mapname, section=compName, item=referenceName. mapname and compName are expected to already be set from prior command processing.

Parameters:
referenceName -
Returns:
retrieved value or null

lookupAppMapCoordReference

protected java.awt.Point lookupAppMapCoordReference(java.lang.String referenceName)
lookupAppMapCoordReference: uses 'convertCoords' after the call to 'lookupAppMapReference'.

Parameters:
referenceName, - String, the reference name passed on to method 'lookupAppMapReference' to lookup the coordinate string from an AppMap. Then that value is passed on to convertCoords.
Returns:
Point if successfull, null otherwise (if alpha chars instead of digits are encountered; or if row or col less than one)

lookupAppMapLineReference

protected java.awt.Polygon lookupAppMapLineReference(java.lang.String referenceName)
lookupAppMapLineReference: uses 'convertLine' after the call to 'lookupAppMapReference'.

Parameters:
referenceName, - String, the reference name passed on to method 'lookupAppMapReference' to lookup the Line string from an AppMap. Then that value is passed on to convertLine.
Returns:
Polygon if successfull, null otherwise (if alpha chars instead of digits are encountered; or if less than 2 points are detected.)

lookupAppMapNumReference

protected java.lang.Integer lookupAppMapNumReference(java.lang.String referenceName)

Purpose: lookupAppMapNumReference: uses 'convertNum' after the call to 'lookupAppMapReference'.

Parameters:
referenceName, - String, the reference name passed on to method 'lookupAppMapReference' to lookup the number string from an AppMap. Then that value is passed on to convertNum.
Returns:
Integer if successfull, null otherwise (if alpha chars instead of digits are encountered; or if index is less than one)

componentFailureMessage

protected void componentFailureMessage(java.lang.String detail)
"Unable to perform action on compName in file line N." "[Detail]"
Purpose: log an "Unable to perform function" FAILED_MESSAGE with detail. Expects testRecordData to already have filename, lineNumber, compName, and command.


componentSuccessMessage

protected void componentSuccessMessage(java.lang.String detail)
"windowName compName action successful." "[detail]"
Purpose: Log a generic success message.


componentExecutedFailureMessage

protected void componentExecutedFailureMessage(java.lang.String detail)
"windowname compName action processed with a negative result." "[detail]"
Purpose: log a simple failure message when a test record got processed with negative result. When an action intends to make a judgment, a negative result is gotten if the logical result of the judgment is false; the test step will be logged as 'FAIL' although it got executed correctly. Called by some comparing actions. E.g. When doing verifyCaptureText, the result is negative if the body test captured doesn't match the bench mark file. * @param detail -- a detail message


issuePassedSuccess

protected void issuePassedSuccess(java.lang.String comment)
"windowName compName action successful. [comment]" Sets status to OK and issues a PASSED message. string comment is expected to already be localized.


issuePassedSuccessUsing

protected void issuePassedSuccessUsing(java.lang.String using)
"windowName compName action successful using [using]" Sets status to OK and issues a PASSED message. string comment is expected to already be localized, if necessary.


issueInputRecordFailure

protected void issueInputRecordFailure(java.lang.String error)
"Unable to perform action. [error]" "Details + inputrecord" Sets status to FAILURE and issues a FAILED message. called by other issueFailure routines


issueActionFailure

protected void issueActionFailure(java.lang.String error)
"Unable to perform action. [error]. "Details + [error]" Sets status to FAILURE and issues a FAILED message. called by other issueFailure routines


issueActionOnXFailure

protected void issueActionOnXFailure(java.lang.String x,
                                     java.lang.String error)
"Unable to perform action on [x]. [error]." "Details + [error]" Sets status to FAILURE and issues a FAILED message.


issueErrorPerformingAction

protected void issueErrorPerformingAction(java.lang.String error)
"Error performing action. [error]" "Details + [error]"


issueErrorPerformingActionOnX

protected void issueErrorPerformingActionOnX(java.lang.String x,
                                             java.lang.String error)
Sets GENERAL_SCRIPT_FAILURE and issues a FAILED_MESSAGE: "Error performing action on [x]. [error]" "Details + [error]"


issueParameterCountFailure

protected void issueParameterCountFailure()
Issue parameter count error and failure message


issueParameterCountFailure

protected void issueParameterCountFailure(java.lang.String detail)
Issue parameter count error and failure message

Parameters:
detail - detail about specific missing params or command format

issueParameterValueFailure

protected void issueParameterValueFailure(java.lang.String paramName)
Issue parameter value error and failure message

Parameters:
paramName - -- the Name of the action parameter in error.

issueFileErrorFailure

protected void issueFileErrorFailure(java.lang.String filename)
Issue a file error and failure message Filename does not need to be localized.


issueUnknownErrorFailure

protected void issueUnknownErrorFailure(java.lang.String cause)
Issue a generic error and failure message The cause parameter is expected to already be localized.


getComponentRectangle

protected java.awt.Rectangle getComponentRectangle()
Do nothing method returns null. Subclasses should override to provide the true Rectangle bounds of the Component currently represented in the current testRecordData. Subclasses should assume the mapname, windowName, and compName currently stored for the instance hold the information needed to identify and locate the Component on the screen or in the system.

Returns:
Rectangle bounds of the Component or null. If null is received the class assumes relevant error logging and testRecordData.statuscode changes have already been performed.

action_getGuiImage

protected void action_getGuiImage()
                           throws SAFSException
Processes a Component Function Test Record to capture a screen GUI image to a file. Currently, the available formats for the output file are JPG, BMP, TIF, GIF, PNG and PNM. Optionally, the user may utilize the SubArea parameter to only capture a portion of the Component. This routine expects to be called by subclasses only and the subclass must override the getComponentRectangle method to provide the necessary location of the desired Component. Subclasses must also have already set the fields for mapname, windowName, compName, and action. This is usually already done in the process() call from the subclasses. This routine utilizes Java Advanced Imaging (JAI) to output the screen image to the file. JAI must be installed at compile time and runtime.

Throws:
SAFSException

action_verifyGuiImageToFile

protected void action_verifyGuiImageToFile()
                                    throws SAFSException
Processes a Component Function Test Record to verify a screen GUI image to a file. Currently, the available formats for the output file are BMP and JPG. Optionally, the user may utilize the SubArea parameter to only capture a portion of the Component. This routine expects to be called by subclasses only and the subclass must override the getComponentRectangle method to provide the necessary location of the desired Component. Subclasses must also have already set the fields for mapname, windowName, compName, and action. This is usually already done in the process() call from the subclasses. This routine utilizes Java Advanced Imaging (JAI) to output the screen image to the file. JAI must be installed at compile time and runtime.

Throws:
SAFSException

setRectVars

protected boolean setRectVars(java.awt.Rectangle rect,
                              java.lang.String varname)
Set the varname.x, varname.y, varname.w, and varname.h variables to the values retrieved from the rectangle.

Parameters:
loc -
varname -
Returns: