19 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_TEST_BASE_H_
20 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_TEST_BASE_H_
23 #include "net/instaweb/htmlparse/public/empty_html_filter.h"
25 #include "net/instaweb/http/public/response_headers.h"
34 #include "net/instaweb/util/worker_test_base.h"
36 namespace net_instaweb {
38 class MockCriticalImagesFinder;
48 const char kPageUrl[] =
"page.html";
49 const char kBackgroundFetchHeader[] =
"X-Background-Fetch";
55 static const char kProxyHost[];
60 virtual bool Decode(
const GoogleUrl& gurl,
63 GoogleString* decoded)
const;
70 void set_authorized(
bool authorized) { authorized_ = authorized; }
74 DISALLOW_COPY_AND_ASSIGN(ProxyUrlNamer);
88 num_elements_property_(NULL) {
91 virtual void StartDocument();
93 virtual void StartElement(HtmlElement* element);
95 virtual void EndDocument();
97 virtual const char* Name()
const {
return "MockFilter"; }
128 async_fetch_(base_fetch) {}
132 SharedAsyncFetch::HandleHeadersComplete();
139 virtual void HandleDone(
bool success) {
140 SharedAsyncFetch::HandleDone(success);
145 AsyncFetch* async_fetch_;
146 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchCheckingAsyncFetch);
154 : base_fetcher_(fetcher),
155 num_background_fetches_(0) {}
158 virtual void Fetch(
const GoogleString& url,
159 MessageHandler* message_handler,
162 num_background_fetches_++;
166 base_fetcher_->
Fetch(url, message_handler, new_fetch);
169 int num_background_fetches() {
return num_background_fetches_; }
170 void clear_num_background_fetches() { num_background_fetches_ = 0; }
174 int num_background_fetches_;
175 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchCheckingUrlAsyncFetcher);
180 void TestHeadersSetupRace();
183 static const int kHtmlCacheTimeSec = 5000;
186 virtual void SetUp();
187 virtual void TearDown();
190 const StringPiece& url,
191 const RequestHeaders& request_headers,
193 GoogleString* string_out,
194 ResponseHeaders* headers_out,
195 bool proxy_fetch_property_callback_collector_created);
197 void FetchFromProxy(
const StringPiece& url,
198 const RequestHeaders& request_headers,
200 GoogleString* string_out,
201 ResponseHeaders* headers_out);
203 void FetchFromProxy(
const StringPiece& url,
205 GoogleString* string_out,
206 ResponseHeaders* headers_out);
208 void FetchFromProxyLoggingFlushes(
const StringPiece& url,
210 GoogleString* string_out);
212 void FetchFromProxyNoWait(
const StringPiece& url,
213 const RequestHeaders& request_headers,
216 ResponseHeaders* headers_out);
218 void WaitForFetch(
bool proxy_fetch_property_callback_collector_created);
220 void TestPropertyCache(
const StringPiece& url,
221 bool delay_pcache,
bool thread_pcache,
222 bool expect_success);
224 void TestPropertyCacheWithHeadersAndOutput(
225 const StringPiece& url,
bool delay_pcache,
bool thread_pcache,
226 bool expect_success,
bool check_stats,
bool add_create_filter_callback,
227 bool expect_detach_before_pcache,
const RequestHeaders& request_headers,
228 ResponseHeaders* response_headers, GoogleString* output);
230 void SetCriticalImagesInFinder(StringSet* critical_images);
231 void SetCssCriticalImagesInFinder(StringSet* css_critical_images);
233 scoped_ptr<ProxyInterface> proxy_interface_;
234 scoped_ptr<WorkerTestBase::SyncPoint> sync_;
235 ResponseHeaders callback_response_headers_;
236 GoogleString callback_buffer_;
237 bool callback_done_value_;
240 friend class FilterCallback;
Definition: url_namer.h:37
virtual bool Decode(const GoogleUrl &gurl, const RewriteOptions *rewrite_options, GoogleUrl *domain, GoogleString *decoded) const
Given the request_url, generate the original url.
Definition: proxy_interface_test_base.h:53
Holds the value & stability-metadata for a property.
Definition: property_cache.h:122
virtual bool IsAuthorized(const GoogleUrl &gurl, const RewriteOptions &options) const
Definition: proxy_interface_test_base.h:65
Definition: test_rewrite_driver_factory.h:79
Definition: rewrite_test_base.h:88
ResponseHeaders * response_headers()
See doc for request_headers and set_request_headers.
Definition: async_fetch.h:267
Definition: async_fetch.h:53
Definition: proxy_interface_test_base.h:178
Definition: proxy_interface_test_base.h:83
virtual void Fetch(const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch)=0
Definition: rewrite_driver.h:98
virtual void Fetch(const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch)
Definition: proxy_interface_test_base.h:158
virtual bool IsBackgroundFetch() const
Definition: async_fetch.h:125
virtual void HandleHeadersComplete()
Definition: proxy_interface_test_base.h:131
Definition: proxy_interface_test_base.h:151
UrlAsyncFetcher()
Definition: url_async_fetcher.h:81
Definition: rewrite_options.h:81
Definition: proxy_interface_test_base.h:124
Definition: url_async_fetcher.h:33
Definition: mock_critical_images_finder.h:36
Definition: proxy_interface_test_base.h:108