Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/MHTMLTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/MHTMLTest.cpp b/third_party/WebKit/Source/web/tests/MHTMLTest.cpp |
| index 494f0713505ffc3e915dcbb684d4756014b7332f..e303756fdd404b25b564b049c96b47f8aef54d13 100644 |
| --- a/third_party/WebKit/Source/web/tests/MHTMLTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/MHTMLTest.cpp |
| @@ -35,6 +35,7 @@ |
| #include "platform/SerializedResource.h" |
| #include "platform/SharedBuffer.h" |
| #include "platform/mhtml/MHTMLArchive.h" |
| +#include "platform/mhtml/MHTMLParser.h" |
| #include "platform/testing/URLTestHelpers.h" |
| #include "platform/testing/UnitTestHelpers.h" |
| #include "platform/weborigin/KURL.h" |
| @@ -161,6 +162,15 @@ class MHTMLTest : public ::testing::Test { |
| } |
| MHTMLArchive::GenerateMHTMLFooterForTesting(boundary, |
| *mhtml_data->MutableData()); |
| + |
| + // Validate the generated MHTML. |
| + MHTMLParser parser( |
| + SharedBuffer::Create(mhtml_data->data(), mhtml_data->length())); |
| + if (parser.ParseArchive().IsEmpty()) { |
| + ADD_FAILURE() << "Invalid MHTML"; |
| + return RawData::Create(); |
| + } |
| + |
| return mhtml_data.Release(); |
| } |
| @@ -206,6 +216,7 @@ TEST_F(MHTMLTest, TestMHTMLEncoding) { |
| AddTestResources(); |
| RefPtr<RawData> data = Serialize("Test Serialization", "text/html", |
| MHTMLArchive::kUseDefaultEncoding); |
| + ASSERT_FALSE(HasFailure()); |
|
dcheng
2017/04/26 08:52:39
Per https://github.com/google/googletest/blob/mast
|
| // Read the MHTML data line per line and do some pseudo-parsing to make sure |
| // the right encoding is used for the different sections. |
| @@ -242,6 +253,8 @@ TEST_F(MHTMLTest, MHTMLFromScheme) { |
| AddTestResources(); |
| RefPtr<RawData> raw_data = Serialize("Test Serialization", "text/html", |
| MHTMLArchive::kUseDefaultEncoding); |
| + ASSERT_FALSE(HasFailure()); |
| + |
| RefPtr<SharedBuffer> data = |
| SharedBuffer::Create(raw_data->data(), raw_data->length()); |
| KURL http_url = ToKURL("http://www.example.com"); |