Wt  3.3.0
Public Member Functions | Private Member Functions
Wt::Test::WTestEnvironment Class Reference

An environment for testing purposes. More...

#include <Wt/Test/WTestEnvironment>

Inheritance diagram for Wt::Test::WTestEnvironment:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 WTestEnvironment (EntryPointType type=Application)
 Default constructor.
 WTestEnvironment (const std::string &applicationPath, const std::string &configurationFile, EntryPointType type=Application)
 Constructor with custom configuration.
 ~WTestEnvironment ()
 Destructor.
void setParameterMap (const Http::ParameterMap &parameters)
 Sets parameters to the application.
void setCookies (const CookieMap &cookies)
 Sets HTTP cookies.
void setHeaderValue (const std::string &value)
 Sets a HTTP header value.
void setSupportsCookies (bool enabled)
 Sets whether cookies are supported.
void setAjax (bool enabled)
 Sets whether AJAX is supported.
void setDpiScale (double dpiScale)
 Sets the display's DPI scale.
void setLocale (const WLocale &locale)
 Sets the locale.
void setHostName (const std::string &hostName)
 Sets the host name.
void setUrlScheme (const std::string &scheme)
 Sets the URL scheme.
void setUserAgent (const std::string &userAgent)
 Sets the user agent.
void setReferer (const std::string &referer)
 Sets the referer.
void setAccept (const std::string &accept)
 Sets the accept header.
void setServerSignature (const std::string &signature)
 Sets the server signature.
void setServerSoftware (const std::string &software)
 Sets the server software.
void setServerAdmin (const std::string &serverAdmin)
 Sets the server admin.
void setClientAddress (const std::string &clientAddress)
 Sets the client address.
void setInternalPath (const std::string &internalPath)
 Sets the initial internal path.
void setContentType (ContentType contentType)
 Sets the content type.
virtual Signal< WDialog * > & dialogExecuted () const
 Signal used to test a dialog/messagebox reentrant event loop.
virtual Signal< WPopupMenu * > & popupExecuted () const
 Signal used to test a popup menu reentrant event loop.
void endRequest ()
 Simulates the end of a request by the main event loop.
void startRequest ()
 Simulates the start of a new request by the main event loop.
void setSessionIdInUrl (bool sessionIdInUrl)
 Simulates the presence of the session ID in the URL.

Private Member Functions

virtual bool isTest () const
 Returns whether this is a mocked test environment.

Detailed Description

An environment for testing purposes.

This environment is useful for use in automated (integration/unit) tests: you may configure its properties and pass it to the constructor of an application.

This is useful for automated test-cases:

 void testX() {
   Test::WTestEnvironment environment;
   MyApplication app(environment);
   ...
 }
See also:
WEnvironment, WApplication::WApplication(const WEnvironment&)

Constructor & Destructor Documentation

Wt::Test::WTestEnvironment::WTestEnvironment ( EntryPointType  type = Application)

Default constructor.

Constructs a test environment that resembles FireFox 3.0 with default settings.

After construction, but before passing it to the constructor of a WApplication, you can change any of the environment properties using the setter methods.

Wt::Test::WTestEnvironment::WTestEnvironment ( const std::string &  applicationPath,
const std::string &  configurationFile,
EntryPointType  type = Application 
)

Constructor with custom configuration.

Constructs a test environment that resembles FireFox 3.0 with default settings.

The applicationPath is the simulated deployment path. The configuration file points to a wt_config.xml configuration file. The type indicates the application type.

After construction, but before passing it to the constructor of a WApplication, you can change any of the environment properties using the setter methods.


Member Function Documentation

Signal< WDialog * > & Wt::Test::WTestEnvironment::dialogExecuted ( ) const [virtual]

Signal used to test a dialog/messagebox reentrant event loop.

This signal is emitted when a dialog or message box is being executed using WDialog::exec() or WMessageBox::exec(), and allows you to interact with the dialog contents.

In the end, the dialog should be closed while executing this signal, (calling done() directly or indirectly) so that the main event loop can continue.

Reimplemented from Wt::WEnvironment.

void Wt::Test::WTestEnvironment::endRequest ( )

Simulates the end of a request by the main event loop.

The environemnt (and application is) started from within the main event loop. To simulate the delivery of events posted to the application-under-test, by WServer::post(), you need to simulate the release of the session lock.

See also:
startRequest()
Signal< WPopupMenu * > & Wt::Test::WTestEnvironment::popupExecuted ( ) const [virtual]

Signal used to test a popup menu reentrant event loop.

This signal is emitted when a popup menu is being executed using WPopupMenu::exec(), and allows you to interact with the popup menu (i.e. to select an option).

See also:
dialogExecuted()

Reimplemented from Wt::WEnvironment.

void Wt::Test::WTestEnvironment::setAccept ( const std::string &  accept)

Sets the accept header.

The default value is "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8".
See also:
accept()
void Wt::Test::WTestEnvironment::setAjax ( bool  enabled)

Sets whether AJAX is supported.

The default value is true.

See also:
ajax()
void Wt::Test::WTestEnvironment::setClientAddress ( const std::string &  clientAddress)

Sets the client address.

The default value is "127.0.0.1".

See also:
clientAddress()
void Wt::Test::WTestEnvironment::setContentType ( ContentType  contentType)

Sets the content type.

The default value is XHTML1.

See also:
contentType()
void Wt::Test::WTestEnvironment::setCookies ( const CookieMap cookies)

Sets HTTP cookies.

The default value is an empty map.

See also:
cookies()
void Wt::Test::WTestEnvironment::setDpiScale ( double  dpiScale)

Sets the display's DPI scale.

The default value is 1.

See also:
dpiScale()
void Wt::Test::WTestEnvironment::setHeaderValue ( const std::string &  value)

Sets a HTTP header value.

The default value is no headers.

See also:
headerValue()
void Wt::Test::WTestEnvironment::setHostName ( const std::string &  hostName)

Sets the host name.

The default value is "localhost".

See also:
hostName()
void Wt::Test::WTestEnvironment::setInternalPath ( const std::string &  internalPath)

Sets the initial internal path.

The default value is "".

See also:
internalPath()

Reimplemented from Wt::WEnvironment.

void Wt::Test::WTestEnvironment::setLocale ( const WLocale locale)

Sets the locale.

The default value is WLocale("en").

See also:
locale()
void Wt::Test::WTestEnvironment::setParameterMap ( const Http::ParameterMap parameters)

Sets parameters to the application.

The default value is an empty map.

See also:
getParameterMap()
void Wt::Test::WTestEnvironment::setReferer ( const std::string &  referer)

Sets the referer.

The default value is "".

See also:
referer()
void Wt::Test::WTestEnvironment::setServerAdmin ( const std::string &  serverAdmin)

Sets the server admin.

The default value is "your@onyourown.here".

See also:
serverAdmin()
void Wt::Test::WTestEnvironment::setServerSignature ( const std::string &  signature)

Sets the server signature.

The default value is "None (WTestEnvironment)".

See also:
serverSignature()
void Wt::Test::WTestEnvironment::setServerSoftware ( const std::string &  software)

Sets the server software.

The default value is "None (WTestEnvironment)".

See also:
serverSoftware()
void Wt::Test::WTestEnvironment::setSessionIdInUrl ( bool  sessionIdInUrl)

Simulates the presence of the session ID in the URL.

A session ID in the URL should cause a trampoline to be used for references to external servers.

The default value is false.

void Wt::Test::WTestEnvironment::setSupportsCookies ( bool  enabled)

Sets whether cookies are supported.

The default value is true.

See also:
supportsCookies()
void Wt::Test::WTestEnvironment::setUrlScheme ( const std::string &  scheme)

Sets the URL scheme.

The default value is "http".

See also:
urlScheme()
void Wt::Test::WTestEnvironment::setUserAgent ( const std::string &  userAgent)

Sets the user agent.

The default value is no "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.11) Gecko/2009060309 Ubuntu/9.04 (jaunty) Firefox/3.0.11".

See also:
userAgent()

Reimplemented from Wt::WEnvironment.

void Wt::Test::WTestEnvironment::startRequest ( )

Simulates the start of a new request by the main event loop.

See also:
endRequest()
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Mon Apr 8 2013 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1