/usr/include/Wt/Test/WTestEnvironment is in libwttest-dev 3.3.6+dfsg-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WTEST_ENVIRONMENT_H_
#define WTEST_ENVIRONMENT_H_
#include <string>
#include <map>
#include <vector>
#include <Wt/WEnvironment>
#include <Wt/WServer>
namespace Wt {
class WebController;
namespace Test {
/*! \class WTestEnvironment Wt/Test/WTestEnvironment Wt/Test/WTestEnvironment
* \brief 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:
* \if cpp
* \code
* void testX() {
* Test::WTestEnvironment environment;
* MyApplication app(environment);
* ...
* }
* \endcode
* \elseif java
* \code
* void testX() {
* WTestEnvironment environment(new Configuration());
* MyApplication app(environment);
* ...
* }
* \endcode
* \endif
*
* \sa WEnvironment, WApplication::WApplication(const WEnvironment&)
*/
class WTCONNECTOR_API WTestEnvironment : public WEnvironment
{
public:
#ifndef WT_TARGET_JAVA
/*! \brief 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.
*/
WTestEnvironment(EntryPointType type = Application);
/*! \brief Constructor with custom configuration
*
* Constructs a test environment that resembles FireFox 3.0 with default
* settings.
*
* The <i>applicationPath</i> is the simulated deployment path. The
* configuration file points to a wt_config.xml configuration file.
* The <i>type</i> 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.
*/
WTestEnvironment(const std::string& applicationPath,
const std::string& configurationFile,
EntryPointType type = Application);
#else
/*! \brief 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.
*/
WTestEnvironment(Configuration *configuration,
EntryPointType type = Application);
/*! \brief Closes the test environment.
*
* Destroys the test environment. This will allow the environment and the
* application under test to be garbage collected.
*/
void close();
#endif // WT_TARGET_JAVA
/*! \brief Destructor.
*/
~WTestEnvironment();
/*! \brief Sets parameters to the application.
*
* The default value is an empty map.
*
* \sa getParameterMap()
*/
void setParameterMap(const Http::ParameterMap& parameters);
/*! \brief Sets HTTP cookies.
*
* The default value is an empty map.
*
* \sa cookies()
*/
void setCookies(const CookieMap& cookies);
/*! \brief Sets a HTTP header value.
*
* The default value is no headers.
*
* \sa headerValue()
*/
void setHeaderValue(const std::string& value);
/*! \brief Sets whether cookies are supported.
*
* The default value is <i>true</i>.
*
* \sa supportsCookies()
*/
void setSupportsCookies(bool enabled);
/*! \brief Sets whether AJAX is supported.
*
* The default value is <i>true</i>.
*
* \sa ajax()
*/
void setAjax(bool enabled);
/*! \brief Sets the display's DPI scale.
*
* The default value is 1.
*
* \sa dpiScale()
*/
void setDpiScale(double dpiScale);
/*! \brief Sets the locale.
*
* \if cpp
* The default value is WLocale("en").
* \endif
*
* \if java
* The default value is the English locale ("en").
* \endif
*
* \sa locale()
*/
void setLocale(const WLocale& locale);
/*! \brief Sets the host name.
*
* The default value is "localhost".
*
* \sa hostName()
*/
void setHostName(const std::string& hostName);
/*! \brief Sets the URL scheme.
*
* The default value is "http".
*
* \sa urlScheme()
*/
void setUrlScheme(const std::string& scheme);
/*! \brief 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".
*
* \sa userAgent()
*/
void setUserAgent(const std::string& userAgent);
/*! \brief Sets the referer.
*
* The default value is "".
*
* \sa referer()
*/
void setReferer(const std::string& referer);
/*! \brief Sets the accept header.
*
* \htmlonly
* The default value is
* "text/html,application/xhtml+xml,application/xml;q=0.9,*<span>/</span>*;q=0.8".
* \endhtmlonly
*
* \sa accept()
*/
void setAccept(const std::string& accept);
/*! \brief Sets the server signature.
*
* The default value is "None (WTestEnvironment)".
*
* \sa serverSignature()
*/
void setServerSignature(const std::string& signature);
/*! \brief Sets the server software.
*
* The default value is "None (WTestEnvironment)".
*
* \sa serverSoftware()
*/
void setServerSoftware(const std::string& software);
/*! \brief Sets the server admin.
*
* The default value is "your@onyourown.here".
*
* \sa serverAdmin()
*/
void setServerAdmin(const std::string& serverAdmin);
/*! \brief Sets the client address.
*
* The default value is "127.0.0.1".
*
* \sa clientAddress()
*/
void setClientAddress(const std::string& clientAddress);
/*! \brief Sets the initial internal path.
*
* The default value is "".
*
* \sa internalPath()
*/
void setInternalPath(const std::string& internalPath);
/*! \brief Sets the content type (<b>deprecated</b>.
*
* Since contentType is now always HTML5, this setting is ignored.
*/
void setContentType(ContentType contentType);
/*! \brief %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.
*/
virtual Signal<WDialog *>& dialogExecuted() const;
/*! \brief %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).
*
* \sa dialogExecuted()
*/
virtual Signal<WPopupMenu *>& popupExecuted() const;
/*! \brief 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.
*
* \sa startRequest()
*/
void endRequest();
/*! \brief Simulates the start of a new request by the main event loop.
*
* \sa endRequest()
*/
void startRequest();
/*! \brief 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 \c false.
*/
void setSessionIdInUrl(bool sessionIdInUrl);
private:
boost::shared_ptr<WebSession> theSession_;
#ifndef WT_TARGET_JAVA
WServer *server_;
#endif
WebController *controller_;
mutable Signal<WDialog *> dialogExecuted_;
mutable Signal<WPopupMenu *> popupExecuted_;
virtual bool isTest() const;
void init(EntryPointType type);
};
}
}
#endif // WTEST_ENVIRONMENT_H_
|