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

Unified Diff: chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc

Issue 374063002: [fsp] Fix crash because of calling net::GetMimeTypeFromFile on UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a comment. Created 6 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
« no previous file with comments | « chrome/browser/extensions/api/file_handlers/mime_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc
diff --git a/chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc b/chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc
index f4e457781b6d3eaaa4de5597f3fbf59ab3606692..3ee9bcad6301e7ec0834cd7d427e918bfc91b4ee 100644
--- a/chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc
+++ b/chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc
@@ -76,6 +76,7 @@ TEST_F(FileHandlersMimeUtilTest, GetMimeTypeForLocalPath) {
&profile_,
base::FilePath::FromUTF8Unsafe(kJPEGExtensionFilePath),
base::Bind(&OnMimeTypeResult, &result));
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
base::RunLoop().RunUntilIdle();
EXPECT_EQ("image/jpeg", result);
}
@@ -86,6 +87,7 @@ TEST_F(FileHandlersMimeUtilTest, GetMimeTypeForLocalPath) {
&profile_,
base::FilePath::FromUTF8Unsafe(kJPEGExtensionUpperCaseFilePath),
base::Bind(&OnMimeTypeResult, &result));
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
base::RunLoop().RunUntilIdle();
EXPECT_EQ("image/jpeg", result);
}
@@ -95,8 +97,14 @@ TEST_F(FileHandlersMimeUtilTest, GetMimeTypeForLocalPath) {
GetMimeTypeForLocalPath(&profile_,
html_mime_file_path_,
base::Bind(&OnMimeTypeResult, &result));
+
+ // Since there are two calls to the blocking pool, it has to be flushed
+ // twice.
content::BrowserThread::GetBlockingPool()->FlushForTesting();
base::RunLoop().RunUntilIdle();
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
+ base::RunLoop().RunUntilIdle();
+
EXPECT_EQ("text/html", result);
}
}
@@ -117,8 +125,13 @@ TEST_F(FileHandlersMimeUtilTest, MimeTypeCollector_ForURLs) {
std::vector<std::string> result;
collector.CollectForURLs(urls, base::Bind(&OnMimeTypesCollected, &result));
- content::BrowserThread::GetBlockingPool()->FlushForTesting();
- base::RunLoop().RunUntilIdle();
+ // Each URL may do up to 2 calls to the blocking pool. Hence, we need to
+ // flush it at least 6 times. This is unelegant, but there seem to be no
+ // better way.
+ for (int i = 0; i < 6; ++i) {
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
+ base::RunLoop().RunUntilIdle();
+ }
ASSERT_EQ(3u, result.size());
EXPECT_EQ("image/jpeg", result[0]);
@@ -139,8 +152,10 @@ TEST_F(FileHandlersMimeUtilTest, MimeTypeCollector_ForLocalPaths) {
collector.CollectForLocalPaths(local_paths,
base::Bind(&OnMimeTypesCollected, &result));
- content::BrowserThread::GetBlockingPool()->FlushForTesting();
- base::RunLoop().RunUntilIdle();
+ for (int i = 0; i < 6; ++i) {
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
+ base::RunLoop().RunUntilIdle();
+ }
ASSERT_EQ(3u, result.size());
EXPECT_EQ("image/jpeg", result[0]);
« no previous file with comments | « chrome/browser/extensions/api/file_handlers/mime_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698