Chromium Code Reviews| Index: Source/web/tests/PageSerializerTest.cpp |
| diff --git a/Source/web/tests/PageSerializerTest.cpp b/Source/web/tests/PageSerializerTest.cpp |
| index 44536240ed9b291bfe7088d47567b8dfcaa62650..90fd0fbe24f94928564730020f8eebe8a4065947 100644 |
| --- a/Source/web/tests/PageSerializerTest.cpp |
| +++ b/Source/web/tests/PageSerializerTest.cpp |
| @@ -143,16 +143,32 @@ protected: |
| return m_resources; |
| } |
| - bool isSerialized(const char* url, const char* mimeType) |
| + |
| + const SerializedResource* getResource(const char* url, const char* mimeType) |
| { |
| KURL kURL = KURL(m_baseUrl, url); |
| WTF::String mime(mimeType); |
| for (size_t i = 0; i < m_resources.size(); ++i) { |
| const SerializedResource& resource = m_resources[i]; |
| - if (resource.url == kURL && !resource.data->isEmpty() && equalIgnoringCase(resource.mimeType, mime)) |
| - return true; |
| + if (resource.url == kURL && !resource.data->isEmpty() |
| + && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime))) |
| + return &resource; |
| } |
| - return false; |
| + return 0; |
| + } |
| + |
| + bool isSerialized(const char* url, const char* mimeType = 0) |
| + { |
| + return getResource(url, mimeType); |
| + } |
| + |
| + WTF::String getSerializedData(const char* url, const char* mimeType = 0) |
| + { |
| + const SerializedResource* resource = getResource(url, mimeType); |
| + if (resource) { |
| + return WTF::String(resource->data->data()); |
| + } |
| + return WTF::String(); |
|
abarth-chromium
2013/08/22 17:13:44
No need for WTF::
Also, no need for { and }
|
| } |
| WebViewImpl* m_webViewImpl; |
| @@ -179,4 +195,26 @@ TEST_F(PageSerializerTest, InputImage) |
| EXPECT_FALSE(isSerialized("non-existing-button.png", "image/png")); |
| } |
| +TEST_F(PageSerializerTest, XMLDeclaration) |
| +{ |
| + setBaseFolder("pageserializer/xmldecl/"); |
|
abarth-chromium
2013/08/22 17:13:44
Why do these need separate folders? They seem to
Tiger
2013/08/26 12:39:22
There is no need for them to be in a sub folder. I
|
| + |
| + registerURL("xmldecl.xml", "text/xml"); |
| + serialize("xmldecl.xml"); |
| + |
| + WTF::String expectedStart("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
| + EXPECT_TRUE(getSerializedData("xmldecl.xml").startsWith(expectedStart)); |
| +} |
| + |
| +TEST_F(PageSerializerTest, DTD) |
| +{ |
| + setBaseFolder("pageserializer/dtd/"); |
| + |
| + registerURL("dtd.html", "text/html"); |
| + serialize("dtd.html"); |
| + |
| + WTF::String expectedStart("<!DOCTYPE html>"); |
|
abarth-chromium
2013/08/22 17:13:44
No need for WTF::
|
| + EXPECT_TRUE(getSerializedData("dtd.html").startsWith(expectedStart)); |
| +} |
| + |
| } |