Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: ios/web/web_state/web_state_impl_unittest.mm

Issue 2698413004: Implemented WebStateObserver::DidFinishNavigation(NavigationHandle*). (Closed)
Patch Set: Addressed review comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/web_state_impl.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « ios/web/web_state/web_state_impl.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698