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 |
not at google - send to devlin
2014/07/08 16:02:28
inelegant
and indeed.
it would be nice if FlushF
mtomasz
2014/07/09 02:21:02
I just found a utility function in drive code:
htt
not at google - send to devlin
2014/07/09 02:38:20
hey that would be good. how do you propose to reus
mtomasz
2014/07/09 03:55:42
We could move that code from test_util.h|cc to a n
not at google - send to devlin
2014/07/09 13:23:50
sounds good.
|
+ // 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]); |