wxTst::CRCppEmitter Class Reference

Singleton emitting C++ code used for test case bootstrapping. More...

#include <CRCppEmitter.h>

Collaboration diagram for wxTst::CRCppEmitter:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void AddCode (wxString str)
 Add code, no-na.
virtual void AddComment (wxString str)
 Add comment, no-na.
virtual wxString AddContainerLookupCode (const wxString &containerName, const wxString &itemDesc=_T(""), const wxString &containerVarNameSuffix=_T(""))
 Add code for container lookup.
virtual void AddVerbatimStringWithLineBreaks (wxString str)
 Add long string verbatim, i.e. keep line breaks.
virtual wxString GetCaptureFilename () const
 [TEST] Get filename of current capturing target.
virtual wxString GetTab () const
 Get current tabulator in the shape of a string (helper method).
virtual unsigned int GetTabSize () const
 Get current tabulator size.
virtual wxString MakeVarName (const wxString &name, const wxString &suffix=_T(""))
 Make unique variable name based on given name.
virtual void SetTabSize (unsigned int size)
 Set new tabulator size.
virtual void SetTestCaseFileContext (const wxString &filename, size_t lineNmb=-1)

Static Public Member Functions

static void Destroy ()
 Threadsafe destruction of static singleton instance.
static CRCppEmitter * GetInstance ()
 Get single private instance (Singleton pattern).

Protected Member Functions

virtual wxString BreakString (const wxString &str, const wxArrayString &breakStrs, unsigned int &idx, size_t minIdx=wxString::npos, bool isCode=false) const
 CRCppEmitter ()
 Constructor.
virtual bool HasBrokenInString (const wxString &line) const
 Calculates, if given line has been broken in the middle of a string constant.
virtual bool IsContainerVarNameDuplicate (const wxString &str) const
 Checks, if given string is a duplicate of a container variable name.
virtual wxString MakeFirstCharLowerCase (const wxString &str) const
 Get given string with first character converted to lower case.
virtual ~CRCppEmitter ()
 Destructor.


Detailed Description

Singleton emitting C++ code used for test case bootstrapping.

Definition at line 31 of file CRCppEmitter.h.


Constructor & Destructor Documentation

CRCppEmitter::CRCppEmitter (  )  [protected]

Constructor.

Definition at line 28 of file CRCppEmitter.cpp.

References SetTabSize().

Referenced by GetInstance().

CRCppEmitter::~CRCppEmitter (  )  [protected, virtual]

Destructor.

Definition at line 35 of file CRCppEmitter.cpp.


Member Function Documentation

void CRCppEmitter::AddCode ( wxString  str  )  [virtual]

void CRCppEmitter::AddComment ( wxString  str  )  [virtual]

Add comment, no-na.

Parameters:
str comment to add

Definition at line 139 of file CRCppEmitter.cpp.

References BreakString().

Referenced by wxTst::CRMenuSelectionEvent::EmitCpp(), and wxTst::CREventCaptureManager::FilterEvent().

wxString CRCppEmitter::AddContainerLookupCode ( const wxString &  containerName,
const wxString &  itemDesc = _T(""),
const wxString &  containerVarNameSuffix = _T("") 
) [virtual]

Add code for container lookup.

Prevents multiple outputs of the same container lookup code, thus, use returned actual container name in further code emitting.

Parameters:
containerName name of container to emit lookup code
itemDesc description of item initiating the container lookup; only used for emitted assertion message
containerVarNameSuffix suffix for container variable name
Returns:
name of container variable in emitted code

Definition at line 229 of file CRCppEmitter.cpp.

References AddCode(), IsContainerVarNameDuplicate(), and MakeFirstCharLowerCase().

Referenced by wxTst::CRTreeSelectionChangingEvent::EmitCpp(), wxTst::CRTreeItemRightClickEvent::EmitCpp(), wxTst::CRTextUpdateEvent::EmitCpp(), wxTst::CRSpinCtrlUpdateEvent::EmitCpp(), wxTst::CRSliderUpdateEvent::EmitCpp(), wxTst::CRRadioBoxSelectionEvent::EmitCpp(), wxTst::CRNotebookPageChangeEvent::EmitCpp(), wxTst::CRMenuSelectionEvent::EmitCpp(), wxTst::CRChoiceSelectionEvent::EmitCpp(), wxTst::CRCheckBoxClickEvent::EmitCpp(), and wxTst::CRButtonClickEvent::EmitCpp().

void CRCppEmitter::AddVerbatimStringWithLineBreaks ( wxString  str  )  [virtual]

Add long string verbatim, i.e. keep line breaks.

Parameters:
str string to add

Definition at line 221 of file CRCppEmitter.cpp.

wxString CRCppEmitter::BreakString ( const wxString &  str,
const wxArrayString &  breakStrs,
unsigned int &  idx,
size_t  minIdx = wxString::npos,
bool  isCode = false 
) const [protected, virtual]

Definition at line 325 of file CRCppEmitter.cpp.

References HasBrokenInString().

Referenced by AddCode(), and AddComment().

void CRCppEmitter::Destroy (  )  [static]

Threadsafe destruction of static singleton instance.

Definition at line 63 of file CRCppEmitter.cpp.

wxString CRCppEmitter::GetCaptureFilename (  )  const [virtual]

[TEST] Get filename of current capturing target.

Only required for testing!

Returns:
current capturing target filename

Definition at line 135 of file CRCppEmitter.cpp.

CRCppEmitter * CRCppEmitter::GetInstance (  )  [static]

wxString CRCppEmitter::GetTab (  )  const [virtual]

Get current tabulator in the shape of a string (helper method).

Returns:
current tabulator

Definition at line 85 of file CRCppEmitter.cpp.

Referenced by wxTst::CRNotebookPageChangeEvent::EmitCpp().

unsigned int CRCppEmitter::GetTabSize (  )  const [virtual]

Get current tabulator size.

Returns:
current tabulator size

Definition at line 79 of file CRCppEmitter.cpp.

bool CRCppEmitter::HasBrokenInString ( const wxString &  line  )  const [protected, virtual]

Calculates, if given line has been broken in the middle of a string constant.

This allows to use line splicing correctly: before by means of '\' at the end of line, now using '"' at the end and beginning of the code emitting.

Parameters:
line line to investigate for string constant delimiters ('"' char)
Returns:
true, if line has been broken in the middle of a string constant

Definition at line 423 of file CRCppEmitter.cpp.

Referenced by AddCode(), and BreakString().

bool CRCppEmitter::IsContainerVarNameDuplicate ( const wxString &  str  )  const [protected, virtual]

Checks, if given string is a duplicate of a container variable name.

Parameters:
str string to check for duplication
Returns:
true, if given string is a duplicate

Definition at line 430 of file CRCppEmitter.cpp.

Referenced by AddContainerLookupCode(), and MakeVarName().

wxString CRCppEmitter::MakeFirstCharLowerCase ( const wxString &  str  )  const [protected, virtual]

Get given string with first character converted to lower case.

Parameters:
str string to convert
Returns:
string with first character converted to lower case

Definition at line 449 of file CRCppEmitter.cpp.

Referenced by AddContainerLookupCode(), and MakeVarName().

wxString CRCppEmitter::MakeVarName ( const wxString &  name,
const wxString &  suffix = _T("") 
) [virtual]

Make unique variable name based on given name.

Stores returned variable name in container for guaranteeing future variable uniqueness as well. Suffix: e.g. "&Open... Ctrl+O" + "MenuItemId" => "Open... Ctrl+O" + "MenuItemId" => "Open" + "MenuItemId" => "openMenuItemId"

Parameters:
name base for unique variable name
suffix optional suffix of variable name
Returns:
unique variable name based on given name

Definition at line 275 of file CRCppEmitter.cpp.

References IsContainerVarNameDuplicate(), and MakeFirstCharLowerCase().

Referenced by wxTst::CRTreeSelectionChangingEvent::EmitCpp(), wxTst::CRTreeItemRightClickEvent::EmitCpp(), wxTst::CRTextUpdateEvent::EmitCpp(), wxTst::CRSpinCtrlUpdateEvent::EmitCpp(), wxTst::CRSliderUpdateEvent::EmitCpp(), wxTst::CRRadioBoxSelectionEvent::EmitCpp(), wxTst::CRNotebookPageChangeEvent::EmitCpp(), wxTst::CRMenuSelectionEvent::EmitCpp(), wxTst::CRChoiceSelectionEvent::EmitCpp(), wxTst::CRCheckBoxClickEvent::EmitCpp(), and wxTst::CRButtonClickEvent::EmitCpp().

void CRCppEmitter::SetTabSize ( unsigned int  size  )  [virtual]

Set new tabulator size.

Parameters:
size new tabulator size

Definition at line 73 of file CRCppEmitter.cpp.

Referenced by CRCppEmitter().

void CRCppEmitter::SetTestCaseFileContext ( const wxString &  filename,
size_t  lineNmb = -1 
) [virtual]

Definition at line 91 of file CRCppEmitter.cpp.

Referenced by wxTst::CRCapture::Capture().


The documentation for this class was generated from the following files:

wxWidgets Logo Get wxGuiTesting at SourceForge.net. Fast, secure and Free Open Source software downloads
Generated on Tue Mar 17 17:29:30 2009 for wxGuiTesting by doxygen 1.5.5