| QAA API |
Subsystem list |
Top level |
Defined in: CommonUtils.inc
| Data Types | Error Reporting Routines | Results File Indentation Block Routines | Other Results File Routines | Debugging Routines | Miscellaneous Routines |
CUstringOrList -- a string or a list of stringsCUloggingOption -- logging optionsCUfeature -- identifies a product featureCUfeatureOrList -- a feature or list of featuresCUtestPhase -- describes a phase of testing
list of CALL
| CUgetCallStack
| ( );
|
void
| CUlogCallStack
| (list of CALL luCalls,
integer iSkip optional);
|
void
| CUlogError
| (string sErrorMessage);
|
void
| CUsetupError
| (string sErrorMessage);
|
void
| CUlogException
| (string sAdditionalInfo optional);
|
void
| CUlogWarning
| (string sWarningMessage);
|
void
| CUobsoleteRoutineWarning
| (string sNewRoutineName);
|
void
| LogHack
| (string sYourNameAndTheDate);
|
CUlogBlockState
| CUbeginLogBlock
| (string sDescription);
|
void
| CUendLogBlock
| (string sDescription);
|
CUlogBlockState
| CUgetLogBlockState
| ( );
|
void
| CUrestoreLogBlockState
| (CUlogBlockState uState);
|
void
| CUlogBlockNesting
| ( );
|
CUlogBlockState
| CUbeginFeatureTest
| (CUfeatureOrList uFeature);
|
void
| CUendFeatureTest
| (CUfeatureOrList uFeature);
|
void
| CUtestcaseFeature
| (CUfeatureOrList uFeature);
|
void
| CUlogTestPhase
| (CUtestPhase ePhase);
|
CUlogBlockState
| CUbeginTestOutOfContext
| (varargs of CUfeature);
|
void
| CUendTestOutOfContext
| (varargs of CUfeature);
|
list of CUfeature
| CUgetFeatureContext
| ();
|
string
| CUfeatureToString
| (CUfeature uFeature);
|
void
| CUdisambiguateTC
| (varargs of anytype);
|
void
| CUlogOutputFileName
| (string sFullPathName);
|
void
| CUlogGuiAction
| (string sAction, window w);
|
void
| CUlogScreenShot
| ();
|
boolean
| CUloggingOptionEnabled
| (CUloggingOption eOption);
|
void
| CUdebugPrint
| (string sSubsystemPrefix, varargs of anytype);
|
boolean
| CUdebugEnabled
| (string sSubsystemPrefix);
|
void
| CUenableDebug
| (string sSubsystemPrefix, boolean bOn optional);
|
string
| CUconcatPath
| (varargs of CUstringOrList);
|
void
| CUensurePathExists
| (list of string lsPath);
|
string
| CUgetDateTimeString
| ();
|
boolean
| CUisInRect
| (int iX, int iY, RECT rRect);
|
anytype
| CUmapList
| (list of anytype list1, anytype element1, list of anytype list2);
|
anytype
| CUmapTemplateToList
| (list of string list1, string element1, list of anytype list2 optional);
|
boolean
| CUstringIsEnumVal
| (string s, DATATYPE enumType);
|
boolean
| CUisDefined
| (string sVariableName, out anytype aValue optional);
|
string
| CUintegerToString
| (integer iValue, integer iRadix, string sDigits optional);
|
integer
| CUregisterSourceFile
| (list of string lsSourceTreePath, list of string lsSourceFilePath);
|
void
| CUcopyDirectoryAndContents
| (string sOriginalPath, string sDestinationPath);
|
integer
| _CUdeleteDirectoryAndContents
| (string sPath);
|
type CUstringOrList is { string, list of string };
glsCU_LOGGING_OPTIONS
in MClocal.inc.CUloggingOptionEnabled.
type CUloggingOption is enum { /* see below */ };
eCU_LOG_GUI_ACTIONS
| When this option is enabled, every action performed by the script on the application's UI is logged in the results file. This option is not used by scripts or testcases, but only by the methods and subroutines of the infrastructure. |
eCU_LOG_VERBOSE
| This option enables additional output. If it is used at all, it is used only by scripts and testcases, not by the infrastructure. |
eCU_OBSOLETE_WARNING
| This option causes notifications of obsolete API features to be reported as warnings rather than as errors. |
eCU_LOG_FULL_FEATURE_CONTEXT
| This option causes the complete feature context to be reported on every feature block. Without this option, only the individual feature is reported. (Not available yet.) |
CUfeature to a readable text string
by calling CUfeatureToString.
Features are defined as constants.
PRODUCT features are defined in "Shared/AllFeatures.inc".
See also Product Features - Identification & Management .
CUfeature
or a list of CUfeature.
CUlogTestPhase.
| 1. | eCU_TEST_SETUP
| Perform any setup that the test requires, such as opening bins, loading sequences, changing settings, etc. Some tests may not require any setup; some or all of a test's setup may be performed implicitly by the recovery system. |
| 2. | eCU_TEST_EXECUTE
| This phase should only include the operation being tested. Typically, this phase will consist of a single call to a subroutine or method. Every test must include this phase. |
| 3. | eCU_TEST_VERIFY
| Verify the results of the test, to ensure that the test was successful. Some verification may be performed implicitly by the infrastructure and/or the recovery system. |
| 4. | eCU_TEST_CLEANUP
| Perform any cleanup that the test requires, such as deleting sequences, closing dialogs, etc. You should normally leave around anything that the test created, so that it can be examined after the test script finishes running. Most tests will not require this phase. |
| 5. | eCU_TEST_RESULTS
| Report any results from the test, e.g. timing or performance information. Most tests will not require this phase. |
type CUtestPhase is enum { /* see above */ };
CUbeginFeatureTest must have a matching
call to CUendFeatureTest
later in your script.
This routine implicitly sets the current test phase to eCU_TEST_SETUP.
You must not call this routine from inside a testcase.
If you do, an assertion will fail. To set the feature for a testcase, use
CUtestcaseFeature.
See also Product Features - Identification & Management .
CUlogBlockState CUbeginFeatureTest
(CUfeatureOrList uFeature);
uFeatureReturnsCUrestoreLogBlockState.ResOpenList directly.
Every call to CUbeginLogBlock must have a matching
call to CUendLogBlock later in your code.
CUlogBlockState CUbeginLogBlock (string sDescription);
sDescriptionReturnsCUrestoreLogBlockState.string CUconcatPath (varargs of CUstringOrList
luStrings);
luStringsReturnsHFILE file = FileOpen(CUconcatPath(glsMC_INPUT_DATA_DIR, "MyInputFile"), FM_READ);
Print, except that the first argument
must a string containing the subsystem prefix, e.g. "BIN", "PRJ", "REC",
"EDL", etc. For debugging statements in a script, use "script".
Do not conditionalize calls to CUdebugPrint; the test for
whether or not to actually print anything is built into the routine.
You can enable debugging statements by adding strings to the variable
glsCUdebugPrint in
MClocal.inc.
This variable contains a list of subsystem prefix strings.
When CUdebugPrint is called, it checks to see if its
sSubsystemPrefix parameter appears in glsCUdebugPrint.
If it does, the debugging statement is printed; otherwise, it is not.
You can also specify "all" in glsCUdebugPrint to enable
all debugging statements.
void CUdebugPrint(string sSubsystemPrefix, varargs of anytype);
sSubsystemPrefixCUdebugPrint,
e.g. "BIN", "PRJ", "REC", "EDL", etc., or "script" if it's for a script.window BINopenBin (string sName)
{
window w;
CUdebugPrint("BIN", "BINopenBin(" + sName + ")");
// ... open the bin and assign "w" to be the bin window
CUdebugPrint("BIN", " return " + [string] w);
return w;
}
In most cases, you can simply pass all the parameters for your testcase to
CUdisambiguateTC.
Note, however, that sometimes a parameter may change when, in fact,
the test is the same. An example of this is bin mob IDs.
Such parameters should not be passed to CUdisambiguateTC.
All the parameters passed to CUdisambiguateTC are converted
to text strings and concatenated into a single string.
The length of this concatenated string must not exceed 255 characters.
You may call CUdisambiguateTC at most once in any testcase.
Calling it more than once within the same testcase is illegal.
You can call it anywhere in the testcase, but you should call it near
the top of the testcase so that it won't be skipped over because of
exceptions raised during the actual test execution.
void CUdisambiguateTC (varargs of anytype)
testcase tcMyTestcase (integer iArg1, string sArg2)
{
CUdisambiguateTC(iArg1, sArg2);
// ... body of testcase ...
}
CUbeginFeatureTest
must have a matching call to CUendFeatureTest later in your script.
This routine implicitly sets the test phase to eCU_TEST_CLEANUP.See also Product Features - Identification & Management .
void CUendFeatureTest (CUfeatureOrList uFeature);
uFeatureCUbeginFeatureTest.
This is to ensure that you don't forget to match up your calls
to CUbeginFeatureTest and CUendFeatureTest.
ResCloseList directly.
Every call to CUbeginLogBlock
must have a matching call to CUendLogBlock later in your code.
void CUendLogBlock (string sDescription);
sDescriptionCUbeginLogBlock.
This is to ensure that you don't forget to match up your calls
to CUbeginLogBlock and CUendLogBlock.
void CUensurePathExists (list of string lsPath);
lsPathCUensurePathExists(glsMC_OUTPUT_DATA_DIR + { "MySubsysDir", "MyTestDir" });
string CUfeatureToString(CUfeature uFeature);
uFeatureReturnsCUgetCallStack
routine itself. The first item in the returned list identifies the code
that called CUgetCallStack; the last item in the list is main().This routine is intended for error reporting.
list of CALL CUgetCallStack();
ReturnsMCgetDateTimeString; arguments are the same.)Returns a string that contains the current date and time. The string has the format: "YYMMDD.HHMMSS". For example, at 1:23:45 pm on 5 January 1996, this routine will return the string "960105.132345".
You should use this routine to create file names for output files when you want a new output file to be created every time your test runs (instead of overwriting the same output file). The string is formatted so that when such file names are sorted alphabetically, they will also be sorted chronologically.
string CUgetDateTimeString ();
Returns// construct path for directory containing cut lists list of string lsFilePath = glsMC_OUTPUT_DATA_DIR; ListAppend(lsFilePath, "Cut Lists"); // make sure the directory exists if (! SYS_DirExists(CUconcatPath(lsFilePath)) SYS_MakeDir(CUconcatPath(lsFilePath)); // construct path for a new cut list file ListAppend(lsFilePath, CUgetDateTimeString()); string sFileName = CUconcatPath(lsFilePath); // use the file name to save a cut list in ...
CUrestoreLogBlockState.
CUlogBlockState CUgetLogBlockState ( );
Returnsstring CUintegerToString (integer iValue, integer iRadix, string sDigits optional);
iValueiValueiDigitsReturnsboolean CUisDefined (string sName, out anytype aValue optional);
sNameReturnsaValueMCisInRect; arguments are the same.)Determines whether the point specified by the X and Y coordinates lies within the given rectangle.
boolean CUisInRect (int iX, int iY, RECT rRect);
iXiYrRectReturnsvoid CUlogBlockNesting ( )
void CUlogCallStack (
list of CALL luCalls,
integer iLevelsToSkip optional);
luCallsExceptCalls or
CUgetCallStack.
iLevelsToSkip(none)
LogError.
You should always call CUlogError instead of calling
LogError directly.This routine places a standard prefix in front of the error message string, something like "ERROR:". You should not explicitly place such a prefix in your error message string. It also logs the current call stack.
void CUlogError(string sErrorMessage);
sErrorMessageCUlogError does that for you.
This is a wrapper for the built-in 4Test function ExceptLog.
You should always call CUlogException instead of calling
ExceptLog directly.
void CUlogException(string sAdditionalInfo optional);
sAdditionalInfo
void AttemptTheImpossible()
{
do
{
... some code that attempts the impossible ...
}
except
{
if (ExceptNum() == X_SOMETHING_WENT_WRONG)
{
CUlogException("attempting the impossible");
... cleanup code ...
}
else reraise; // never handle all exceptions indiscriminately!
}
}
glsCU_LOGGING_OPTIONS
in MClocal.inc.
boolean CUloggingOptionEnabled
(CUloggingOption eOption);
eOptionReturnsvoid CUlogGuiAction(string sAction, window w);
sActionwCUlogGuiAction automatically reports the window's parents.// a method of QChildWin
void TypeKeys (string sKeys, number nDelay optional)
{
CUlogGuiAction("type """ + sKeys + """ into", this);
ChildWin::TypeKeys(sKeys, nDelay);
}
If you implement code that you consider to be a "hack", precede the hack with a call to this function, supplying your name (required), the current date (required), and any other info you might want to provide (optional) all as a part of the single string parameter that this function takes. And then precede all of that with sufficient comments to explain the hack to anyone who might need to undo or fix the hack or otherwise maintain, debug or understand the code in the future.
void LogHack (string sYourNameAndTheDate);
sYourNameAndTheDateWe (the lords of the infrastructure) may from time to time temporarily modify this routine to cause different behavior.
Hacks (instances of this routine being called) may also be found by text-searching the script source tree.
Use this routine to report a file which is part of your test results, but separate from the standard QAP results file. This routine will format its output in such a way that the tools that process a results file will be able to find your other file.
void CUlogOutputFileName(string sFileName, string sDescription optional);
sFileNamesDescriptionglsCU_SCREEN_SHOT_DIR.
void CUlogScreenShot();
(none)
(none)
eCU_TEST_SETUP
eCU_TEST_EXECUTE
eCU_TEST_VERIFY
eCU_TEST_CLEANUP
eCU_TEST_RESULTS can appear anywhere after eCU_TEST_EXECUTE.For more information, see the discussion in the Recovery System about defining testcases.
CUbeginFeatureTest implicitly sets the test phase to eCU_TEST_SETUP.CUendFeatureTest implicitly sets the test phase to eCU_TEST_CLEANUP.eCU_TEST_SETUP.eCU_TEST_CLEANUP.eCU_TEST_EXECUTE at some point during
its execution (unless it terminates early because an exception was raised).
In general, you should only need to call this routine inside a testcase
to set the phase to eCU_TEST_EXECUTE or eCU_TEST_VERIFY.
void CUlogTestPhase(CUtestPhase ePhase);
ePhase(none)
LogWarning.
You should always call CUlogWarning instead of calling
LogWarning directly.This routine places a standard prefix in front of the warning message string, something like "WARNING:". You should not explicitly place such a prefix in your warning message string. It also logs the current call stack.
void CUlogWarning(string sWarningMessage);
sWarningMessageCUlogWarning does that for you.(none)
MCmapList; arguments are the same.)Maps an element of one list onto another list by looking up an element in one list and returning the corresponding element in another list. Both lists must contain the same number of elements. If the element is not found in the list, an exception is raised.
This function is intended for use in methods that convert between enums and strings (see example below).
anytype CUmapList (list of anytype list1, anytype element1,
list of anytype list2);
list1element1 appears.element1list1.list2Returnslist2 whose position correponds to the position
in list1 of element1.type CPRcolor is enum { eCPR_COLOR_MONOCHROME, eCPR_COLOR_REDUCED, eCPR_COLOR_FULL };
private list of CPRcolor leColors =
{ eCPR_COLOR_MONOCHROME, eCPR_COLOR_REDUCED, eCPR_COLOR_FULL };
private list of string lsColors =
{ "Monochrome", "Reduced Chroma", "Full Chroma" };
window QChildWin gwCPRwindow
{
// ...
AMacPopupMenu Color { tag = "" };
// ...
void SetColor (CPRcolor eColor)
{
this.Color.Select(CUmapList(leColors, eColor, lsColors));
}
CPRcolor GetColor ()
{
return CUmapList(lsColors, this.Color.GetText(), leColors);
}
}
Matches a template (or abbreviation) string to one item in a list of string, returning the matched item, or (optionally) the corresponding item in another list, as in CUmapList.
A template is made up of regular characters and wildcard characters. The wildcard characters are asterisk ("*") and question mark. An asterisk matches zero or more characters, and a question mark matches exactly one character.
anytype CUmapTemplateToList (list of string list1, string element1,
list of anytype list2 optional);
list1element1 appears.element1list1.list2list1 is returned.Returnslist1 matching the provided template, or the
corresponding element of list2 if provided.
An exception is raised if there is no match for the template ("not found") or if there are multiple matches ("not unique").
list of string lsFruits = {"Apples", "Bananas", "Pears"};
sFound = CUmapTemplateToList(lsFruits, "B*");
eFruit = CUmapTemplateToList(lsFruits, "B*", leFruitEnums);
sFound is now assigned the value "Bananas", and
eFruit is assigned a value from the corresponding enumerated type.
CUobsoleteRoutineWarning
and then call the new routine.This routine logs an error message to the results file. The error message includes the name of the old routine, the name of the new routine, and the source file name and line number where the old routine was called from. All of this information is generated automatically, except for the new routine name, which you must provide. This routine returns normally, allowing the script to proceed.
Script writers should never need to call this routine.
void CUobsoleteRoutineWarning (string sNewRoutineName);
sNewRoutineNameboolean MCisInRect (int iX, int iY, RECT r)
{
CUobsoleteRoutineWarning("CUisInRect");
return CUisInRect(iX, iY, r);
}
integer CUregisterSourceFile (list of string lsSourceTreePath, list of string lsFilePath);
lsSourceTreePathglsMC_QAP_DIR.lsSourceTreePathReturns
private integer _junk_ = CUregisterSourceFile(glsMC_QAP_DIR, { "Shared", "CommonUtils.inc" });
void CUcopyDirectoryAndContents (string sOriginalPath, string sDestinationPath);
sOriginalPathCUconcatPath to create the path string.
sDestinationPathCUconcatPath to create the path string.
CUcopyDirectoryAndContents("MyDrive\MyFolder", "MyDrive\MyNewFolder");
void _CUdeleteDirectoryAndContents (string sPath);
sPathCUconcatPath to create the path string.
_CUdeleteDirectoryAndContents("MyDrive\MyDirectoryToDelete");
CUbeginLogBlock or
CUgetLogBlockState.
Use this function during exception handling to restore the
block level. If you don't, your indentation levels may get messed up.
Note that TestcaseEnter does this for you automatically.
void CUrestoreLogBlockState (CUlogBlockState uState);
uState
CUlogBlockState uMyLogState = CUbeginLogBlock("my block");
do
{
TrySomethingThatMightFail();
}
except
{
if (ExceptNum() != SOMETHING_I_CAN_HANDLE)
reraise;
CUrestoreLogBlockState(uMyLogState);
HandleMyException();
}
CUendLogBlock("my block");
void CUlogError(string sErrorMessage);
sErrorMessageCUlogError does that for you.boolean CUstringIsEnumVal (string s, DATATYPE enumType);
type MyEnumType is enum { enum1, enum2, enum3 }
//if a match is found, convert(cast) the string to the enum
if(CUstringIsEnumVal("myString", MyEnumType))
{
MyEnumType eMyEnum;
eMyEnum = [MyEnumType]myString;
}
CUbeginFeatureTest).
Calling this routine is optional, if and only if the testcase is called
from within a feature block.
Calling this routine more than once within the same testcase is illegal.
You can call it anywhere in the testcase, but you should call it near the top of the
testcase so that it won't be skipped over because of exceptions raised
during the actual test execution. See also Product Features - Identification & Management .
void CUtestcaseFeature
(CUfeatureOrList uFeature);
uFeature