Commit 9725008a authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Properly initialize WebStates in unit tests

Those tests trigger code path that access the toolbar if there
is an active WebState in the WebStateList. This requires that
the WebState returns non-null BrowserState and NavigationManager
so set the corresponding property on the TestWebState.

Bug: none
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ic950a706b31ac153cdfb71b510681c09886c3da0
Reviewed-on: https://chromium-review.googlesource.com/1106176Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569228}
parent dfea3441
......@@ -78,6 +78,7 @@ class LocationBarLegacyCoordinatorTest : public PlatformTest {
browser_state_ = test_cbs_builder.Build();
auto web_state = std::make_unique<web::TestWebState>();
web_state->SetBrowserState(browser_state_.get());
web_state->SetCurrentURL(GURL("http://test/"));
web_state_list_.InsertWebState(0, std::move(web_state),
WebStateList::INSERT_FORCE_INDEX,
......
......@@ -112,6 +112,7 @@ class ToolbarMediatorTest : public PlatformTest {
std::make_unique<ToolbarTestNavigationManager>();
navigation_manager_ = navigation_manager.get();
test_web_state_ = std::make_unique<ToolbarTestWebState>();
test_web_state_->SetBrowserState(chrome_browser_state_.get());
test_web_state_->SetNavigationManager(std::move(navigation_manager));
test_web_state_->SetLoading(true);
web_state_ = test_web_state_.get();
......@@ -148,6 +149,9 @@ class ToolbarMediatorTest : public PlatformTest {
void InsertNewWebState(int index) {
auto web_state = std::make_unique<web::TestWebState>();
web_state->SetBrowserState(chrome_browser_state_.get());
web_state->SetNavigationManager(
std::make_unique<web::TestNavigationManager>());
GURL url("http://test/" + std::to_string(index));
web_state->SetCurrentURL(url);
web_state_list_->InsertWebState(index, std::move(web_state),
......
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