Commit 28b2c4af authored by Sophie Chang's avatar Sophie Chang Committed by Commit Bot

Lazily create a TestingProfile in OptimizationGuideHintsManagerTest

This currently crashes on Android O builders when we intend to move
the clock forward since the queue flushes all pending tasks and one of
the tasks that gets posted at the end of startup attempts that the
creation of a TestingProfile triggers is to instantiate a
system_network_context_manager which is null in unit tests.
(crbug/981057)

Bug: 999349
Change-Id: Ie60ca11674eb332a277dc783181f0230c7a23ef5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1788300Reviewed-by: default avatarDoug Arnett <dougarnett@chromium.org>
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693943}
parent 9aeee548
...@@ -316,8 +316,11 @@ class OptimizationGuideHintsManagerTest ...@@ -316,8 +316,11 @@ class OptimizationGuideHintsManagerTest
std::unique_ptr<content::MockNavigationHandle> std::unique_ptr<content::MockNavigationHandle>
CreateMockNavigationHandleWithOptimizationGuideWebContentsObserver( CreateMockNavigationHandleWithOptimizationGuideWebContentsObserver(
const GURL& url) { const GURL& url) {
if (!testing_profile_) {
testing_profile_ = std::make_unique<TestingProfile>();
}
content::WebContents* web_contents = content::WebContents* web_contents =
web_contents_factory_->CreateWebContents(&testing_profile_); web_contents_factory_->CreateWebContents(testing_profile_.get());
OptimizationGuideWebContentsObserver::CreateForWebContents(web_contents); OptimizationGuideWebContentsObserver::CreateForWebContents(web_contents);
std::unique_ptr<content::MockNavigationHandle> navigation_handle = std::unique_ptr<content::MockNavigationHandle> navigation_handle =
std::make_unique<content::MockNavigationHandle>(web_contents); std::make_unique<content::MockNavigationHandle>(web_contents);
...@@ -371,7 +374,7 @@ class OptimizationGuideHintsManagerTest ...@@ -371,7 +374,7 @@ class OptimizationGuideHintsManagerTest
content::BrowserTaskEnvironment task_environment_{ content::BrowserTaskEnvironment task_environment_{
base::test::TaskEnvironment::MainThreadType::UI, base::test::TaskEnvironment::MainThreadType::UI,
base::test::TaskEnvironment::TimeSource::MOCK_TIME}; base::test::TaskEnvironment::TimeSource::MOCK_TIME};
TestingProfile testing_profile_; std::unique_ptr<TestingProfile> testing_profile_;
std::unique_ptr<content::TestWebContentsFactory> web_contents_factory_; std::unique_ptr<content::TestWebContentsFactory> web_contents_factory_;
std::unique_ptr<OptimizationGuideHintsManager> hints_manager_; std::unique_ptr<OptimizationGuideHintsManager> hints_manager_;
std::unique_ptr<TestOptimizationGuideService> optimization_guide_service_; std::unique_ptr<TestOptimizationGuideService> optimization_guide_service_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment