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

Side by Side Diff: ios/web/web_state/navigation_callbacks_inttest.mm

Issue 2759613003: Use SameDocument instead of SamePage term on iOS. (Closed)
Patch Set: Actually fixed tests Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #import "ios/web/public/navigation_item.h" 8 #import "ios/web/public/navigation_item.h"
9 #import "ios/web/public/navigation_manager.h" 9 #import "ios/web/public/navigation_manager.h"
10 #import "ios/web/public/test/http_server.h" 10 #import "ios/web/public/test/http_server.h"
(...skipping 21 matching lines...) Expand all
32 EXPECT_FALSE(context->IsSameDocument()); 32 EXPECT_FALSE(context->IsSameDocument());
33 EXPECT_FALSE(context->IsErrorPage()); 33 EXPECT_FALSE(context->IsErrorPage());
34 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 34 NavigationManager* navigation_manager = web_state->GetNavigationManager();
35 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 35 NavigationItem* item = navigation_manager->GetLastCommittedItem();
36 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 36 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
37 EXPECT_EQ(url, item->GetURL()); 37 EXPECT_EQ(url, item->GetURL());
38 } 38 }
39 39
40 // Verifies correctness of |NavigationContext| for same page navigation passed 40 // Verifies correctness of |NavigationContext| for same page navigation passed
41 // to |DidFinishNavigation|. 41 // to |DidFinishNavigation|.
42 ACTION_P2(VerifySamePageContext, web_state, url) { 42 ACTION_P2(VerifySameDocumentContext, web_state, url) {
43 NavigationContext* context = arg0; 43 NavigationContext* context = arg0;
44 ASSERT_TRUE(context); 44 ASSERT_TRUE(context);
45 EXPECT_EQ(web_state, context->GetWebState()); 45 EXPECT_EQ(web_state, context->GetWebState());
46 EXPECT_EQ(url, context->GetUrl()); 46 EXPECT_EQ(url, context->GetUrl());
47 EXPECT_TRUE(context->IsSameDocument()); 47 EXPECT_TRUE(context->IsSameDocument());
48 EXPECT_FALSE(context->IsErrorPage()); 48 EXPECT_FALSE(context->IsErrorPage());
49 NavigationManager* navigation_manager = web_state->GetNavigationManager(); 49 NavigationManager* navigation_manager = web_state->GetNavigationManager();
50 NavigationItem* item = navigation_manager->GetLastCommittedItem(); 50 NavigationItem* item = navigation_manager->GetLastCommittedItem();
51 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0); 51 EXPECT_GT(item->GetTimestamp().ToInternalValue(), 0);
52 EXPECT_EQ(url, item->GetURL()); 52 EXPECT_EQ(url, item->GetURL());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 web::test::SetUpSimpleHttpServer(responses); 96 web::test::SetUpSimpleHttpServer(responses);
97 97
98 // Perform new page navigation. 98 // Perform new page navigation.
99 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 99 EXPECT_CALL(*observer_, DidFinishNavigation(_))
100 .WillOnce(VerifyNewPageContext(web_state(), url)); 100 .WillOnce(VerifyNewPageContext(web_state(), url));
101 LoadUrl(url); 101 LoadUrl(url);
102 102
103 // Perform same-page navigation. 103 // Perform same-page navigation.
104 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); 104 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
105 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 105 EXPECT_CALL(*observer_, DidFinishNavigation(_))
106 .WillOnce(VerifySamePageContext(web_state(), hash_url)); 106 .WillOnce(VerifySameDocumentContext(web_state(), hash_url));
107 LoadUrl(hash_url); 107 LoadUrl(hash_url);
108 108
109 // Perform same-page navigation by going back. 109 // Perform same-page navigation by going back.
110 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 110 EXPECT_CALL(*observer_, DidFinishNavigation(_))
111 .WillOnce(VerifySamePageContext(web_state(), url)); 111 .WillOnce(VerifySameDocumentContext(web_state(), url));
112 ExecuteBlockAndWaitForLoad(url, ^{ 112 ExecuteBlockAndWaitForLoad(url, ^{
113 navigation_manager()->GoBack(); 113 navigation_manager()->GoBack();
114 }); 114 });
115 } 115 }
116 116
117 // Tests renderer-initiated hash change. 117 // Tests renderer-initiated hash change.
118 TEST_F(DidFinishNavigationTest, RendererInitiatedHashChangeNavigation) { 118 TEST_F(DidFinishNavigationTest, RendererInitiatedHashChangeNavigation) {
119 const GURL url = HttpServer::MakeUrl("http://chromium.test"); 119 const GURL url = HttpServer::MakeUrl("http://chromium.test");
120 std::map<GURL, std::string> responses; 120 std::map<GURL, std::string> responses;
121 responses[url] = "Chromium Test"; 121 responses[url] = "Chromium Test";
122 web::test::SetUpSimpleHttpServer(responses); 122 web::test::SetUpSimpleHttpServer(responses);
123 123
124 // Perform new page navigation. 124 // Perform new page navigation.
125 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 125 EXPECT_CALL(*observer_, DidFinishNavigation(_))
126 .WillOnce(VerifyNewPageContext(web_state(), url)); 126 .WillOnce(VerifyNewPageContext(web_state(), url));
127 LoadUrl(url); 127 LoadUrl(url);
128 128
129 // Perform same-page navigation using JavaScript. 129 // Perform same-page navigation using JavaScript.
130 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1"); 130 const GURL hash_url = HttpServer::MakeUrl("http://chromium.test#1");
131 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 131 EXPECT_CALL(*observer_, DidFinishNavigation(_))
132 .WillOnce(VerifySamePageContext(web_state(), hash_url)); 132 .WillOnce(VerifySameDocumentContext(web_state(), hash_url));
133 ExecuteJavaScript(@"window.location.hash = '#1'"); 133 ExecuteJavaScript(@"window.location.hash = '#1'");
134 } 134 }
135 135
136 // Tests state change. 136 // Tests state change.
137 TEST_F(DidFinishNavigationTest, StateNavigation) { 137 TEST_F(DidFinishNavigationTest, StateNavigation) {
138 const GURL url = HttpServer::MakeUrl("http://chromium.test"); 138 const GURL url = HttpServer::MakeUrl("http://chromium.test");
139 std::map<GURL, std::string> responses; 139 std::map<GURL, std::string> responses;
140 responses[url] = "Chromium Test"; 140 responses[url] = "Chromium Test";
141 web::test::SetUpSimpleHttpServer(responses); 141 web::test::SetUpSimpleHttpServer(responses);
142 142
143 // Perform new page navigation. 143 // Perform new page navigation.
144 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 144 EXPECT_CALL(*observer_, DidFinishNavigation(_))
145 .WillOnce(VerifyNewPageContext(web_state(), url)); 145 .WillOnce(VerifyNewPageContext(web_state(), url));
146 LoadUrl(url); 146 LoadUrl(url);
147 147
148 // Perform push state using JavaScript. 148 // Perform push state using JavaScript.
149 const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html"); 149 const GURL push_url = HttpServer::MakeUrl("http://chromium.test/test.html");
150 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 150 EXPECT_CALL(*observer_, DidFinishNavigation(_))
151 .WillOnce(VerifySamePageContext(web_state(), push_url)); 151 .WillOnce(VerifySameDocumentContext(web_state(), push_url));
152 ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')"); 152 ExecuteJavaScript(@"window.history.pushState('', 'Test', 'test.html')");
153 153
154 // Perform replace state using JavaScript. 154 // Perform replace state using JavaScript.
155 const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html"); 155 const GURL replace_url = HttpServer::MakeUrl("http://chromium.test/1.html");
156 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 156 EXPECT_CALL(*observer_, DidFinishNavigation(_))
157 .WillOnce(VerifySamePageContext(web_state(), replace_url)); 157 .WillOnce(VerifySameDocumentContext(web_state(), replace_url));
158 ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')"); 158 ExecuteJavaScript(@"window.history.replaceState('', 'Test', '1.html')");
159 } 159 }
160 160
161 // Tests native content navigation. 161 // Tests native content navigation.
162 TEST_F(DidFinishNavigationTest, NativeContentNavigation) { 162 TEST_F(DidFinishNavigationTest, NativeContentNavigation) {
163 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize()); 163 GURL url(url::SchemeHostPort(kTestNativeContentScheme, "ui", 0).Serialize());
164 EXPECT_CALL(*observer_, DidFinishNavigation(_)) 164 EXPECT_CALL(*observer_, DidFinishNavigation(_))
165 .WillOnce(VerifyNewPageContext(web_state(), url)); 165 .WillOnce(VerifyNewPageContext(web_state(), url));
166 LoadUrl(url); 166 LoadUrl(url);
167 } 167 }
168 168
169 } // namespace web 169 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/public/test/fakes/test_web_state_observer.mm ('k') | ios/web/web_state/navigation_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698