Custom Adapter Reference |
Custom Recorder Adapters implement the following calls. The shaded rows list functions that other adapter types also implement.
Identifies a Custom Recorder Adapter.
BOOL IsCustomRecorderAdapter
();
Return TRUE to indicate that this is a Custom Recorder Adapter. Any other response disables the adapter.
A C adapter should respond to this call as illustrated below.
extern "C" BOOL LINKDLL IsCustomRecorderAdapter() { return TRUE; }
Performs initialization procedures.
intInitializeRecorder
(TCHAR *errorMessage
, size_terrorMessageSize
);
Initialization procedures are optional and adapter-defined. A return of RSR_SUCCESS
indicates that the adapter is prepared to begin recording a session on request.
extern "C" int LINKDLLInitializeRecorder
(TCHAR *errorMessage
, size_terrorMessageSize
) { //perform initialization procedures if (successful) return RSR_SUCCESS else { TCHAR buf[] = "Recorder failed to initialize"; if (_tcslen(buf) >= errorMessageSize) return RSR_BUFFER_TOO_SHORT; _tcscpy(errorMessage, buf); return RSR_FAILURE; } }
StartRecording()
,
StopRecording()
intStartRecording
(TCHAR *sessionPath
, size_tsessionPathSize
, StatusCallbackPtrfPtr
, TCHAR *errorMessage
, size_terrorMessageSize
);
This example starts recording into an XML session file.
extern "C"
int LINKDLL StartRecording
(TCHAR* pathname,
size_t pathnameSize,
StatusCallbackPtr fPtr,
TCHAR* errorMessage,
size_t errorMessageSize)
{
TCHAR buf[1024];
_tcscpy (buf, "Start recording to: ");
_tcscat(buf, pathname);
MessageBox(NULL, buf,"", MB_OK);
TCHAR fileName[1024];
_tcscpy(fileName, pathname);
_tcscat(fileName, ".xml");
ofstream of (fileName);
if (of)
of << "<?xml version=\"1.0\" ?>\n<Sample>\n </Sample>" << endl;
fPtr(RSR_CALLBACK_PROGRESS, "I am doing OK");
return RSR_SUCCESS;
}
InitializeRecorder(), StopRecording()
Concludes a recording session.
intStopRecording
(TCHAR *errorMessage
, size_terrorMessageSize
);
This call is made when a Robot user ends a recording session. Stop recording and return RSR_SUCCESS
.
If you return RSR_BUFFER_TOO_SHORT
to indicate that the initial errorMessageSize
is too small, Robot loops until errorMessageSize
is large enough to contain errorMessage
.
extern "C"
int LINKDLL StopRecording
(TCHAR* errorMessage,
size_t errorMessageSize)
{
//stop recording
if (successful)
return RSR_SUCCESS
else
{
TCHAR buf[] = "Couldn't stop!!!";
if (_tcslen(buf) >= errorMessageSize)
return RSR_BUFFER_TOO_SHORT;
_tcscpy(errorMessage, buf);
return RSR_FAILURE;
}
}
InitializeRecorder(), StartRecording()
Returns the public name of this adapter.
intGetDisplayName
(TCHAR *name
, size_tnameSize
);
name |
Pointer to a container for the adapter's display name. Copy the name to this location. |
nameSize |
INPUT. The size allocated for name . The adapter's display name cannot exceed this size. |
Specify the GUI name for this adapter. This name is presented to the Robot user (in the Recorder list box beside the Use Custom radio box) on the Method tab of the Session Record Options dialog.
This example specifies that the GUI name of this adapter is rtweblogicEJB
.
extern "C"
int LINKDLL GetDisplayName
(TCHAR *name, size_t nameSize)
{
TCHAR buf[] = "rtweblogicEJB";
if (_tcslen(buf) > nameSize)
return RSR_BUFFER_TOO_SHORT;
_tcscpy(name, buf);
return RSR_SUCCESS;
}
Returns configuration options in effect for this adapter.
intGetOptions
(TCHAR *options
, size_toptionsSize
);
As illustrated in the example, options supported by an adapter should be entered from a saved, local file. Otherwise, they do not persist between sessions.
Your adapter can define a custom format for options and provide a custom GUI for displaying and editing them and code to communicate the user's choices to the adapter. Do not include custom-format options in your response to this call.
The following table describes the Robot-defined configuration option arguments that a Custom Recorder Adapter can support. See Adapter Configuration on page 81 for a mapping of these options to the Robot GUI.
The following response indicates that this adapter:
extern "C"
int LINKDLL GetOptions
(TCHAR* options, size_t optionsSize)
{
TCHAR buf[RSR_MAX_OPTIONS];
_tcscpy(buf, _T(""));
_tcscat(buf, SESSION_FILES);
_tcscat(buf, _T(",xml"));
_tcscat(buf, _T(";"));
_tcscat(buf, DEFAULT_SCRIPT_GENERATOR);
_tcscat(buf, _T(",mySGA"));
_tcscat(buf, _T(";"));
_tcscat(buf, RECORD_SPLITS);
_tcscat(buf, _T(";"));
if (_tcslen(buf) > optionsSize)
return RSR_BUFFER_TOO_SHORT;
_tcscpy(options, buf);
return RSR_SUCCESS;
}
Sets user-specified configuration options for this adapter.
intSetOptions
(TCHAR *options
, size_toptionsSize
);
options |
INPUT. Pointer to a read-only location containing the Robot user's selections. |
optionsSize |
INPUT. The size of options . |
When the user selects or specifies a value for a Robot-defined option or edits an adapter-defined option, this call communicates the user's choice to your adapter.
This call also returns a user's choices for adapter-defined options, in the triplet format, that were selected from a Robot-provided dialog. However, if you use a custom GUI for displaying and editing custom options, you are responsible for reading the dialog, conveying the user's choices to the adapter, parsing, validation, and sending an appropriate error message for invalid user specifications.
This example checks to see whether a Robot user selected the Think maximum (ms) option.
extern "C"
int LINKDLL SetOptions
(TCHAR* options, size_t optionsSize)
{
/* CStringArray declared for parsed sub-strings */
CStringArray OptionsArray;
/* parse the original string with semi-colon delimeter.*/
ParseString(options,';',&OptionsArray);
for(int i = 0;i<OptionsArray.GetSize();i++)
{
/* for every sub-string, create another CStringArray*/
CStringArray SubArray;
if(!OptionsArray.GetAt(i).IsEmpty())
{
/*parse the substrings with comma delimeters */
ParseString (OptionsArray.GetAt(i).GetBuffer
(OptionsArray.GetAt(i).GetLength()),',',&SubArray);
/* deal with each sub-string set */
if(SubArray[0]==GENERATOR_THINK)
{
if(SubArray[1] == 0)
{
int think_min = SubArray[2];
}
else
{
/* Unrecognized option -- error may be thrown*/
}
}
}
}
Provides a custom GUI for adapter-defined configuration options.
intDisplayCustomConfigGUI
(TCHAR *errorMessage
, size_terrorMessageSize
);
If your adapter specifies the option CONFIGURATION,USE_CUSTOM_UI
, a Configure button on the Method:Custom tab of the Session Record Options dialog is enabled. If a user clicks this button, Robot issues this call. In response, your adapter should display a custom GUI for entering or editing custom configuration options.
GetOptions()
, and the options need not adhere to the triplet format defined by Robot for custom options.
GetOptions()
, the Robot user can use a provided triplet grid as well as your custom GUI.
GetOptions()
. Doing so causes an error because the format is not understood.
SetOptions()
. With a custom GUI, you are responsible for reading and persisting user choices.
extern "C" int LINKDLLDisplayCustomConfigGUI
(TCHAR *errorMessage
, size_terrorMessageSize
) { //display custom GUI and gather user input if (successful) return RSR_SUCCESS; else { TCHAR buf[] = "Custom GUI failed to start"; if (_tcslen(buf) > errorMessageSize) return RSR_BUFFER_TOO_SHORT; _tcscpy(errorMessage, buf); return RSR_FAILURE; } }
Session Recording Extensibility Reference | Rational Software Corporation |
Copyright (c) 2003, Rational Software Corporation | http://www.rational.com support@rational.com info@rational.com |