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

Unified Diff: chrome/browser/google/google_update_win_unittest.cc

Issue 2952133002: Use task runner in version_updater_win.cc. (Closed)
Patch Set: remove task runner injection Created 3 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/google/google_update_win_unittest.cc
diff --git a/chrome/browser/google/google_update_win_unittest.cc b/chrome/browser/google/google_update_win_unittest.cc
index 033fa73b88e415a17d97e21258f67fc7a6f3d333..51621fa8fa1626f59d02c6c623c90c35c211ea94 100644
--- a/chrome/browser/google/google_update_win_unittest.cc
+++ b/chrome/browser/google/google_update_win_unittest.cc
@@ -19,9 +19,8 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_path_override.h"
+#include "base/test/scoped_task_environment.h"
#include "base/test/test_reg_util_win.h"
-#include "base/test/test_simple_task_runner.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "base/version.h"
#include "base/win/registry.h"
#include "base/win/scoped_comptr.h"
@@ -529,9 +528,7 @@ class GoogleUpdateWinTest : public ::testing::TestWithParam<bool> {
protected:
GoogleUpdateWinTest()
- : task_runner_(new base::TestSimpleTaskRunner()),
- task_runner_handle_(task_runner_),
- system_level_install_(GetParam()),
+ : system_level_install_(GetParam()),
scoped_install_details_(system_level_install_, 0) {}
void SetUp() override {
@@ -622,8 +619,7 @@ class GoogleUpdateWinTest : public ::testing::TestWithParam<bool> {
static const base::char16 kClientState[];
static const base::char16 kChromeGuid[];
- scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
gab 2017/07/17 17:14:40 TestSimpleTaskRunner ignores delays in delayed tas
calamity 2017/07/19 09:03:38 Done.
- base::ThreadTaskRunnerHandle task_runner_handle_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
bool system_level_install_;
install_static::ScopedInstallDetails scoped_install_details_;
std::unique_ptr<base::ScopedPathOverride> file_exe_override_;
@@ -672,9 +668,9 @@ TEST_P(GoogleUpdateWinTest, InvalidInstallDirectory) {
EXPECT_CALL(mock_update_check_delegate_,
OnError(CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY, _, _));
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test the case where the GoogleUpdate class can't be created for an update
@@ -686,9 +682,9 @@ TEST_P(GoogleUpdateWinTest, NoGoogleUpdateForCheck) {
// Expect the appropriate error when the on-demand class cannot be created.
EXPECT_CALL(mock_update_check_delegate_,
OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, _, _));
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test the case where the GoogleUpdate class can't be created for an upgrade.
@@ -699,9 +695,9 @@ TEST_P(GoogleUpdateWinTest, NoGoogleUpdateForUpgrade) {
// Expect the appropriate error when the on-demand class cannot be created.
EXPECT_CALL(mock_update_check_delegate_,
OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, _, _));
- BeginUpdateCheck(task_runner_, std::string(), true, 0,
+ BeginUpdateCheck(std::string(), true, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test the case where the GoogleUpdate class returns an error when an update
@@ -716,9 +712,9 @@ TEST_P(GoogleUpdateWinTest, FailUpdateCheck) {
EXPECT_CALL(mock_update_check_delegate_,
OnError(GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, _, _));
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test the case where the GoogleUpdate class reports that updates are disabled
@@ -741,9 +737,9 @@ TEST_P(GoogleUpdateWinTest, UpdatesDisabledByPolicy) {
EXPECT_CALL(mock_update_check_delegate_,
OnError(GOOGLE_UPDATE_DISABLED_BY_POLICY, _, _));
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test the case where the GoogleUpdate class reports that manual updates are
@@ -767,9 +763,9 @@ TEST_P(GoogleUpdateWinTest, ManualUpdatesDisabledByPolicy) {
EXPECT_CALL(mock_update_check_delegate_,
OnError(GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY, _, _));
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test an update check where no update is available.
@@ -788,9 +784,9 @@ TEST_P(GoogleUpdateWinTest, UpdateCheckNoUpdate) {
EXPECT_CALL(mock_update_check_delegate_,
OnUpdateCheckComplete(IsEmpty())); // new_version
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test an update check where an update is available.
@@ -809,9 +805,9 @@ TEST_P(GoogleUpdateWinTest, UpdateCheckUpdateAvailable) {
EXPECT_CALL(mock_update_check_delegate_,
OnUpdateCheckComplete(StrEq(new_version_)));
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test a successful upgrade.
@@ -854,9 +850,9 @@ TEST_P(GoogleUpdateWinTest, UpdateInstalled) {
EXPECT_CALL(mock_update_check_delegate_,
OnUpgradeComplete(StrEq(new_version_)));
}
- BeginUpdateCheck(task_runner_, std::string(), true, 0,
+ BeginUpdateCheck(std::string(), true, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test a failed upgrade where Google Update reports that the installer failed.
@@ -905,9 +901,9 @@ TEST_P(GoogleUpdateWinTest, UpdateFailed) {
OnError(GOOGLE_UPDATE_ERROR_UPDATING, HasSubstr(error),
StrEq(new_version_)));
}
- BeginUpdateCheck(task_runner_, std::string(), true, 0,
+ BeginUpdateCheck(std::string(), true, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
// Test that a retry after a USING_EXTERNAL_UPDATER failure succeeds.
@@ -946,9 +942,9 @@ TEST_P(GoogleUpdateWinTest, RetryAfterExternalUpdaterError) {
// Expect the update check to succeed.
EXPECT_CALL(mock_update_check_delegate_,
OnUpdateCheckComplete(IsEmpty())); // new_version
- BeginUpdateCheck(task_runner_, std::string(), false, 0,
+ BeginUpdateCheck(std::string(), false, 0,
mock_update_check_delegate_.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
TEST_P(GoogleUpdateWinTest, UpdateInstalledMultipleDelegates) {
@@ -1006,11 +1002,11 @@ TEST_P(GoogleUpdateWinTest, UpdateInstalledMultipleDelegates) {
EXPECT_CALL(mock_update_check_delegate_2,
OnUpgradeComplete(StrEq(new_version_)));
}
- BeginUpdateCheck(task_runner_, std::string(), true, 0,
+ BeginUpdateCheck(std::string(), true, 0,
mock_update_check_delegate_.AsWeakPtr());
- BeginUpdateCheck(task_runner_, std::string(), true, 0,
+ BeginUpdateCheck(std::string(), true, 0,
mock_update_check_delegate_2.AsWeakPtr());
- task_runner_->RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
INSTANTIATE_TEST_CASE_P(UserLevel, GoogleUpdateWinTest, Values(false));

Powered by Google App Engine
This is Rietveld 408576698