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

Unified Diff: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc

Issue 2418583002: Fix OfflinePageUtilsTest.CheckExistenceOfPagesWithURL. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
index 80772e7944261d6ecc7a0dac047779f77c83ef8d..1fd1688edc25713b05cc0a7d567fb754ebafc6f5 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
+++ b/chrome/browser/android/offline_pages/offline_page_utils_unittest.cc
@@ -13,8 +13,8 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/run_loop.h"
#include "base/strings/string16.h"
-#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
#include "chrome/browser/android/offline_pages/test_offline_page_model_builder.h"
@@ -26,6 +26,7 @@
#include "components/offline_pages/offline_page_test_archiver.h"
#include "components/offline_pages/offline_page_test_store.h"
#include "components/offline_pages/offline_page_types.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "net/base/filename_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -58,7 +59,6 @@ class OfflinePageUtilsTest
~OfflinePageUtilsTest() override;
void SetUp() override;
- void RunUntilIdle();
// Necessary callbacks for the offline page model.
void OnSavePageDone(SavePageResult result, int64_t offlineId);
@@ -79,17 +79,13 @@ class OfflinePageUtilsTest
const GURL& url,
const base::FilePath& file_name);
+ content::TestBrowserThreadBundle browser_thread_bundle_;
int64_t offline_id_;
GURL url_;
-
- scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
- base::ThreadTaskRunnerHandle task_runner_handle_;
TestingProfile profile_;
};
-OfflinePageUtilsTest::OfflinePageUtilsTest()
- : task_runner_(new base::TestSimpleTaskRunner),
- task_runner_handle_(task_runner_) {}
+OfflinePageUtilsTest::OfflinePageUtilsTest() = default;
OfflinePageUtilsTest::~OfflinePageUtilsTest() {}
@@ -105,17 +101,13 @@ void OfflinePageUtilsTest::SetUp() {
// Set up the factory for testing.
OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse(
&profile_, BuildTestOfflinePageModel);
- RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
// Make sure the store contains the right offline pages before the load
// happens.
CreateOfflinePages();
}
-void OfflinePageUtilsTest::RunUntilIdle() {
- task_runner_->RunUntilIdle();
fgorski 2016/10/12 19:52:19 can you implement this one in terms of base::RunLo
fdoray 2016/10/12 19:57:06 Done.
-}
-
void OfflinePageUtilsTest::OnSavePageDone(SavePageResult result,
int64_t offline_id) {
offline_id_ = offline_id;
@@ -149,7 +141,7 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
model->SavePage(
kTestPage1Url, client_id, 0l, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
- RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
// Create page 2.
archiver = BuildArchiver(kTestPage2Url,
@@ -158,7 +150,7 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
model->SavePage(
kTestPage2Url, client_id, 0l, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
- RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
// Create page 4 - expired page.
archiver = BuildArchiver(kTestPage4Url,
@@ -167,11 +159,11 @@ void OfflinePageUtilsTest::CreateOfflinePages() {
model->SavePage(
kTestPage4Url, client_id, 0l, std::move(archiver),
base::Bind(&OfflinePageUtilsTest::OnSavePageDone, AsWeakPtr()));
- RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
model->ExpirePages(
std::vector<int64_t>({offline_id()}), base::Time::Now(),
base::Bind(&OfflinePageUtilsTest::OnExpirePageDone, AsWeakPtr()));
- RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
std::unique_ptr<OfflinePageTestArchiver> OfflinePageUtilsTest::BuildArchiver(
@@ -190,13 +182,13 @@ TEST_F(OfflinePageUtilsTest, CheckExistenceOfPagesWithURL) {
OfflinePageUtils::CheckExistenceOfPagesWithURL(
profile(), kDownloadNamespace, kTestPage1Url,
base::Bind(&BoolCallback, base::Unretained(&page_exists)));
- RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
EXPECT_TRUE(page_exists);
// This one should be missing
OfflinePageUtils::CheckExistenceOfPagesWithURL(
profile(), kDownloadNamespace, kTestPage3Url,
base::Bind(&BoolCallback, base::Unretained(&page_exists)));
- RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(page_exists);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698