Wt
3.3.8
|
An environment for testing purposes. More...
#include <Wt/Test/WTestEnvironment>
Public Member Functions | |
WTestEnvironment (EntryPointType type=Application) | |
Default constructor. More... | |
WTestEnvironment (const std::string &applicationPath, const std::string &configurationFile, EntryPointType type=Application) | |
Constructor with custom configuration. More... | |
~WTestEnvironment () | |
Destructor. | |
void | setParameterMap (const Http::ParameterMap ¶meters) |
Sets parameters to the application. More... | |
void | setCookies (const CookieMap &cookies) |
Sets HTTP cookies. More... | |
void | setHeaderValue (const std::string &value) |
Sets a HTTP header value. More... | |
void | setSupportsCookies (bool enabled) |
Sets whether cookies are supported. More... | |
void | setAjax (bool enabled) |
Sets whether AJAX is supported. More... | |
void | setDpiScale (double dpiScale) |
Sets the display's DPI scale. More... | |
void | setLocale (const WLocale &locale) |
Sets the locale. More... | |
void | setHostName (const std::string &hostName) |
Sets the host name. More... | |
void | setUrlScheme (const std::string &scheme) |
Sets the URL scheme. More... | |
void | setUserAgent (const std::string &userAgent) |
Sets the user agent. More... | |
void | setReferer (const std::string &referer) |
Sets the referer. More... | |
void | setAccept (const std::string &accept) |
Sets the accept header. More... | |
void | setServerSignature (const std::string &signature) |
Sets the server signature. More... | |
void | setServerSoftware (const std::string &software) |
Sets the server software. More... | |
void | setServerAdmin (const std::string &serverAdmin) |
Sets the server admin. More... | |
void | setClientAddress (const std::string &clientAddress) |
Sets the client address. More... | |
void | setInternalPath (const std::string &internalPath) |
Sets the initial internal path. More... | |
void | setContentType (ContentType contentType) |
Sets the content type (deprecated. More... | |
void | setAppRoot (const std::string &appRoot) |
Sets the server's appRoot. More... | |
void | setDocRoot (const std::string &docRoot) |
Sets the docRoot. More... | |
virtual Signal< WDialog * > & | dialogExecuted () const |
Signal used to test a dialog/messagebox reentrant event loop. More... | |
virtual Signal< WPopupMenu * > & | popupExecuted () const |
Signal used to test a popup menu reentrant event loop. More... | |
void | endRequest () |
Simulates the end of a request by the main event loop. More... | |
void | startRequest () |
Simulates the start of a new request by the main event loop. More... | |
void | setSessionIdInUrl (bool sessionIdInUrl) |
Simulates the presence of the session ID in the URL. More... | |
Public Member Functions inherited from Wt::WEnvironment | |
const Http::ParameterMap & | getParameterMap () const |
Parameters passed to the application. More... | |
const Http::ParameterValues & | getParameterValues (const std::string &name) const |
Returns values for a query parameter. More... | |
const std::string * | getParameter (const std::string &name) const |
Returns a single value for a query parameter. More... | |
const CookieMap & | cookies () const |
Returns the cookies from the environment. More... | |
const std::string | getCookie (const std::string &cookieName) const |
Returns a cookie value. More... | |
const std::string * | getCookieValue (const std::string &cookieName) const |
Returns a cookie value. More... | |
const std::string | headerValue (const std::string &field) const |
Returns a header value. More... | |
bool | supportsCookies () const |
Returns whether the browser has enabled support for cookies. More... | |
bool | javaScript () const |
Returns whether the browser has enabled support for JavaScript. More... | |
bool | ajax () const |
Returns whether the browser has enabled support for AJAX. More... | |
bool | webGL () const |
Returns whether the browser has support for WebGL. More... | |
int | screenWidth () const |
Returns the horizontal resolution of the client's screen. More... | |
int | screenHeight () const |
Returns the vertical resolution of the client's screen. More... | |
double | dpiScale () const |
Returns the browser-side DPI scaling factor. More... | |
const WLocale & | locale () const |
Returns the preferred language indicated in the request header. More... | |
int | timeZoneOffset () const |
Returns the time zone offset as reported by the client. More... | |
const std::string & | hostName () const |
Returns the server host name that is used by the client. More... | |
const std::string & | urlScheme () const |
Returns the URL scheme used for the current request ("http" or "https" ). | |
const std::string & | userAgent () const |
Returns the user agent. More... | |
const std::string & | referer () const |
Returns the referer. More... | |
const std::string & | accept () const |
Returns the accept header. More... | |
bool | agentIsSpiderBot () const |
Returns if the user agent is a (known) indexing spider bot. More... | |
const std::string & | serverSignature () const |
Returns the web server signature. More... | |
const std::string & | serverSoftware () const |
Returns the web server software. More... | |
const std::string & | serverAdmin () const |
Returns the email address of the server admin. More... | |
const std::string & | clientAddress () const |
Returns the IP address of the client. More... | |
const std::string & | pathInfo () const |
Returns the path info of the original request (deprecated) More... | |
const std::string & | internalPath () const |
Returns the initial internal path. More... | |
const std::string & | deploymentPath () const |
Returns the deployment path. More... | |
void | libraryVersion (int &series, int &major, int &minor) const |
Returns the version of the Wt library, broken down. More... | |
std::string | sessionId () const |
Returns the Wt session id (deprecated). More... | |
std::string | getCgiValue (const std::string &varName) const |
Returns a raw CGI environment variable. More... | |
ContentType | contentType () const |
The type of the content provided to the browser. More... | |
UserAgent | agent () const |
Returns the user agent type. More... | |
bool | agentIsIE () const |
Returns whether the user agent is Microsoft Internet Explorer. More... | |
bool | agentIsIElt (int version) const |
Returns whether the user agent is an older version of IE. More... | |
bool | agentIsIEMobile () const |
Returns whether the user agent is Internet Explorer Mobile. More... | |
bool | agentIsOpera () const |
Returns whether the user agent is Opera. More... | |
bool | agentIsWebKit () const |
Returns whether the user agent is WebKit-based. More... | |
bool | agentIsMobileWebKit () const |
Returns whether the user agent is Mobile WebKit-based. More... | |
bool | agentIsSafari () const |
Returns whether the user agent is Safari. More... | |
bool | agentIsChrome () const |
Returns whether the user agent is Chrome. More... | |
bool | agentIsGecko () const |
Returns whether the user agent is Gecko-based. More... | |
WServer * | server () const |
Returns the server. More... | |
WSslInfo * | sslInfo () const |
Returns information on the SSL client certificate or 0 if no authentication took place. More... | |
bool | internalPathUsingFragments () const |
Returns whether internal paths are implemented using URI fragments. More... | |
bool | supportsCss3Animations () const |
Returns whether this agent supports CSS3 animations. | |
Private Member Functions | |
virtual bool | isTest () const |
Returns whether this is a mocked test environment. | |
Additional Inherited Members | |
Public Types inherited from Wt::WEnvironment | |
typedef std::map< std::string, std::string > | CookieMap |
Cookie map. More... | |
Static Public Member Functions inherited from Wt::WEnvironment | |
static std::string | libraryVersion () |
Returns the version of the Wt library. More... | |
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:
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 application path used to match <application-settings>
in the configuration file. 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.
|
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::setAppRoot | ( | const std::string & | appRoot | ) |
Sets the server's appRoot.
void Wt::Test::WTestEnvironment::setClientAddress | ( | const std::string & | clientAddress | ) |
void Wt::Test::WTestEnvironment::setContentType | ( | ContentType | contentType | ) |
Sets the content type (deprecated.
Since contentType is now always HTML5, this setting is ignored.
void Wt::Test::WTestEnvironment::setCookies | ( | const CookieMap & | cookies | ) |
void Wt::Test::WTestEnvironment::setDocRoot | ( | const std::string & | docRoot | ) |
Sets the docRoot.
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 | ) |
void Wt::Test::WTestEnvironment::setLocale | ( | const WLocale & | 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::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 | ) |
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".
void Wt::Test::WTestEnvironment::startRequest | ( | ) |
Simulates the start of a new request by the main event loop.