Commit be935a21 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Reset FullscreenModel when the active WebState changes.

Bug: 799101
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: If760fdaf17dfe79b54510c0eaa2e670dfb326a2c
Reviewed-on: https://chromium-review.googlesource.com/882665
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532676}
parent 78800d85
...@@ -32,7 +32,6 @@ class FullscreenWebStateListObserverTest : public PlatformTest { ...@@ -32,7 +32,6 @@ class FullscreenWebStateListObserverTest : public PlatformTest {
mediator_(&controller_, &model_), mediator_(&controller_, &model_),
web_state_list_(&web_state_list_delegate_), web_state_list_(&web_state_list_delegate_),
observer_(&controller_, &model_, &web_state_list_, &mediator_) { observer_(&controller_, &model_, &web_state_list_, &mediator_) {
SetUpFullscreenModelForTesting(&model_, 100.0);
} }
~FullscreenWebStateListObserverTest() override { ~FullscreenWebStateListObserverTest() override {
...@@ -62,6 +61,7 @@ TEST_F(FullscreenWebStateListObserverTest, ObserveActiveWebState) { ...@@ -62,6 +61,7 @@ TEST_F(FullscreenWebStateListObserverTest, ObserveActiveWebState) {
WebStateList::INSERT_ACTIVATE, WebStateList::INSERT_ACTIVATE,
WebStateOpener()); WebStateOpener());
// Simulate a scroll to 0.5 progress. // Simulate a scroll to 0.5 progress.
SetUpFullscreenModelForTesting(&model(), 100.0);
SimulateFullscreenUserScrollForProgress(&model(), 0.5); SimulateFullscreenUserScrollForProgress(&model(), 0.5);
EXPECT_EQ(model().progress(), 0.5); EXPECT_EQ(model().progress(), 0.5);
// Simulate a navigation. The model should be reset by the observers. // Simulate a navigation. The model should be reset by the observers.
......
...@@ -57,8 +57,11 @@ void FullscreenWebStateObserver::SetWebState(web::WebState* web_state) { ...@@ -57,8 +57,11 @@ void FullscreenWebStateObserver::SetWebState(web::WebState* web_state) {
if (web_state_) if (web_state_)
web_state_->RemoveObserver(this); web_state_->RemoveObserver(this);
web_state_ = web_state; web_state_ = web_state;
if (web_state_) if (web_state_) {
web_state_->AddObserver(this); web_state_->AddObserver(this);
// The toolbar should be visible whenever the current tab changes.
model_->ResetForNavigation();
}
// Update the model according to the new WebState. // Update the model according to the new WebState.
SetIsLoading(web_state_ ? web_state->IsLoading() : false); SetIsLoading(web_state_ ? web_state->IsLoading() : false);
SetDisableFullscreenForSSL(ShouldDisableFullscreenForWebStateSSL(web_state_)); SetDisableFullscreenForSSL(ShouldDisableFullscreenForWebStateSSL(web_state_));
......
...@@ -26,8 +26,6 @@ class FullscreenWebStateObserverTest : public PlatformTest { ...@@ -26,8 +26,6 @@ class FullscreenWebStateObserverTest : public PlatformTest {
controller_(&model_), controller_(&model_),
mediator_(&controller_, &model_), mediator_(&controller_, &model_),
observer_(&controller_, &model_, &mediator_) { observer_(&controller_, &model_, &mediator_) {
// Set up model.
SetUpFullscreenModelForTesting(&model_, 100.0);
// Set up a TestNavigationManager. // Set up a TestNavigationManager.
std::unique_ptr<web::TestNavigationManager> navigation_manager = std::unique_ptr<web::TestNavigationManager> navigation_manager =
std::make_unique<web::TestNavigationManager>(); std::make_unique<web::TestNavigationManager>();
...@@ -35,6 +33,8 @@ class FullscreenWebStateObserverTest : public PlatformTest { ...@@ -35,6 +33,8 @@ class FullscreenWebStateObserverTest : public PlatformTest {
web_state_.SetNavigationManager(std::move(navigation_manager)); web_state_.SetNavigationManager(std::move(navigation_manager));
// Begin observing the WebState. // Begin observing the WebState.
observer_.SetWebState(&web_state_); observer_.SetWebState(&web_state_);
// Set up model.
SetUpFullscreenModelForTesting(&model_, 100.0);
} }
~FullscreenWebStateObserverTest() override { ~FullscreenWebStateObserverTest() override {
......
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