HP LoadRunner Protocol SDK Test Run API Reference
12.02
|
The template for an API function that is declared with named arguments ("key=value"). More...
#include <ApiFunctionWithNamedArgs.h>
Public Member Functions | |
CApiFunctionWithNamedArguments (const char *mDisplayName="", int mIconId=-1) | |
Instantiates CApiFunctionWithNamedArguments with the icon and display name. More... | |
virtual | ~CApiFunctionWithNamedArguments () |
Destructor. | |
void | DefineStringArgument (const char *mKey, bool mIsOptional, const char *mDefaultValue="", StringArgumentValidationType mValidationCallback=NULL) |
Defines a formal string argument. More... | |
void | DefineBooleanArgument (const char *mKey, bool mIsOptional, bool mDefaultValue=true, BooleanArgumentValidationType mValidationCallback=NULL) |
Defines a formal boolean argument. More... | |
void | DefineNumericArgument (const char *mKey, bool mIsOptional, double mDefaultValue=0, NumericArgumentValidationType mValidationCallback=NULL) |
Defines a formal numeric argument. More... | |
const char * | GetStringArgumentValue (const char *mKey) const |
Returns the value of a string argument. More... | |
bool | GetBooleanArgumentValue (const char *mKey) const |
Returns the value of a boolean argument. More... | |
double | GetNumericArgumentValue (const char *mKey) const |
Returns the value of a numeric argument. More... | |
bool | IsSpecified (const char *mKey) const |
Checks if an argument with the specified key was passed. More... | |
![]() | |
CApiFunction (const char *mDisplayName="", int mIconId=-1) | |
Instantiates a CApiFunction with icon and display name. More... | |
virtual | ~CApiFunction () |
Destructor. | |
int | Run (const char *mStepName, va_list mVaList=0) |
Executes this API function for one step. More... | |
void | WastedTime (long mMilliSeconds) |
Adds to the wasted time of all open transactions Every call to this method increases the wasted time of all open transactions, including the automatic transaction per step, if any. More... | |
void | ThinkTime (long mSeconds) |
Adds to the think time of all open transactions. More... | |
void | SetResultMessage (int mMessageID,...) |
Sets the message for the test result report. More... | |
Protected Member Functions | |
virtual void | HandleArguments (va_list mVaList) |
Checks if the step arguments are valid and complete. More... | |
virtual bool | CrossArgumentValidation () |
Validates cross argument relations. More... | |
![]() | |
virtual void | Init ()=0 |
Initializations for this API function. More... | |
virtual void | Invoke ()=0 |
Performs the logic of the API function. | |
virtual void | Terminate ()=0 |
Normal termination of the API function. More... | |
virtual void | Abort ()=0 |
Halts the API function when an unrecoverable exception is raised. More... | |
Additional Inherited Members | |
![]() | |
char * | m_stepName |
The display name for the step in which this API function is called. | |
char * | m_displayName |
The API function display name used in log messages and in the result report. | |
int | m_iconId |
The API function icon id. The icon is used in the test result report. | |
char * | m_fullName |
The name used in log messages. | |
The template for an API function that is declared with named arguments ("key=value").
Class CApiFunctionWithNamedArguments extends class CApiFunction to provide a template for an API function that is declared with named arguments ("key=value"). CApiFunctionWithNamedArguments automatically handles the arguments: matching actual arguments to formal arguments, parameterization, validations, and so on. Create a class derived from CApiFunctionWithNamedArguments to implement each API function with named arguments. A function with named arguments is declared as in this example:
The invocation of the function specifies the arguments:
CApiFunctionWithNamedArguments::CApiFunctionWithNamedArguments | ( | const char * | mDisplayName = "" , |
int | mIconId = -1 |
||
) |
Instantiates CApiFunctionWithNamedArguments with the icon and display name.
On UNIX platforms, the icon is not supported; pass the default ID, -1.
mDisplayName | The step display name used in log messages and in the result report |
mIconId | The step icon ID from resource.h. The icon is used in the test result report |
|
protectedvirtual |
Validates cross argument relations.
This function handles function-specific validations. For example, sometimes it is unavoidable that the set of valid values for one argument depends on the value of another argument, or than an optional argument may be required in the case that another argument is or is not passed. If you have such a situation, implement this method to check that such constraints are met.
void CApiFunctionWithNamedArguments::DefineBooleanArgument | ( | const char * | mKey, |
bool | mIsOptional, | ||
bool | mDefaultValue = true , |
||
BooleanArgumentValidationType | mValidationCallback = NULL |
||
) |
Defines a formal boolean argument.
SDK_INTERNAL_ERROR | Internal error |
mKey | Argument key |
mIsOptional | true if the argument is optional, false if mandatory |
mDefaultValue | Default value |
mValidationCallback | verification callback |
void CApiFunctionWithNamedArguments::DefineNumericArgument | ( | const char * | mKey, |
bool | mIsOptional, | ||
double | mDefaultValue = 0 , |
||
NumericArgumentValidationType | mValidationCallback = NULL |
||
) |
Defines a formal numeric argument.
SDK_INTERNAL_ERROR | Internal error |
mKey | Argument key |
mIsOptional | true if the argument is optional, alse if mandatory |
mDefaultValue | Default value |
mValidationCallback | verification callback |
void CApiFunctionWithNamedArguments::DefineStringArgument | ( | const char * | mKey, |
bool | mIsOptional, | ||
const char * | mDefaultValue = "" , |
||
StringArgumentValidationType | mValidationCallback = NULL |
||
) |
Defines a formal string argument.
SDK_INTERNAL_ERROR | Internal error |
mKey | Argument key |
mIsOptional | true if the argument is optional, false if mandatory |
mDefaultValue | Default value |
mValidationCallback | verification callback |
bool CApiFunctionWithNamedArguments::GetBooleanArgumentValue | ( | const char * | mKey | ) | const |
Returns the value of a boolean argument.
If no argument with the specified key was passed, returns the default value set in DefineBooleanArgument
.
SDK_INTERNAL_ERROR | Internal error |
SDK_ACCESSING_ARG_BEFORE_PARSING_COMPLETE | Accessing argument value before argument parsing is completed |
SDK_ARG_NOT_FOUND | Runtime Setting argument was not found |
mKey | the argument key |
double CApiFunctionWithNamedArguments::GetNumericArgumentValue | ( | const char * | mKey | ) | const |
Returns the value of a numeric argument.
If no argument with the specified key was passed, returns the default value set in DefineNumericArgument
.
SDK_INTERNAL_ERROR | Internal error |
SDK_ACCESSING_ARG_BEFORE_PARSING_COMPLETE | Accessing argument value before argument parsing is completed |
SDK_ARG_NOT_FOUND | Runtime Setting argument was not found |
mKey | the argument key |
const char* CApiFunctionWithNamedArguments::GetStringArgumentValue | ( | const char * | mKey | ) | const |
Returns the value of a string argument.
If no argument with the specified key was passed, returns the default value set in DefineStringArgument
.
SDK_INTERNAL_ERROR | Internal error |
SDK_ACCESSING_ARG_BEFORE_PARSING_COMPLETE | Accessing argument value before argument parsing is completed |
SDK_ARG_NOT_FOUND | Runtime Setting argument was not found |
mKey | the argument key |
|
protectedvirtual |
Checks if the step arguments are valid and complete.
If the arguments do not pass validation, throws exception. This method is implemented by the LoadRunner infrastructure, not by the protocol developer.
ABORT_BY_CONTINUE_ON_ERROR | Termination depends on the current value of the continue on error flag. The exception value is SDK_VERIFICATION_FAILED or SDK_CROSS_ARG_FAILED. |
mVaList | variable-length argument list |
Reimplemented from CApiFunction.
bool CApiFunctionWithNamedArguments::IsSpecified | ( | const char * | mKey | ) | const |
Checks if an argument with the specified key was passed.
SDK_INTERNAL_ERROR | Internal error |
SDK_ACCESSING_ARG_BEFORE_PARSING_COMPLETE | Accessing argument value before argument parsing is completed |
SDK_ARG_NOT_FOUND | Runtime Setting argument was not found |
mKey | the argument key |