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

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

Issue 380993002: Upstream RunBlockingPoolTask(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. 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
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 3ee9bcad6301e7ec0834cd7d427e918bfc91b4ee..626e895ffea8408448b7b1f8c37814e9696d6db1 100644
--- a/chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc
+++ b/chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc
@@ -15,6 +15,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_file_system_context.h"
+#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -76,8 +77,7 @@ TEST_F(FileHandlersMimeUtilTest, GetMimeTypeForLocalPath) {
&profile_,
base::FilePath::FromUTF8Unsafe(kJPEGExtensionFilePath),
base::Bind(&OnMimeTypeResult, &result));
- content::BrowserThread::GetBlockingPool()->FlushForTesting();
- base::RunLoop().RunUntilIdle();
+ content::RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ("image/jpeg", result);
}
@@ -87,8 +87,7 @@ TEST_F(FileHandlersMimeUtilTest, GetMimeTypeForLocalPath) {
&profile_,
base::FilePath::FromUTF8Unsafe(kJPEGExtensionUpperCaseFilePath),
base::Bind(&OnMimeTypeResult, &result));
- content::BrowserThread::GetBlockingPool()->FlushForTesting();
- base::RunLoop().RunUntilIdle();
+ content::RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ("image/jpeg", result);
}
@@ -97,14 +96,7 @@ 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();
-
+ content::RunAllBlockingPoolTasksUntilIdle();
EXPECT_EQ("text/html", result);
}
}
@@ -124,14 +116,7 @@ TEST_F(FileHandlersMimeUtilTest, MimeTypeCollector_ForURLs) {
std::vector<std::string> result;
collector.CollectForURLs(urls, base::Bind(&OnMimeTypesCollected, &result));
-
- // 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();
- }
+ content::RunAllBlockingPoolTasksUntilIdle();
ASSERT_EQ(3u, result.size());
EXPECT_EQ("image/jpeg", result[0]);
@@ -151,11 +136,7 @@ TEST_F(FileHandlersMimeUtilTest, MimeTypeCollector_ForLocalPaths) {
std::vector<std::string> result;
collector.CollectForLocalPaths(local_paths,
base::Bind(&OnMimeTypesCollected, &result));
-
- for (int i = 0; i < 6; ++i) {
- content::BrowserThread::GetBlockingPool()->FlushForTesting();
- base::RunLoop().RunUntilIdle();
- }
+ content::RunAllBlockingPoolTasksUntilIdle();
ASSERT_EQ(3u, result.size());
EXPECT_EQ("image/jpeg", result[0]);

Powered by Google App Engine
This is Rietveld 408576698