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

Unified Diff: content/browser/download/mhtml_generation_browsertest.cc

Issue 2519273002: Fail when saving page as MHTML provides information about the cause. (Closed)
Patch Set: Fixed typo. Created 4 years, 1 month 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 | content/browser/download/mhtml_generation_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/mhtml_generation_browsertest.cc
diff --git a/content/browser/download/mhtml_generation_browsertest.cc b/content/browser/download/mhtml_generation_browsertest.cc
index 76a948487dc45f622320861dd60b7be6f91e9025..1a71a9e50db3a2bce64d885faf1b41c85c6ed4ec 100644
--- a/content/browser/download/mhtml_generation_browsertest.cc
+++ b/content/browser/download/mhtml_generation_browsertest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <stdint.h>
+#include <memory>
#include "base/bind.h"
#include "base/callback.h"
@@ -12,6 +13,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/histogram_tester.h"
#include "base/threading/thread_restrictions.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/common/frame_messages.h"
@@ -111,6 +113,7 @@ class MHTMLGenerationTest : public ContentBrowserTest {
void GenerateMHTMLForCurrentPage(const MHTMLGenerationParams& params) {
base::RunLoop run_loop;
+ histogram_tester_.reset(new base::HistogramTester());
shell()->web_contents()->GenerateMHTML(
params, base::Bind(&MHTMLGenerationTest::MHTMLGenerated,
@@ -194,6 +197,7 @@ class MHTMLGenerationTest : public ContentBrowserTest {
bool has_mhtml_callback_run() const { return has_mhtml_callback_run_; }
int64_t file_size() const { return file_size_; }
+ base::HistogramTester* histogram_tester() { return histogram_tester_.get(); }
base::ScopedTempDir temp_dir_;
@@ -206,6 +210,7 @@ class MHTMLGenerationTest : public ContentBrowserTest {
bool has_mhtml_callback_run_;
int64_t file_size_;
+ std::unique_ptr<base::HistogramTester> histogram_tester_;
};
// Tests that generating a MHTML does create contents.
@@ -230,6 +235,11 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
EXPECT_THAT(mhtml,
HasSubstr("Content-Transfer-Encoding: quoted-printable"));
}
+
+ // Checks that the final status reported to UMA is correct.
+ histogram_tester()->ExpectUniqueSample(
+ "PageSerialization.MhtmlGeneration.FinalSaveStatus",
+ static_cast<int>(MhtmlSaveStatus::SUCCESS), 1);
}
class GenerateMHTMLAndExitRendererMessageFilter : public BrowserMessageFilter {
@@ -355,6 +365,11 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, InvalidPath) {
ASSERT_FALSE(HasFailure()); // No failures with the invocation itself?
EXPECT_EQ(file_size(), -1); // Expecting that the callback reported failure.
+
+ // Checks that the final status reported to UMA is correct.
+ histogram_tester()->ExpectUniqueSample(
+ "PageSerialization.MhtmlGeneration.FinalSaveStatus",
+ static_cast<int>(MhtmlSaveStatus::FILE_CREATION_ERROR), 1);
}
// Tests that MHTML generated using the default 'quoted-printable' encoding does
@@ -454,6 +469,11 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreMainFrame) {
// Make sure the contents are missing.
EXPECT_THAT(mhtml, Not(HasSubstr("test body")));
+
+ // Checks that the final status reported to UMA is correct.
+ histogram_tester()->ExpectUniqueSample(
+ "PageSerialization.MhtmlGeneration.FinalSaveStatus",
+ static_cast<int>(MhtmlSaveStatus::FRAME_SERIALIZATION_FORBIDDEN), 1);
}
IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest,
« no previous file with comments | « no previous file | content/browser/download/mhtml_generation_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698