21 #ifndef NET_INSTAWEB_HTTP_PUBLIC_FETCHER_TEST_H_
22 #define NET_INSTAWEB_HTTP_PUBLIC_FETCHER_TEST_H_
24 #include "base/logging.h"
28 #include "net/instaweb/http/public/request_context.h"
39 namespace net_instaweb {
41 class ResponseHeaders;
42 class UrlAsyncFetcher;
46 static const char kStartDate[];
47 static const char kHtmlContent[];
48 static const char kGoodUrl[];
49 static const char kNotCachedUrl[];
50 static const char kBadUrl[];
51 static const char kHeaderName[];
52 static const char kHeaderValue[];
53 static const char kErrorMessage[];
63 return &wait_url_async_fetcher_;
73 bool check_error_message,
74 bool* callback_called)
76 expect_success_(expect_success),
77 check_error_message_(check_error_message),
78 callback_called_(callback_called) {
81 virtual void HandleDone(
bool success) {
82 *callback_called_ =
true;
83 CHECK_EQ(expect_success_, success);
91 bool check_error_message_;
92 bool* callback_called_;
99 bool success,
bool check_error_message,
const GoogleString& content,
106 bool* callback_called);
111 bool expect_success,
bool check_error_message,
112 bool* callback_called);
118 LOG(FATAL) <<
"async_fetcher() must be overridden before use.";
123 return (GTestSrcDir() +
124 "/net/instaweb/http/testdata/google.http");
130 const ResponseHeaders& response_headers);
132 GoogleMessageHandler message_handler_;
133 MockUrlFetcher mock_fetcher_;
134 WaitUrlAsyncFetcher wait_url_async_fetcher_;
135 CountingUrlAsyncFetcher counting_fetcher_;
136 scoped_ptr<ThreadSystem> thread_system_;
137 SimpleStats statistics_;
140 void Populate(
const char* cache_control,
141 ResponseHeaders* response_headers,
Definition: counting_url_async_fetcher.h:36
Definition: fetcher_test.h:70
ResponseHeaders * response_headers()
See doc for request_headers and set_request_headers.
virtual UrlAsyncFetcher * async_fetcher()
Definition: fetcher_test.h:117
WaitUrlAsyncFetcher * wait_fetcher()
Helpful classes for testing.
Definition: fetcher_test.h:62
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: fetcher_test.h:44
Definition: wait_url_async_fetcher.h:37
static void ValidateMockFetcherResponse(bool success, bool check_error_message, const GoogleString &content, const ResponseHeaders &response_headers)
This checks that response matches the mock response we setup.
void ValidateOutput(const GoogleString &content, const ResponseHeaders &response_headers)
Definition: async_fetch.h:192
int CountFetchesAsync(const StringPiece &url, bool expect_success, bool *callback_called)
Definition: url_async_fetcher.h:33