diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 15:50:50 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-14 15:50:50 +0000 |
commit | 87a09a9ee309f5c600d3c81771d79005a219dc78 (patch) | |
tree | 0b4f0abeeb393d79fe23efa159ae736af8c2101b /net/url_request/url_request_test_util.h | |
parent | 8423a97deb51c5096c2e5b27004bc786dc431864 (diff) | |
download | chromium_src-87a09a9ee309f5c600d3c81771d79005a219dc78.zip chromium_src-87a09a9ee309f5c600d3c81771d79005a219dc78.tar.gz chromium_src-87a09a9ee309f5c600d3c81771d79005a219dc78.tar.bz2 |
Unit testing of event generation NetworkDelegate / Web Request API
The network stack has many different code paths. This CL uses the existing network unit tests to check which events are generated for the Web Request API.
BUG=86139
TEST=no
Review URL: http://codereview.chromium.org/7284008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92543 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_test_util.h')
-rw-r--r-- | net/url_request/url_request_test_util.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h index 74d8fab..14cee1c 100644 --- a/net/url_request/url_request_test_util.h +++ b/net/url_request/url_request_test_util.h @@ -47,16 +47,29 @@ class HostPortPair; class TestURLRequestContext : public net::URLRequestContext { public: TestURLRequestContext(); + // Default constructor like TestURLRequestContext() but does not call + // Init() in case |delay_initialization| is true. This allows modifying the + // URLRequestContext before it is constructed completely. If + // |delay_initialization| is true, Init() needs be be called manually. + explicit TestURLRequestContext(bool delay_initialization); + // We need this constructor because TestURLRequestContext("foo") actually + // calls the boolean constructor rather than the std::string constructor. + explicit TestURLRequestContext(const char* proxy); explicit TestURLRequestContext(const std::string& proxy); TestURLRequestContext(const std::string& proxy, net::HostResolver* host_resolver); + // Configures the proxy server, must not be called after Init(). + void SetProxyFromString(const std::string& proxy); + void SetProxyDirect(); + + void Init(); + protected: virtual ~TestURLRequestContext(); private: - void Init(); - + bool initialized_; net::URLRequestContextStorage context_storage_; }; @@ -203,11 +216,23 @@ class TestNetworkDelegate : public net::NetworkDelegate { net::URLRequest* request); virtual void OnPACScriptError(int line_number, const string16& error); + void InitRequestStatesIfNew(int request_id); + int last_os_error_; int error_count_; int created_requests_; int destroyed_requests_; int completed_requests_; + + // net::NetworkDelegate callbacks happen in a particular order (e.g. + // OnBeforeURLRequest is always called before OnBeforeSendHeaders). + // This bit-set indicates for each request id (key) what events may be sent + // next. + std::map<int, int> next_states_; + + // A log that records for each request id (key) the order in which On... + // functions were called. + std::map<int, std::string> event_order_; }; #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |