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

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

Issue 2873023002: Call WebStateObserver::ProvisionalNavigationStarted for state navigations (Closed)
Patch Set: Rebased Created 3 years, 7 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 | « no previous file | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/navigation_callbacks_inttest.mm
diff --git a/ios/web/web_state/navigation_callbacks_inttest.mm b/ios/web/web_state/navigation_callbacks_inttest.mm
index d9eba625dc7bf24a66aacef381bdabef0e2c059a..23b2f6af14c3c99ba739c810ed1b8acce9648010 100644
--- a/ios/web/web_state/navigation_callbacks_inttest.mm
+++ b/ios/web/web_state/navigation_callbacks_inttest.mm
@@ -81,6 +81,7 @@ class WebStateObserverMock : public WebStateObserver {
public:
WebStateObserverMock(WebState* web_state) : WebStateObserver(web_state) {}
MOCK_METHOD1(DidFinishNavigation, void(NavigationContext* context));
+ MOCK_METHOD1(ProvisionalNavigationStarted, void(const GURL& url));
};
} // namespace
@@ -88,8 +89,9 @@ class WebStateObserverMock : public WebStateObserver {
using test::HttpServer;
using testing::_;
-// Test fixture for WebStateDelegate::DidFinishNavigation integration tests.
-class DidFinishNavigationTest : public WebIntTest {
+// Test fixture for WebStateDelegate::ProvisionalNavigationStarted and
+// WebStateDelegate::DidFinishNavigation integration tests.
+class StartAndFinishNavigationTest : public WebIntTest {
void SetUp() override {
WebIntTest::SetUp();
observer_ = base::MakeUnique<WebStateObserverMock>(web_state());
@@ -100,37 +102,41 @@ class DidFinishNavigationTest : public WebIntTest {
};
// Tests successful navigation to a new page.
-TEST_F(DidFinishNavigationTest, NewPageNavigation) {
+TEST_F(StartAndFinishNavigationTest, NewPageNavigation) {
const GURL url = HttpServer::MakeUrl("http://chromium.test");
std::map<GURL, std::string> responses;
responses[url] = "Chromium Test";
web::test::SetUpSimpleHttpServer(responses);
// Perform new page navigation.
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifyNewPageContext(web_state(), url));
LoadUrl(url);
}
// Tests user-initiated hash change.
-TEST_F(DidFinishNavigationTest, UserInitiatedHashChangeNavigation) {
+TEST_F(StartAndFinishNavigationTest, UserInitiatedHashChangeNavigation) {
const GURL url = HttpServer::MakeUrl("http://chromium.test");
std::map<GURL, std::string> responses;
responses[url] = "Chromium Test";
web::test::SetUpSimpleHttpServer(responses);
// Perform new page navigation.
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifyNewPageContext(web_state(), url));
LoadUrl(url);
// Perform same-page navigation.
const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifySameDocumentContext(web_state(), hash_url));
LoadUrl(hash_url);
// Perform same-page navigation by going back.
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifySameDocumentContext(web_state(), url));
ExecuteBlockAndWaitForLoad(url, ^{
@@ -139,52 +145,58 @@ TEST_F(DidFinishNavigationTest, UserInitiatedHashChangeNavigation) {
}
// Tests renderer-initiated hash change.
-TEST_F(DidFinishNavigationTest, RendererInitiatedHashChangeNavigation) {
+TEST_F(StartAndFinishNavigationTest, RendererInitiatedHashChangeNavigation) {
const GURL url = HttpServer::MakeUrl("http://chromium.test");
std::map<GURL, std::string> responses;
responses[url] = "Chromium Test";
web::test::SetUpSimpleHttpServer(responses);
// Perform new page navigation.
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifyNewPageContext(web_state(), url));
LoadUrl(url);
// Perform same-page navigation using JavaScript.
const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifySameDocumentContext(web_state(), hash_url));
ExecuteJavaScript(@"window.location.hash = '#1'");
}
// Tests state change.
-TEST_F(DidFinishNavigationTest, StateNavigation) {
+TEST_F(StartAndFinishNavigationTest, StateNavigation) {
const GURL url = HttpServer::MakeUrl("http://chromium.test");
std::map<GURL, std::string> responses;
responses[url] = "Chromium Test";
web::test::SetUpSimpleHttpServer(responses);
// Perform new page navigation.
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifyNewPageContext(web_state(), url));
LoadUrl(url);
// Perform push state using JavaScript.
const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html");
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifySameDocumentContext(web_state(), push_url));
ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')");
// Perform replace state using JavaScript.
const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html");
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifySameDocumentContext(web_state(), replace_url));
ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')");
}
// Tests native content navigation.
-TEST_F(DidFinishNavigationTest, NativeContentNavigation) {
+TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) {
GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize());
+ EXPECT_CALL(*observer_, ProvisionalNavigationStarted(_));
EXPECT_CALL(*observer_, DidFinishNavigation(_))
.WillOnce(VerifyNewNativePageContext(web_state(), url));
LoadUrl(url);
« no previous file with comments | « no previous file | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698