#include <Wt/Test/WTestEnvironment>
Public Member Functions | |
WTestEnvironment (const std::string &applicationPath="/", const std::string &configurationFile=WT_CONFIG_XML, ApplicationType type=Application) | |
Default constructor. | |
~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. |
This environment is useful for use in unit tests: you may configure its properties and pass it to the constructor of an application.
This is useful for (unit) test-cases:
void testX() {
Test::WTestEnvironment environment;
MyApplication app(environment);
...
}
Wt::Test::WTestEnvironment::WTestEnvironment | ( | const std::string & | applicationPath = "/" , |
|
const std::string & | configurationFile = WT_CONFIG_XML , |
|||
ApplicationType | type = Application | |||
) |
Default constructor.
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.
Wt::Test::WTestEnvironment::~WTestEnvironment | ( | ) |
Destructor.
!
void Wt::Test::WTestEnvironment::setParameterMap | ( | const Http::ParameterMap & | parameters | ) |
void Wt::Test::WTestEnvironment::setCookies | ( | const CookieMap & | cookies | ) |
void Wt::Test::WTestEnvironment::setHeaderValue | ( | const std::string & | value | ) |
void Wt::Test::WTestEnvironment::setSupportsCookies | ( | bool | enabled | ) |
void Wt::Test::WTestEnvironment::setAjax | ( | bool | enabled | ) |
void Wt::Test::WTestEnvironment::setDpiScale | ( | double | dpiScale | ) |
void Wt::Test::WTestEnvironment::setLocale | ( | const std::string & | locale | ) |
void Wt::Test::WTestEnvironment::setHostName | ( | const std::string & | hostName | ) |
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::setReferer | ( | const std::string & | referer | ) |
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::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::setServerAdmin | ( | const std::string & | serverAdmin | ) |
void Wt::Test::WTestEnvironment::setClientAddress | ( | const std::string & | clientAddress | ) |
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::setContentType | ( | ContentType | contentType | ) |