Skip to content

Commit

Permalink
[TaskEnvironment] Mass-migrate away from ScopedTaskEnvironment
Browse files Browse the repository at this point in the history
(second half of
 https://chromium-review.googlesource.com/c/chromium/src/+/1756247)

This is step #1 of the mass migration. Some of these will be
backported to SingleThreadTaskEnvironment in a later phase.

scoped_task_environment.h will also only move in a follow-up CL.

TBR=dcheng@chromium.org

Bug: 992483
Change-Id: Ie80f083eeeb209180ab3c2884f1b566f73549cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1756248
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688142}
  • Loading branch information
Gabriel Charette authored and Commit Bot committed Aug 19, 2019
1 parent 855f22b commit dfa3604
Show file tree
Hide file tree
Showing 1,122 changed files with 3,162 additions and 3,370 deletions.
2 changes: 1 addition & 1 deletion PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@
'base::ScopedMockTimeMessageLoopTaskRunner',
(
'ScopedMockTimeMessageLoopTaskRunner is deprecated. Prefer',
'ScopedTaskEnvironment::TimeSource::MOCK_TIME. There are still a',
'TaskEnvironment::TimeSource::MOCK_TIME. There are still a',
'few cases that may require a ScopedMockTimeMessageLoopTaskRunner',
'(i.e. mocking the main MessageLoopForUI in browser_tests), but check',
'with gab@ first if you think you need it)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AwContentBrowserClientTest : public testing::Test {
mojo::core::Init();
}

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
};

TEST_F(AwContentBrowserClientTest, DisableCreatingThreadPool) {
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/aw_form_database_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class AwFormDatabaseServiceTest : public Test {

void TearDown() override {
service_->Shutdown();
scoped_task_environment_.RunUntilIdle();
task_environment_.RunUntilIdle();
}

// The path to the temporary directory used for the test operations.
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
base::ScopedTempDir temp_dir_;
JNIEnv* env_;
std::unique_ptr<AwFormDatabaseService> service_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AwMetricsServiceClientTest : public testing::Test {
~AwMetricsServiceClientTest() override {}

private:
base::test::ScopedTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;

DISALLOW_COPY_AND_ASSIGN(AwMetricsServiceClientTest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class AndroidStreamReaderURLLoaderTest : public ::testing::Test {
return std::string(buffer.data(), buffer.size());
}

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;

DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLLoaderTest);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class AwSafeBrowsingWhitelistManagerTest : public testing::Test {

void SetWhitelist(std::vector<std::string>&& whitelist, bool expected);

base::test::ScopedTaskEnvironment scoped_task_environment_{
base::test::ScopedTaskEnvironment::MainThreadType::IO};
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::MainThreadType::IO};
std::unique_ptr<AwSafeBrowsingWhitelistManager> wm_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jboolean JNI_MemoryMetricsLoggerTest_ForceRecordHistograms(JNIEnv* env) {
return false;

TestTimeouts::Initialize();
base::test::ScopedTaskEnvironment scoped_task_environment(
base::test::ScopedTaskEnvironment::ThreadingMode::MAIN_THREAD_ONLY);
base::test::TaskEnvironment task_environment(
base::test::TaskEnvironment::ThreadingMode::MAIN_THREAD_ONLY);
base::RunLoop run_loop;
bool result = false;
memory_metrics_logger->ScheduleRecordForTesting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace util {

TEST(MultiSourceMemoryPressureMonitorTest, RunDispatchCallback) {
base::test::ScopedTaskEnvironment task_environment;
base::test::TaskEnvironment task_environment;
MultiSourceMemoryPressureMonitor monitor;
auto* aggregator = monitor.aggregator_for_testing();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class IconConverterTest : public testing::Test {
std::vector<std::string>* encoded_data() { return &encoded_data_; }

private:
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
std::unique_ptr<IconConverter> icon_converter_;
std::vector<std::string> encoded_data_;
std::vector<SkBitmap> decoded_icons_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class AnimatingLayoutManagerSteppingTest : public testing::Test {
View* view_;
std::vector<View*> children_;
AnimatingLayoutManager* animating_layout_manager_ = nullptr;
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
std::unique_ptr<gfx::AnimationContainerTestApi> container_test_api_;
};

Expand Down
2 changes: 1 addition & 1 deletion components/arc/power/arc_power_bridge_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ArcPowerBridgeTest : public testing::Test {
return chromeos::FakePowerManagerClient::Get();
}

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;

service_manager::TestConnectorFactory connector_factory_;

Expand Down
2 changes: 1 addition & 1 deletion components/arc/session/arc_data_remover_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ArcDataRemoverTest : public testing::Test {
private:
TestingPrefServiceSimple prefs_;
const cryptohome::Identification cryptohome_id_{EmptyAccountId()};
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
std::unique_ptr<TestUpstartClient> test_upstart_client_;

DISALLOW_COPY_AND_ASSIGN(ArcDataRemoverTest);
Expand Down
2 changes: 1 addition & 1 deletion components/arc/session/arc_session_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class ArcSessionImplTest : public testing::Test {
}

private:
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
user_manager::ScopedUserManager scoped_user_manager_{
std::make_unique<user_manager::FakeUserManager>()};

Expand Down
5 changes: 2 additions & 3 deletions components/arc/session/arc_session_runner_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class ArcSessionRunnerTest : public testing::Test,
public ArcSessionRunner::Observer {
public:
ArcSessionRunnerTest()
: scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
: task_environment_(base::test::TaskEnvironment::MainThreadType::UI) {}

void SetUp() override {
chromeos::SessionManagerClient::InitializeFakeInMemory();
Expand Down Expand Up @@ -137,7 +136,7 @@ class ArcSessionRunnerTest : public testing::Test,
bool stopped_called_;
bool restarting_called_;
std::unique_ptr<ArcSessionRunner> arc_session_runner_;
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;

DISALLOW_COPY_AND_ASSIGN(ArcSessionRunnerTest);
};
Expand Down
5 changes: 2 additions & 3 deletions components/arc/wake_lock/arc_wake_lock_bridge_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ using device::mojom::WakeLockType;
class ArcWakeLockBridgeTest : public testing::Test {
public:
ArcWakeLockBridgeTest()
: scoped_task_environment_(
base::test::ScopedTaskEnvironment::TimeSource::MOCK_TIME),
: task_environment_(base::test::TaskEnvironment::TimeSource::MOCK_TIME),
wake_lock_provider_(
connector_factory_.RegisterInstance(device::mojom::kServiceName)) {
bridge_service_ = std::make_unique<ArcBridgeService>();
Expand Down Expand Up @@ -98,7 +97,7 @@ class ArcWakeLockBridgeTest : public testing::Test {
}

private:
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;

service_manager::TestConnectorFactory connector_factory_;
device::TestWakeLockProvider wake_lock_provider_;
Expand Down
2 changes: 1 addition & 1 deletion components/assist_ranker/base_predictor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BasePredictorTest : public ::testing::Test {

private:
// Sets up the task scheduling/task-runner environment for each test.
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;

// Sets itself as the global UkmRecorder on construction.
ukm::TestAutoSetUkmRecorder test_ukm_recorder_;
Expand Down
4 changes: 2 additions & 2 deletions components/assist_ranker/ranker_model_loader_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class RankerModelLoaderImplTest : public ::testing::Test {
void OnModelAvailable(std::unique_ptr<RankerModel> model);

// Sets up the task scheduling/task-runner environment for each test.
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;

// Override the default URL loader to return custom responses for tests.
network::TestURLLoaderFactory test_loader_factory_;
Expand Down Expand Up @@ -175,7 +175,7 @@ bool RankerModelLoaderImplTest::DoLoaderTest(const base::FilePath& model_path,
test_shared_loader_factory_, model_path, model_url,
"RankerModelLoaderImplTest");
loader->NotifyOfRankerActivity();
scoped_task_environment_.RunUntilIdle();
task_environment_.RunUntilIdle();

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class TestLogger : public RendererSavePasswordProgressLogger {
} // namespace

TEST(RendererSavePasswordProgressLoggerTest, SendLog) {
base::test::ScopedTaskEnvironment task_environment;
base::test::TaskEnvironment task_environment;
FakeContentPasswordManagerDriver fake_driver;
mojom::PasswordManagerDriverPtr driver_ptr =
fake_driver.CreateInterfacePtrAndBind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class AddressNormalizerTest : public testing::Test {
~AddressNormalizerTest() override {}

void WaitForAddressValidatorInitialization() {
scoped_task_environment_.RunUntilIdle();
task_environment_.RunUntilIdle();
}

bool normalization_successful() const { return success_; }
Expand All @@ -103,7 +103,7 @@ class AddressNormalizerTest : public testing::Test {

TestAddressNormalizer* normalizer() { return &normalizer_; }

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;

bool AreRulesLoadedForRegion(const std::string& region_code) {
return normalizer_.AreRulesLoadedForRegion(region_code);
Expand Down Expand Up @@ -187,7 +187,7 @@ TEST_F(AddressNormalizerTest,
base::Unretained(this)));

// Let the timeout execute.
scoped_task_environment_.RunUntilIdle();
task_environment_.RunUntilIdle();

// Since the rules are never loaded and the timeout is 0, the callback should
// get notified that the address could not be normalized.
Expand Down Expand Up @@ -338,7 +338,7 @@ TEST_F(AddressNormalizerTest, FormatPhone_AddressNotNormalizedAsync) {
base::Unretained(this)));

// Let the timeout execute.
scoped_task_environment_.RunUntilIdle();
task_environment_.RunUntilIdle();

// Make sure the address was not normalized.
EXPECT_FALSE(normalization_successful());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class AutocompleteHistoryManagerTest : public testing::Test {
date_last_used);
}

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
scoped_refptr<MockWebDataService> web_data_service_;
std::unique_ptr<AutocompleteHistoryManager> autocomplete_manager_;
std::unique_ptr<PrefService> prefs_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class AutofillAssistantTest : public testing::Test {
return static_cast<CardUnmaskDelegate*>(full_card_request);
}

base::test::ScopedTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;
TestAutofillClient autofill_client_;
testing::NiceMock<TestAutofillDriver> autofill_driver_;
TestPersonalDataManager pdm_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class AutofillDownloadManagerTest : public AutofillDownloadManager::Observer,
};

ScopedActiveAutofillExperiments scoped_active_autofill_experiments;
base::test::ScopedTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;
std::list<ResponseData> responses_;
scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_;
network::TestURLLoaderFactory test_url_loader_factory_;
Expand Down Expand Up @@ -1492,8 +1492,8 @@ class AutofillServerCommunicationTest
return succeeded;
}

base::test::ScopedTaskEnvironment scoped_task_environment_{
base::test::ScopedTaskEnvironment::MainThreadType::IO};
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::MainThreadType::IO};
base::test::ScopedCommandLine scoped_command_line_;
base::test::ScopedFeatureList scoped_feature_list_1_;
base::test::ScopedFeatureList scoped_feature_list_2_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AutofillDriverFactoryTest : public testing::Test {

protected:
// For TestAutofillDriver.
base::test::ScopedTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;

MockAutofillClient client_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class AutofillExternalDelegateUnitTest : public testing::Test {
kQueryId, suggestions, /*autoselect_first_suggestion=*/false);
}

base::test::ScopedTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;

testing::NiceMock<MockAutofillClient> autofill_client_;
std::unique_ptr<testing::NiceMock<MockAutofillDriver>> autofill_driver_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ class AutofillManagerTest : public testing::Test {
}

protected:
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
MockAutofillClient autofill_client_;
std::unique_ptr<MockAutofillDriver> autofill_driver_;
std::unique_ptr<TestAutofillManager> autofill_manager_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class AutofillMergeTest : public DataDrivenTest,
// Deserializes |str| into a field type.
ServerFieldType StringToFieldType(const std::string& str);

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
TestAutofillClient autofill_client_;
PersonalDataManagerMock personal_data_;
std::unique_ptr<FormDataImporter> form_data_importer_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class AutofillMetricsTest : public testing::Test {
// Purge recorded UKM metrics for running more tests.
void PurgeUKM();

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
MockAutofillClient autofill_client_;
ukm::TestUkmRecorder* test_ukm_recorder_;
syncer::TestSyncService sync_service_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class AutofillProfileValidatorTest : public testing::Test {
expected_validity_;

private:
base::test::ScopedTaskEnvironment scoped_task_scheduler;
base::test::TaskEnvironment scoped_task_scheduler;

DISALLOW_COPY_AND_ASSIGN(AutofillProfileValidatorTest);
};
Expand Down
4 changes: 2 additions & 2 deletions components/autofill/core/browser/field_filler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -758,14 +758,14 @@ class AutofillSelectWithStatesTest
std::unique_ptr<Storage>(new NullStorage), "en-US");
// Make sure the normalizer is done initializing its member(s) in
// background task(s).
scoped_task_environment_.RunUntilIdle();
task_environment_.RunUntilIdle();
}

protected:
AddressNormalizer* normalizer() { return normalizer_.get(); }

private:
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
std::unique_ptr<AddressNormalizerImpl> normalizer_;

DISALLOW_COPY_AND_ASSIGN(AutofillSelectWithStatesTest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ class FormDataImporterTestBase {
run_loop.Run();
}

base::test::ScopedTaskEnvironment task_environment_{
base::test::ScopedTaskEnvironment::MainThreadType::UI};
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::MainThreadType::UI};
std::unique_ptr<PrefService> prefs_;
scoped_refptr<AutofillWebDataService> autofill_database_service_;
scoped_refptr<WebDatabaseService> web_database_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class SubKeyRequesterTest : public testing::Test {

~SubKeyRequesterTest() override {}

base::test::ScopedTaskEnvironment scoped_task_environment_;
base::test::TaskEnvironment task_environment_;
std::unique_ptr<TestSubKeyRequester> requester_;

private:
Expand Down Expand Up @@ -157,7 +157,7 @@ TEST_F(SubKeyRequesterTest, StartRequest_RulesNotLoaded_WillNotLoad) {
requester_->StartRegionSubKeysRequest(kLocale, kLanguage, 0, std::move(cb));

// Let the timeout execute.
scoped_task_environment_.RunUntilIdle();
task_environment_.RunUntilIdle();

// Since the rules are never loaded and the timeout is 0, the delegate should
// get notified that the subkeys could not be received.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class AutofillWalletDataTypeControllerTest : public testing::Test {
last_error_ = error;
}

base::test::ScopedTaskEnvironment task_environment_;
base::test::TaskEnvironment task_environment_;
TestingPrefServiceSimple prefs_;
syncer::UserShare user_share_;
testing::NiceMock<syncer::MockSyncService> sync_service_;
Expand Down
Loading

0 comments on commit dfa3604

Please sign in to comment.