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

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

Issue 2175933002: More aggressive IO asserts in content_browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 1 less instance of ScopedAllowIO in DumpAccessibilityTestBase::RunTestForPlatform. Created 4 years, 5 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
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 8a8052efd3d4cba81795b59e0ef338543d48779f..303337fedc7d6e9803028e654e8afdd55fef3247 100644
--- a/content/browser/download/mhtml_generation_browsertest.cc
+++ b/content/browser/download/mhtml_generation_browsertest.cc
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/thread_restrictions.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/common/frame_messages.h"
#include "content/public/browser/render_process_host.h"
@@ -122,6 +123,7 @@ class MHTMLGenerationTest : public ContentBrowserTest {
}
int64_t ReadFileSizeFromDisk(base::FilePath path) {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_to_test_file_size;
int64_t file_size;
if (!base::GetFileSize(path, &file_size)) return -1;
return file_size;
@@ -220,10 +222,13 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
EXPECT_GT(file_size(), 0); // Verify the size reported by the callback.
EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size.
- std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
- EXPECT_THAT(mhtml,
- HasSubstr("Content-Transfer-Encoding: quoted-printable"));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ std::string mhtml;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ EXPECT_THAT(mhtml,
+ HasSubstr("Content-Transfer-Encoding: quoted-printable"));
+ }
}
class GenerateMHTMLAndExitRendererMessageFilter : public BrowserMessageFilter {
@@ -364,11 +369,14 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateNonBinaryMHTMLWithImage) {
EXPECT_GT(file_size(), 0); // Verify the size reported by the callback.
EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size.
- std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
- EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64"));
- EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary")));
- EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg"));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ std::string mhtml;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: base64"));
+ EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: binary")));
+ EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg"));
+ }
}
// Tests that MHTML generated using the binary encoding contains the 'binary'
@@ -387,11 +395,14 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateBinaryMHTMLWithImage) {
EXPECT_GT(file_size(), 0); // Verify the size reported by the callback.
EXPECT_GT(ReadFileSizeFromDisk(path), 100); // Verify the actual file size.
- std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
- EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary"));
- EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64")));
- EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg"));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ std::string mhtml;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ EXPECT_THAT(mhtml, HasSubstr("Content-Transfer-Encoding: binary"));
+ EXPECT_THAT(mhtml, Not(HasSubstr("Content-Transfer-Encoding: base64")));
+ EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*blank.jpg"));
+ }
}
IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) {
@@ -407,7 +418,10 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLIgnoreNoStore) {
ASSERT_FALSE(HasFailure());
std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ }
// Make sure the contents of the body are present.
EXPECT_THAT(mhtml, HasSubstr("test body"));
@@ -432,7 +446,10 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreMainFrame) {
EXPECT_EQ(-1, file_size());
std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ }
// Make sure the contents are missing.
EXPECT_THAT(mhtml, Not(HasSubstr("test body")));
@@ -455,7 +472,10 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest,
EXPECT_LT(0, file_size());
std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ }
EXPECT_THAT(mhtml, HasSubstr("Main Frame"));
// Make sure that no-store subresources exist in this mode.
@@ -479,7 +499,10 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTMLObeyNoStoreSubFrame) {
EXPECT_LT(0, file_size());
std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ }
EXPECT_THAT(mhtml, HasSubstr("Main Frame"));
// Make sure the contents are missing.
@@ -519,7 +542,10 @@ IN_PROC_BROWSER_TEST_F(
2 /* expected number of frames */, expectations, forbidden);
std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml));
+ }
}
IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest,
@@ -543,7 +569,10 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest,
2 /* expected number of frames */, expectations, forbidden);
std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ ASSERT_TRUE(base::ReadFileToString(params.file_path, &mhtml));
+ }
}
// Test suite that allows testing --site-per-process against cross-site frames.
@@ -583,7 +612,10 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationSitePerProcessTest, GenerateMHTML) {
ASSERT_FALSE(HasFailure());
std::string mhtml;
- ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ {
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_content_verification;
+ ASSERT_TRUE(base::ReadFileToString(path, &mhtml));
+ }
// Make sure the contents of both frames are present.
EXPECT_THAT(mhtml, HasSubstr("This page has one cross-site iframe"));
« no previous file with comments | « content/browser/download/download_browsertest.cc ('k') | content/browser/indexed_db/indexed_db_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698