| Index: ios/web/web_state/web_state_impl_unittest.mm
|
| diff --git a/ios/web/web_state/web_state_impl_unittest.mm b/ios/web/web_state/web_state_impl_unittest.mm
|
| index c6f13baf4724aaa02e1438cbb38c92c18e070fe5..992132f9f2dbc2eb5afb9ca6c315292d65e3df37 100644
|
| --- a/ios/web/web_state/web_state_impl_unittest.mm
|
| +++ b/ios/web/web_state/web_state_impl_unittest.mm
|
| @@ -12,6 +12,7 @@
|
| #include "base/bind.h"
|
| #include "base/logging.h"
|
| #import "base/mac/bind_objc_block.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #import "base/test/ios/wait_util.h"
|
| #include "base/values.h"
|
| @@ -128,6 +129,7 @@ class TestWebStateObserver : public WebStateObserver {
|
| page_loaded_called_with_success_(false),
|
| url_hash_changed_called_(false),
|
| history_state_changed_called_(false),
|
| + did_finish_navigation_called_(false),
|
| web_state_destroyed_called_(false) {}
|
|
|
| // Methods returning true if the corresponding WebStateObserver method has
|
| @@ -151,6 +153,9 @@ class TestWebStateObserver : public WebStateObserver {
|
| bool history_state_changed_called() const {
|
| return history_state_changed_called_;
|
| }
|
| + bool did_finish_navigation_called() const {
|
| + return did_finish_navigation_called_;
|
| + }
|
| bool web_state_destroyed_called() const {
|
| return web_state_destroyed_called_;
|
| }
|
| @@ -170,6 +175,9 @@ class TestWebStateObserver : public WebStateObserver {
|
| const LoadCommittedDetails& load_details) override {
|
| navigation_item_committed_called_ = true;
|
| }
|
| + void DidFinishNavigation(NavigationContext* navigation_context) override {
|
| + did_finish_navigation_called_ = true;
|
| + }
|
| void PageLoaded(PageLoadCompletionStatus load_completion_status) override {
|
| page_loaded_called_with_success_ =
|
| load_completion_status == PageLoadCompletionStatus::SUCCESS;
|
| @@ -189,6 +197,7 @@ class TestWebStateObserver : public WebStateObserver {
|
| bool page_loaded_called_with_success_;
|
| bool url_hash_changed_called_;
|
| bool history_state_changed_called_;
|
| + bool did_finish_navigation_called_;
|
| bool web_state_destroyed_called_;
|
| };
|
|
|
| @@ -393,6 +402,18 @@ TEST_F(WebStateTest, ObserverTest) {
|
| web_state_->OnHistoryStateChanged();
|
| EXPECT_TRUE(observer->history_state_changed_called());
|
|
|
| + // Test that DidFinishNavigation() is called for same page navigations.
|
| + EXPECT_FALSE(observer->did_finish_navigation_called());
|
| + web_state_->OnSamePageNavigation(GURL("http://test"));
|
| + EXPECT_TRUE(observer->did_finish_navigation_called());
|
| +
|
| + // Reset the observer and test that DidFinishNavigation() is called
|
| + // for error navigations.
|
| + observer = base::MakeUnique<TestWebStateObserver>(web_state_.get());
|
| + EXPECT_FALSE(observer->did_finish_navigation_called());
|
| + web_state_->OnErrorPageNavigation(GURL("http://test"));
|
| + EXPECT_TRUE(observer->did_finish_navigation_called());
|
| +
|
| // Test that WebStateDestroyed() is called.
|
| EXPECT_FALSE(observer->web_state_destroyed_called());
|
| web_state_.reset();
|
|
|