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

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

Issue 2902083003: Fixed Navigation callbacks for reloading native context. (Closed)
Patch Set: 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 085212aab4ce4195593d2b00813c13f43de52ce8..cedf3bb930ab36c050ea6e5e50a5caf029448933 100644
--- a/ios/web/web_state/navigation_callbacks_inttest.mm
+++ b/ios/web/web_state/navigation_callbacks_inttest.mm
@@ -150,6 +150,45 @@ ACTION_P3(VerifyNewNativePageFinishedContext, web_state, url, context) {
EXPECT_EQ(url, item->GetURL());
}
+// Verifies correctness of |NavigationContext| (|arg0|) for reload navigation
+// passed to |DidStartNavigation|. Stores |NavigationContext| in |context|
+// pointer.
+ACTION_P3(VerifyReloadStartedContext, web_state, url, context) {
+ *context = arg0;
+ ASSERT_TRUE(*context);
+ EXPECT_EQ(web_state, (*context)->GetWebState());
+ EXPECT_EQ(url, (*context)->GetUrl());
+ EXPECT_TRUE(
+ PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_RELOAD,
+ (*context)->GetPageTransition()));
+ EXPECT_FALSE((*context)->IsSameDocument());
+ EXPECT_FALSE((*context)->GetError());
+ EXPECT_FALSE((*context)->GetResponseHeaders());
+ // TODO(crbug.com/676129): Reload does not create a pending item. Check
+ // pending item once the bug is fixed.
+ EXPECT_FALSE(web_state->GetNavigationManager()->GetPendingItem());
+}
+
+// Verifies correctness of |NavigationContext| (|arg0|) for reload navigation
+// passed to |DidFinishNavigation|. Asserts that |NavigationContext| the same as
+// |context|.
+ACTION_P3(VerifyReloadFinishedContext, web_state, url, context) {
+ ASSERT_EQ(*context, arg0);
+ ASSERT_TRUE(*context);
+ EXPECT_EQ(web_state, (*context)->GetWebState());
+ EXPECT_EQ(url, (*context)->GetUrl());
+ EXPECT_TRUE(
+ PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_RELOAD,
+ (*context)->GetPageTransition()));
+ EXPECT_FALSE((*context)->IsSameDocument());
+ EXPECT_FALSE((*context)->GetError());
+ EXPECT_FALSE((*context)->GetResponseHeaders());
+ NavigationManager* navigation_manager = web_state->GetNavigationManager();
+ NavigationItem* item = navigation_manager->GetLastCommittedItem();
+ EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
+ EXPECT_EQ(url, item->GetURL());
+}
+
// Mocks DidFinishNavigation navigation callback.
class WebStateObserverMock : public WebStateObserver {
public:
@@ -311,4 +350,20 @@ TEST_F(StartAndFinishNavigationTest, NativeContentNavigation) {
LoadUrl(url);
}
+// Tests native content reload navigation.
+TEST_F(StartAndFinishNavigationTest, NativeContentReload) {
+ GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize());
+ NavigationContext* context = nullptr;
+ EXPECT_CALL(*observer_, DidStartNavigation(_));
+ EXPECT_CALL(*observer_, DidFinishNavigation(_));
+ LoadUrl(url);
+
+ // Reload native content.
+ EXPECT_CALL(*observer_, DidStartNavigation(_))
+ .WillOnce(VerifyReloadStartedContext(web_state(), url, &context));
+ EXPECT_CALL(*observer_, DidFinishNavigation(_))
+ .WillOnce(VerifyReloadFinishedContext(web_state(), url, &context));
+ navigation_manager()->Reload(ReloadType::NORMAL, false /*check_for_repost*/);
+}
+
} // namespace web
« 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