Wt
3.2.0
|
An environment for testing purposes. More...
#include <Wt/Test/WTestEnvironment>
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 ¶meters) |
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 std::string &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. |
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);
...
}
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.
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.
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).
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".void Wt::Test::WTestEnvironment::setAjax | ( | bool | enabled | ) |
void Wt::Test::WTestEnvironment::setClientAddress | ( | const std::string & | clientAddress | ) |
void Wt::Test::WTestEnvironment::setContentType | ( | ContentType | contentType | ) |
void Wt::Test::WTestEnvironment::setCookies | ( | const CookieMap & | cookies | ) |
void Wt::Test::WTestEnvironment::setDpiScale | ( | double | dpiScale | ) |
void Wt::Test::WTestEnvironment::setHeaderValue | ( | const std::string & | value | ) |
void Wt::Test::WTestEnvironment::setHostName | ( | const std::string & | hostName | ) |
void Wt::Test::WTestEnvironment::setInternalPath | ( | const std::string & | internalPath | ) |
Sets the initial internal path.
The default value is "".
Reimplemented from Wt::WEnvironment.
void Wt::Test::WTestEnvironment::setLocale | ( | const std::string & | locale | ) |
void Wt::Test::WTestEnvironment::setParameterMap | ( | const Http::ParameterMap & | parameters | ) |
void Wt::Test::WTestEnvironment::setReferer | ( | const std::string & | referer | ) |
void Wt::Test::WTestEnvironment::setServerAdmin | ( | const std::string & | serverAdmin | ) |
void Wt::Test::WTestEnvironment::setServerSignature | ( | const std::string & | signature | ) |
Sets the server signature.
The default value is "None (WTestEnvironment)".
void Wt::Test::WTestEnvironment::setServerSoftware | ( | const std::string & | software | ) |
void Wt::Test::WTestEnvironment::setSupportsCookies | ( | bool | enabled | ) |
void Wt::Test::WTestEnvironment::setUrlScheme | ( | const std::string & | scheme | ) |
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".
Reimplemented from Wt::WEnvironment.
void Wt::Test::WTestEnvironment::startRequest | ( | ) |
Simulates the start of a new request by the main event loop.