Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
net_instaweb::CssRewriteTestBase Class Reference
Inheritance diagram for net_instaweb::CssRewriteTestBase:
net_instaweb::RewriteTestBase net_instaweb::RewriteOptionsTestBase< OptionsClass > net_instaweb::HtmlParseTestBaseNoAlloc

Protected Types

enum  ValidationFlags {
  kNoFlags = 0, kExpectSuccess = 1<<0, kExpectCached = 1<<1, kExpectNoChange = 1<<2,
  kExpectFallback = 1<<3, kExpectFailure = 1<<4, kNoStatCheck = 1<<5, kNoClearFetcher = 1<<6,
  kNoOtherContexts = 1<<7, kLinkCharsetIsUTF8 = 1<<8, kLinkScreenMedia = 1<<9, kLinkPrintMedia = 1<<10,
  kMetaCharsetUTF8 = 1<<11, kMetaCharsetISO88591 = 1<<12, kMetaHttpEquiv = 1<<13, kMetaHttpEquivUnquoted = 1<<14,
  kFlattenImportsCharsetMismatch = 1<<15, kFlattenImportsInvalidUrl = 1<<16, kFlattenImportsLimitExceeded = 1<<17, kFlattenImportsMinifyFailed = 1<<18,
  kFlattenImportsRecursion = 1<<19, kFlattenImportsComplexQueries = 1<<20, kInputHtml = 1<<21, kOutputHtml = 1<<22
}
 

Protected Member Functions

virtual void SetUp ()
 
bool FlagSet (int flags, ValidationFlags f) const
 
void CheckFlags (int flags)
 Sanity check on flags passed in.
 
bool ValidateRewriteInlineCss (StringPiece id, StringPiece css_input, StringPiece expected_css_output, int flags)
 Check that inline CSS gets rewritten correctly.
 
void GetNamerForCss (StringPiece id, StringPiece expected_css_output, ResourceNamer *namer)
 
GoogleString ExpectedUrlForNamer (const ResourceNamer &namer)
 
GoogleString ExpectedUrlForCss (StringPiece id, StringPiece expected_css_output)
 
void ValidateRewriteExternalCss (StringPiece id, StringPiece css_input, StringPiece expected_css_output, int flags)
 Check that external CSS gets rewritten correctly.
 
void ValidateRewriteExternalCssUrl (StringPiece id, StringPiece css_url, StringPiece css_input, StringPiece expected_css_output, int flags)
 
GoogleString MakeHtmlWithExternalCssLink (StringPiece css_url, int flags, bool insert_debug_message)
 Makes an HTML document with an external CSS link.
 
GoogleString MakeIndentedCssWithImage (StringPiece image_url)
 Makes a CSS body with an external image link, with nice indentation.
 
GoogleString MakeMinifiedCssWithImage (StringPiece image_url)
 Makes a minified CSS body with an external image link.
 
GoogleString ExtractCssBackgroundImage (StringPiece in_css)
 Extract the background image from the css text.
 
void ValidateRewrite (StringPiece id, StringPiece css_input, StringPiece gold_output, int flags)
 
void ValidateFailParse (StringPiece id, StringPiece css_input)
 
void ResetStats ()
 Reset all Variables.
 
bool ValidateWithStats (StringPiece id, StringPiece html_input, StringPiece expected_html_output, StringPiece css_input, StringPiece expected_css_output, int flags)
 Validate HTML rewrite as well as checking statistics.
 
void TestCorruptUrl (const char *junk)
 Helper to test for how we handle trailing junk.
 
- Protected Member Functions inherited from net_instaweb::RewriteTestBase
void Init ()
 
virtual RequestContextPtr CreateRequestContext ()
 
void CallFetcherCallbacksForDriver (WaitUrlAsyncFetcher *fetcher, RewriteDriver *driver)
 
void PopulateDefaultHeaders (const ContentType &content_type, int64 original_content_length, ResponseHeaders *headers)
 
void SetActiveServer (ActiveServerFlag server_to_use)
 
void AdvanceTimeUs (int64 delay_ms)
 
void AdvanceTimeMs (int64 delay_ms)
 
void SetTimeUs (int64 time_us)
 
void SetTimeMs (int64 time_ms)
 
void AdjustTimeUsWithoutWakingAlarms (int64 time_us)
 Adjusts time ignoring any scheduler callbacks. Use with caution.
 
const RequestTimingInfotiming_info ()
 Accessor for TimingInfo.
 
RequestTimingInfomutable_timing_info ()
 
virtual RequestContextPtr request_context ()
 
LoggingInfo * logging_info ()
 
const MetadataCacheInfo & metadata_cache_info ()
 Convenience method to extract read-only metadata_cache_info.
 
GoogleString AppliedRewriterStringFromLog ()
 
void VerifyRewriterInfoEntry (AbstractLogRecord *log_record, const GoogleString &id, int url_index, int rewriter_info_index, int rewriter_info_size, int url_list_size, const GoogleString &url)
 
void SetCurrentUserAgent (const StringPiece &user_agent)
 Sets current_user_agent_.
 
void SetupForWebp ()
 Sets up user-agent and request-header to allow webp processing.
 
void SetupForWebpLossless ()
 
void SetupForWebpAnimated ()
 
void AddRequestAttribute (StringPiece name, StringPiece value)
 
void PopulateRequestHeaders (RequestHeaders *request_headers)
 Populates a RequestHeaders* object with al.
 
virtual void ParseUrl (StringPiece url, StringPiece html_input)
 
GoogleString ExpectedNonce ()
 
GoogleString HttpCacheKey (StringPiece url)
 
int TimedValue (StringPiece name)
 Returns the value of a TimedVariable, specified by name.
 
- Protected Member Functions inherited from net_instaweb::HtmlParseTestBaseNoAlloc
virtual bool AddHtmlTags () const
 
void SetDoctype (StringPiece directive)
 
virtual GoogleString AddHtmlBody (StringPiece html)
 
void ValidateNoChanges (StringPiece case_id, StringPiece html_input)
 
void ValidateNoChangesFail (StringPiece case_id, StringPiece html_input)
 Fail to ValidateNoChanges.
 
void SetupWriter (scoped_ptr< HtmlWriterFilter > *html_writer_filter)
 
void Parse (StringPiece case_id, StringPiece html_input)
 Parse html_input, the result is stored in output_buffer_. More...
 
bool ValidateExpected (StringPiece case_id, StringPiece html_input, StringPiece expected)
 
bool ValidateExpectedUrl (StringPiece url, StringPiece html_input, StringPiece expected)
 Same as ValidateExpected, but with an explicit URL rather than an id.
 
void ValidateExpectedFail (StringPiece case_id, StringPiece html_input, StringPiece expected)
 Fail to ValidateExpected.
 
const GoogleUrlhtml_gurl ()
 

Static Protected Member Functions

static bool ExactlyOneTrue (bool a, bool b)
 
static bool ExactlyOneTrue (bool a, bool b, bool c)
 
static bool ExactlyOneTrue (bool a, bool b, bool c, bool d)
 
static bool ExactlyOneTrue (bool a, bool b, bool c, bool d, bool e)
 

Protected Attributes

Variablenum_blocks_rewritten_
 
Variablenum_fallback_rewrites_
 
Variablenum_parse_failures_
 
Variablenum_rewrites_dropped_
 
UpDownCountertotal_bytes_saved_
 
Variabletotal_original_bytes_
 
Variablenum_uses_
 
Variablenum_flatten_imports_charset_mismatch_
 
Variablenum_flatten_imports_invalid_url_
 
Variablenum_flatten_imports_limit_exceeded_
 
Variablenum_flatten_imports_minify_failed_
 
Variablenum_flatten_imports_recursion_
 
Variablenum_flatten_imports_complex_queries_
 
- Protected Attributes inherited from net_instaweb::RewriteTestBase
const HTTPCache::FindResult kFoundResult
 Common values for HttpBlockingFind* result.
 
const HTTPCache::FindResult kNotFoundResult
 
MockUrlFetcher mock_url_fetcher_
 
scoped_ptr< Statisticsstatistics_
 
scoped_ptr
< TestRewriteDriverFactory
factory_
 
scoped_ptr
< TestRewriteDriverFactory
other_factory_
 
ServerContextserver_context_
 
RewriteDriverrewrite_driver_
 
ServerContextother_server_context_
 
RewriteDriverother_rewrite_driver_
 
scoped_ptr< HtmlWriterFilterother_html_writer_filter_
 
ActiveServerFlag active_server_
 
bool use_managed_rewrite_drivers_
 
StringPiece current_user_agent_
 
StringVector request_attribute_names_
 
StringVector request_attribute_values_
 
MD5Hasher md5_hasher_
 
RewriteOptionsoptions_
 owned by rewrite_driver_.
 
RewriteOptionsother_options_
 owned by other_rewrite_driver_.
 
UrlSegmentEncoder default_encoder_
 
ResponseHeaders response_headers_
 
const GoogleString kEtag0
 Etag with a 0 hash.
 
uint64 expected_nonce_
 
GoogleString debug_message_
 Message used by DebugMessage.
 
- Protected Attributes inherited from net_instaweb::HtmlParseTestBaseNoAlloc
MockMessageHandler message_handler_
 
StringWriter write_to_string_
 
GoogleString output_buffer_
 
bool added_filter_
 
scoped_ptr< HtmlWriterFilterhtml_writer_filter_
 
GoogleString doctype_string_
 

Additional Inherited Members

- Public Types inherited from net_instaweb::RewriteTestBase
enum  ActiveServerFlag { kPrimary, kSecondary }
 
- Public Member Functions inherited from net_instaweb::RewriteTestBase
 RewriteTestBase (std::pair< TestRewriteDriverFactory *, TestRewriteDriverFactory * > factories)
 
virtual void TearDown ()
 
virtual bool AddBody () const
 
virtual TestRewriteDriverFactoryMakeTestFactory ()
 
void AddRecompressImageFilters ()
 
void AddFilter (RewriteOptions::Filter filter)
 Add a single rewrite filter to rewrite_driver_.
 
void AddOtherFilter (RewriteOptions::Filter filter)
 Add a single rewrite filter to other_rewrite_driver_.
 
void AddRewriteFilter (RewriteFilter *filter)
 
void AddFetchOnlyRewriteFilter (RewriteFilter *filter)
 
void AddOtherRewriteFilter (RewriteFilter *filter)
 
void SetBaseUrlForFetch (const StringPiece &url)
 
void SetDriverRequestHeaders ()
 
void SetDownstreamCacheDirectives (StringPiece downstream_cache_purge_method, StringPiece downstream_cache_purge_location_prefix, StringPiece rebeaconing_key)
 
void SetShouldBeaconHeader (StringPiece rebeaconing_key)
 Set ShouldBeacon request header to the specified value.
 
ResourcePtr CreateResource (const StringPiece &base, const StringPiece &url)
 
Timertimer ()
 
void AppendDefaultHeaders (const ContentType &content_type, GoogleString *text)
 Append default headers to the given string.
 
void AppendDefaultHeadersWithCanonical (const ContentType &content_type, StringPiece canonical_url, GoogleString *text)
 Like above, but also include a Link: <..>; rel="canonical" header.
 
void ServeResourceFromManyContexts (const GoogleString &resource_url, const StringPiece &expected_content)
 
void ServeResourceFromManyContextsWithUA (const GoogleString &resource_url, const StringPiece &expected_content, const StringPiece &user_agent)
 
void ServeResourceFromNewContext (const GoogleString &resource_url, const StringPiece &expected_content)
 
virtual RewriteDriverhtml_parse ()
 
void DefaultResponseHeaders (const ContentType &content_type, int64 ttl_sec, ResponseHeaders *response_headers)
 Set default headers for a resource with content_type and Cache ttl_sec.
 
bool FetchResource (const StringPiece &path, const StringPiece &filter_id, const StringPiece &name, const StringPiece &ext, GoogleString *content)
 
bool FetchResource (const StringPiece &path, const StringPiece &filter_id, const StringPiece &name, const StringPiece &ext, GoogleString *content, ResponseHeaders *response)
 
bool FetchResourceUrl (const StringPiece &url, GoogleString *content, ResponseHeaders *response)
 
bool FetchResourceUrl (const StringPiece &url, RequestHeaders *request_headers, GoogleString *content, ResponseHeaders *response_headers)
 
bool FetchResourceUrl (const StringPiece &url, GoogleString *content)
 
bool TryFetchResource (const StringPiece &url)
 Just check if we can fetch a resource successfully, ignore response.
 
void SetUseManagedRewriteDrivers (bool use_managed_rewrite_drivers)
 
GoogleString CssLinkHref (const StringPiece &url)
 
void CollectCssLinks (const StringPiece &id, const StringPiece &html, StringVector *css_links)
 Collects the hrefs for all CSS <link>s on the page.
 
void CollectCssLinks (const StringPiece &id, const StringPiece &html, CssLink::Vector *css_links)
 Collects all information about CSS links into a CssLink::Vector.
 
void EncodePathAndLeaf (const StringPiece &filter_id, const StringPiece &hash, const StringVector &name_vector, const StringPiece &ext, ResourceNamer *namer)
 Encode the given name (path + leaf) using the given pagespeed attributes.
 
StringVector MultiUrl (const StringPiece &url1)
 
StringVector MultiUrl (const StringPiece &url1, const StringPiece &url2)
 
StringVector MultiUrl (const StringPiece &url1, const StringPiece &url2, const StringPiece &url3)
 
StringVector MultiUrl (const StringPiece &url1, const StringPiece &url2, const StringPiece &url3, const StringPiece &url4)
 
GoogleString Encode (const StringPiece &path, const StringPiece &filter_id, const StringPiece &hash, const StringPiece &name, const StringPiece &ext)
 
GoogleString Encode (const StringPiece &path, const StringPiece &filter_id, const StringPiece &hash, const StringVector &name_vector, const StringPiece &ext)
 
GoogleString EncodeNormal (const StringPiece &path, const StringPiece &filter_id, const StringPiece &hash, const StringPiece &name, const StringPiece &ext)
 Same as Encode but specifically using UrlNamer not TestUrlNamer.
 
GoogleString EncodeNormal (const StringPiece &path, const StringPiece &filter_id, const StringPiece &hash, const StringVector &name_vector, const StringPiece &ext)
 
GoogleString EncodeWithBase (const StringPiece &base, const StringPiece &path, const StringPiece &filter_id, const StringPiece &hash, const StringPiece &name, const StringPiece &ext)
 
GoogleString EncodeWithBase (const StringPiece &base, const StringPiece &path, const StringPiece &filter_id, const StringPiece &hash, const StringVector &name_vector, const StringPiece &ext)
 
GoogleString EncodeImage (int width, int height, StringPiece filename, StringPiece hash, StringPiece rewritten_ext)
 
GoogleString AddOptionsToEncodedUrl (const StringPiece &url, const StringPiece &options)
 Takes an already-encoded URL and adds options to to it.
 
void SetupWaitFetcher ()
 
void CallFetcherCallbacks ()
 
void OtherCallFetcherCallbacks ()
 
RewriteOptionsoptions () const
 
RewriteOptionsother_options () const
 
void SetRewriteOptions (RewriteOptions *opts)
 Set the RewriteOptions to be returned by the RewriteOptionsManager.
 
bool AddDomain (StringPiece domain)
 
bool AddOriginDomainMapping (StringPiece to_domain, StringPiece from_domain)
 
bool AddRewriteDomainMapping (StringPiece to_domain, StringPiece from_domain)
 
bool AddShard (StringPiece domain, StringPiece shards)
 
void TestServeFiles (const ContentType *content_type, const StringPiece &filter_id, const StringPiece &rewritten_ext, const StringPiece &orig_name, const StringPiece &orig_content, const StringPiece &rewritten_name, const StringPiece &rewritten_content)
 Helper method to test all manner of resource serving from a filter.
 
void ValidateFallbackHeaderSanitization (StringPiece filter_id)
 
TestRewriteDriverFactoryfactory ()
 
TestRewriteDriverFactoryother_factory ()
 
void UseMd5Hasher ()
 
void SetDefaultLongCacheHeaders (const ContentType *content_type, ResponseHeaders *header)
 
void SetFetchResponse (const StringPiece &url, const ResponseHeaders &response_header, const StringPiece &response_body)
 
void SetResponseWithDefaultHeaders (const StringPiece &relative_url, const ContentType &content_type, const StringPiece &content, int64 ttl_sec)
 Add content to mock fetcher (with default headers).
 
bool LoadFile (const StringPiece &filename, GoogleString *contents)
 
void AddFileToMockFetcher (const StringPiece &url, const StringPiece &filename, const ContentType &content_type, int64 ttl_sec)
 Add the contents of a file to mock fetcher (with default headers).
 
void AddToResponse (const StringPiece &url, const StringPiece &name, const StringPiece &value)
 
void SetFetchResponse404 (const StringPiece &url)
 
void SetFetchFailOnUnexpected (bool fail)
 
void FetcherUpdateDateHeaders ()
 
void ClearFetcherResponses ()
 
virtual void ClearStats ()
 
void ClearRewriteDriver ()
 
MockUrlFetchermock_url_fetcher ()
 
Hasherhasher ()
 
DelayCachedelay_cache ()
 
LRUCachelru_cache ()
 
Statisticsstatistics ()
 
MemFileSystemfile_system ()
 
HTTPCachehttp_cache ()
 
PropertyCachepage_property_cache ()
 
MockMessageHandlermessage_handler ()
 
RewriteDriverrewrite_driver ()
 
RewriteDriverother_rewrite_driver ()
 
MockSchedulermock_scheduler ()
 The scheduler used by rewrite_driver.
 
int64 start_time_ms () const
 
bool ReadFile (const char *filename, GoogleString *contents)
 
bool WriteFile (const char *filename, const StringPiece &contents)
 
ServerContextserver_context ()
 
ServerContextother_server_context ()
 
CountingUrlAsyncFetchercounting_url_async_fetcher ()
 
void SetMockHashValue (const GoogleString &value)
 
void SetCacheDelayUs (int64 delay_us)
 
void SetupWriter () override
 
RewriteDriverMakeDriver (ServerContext *server_context, RewriteOptions *options)
 
GoogleString AbsolutifyUrl (const StringPiece &in)
 Converts a potentially relative URL off kTestDomain to absolute if needed.
 
void TestRetainExtraHeaders (const StringPiece &name, const StringPiece &filter_id, const StringPiece &ext)
 
const UrlSegmentEncoderFindEncoder (const StringPiece &id) const
 
void SetUseTestUrlNamer (bool use_test_url_namer)
 Switch url namers as specified.
 
GoogleString EncodeCssName (const StringPiece &name, bool supports_webp, bool can_inline)
 
bool ReadIfCached (const ResourcePtr &resource)
 
void InitiateResourceRead (const ResourcePtr &resource)
 
HTTPCache::FindResult HttpBlockingFind (const GoogleString &key, HTTPCache *http_cache, HTTPValue *value_out, ResponseHeaders *headers)
 
HTTPCache::FindResult HttpBlockingFindStatus (const GoogleString &key, HTTPCache *http_cache)
 
HTTPCache::FindResult HttpBlockingFindWithOptions (const RewriteOptions *options, const GoogleString &key, HTTPCache *http_cache, HTTPValue *value_out, ResponseHeaders *headers)
 Same as above, but with options (for invalidation checks)
 
void SetXhtmlMimetype ()
 Sets the response-headers Content-Type to "application/xhtml+xml".
 
void SetHtmlMimetype ()
 Sets the response-headers Content-Type to "text/html".
 
void SetMimetype (const StringPiece &mimetype)
 Sets the response-headers Content-Type as specified.
 
void CheckFetchFromHttpCache (StringPiece url, StringPiece expected_contents, int64 expected_expiration_ms)
 
const PropertyCache::CohortSetupCohort (PropertyCache *cache, const GoogleString &cohort)
 Setup statistics for the given cohort and add it to the give PropertyCache.
 
void SetupSharedCache ()
 
MockPropertyPageNewMockPage (const StringPiece &url, const StringPiece &options_signature_hash, UserAgentMatcher::DeviceType device_type)
 Returns a new mock property page for the page property cache.
 
MockPropertyPageNewMockPage (const StringPiece &url)
 
void SetMockLogRecord ()
 Sets MockLogRecord in the driver's request_context.
 
MockLogRecordmock_log_record ()
 Returns the MockLogRecord in the driver.
 
GoogleString GetLazyloadScriptHtml ()
 Helper methods to return js/html snippets related to lazyload images.
 
GoogleString GetLazyloadPostscriptHtml ()
 
void SetCacheInvalidationTimestamp ()
 
void SetCacheInvalidationTimestampForUrl (StringPiece url, bool ignores_metadata_and_pcache)
 
void EnableCachePurge ()
 
void EnableDebug ()
 Enables the debug flag, which is often done on a test-by-test basis.
 
void DebugWithMessage (StringPiece expected_debug_message)
 
GoogleString DebugMessage (StringPiece url)
 
void DisableGzip ()
 
bool WasGzipped (const ResponseHeaders &response_headers)
 Determines whether a response was originally gzipped.
 
- Public Member Functions inherited from net_instaweb::RewriteOptionsTestBase< OptionsClass >
ThreadSystemthread_system ()
 
OptionsClass * NewOptions ()
 
- Static Public Member Functions inherited from net_instaweb::RewriteTestBase
static GoogleString ChangeSuffix (StringPiece old_url, bool append_new_suffix, StringPiece old_suffix, StringPiece new_suffix)
 
static const ProcessContextprocess_context ()
 
- Public Attributes inherited from net_instaweb::RewriteOptionsTestBase< OptionsClass >
scoped_ptr< ThreadSystemthread_system_
 
- Static Public Attributes inherited from net_instaweb::RewriteTestBase
static const char kTestData []
 Testdata directory.
 
static const char kConfiguredBeaconingKey []
 Beaconing key values used when downstream caching is enabled.
 
static const char kWrongBeaconingKey []
 
- Static Protected Attributes inherited from net_instaweb::HtmlParseTestBaseNoAlloc
static const char kTestDomain []
 
static const char kXhtmlDtd []
 DOCTYPE string for claiming XHTML.
 

Member Enumeration Documentation

Enumerator
kExpectSuccess 

CSS parser succeeds and URL should be rewritten.

kExpectCached 

CSS parser succeeds and URL should be rewritten, but everything is from the cache so zero stats.

kExpectNoChange 

CSS parser succeeds but the URL is not rewritten because we increased the size of contents.

kExpectFallback 

CSS parser fails, fallback succeeds.

kExpectFailure 

CSS parser fails, fallback failed or disabled.

kNoStatCheck 
Todo:
TODO(sligocki): Explain why we turn off stats check at each use-site.
kNoClearFetcher 
Todo:
TODO(sligocki): Why would we ever want to clear fetcher?
kNoOtherContexts 
Todo:
TODO(sligocki): Explain why we turn off other contexts.
kFlattenImportsCharsetMismatch 

Flags to the check various import flattening failure statistics.

kInputHtml 

Flags to allow methods to know if the HTML is the test input or output.

Member Function Documentation

void net_instaweb::CssRewriteTestBase::ValidateRewrite ( StringPiece  id,
StringPiece  css_input,
StringPiece  gold_output,
int  flags 
)
inlineprotected

Don't run for external CSS unless inline succeeds.


The documentation for this class was generated from the following file: