Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: third_party/WebKit/Source/web/tests/MHTMLTest.cpp

Issue 2841483007: MHTMLTest::TestMHTMLEncoding checks generated MTHML is well formed. (Closed)
Patch Set: Using ADD_FAILURE and HasFailure. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698