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

Side by Side Diff: ios/web/navigation/crw_session_controller_unittest.mm

Issue 2672723003: Converted CRWSessionController to use NavigationItems. (Closed)
Patch Set: test fixes, self review 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import "ios/web/navigation/crw_session_controller.h" 5 #import "ios/web/navigation/crw_session_controller.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 TEST_F(CRWSessionControllerTest, InitWithWindowName) { 66 TEST_F(CRWSessionControllerTest, InitWithWindowName) {
67 EXPECT_NSEQ(@"test window", [session_controller_ windowName]); 67 EXPECT_NSEQ(@"test window", [session_controller_ windowName]);
68 EXPECT_NSEQ(@"opener", [session_controller_ openerId]); 68 EXPECT_NSEQ(@"opener", [session_controller_ openerId]);
69 EXPECT_FALSE([session_controller_ isOpenedByDOM]); 69 EXPECT_FALSE([session_controller_ isOpenedByDOM]);
70 EXPECT_EQ(0U, [[session_controller_ entries] count]); 70 EXPECT_EQ(0U, [[session_controller_ entries] count]);
71 EXPECT_EQ(nil, [session_controller_ currentEntry]); 71 EXPECT_EQ(nil, [session_controller_ currentEntry]);
72 } 72 }
73 73
74 // Tests session controller state after setting a pending index. 74 // Tests session controller state after setting a pending index.
75 TEST_F(CRWSessionControllerTest, SetPendingIndex) { 75 TEST_F(CRWSessionControllerTest, SetPendingIndex) {
76 [session_controller_ addPendingEntry:GURL("http://www.example.com") 76 [session_controller_ addPendingItem:GURL("http://www.example.com")
77 referrer:web::Referrer() 77 referrer:web::Referrer()
78 transition:ui::PAGE_TRANSITION_TYPED 78 transition:ui::PAGE_TRANSITION_TYPED
79 rendererInitiated:NO]; 79 rendererInitiated:NO];
80 [session_controller_ commitPendingEntry]; 80 [session_controller_ commitPendingItem];
81 81
82 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 82 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
83 [session_controller_ setPendingEntryIndex:0]; 83 [session_controller_ setPendingItemIndex:0];
84 EXPECT_EQ(0, [session_controller_ pendingEntryIndex]); 84 EXPECT_EQ(0, [session_controller_ pendingItemIndex]);
85 EXPECT_EQ([[session_controller_ entries] lastObject], 85 EXPECT_EQ([[session_controller_ entries] lastObject],
86 [session_controller_ pendingEntry]); 86 [session_controller_ pendingEntry]);
87 } 87 }
88 88
89 TEST_F(CRWSessionControllerTest, AddPendingEntry) { 89 TEST_F(CRWSessionControllerTest, addPendingItem) {
90 [session_controller_ 90 [session_controller_ addPendingItem:GURL("http://www.url.com")
91 addPendingEntry:GURL("http://www.url.com") 91 referrer:MakeReferrer("http://www.referer.com")
92 referrer:MakeReferrer("http://www.referer.com") 92 transition:ui::PAGE_TRANSITION_TYPED
93 transition:ui::PAGE_TRANSITION_TYPED 93 rendererInitiated:NO];
94 rendererInitiated:NO];
95 94
96 EXPECT_EQ(0U, [[session_controller_ entries] count]); 95 EXPECT_EQ(0U, [[session_controller_ entries] count]);
97 EXPECT_EQ( 96 EXPECT_EQ(
98 GURL("http://www.url.com/"), 97 GURL("http://www.url.com/"),
99 [session_controller_ currentURL]); 98 [session_controller_ currentURL]);
100 } 99 }
101 100
102 TEST_F(CRWSessionControllerTest, AddPendingEntryWithCommittedEntries) { 101 TEST_F(CRWSessionControllerTest, addPendingItemWithCommittedEntries) {
103 [session_controller_ 102 [session_controller_ addPendingItem:GURL("http://www.committed.url.com")
104 addPendingEntry:GURL("http://www.committed.url.com") 103 referrer:MakeReferrer("http://www.referer.com")
105 referrer:MakeReferrer("http://www.referer.com") 104 transition:ui::PAGE_TRANSITION_TYPED
106 transition:ui::PAGE_TRANSITION_TYPED 105 rendererInitiated:NO];
107 rendererInitiated:NO]; 106 [session_controller_ commitPendingItem];
108 [session_controller_ commitPendingEntry];
109 107
110 [session_controller_ 108 [session_controller_ addPendingItem:GURL("http://www.url.com")
111 addPendingEntry:GURL("http://www.url.com") 109 referrer:MakeReferrer("http://www.referer.com")
112 referrer:MakeReferrer("http://www.referer.com") 110 transition:ui::PAGE_TRANSITION_TYPED
113 transition:ui::PAGE_TRANSITION_TYPED 111 rendererInitiated:NO];
114 rendererInitiated:NO];
115 112
116 EXPECT_EQ(1U, [[session_controller_ entries] count]); 113 EXPECT_EQ(1U, [[session_controller_ entries] count]);
117 EXPECT_EQ( 114 EXPECT_EQ(
118 GURL("http://www.committed.url.com/"), 115 GURL("http://www.committed.url.com/"),
119 [session_controller_ URLForSessionAtIndex:0U]); 116 [session_controller_ URLForSessionAtIndex:0U]);
120 EXPECT_EQ( 117 EXPECT_EQ(
121 GURL("http://www.url.com/"), 118 GURL("http://www.url.com/"),
122 [session_controller_ currentURL]); 119 [session_controller_ currentURL]);
123 } 120 }
124 121
125 // Tests that adding a pending entry resets pending entry index. 122 // Tests that adding a pending entry resets pending entry index.
126 TEST_F(CRWSessionControllerTest, AddPendingEntryWithExisingPendingEntryIndex) { 123 TEST_F(CRWSessionControllerTest, addPendingItemWithExisingPendingEntryIndex) {
127 [session_controller_ addPendingEntry:GURL("http://www.example.com") 124 [session_controller_ addPendingItem:GURL("http://www.example.com")
128 referrer:web::Referrer() 125 referrer:web::Referrer()
129 transition:ui::PAGE_TRANSITION_TYPED 126 transition:ui::PAGE_TRANSITION_TYPED
130 rendererInitiated:NO]; 127 rendererInitiated:NO];
131 [session_controller_ commitPendingEntry]; 128 [session_controller_ commitPendingItem];
132 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 129 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
133 referrer:web::Referrer() 130 referrer:web::Referrer()
134 transition:ui::PAGE_TRANSITION_TYPED 131 transition:ui::PAGE_TRANSITION_TYPED
135 rendererInitiated:NO]; 132 rendererInitiated:NO];
136 [session_controller_ commitPendingEntry]; 133 [session_controller_ commitPendingItem];
137 134
138 // Set 0 as pending entry index. 135 // Set 0 as pending entry index.
139 [session_controller_ setPendingEntryIndex:0]; 136 [session_controller_ setPendingItemIndex:0];
140 EXPECT_EQ(GURL("http://www.example.com/"), 137 EXPECT_EQ(GURL("http://www.example.com/"),
141 [[session_controller_ pendingEntry] navigationItem]->GetURL()); 138 [[session_controller_ pendingEntry] navigationItem]->GetURL());
142 EXPECT_EQ(0, [session_controller_ pendingEntryIndex]); 139 EXPECT_EQ(0, [session_controller_ pendingItemIndex]);
143 140
144 // Add a pending entry, which should drop pending navigation index. 141 // Add a pending entry, which should drop pending navigation index.
145 [session_controller_ addPendingEntry:GURL("http://www.example.com/1") 142 [session_controller_ addPendingItem:GURL("http://www.example.com/1")
146 referrer:web::Referrer() 143 referrer:web::Referrer()
147 transition:ui::PAGE_TRANSITION_TYPED 144 transition:ui::PAGE_TRANSITION_TYPED
148 rendererInitiated:NO]; 145 rendererInitiated:NO];
149 EXPECT_EQ(GURL("http://www.example.com/1"), 146 EXPECT_EQ(GURL("http://www.example.com/1"),
150 [[session_controller_ pendingEntry] navigationItem]->GetURL()); 147 [[session_controller_ pendingEntry] navigationItem]->GetURL());
151 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 148 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
152 } 149 }
153 150
154 TEST_F(CRWSessionControllerTest, AddPendingEntryOverriding) { 151 TEST_F(CRWSessionControllerTest, addPendingItemOverriding) {
152 [session_controller_ addPendingItem:GURL("http://www.url.com")
153 referrer:MakeReferrer("http://www.referer.com")
154 transition:ui::PAGE_TRANSITION_TYPED
155 rendererInitiated:NO];
155 [session_controller_ 156 [session_controller_
156 addPendingEntry:GURL("http://www.url.com") 157 addPendingItem:GURL("http://www.another.url.com")
157 referrer:MakeReferrer("http://www.referer.com")
158 transition:ui::PAGE_TRANSITION_TYPED
159 rendererInitiated:NO];
160 [session_controller_
161 addPendingEntry:GURL("http://www.another.url.com")
162 referrer:MakeReferrer("http://www.another.referer.com") 158 referrer:MakeReferrer("http://www.another.referer.com")
163 transition:ui::PAGE_TRANSITION_TYPED 159 transition:ui::PAGE_TRANSITION_TYPED
164 rendererInitiated:NO]; 160 rendererInitiated:NO];
165 161
166 EXPECT_EQ(0U, [[session_controller_ entries] count]); 162 EXPECT_EQ(0U, [[session_controller_ entries] count]);
167 EXPECT_EQ( 163 EXPECT_EQ(
168 GURL("http://www.another.url.com/"), 164 GURL("http://www.another.url.com/"),
169 [session_controller_ currentURL]); 165 [session_controller_ currentURL]);
170 } 166 }
171 167
172 TEST_F(CRWSessionControllerTest, AddPendingEntryAndCommit) { 168 TEST_F(CRWSessionControllerTest, addPendingItemAndCommit) {
173 [session_controller_ 169 [session_controller_ addPendingItem:GURL("http://www.url.com")
174 addPendingEntry:GURL("http://www.url.com") 170 referrer:MakeReferrer("http://www.referer.com")
175 referrer:MakeReferrer("http://www.referer.com") 171 transition:ui::PAGE_TRANSITION_TYPED
176 transition:ui::PAGE_TRANSITION_TYPED 172 rendererInitiated:NO];
177 rendererInitiated:NO]; 173 [session_controller_ commitPendingItem];
178 [session_controller_ commitPendingEntry];
179 174
180 EXPECT_EQ(1U, [[session_controller_ entries] count]); 175 EXPECT_EQ(1U, [[session_controller_ entries] count]);
181 EXPECT_EQ( 176 EXPECT_EQ(
182 GURL("http://www.url.com/"), 177 GURL("http://www.url.com/"),
183 [session_controller_ URLForSessionAtIndex:0U]); 178 [session_controller_ URLForSessionAtIndex:0U]);
184 EXPECT_EQ( 179 EXPECT_EQ(
185 [[session_controller_ entries] objectAtIndex:0U], 180 [[session_controller_ entries] objectAtIndex:0U],
186 [session_controller_ currentEntry]); 181 [session_controller_ currentEntry]);
187 } 182 }
188 183
189 TEST_F(CRWSessionControllerTest, AddPendingEntryOverridingAndCommit) { 184 TEST_F(CRWSessionControllerTest, addPendingItemOverridingAndCommit) {
185 [session_controller_ addPendingItem:GURL("http://www.url.com")
186 referrer:MakeReferrer("http://www.referer.com")
187 transition:ui::PAGE_TRANSITION_TYPED
188 rendererInitiated:NO];
190 [session_controller_ 189 [session_controller_
191 addPendingEntry:GURL("http://www.url.com") 190 addPendingItem:GURL("http://www.another.url.com")
192 referrer:MakeReferrer("http://www.referer.com")
193 transition:ui::PAGE_TRANSITION_TYPED
194 rendererInitiated:NO];
195 [session_controller_
196 addPendingEntry:GURL("http://www.another.url.com")
197 referrer:MakeReferrer("http://www.another.referer.com") 191 referrer:MakeReferrer("http://www.another.referer.com")
198 transition:ui::PAGE_TRANSITION_TYPED 192 transition:ui::PAGE_TRANSITION_TYPED
199 rendererInitiated:NO]; 193 rendererInitiated:NO];
200 [session_controller_ commitPendingEntry]; 194 [session_controller_ commitPendingItem];
201 195
202 EXPECT_EQ(1U, [[session_controller_ entries] count]); 196 EXPECT_EQ(1U, [[session_controller_ entries] count]);
203 EXPECT_EQ( 197 EXPECT_EQ(
204 GURL("http://www.another.url.com/"), 198 GURL("http://www.another.url.com/"),
205 [session_controller_ URLForSessionAtIndex:0U]); 199 [session_controller_ URLForSessionAtIndex:0U]);
206 EXPECT_EQ( 200 EXPECT_EQ(
207 [[session_controller_ entries] objectAtIndex:0U], 201 [[session_controller_ entries] objectAtIndex:0U],
208 [session_controller_ currentEntry]); 202 [session_controller_ currentEntry]);
209 } 203 }
210 204
211 TEST_F(CRWSessionControllerTest, AddPendingEntryAndCommitMultiple) { 205 TEST_F(CRWSessionControllerTest, addPendingItemAndCommitMultiple) {
212 [session_controller_ 206 [session_controller_ addPendingItem:GURL("http://www.url.com")
213 addPendingEntry:GURL("http://www.url.com") 207 referrer:MakeReferrer("http://www.referer.com")
214 referrer:MakeReferrer("http://www.referer.com") 208 transition:ui::PAGE_TRANSITION_TYPED
215 transition:ui::PAGE_TRANSITION_TYPED 209 rendererInitiated:NO];
216 rendererInitiated:NO]; 210 [session_controller_ commitPendingItem];
217 [session_controller_ commitPendingEntry];
218 211
219 [session_controller_ 212 [session_controller_
220 addPendingEntry:GURL("http://www.another.url.com") 213 addPendingItem:GURL("http://www.another.url.com")
221 referrer:MakeReferrer("http://www.another.referer.com") 214 referrer:MakeReferrer("http://www.another.referer.com")
222 transition:ui::PAGE_TRANSITION_TYPED 215 transition:ui::PAGE_TRANSITION_TYPED
223 rendererInitiated:NO]; 216 rendererInitiated:NO];
224 [session_controller_ commitPendingEntry]; 217 [session_controller_ commitPendingItem];
225 218
226 EXPECT_EQ(2U, [[session_controller_ entries] count]); 219 EXPECT_EQ(2U, [[session_controller_ entries] count]);
227 EXPECT_EQ( 220 EXPECT_EQ(
228 GURL("http://www.url.com/"), 221 GURL("http://www.url.com/"),
229 [session_controller_ URLForSessionAtIndex:0U]); 222 [session_controller_ URLForSessionAtIndex:0U]);
230 EXPECT_EQ( 223 EXPECT_EQ(
231 GURL("http://www.another.url.com/"), 224 GURL("http://www.another.url.com/"),
232 [session_controller_ URLForSessionAtIndex:1U]); 225 [session_controller_ URLForSessionAtIndex:1U]);
233 EXPECT_EQ( 226 EXPECT_EQ(
234 [[session_controller_ entries] objectAtIndex:1U], 227 [[session_controller_ entries] objectAtIndex:1U],
235 [session_controller_ currentEntry]); 228 [session_controller_ currentEntry]);
236 } 229 }
237 230
238 TEST_F(CRWSessionControllerTest, AddPendingEntryAndDiscard) { 231 TEST_F(CRWSessionControllerTest, addPendingItemAndDiscard) {
239 [session_controller_ 232 [session_controller_ addPendingItem:GURL("http://www.url.com")
240 addPendingEntry:GURL("http://www.url.com") 233 referrer:MakeReferrer("http://www.referer.com")
241 referrer:MakeReferrer("http://www.referer.com") 234 transition:ui::PAGE_TRANSITION_TYPED
242 transition:ui::PAGE_TRANSITION_TYPED 235 rendererInitiated:NO];
243 rendererInitiated:NO]; 236 [session_controller_ discardNonCommittedItems];
244 [session_controller_ discardNonCommittedEntries];
245 237
246 EXPECT_EQ(0U, [[session_controller_ entries] count]); 238 EXPECT_EQ(0U, [[session_controller_ entries] count]);
247 EXPECT_EQ(nil, [session_controller_ currentEntry]); 239 EXPECT_EQ(nil, [session_controller_ currentEntry]);
248 } 240 }
249 241
250 // Tests discarding pending entry added via |setPendingEntryIndex:| call. 242 // Tests discarding pending entry added via |setPendingItemIndex:| call.
251 TEST_F(CRWSessionControllerTest, SetPendingEntryIndexAndDiscard) { 243 TEST_F(CRWSessionControllerTest, setPendingItemIndexAndDiscard) {
252 [session_controller_ addPendingEntry:GURL("http://www.example.com") 244 [session_controller_ addPendingItem:GURL("http://www.example.com")
253 referrer:web::Referrer() 245 referrer:web::Referrer()
254 transition:ui::PAGE_TRANSITION_TYPED 246 transition:ui::PAGE_TRANSITION_TYPED
255 rendererInitiated:NO]; 247 rendererInitiated:NO];
256 [session_controller_ commitPendingEntry]; 248 [session_controller_ commitPendingItem];
257 249
258 [session_controller_ setPendingEntryIndex:0]; 250 [session_controller_ setPendingItemIndex:0];
259 EXPECT_TRUE([session_controller_ pendingEntry]); 251 EXPECT_TRUE([session_controller_ pendingEntry]);
260 EXPECT_EQ(0, [session_controller_ pendingEntryIndex]); 252 EXPECT_EQ(0, [session_controller_ pendingItemIndex]);
261 253
262 [session_controller_ discardNonCommittedEntries]; 254 [session_controller_ discardNonCommittedItems];
263 EXPECT_FALSE([session_controller_ pendingEntry]); 255 EXPECT_FALSE([session_controller_ pendingEntry]);
264 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 256 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
265 } 257 }
266 258
267 TEST_F(CRWSessionControllerTest, AddPendingEntryAndDiscardAndAddAndCommit) { 259 TEST_F(CRWSessionControllerTest, addPendingItemAndDiscardAndAddAndCommit) {
268 [session_controller_ 260 [session_controller_ addPendingItem:GURL("http://www.url.com")
269 addPendingEntry:GURL("http://www.url.com") 261 referrer:MakeReferrer("http://www.referer.com")
270 referrer:MakeReferrer("http://www.referer.com") 262 transition:ui::PAGE_TRANSITION_TYPED
271 transition:ui::PAGE_TRANSITION_TYPED 263 rendererInitiated:NO];
272 rendererInitiated:NO]; 264 [session_controller_ discardNonCommittedItems];
273 [session_controller_ discardNonCommittedEntries];
274 265
275 [session_controller_ 266 [session_controller_ addPendingItem:GURL("http://www.another.url.com")
276 addPendingEntry:GURL("http://www.another.url.com") 267 referrer:MakeReferrer("http://www.referer.com")
277 referrer:MakeReferrer("http://www.referer.com") 268 transition:ui::PAGE_TRANSITION_TYPED
278 transition:ui::PAGE_TRANSITION_TYPED 269 rendererInitiated:NO];
279 rendererInitiated:NO]; 270 [session_controller_ commitPendingItem];
280 [session_controller_ commitPendingEntry];
281 271
282 EXPECT_EQ(1U, [[session_controller_ entries] count]); 272 EXPECT_EQ(1U, [[session_controller_ entries] count]);
283 EXPECT_EQ( 273 EXPECT_EQ(
284 GURL("http://www.another.url.com/"), 274 GURL("http://www.another.url.com/"),
285 [session_controller_ URLForSessionAtIndex:0U]); 275 [session_controller_ URLForSessionAtIndex:0U]);
286 EXPECT_EQ( 276 EXPECT_EQ(
287 [[session_controller_ entries] objectAtIndex:0U], 277 [[session_controller_ entries] objectAtIndex:0U],
288 [session_controller_ currentEntry]); 278 [session_controller_ currentEntry]);
289 } 279 }
290 280
291 TEST_F(CRWSessionControllerTest, AddPendingEntryAndCommitAndAddAndDiscard) { 281 TEST_F(CRWSessionControllerTest, addPendingItemAndCommitAndAddAndDiscard) {
292 [session_controller_ 282 [session_controller_ addPendingItem:GURL("http://www.url.com")
293 addPendingEntry:GURL("http://www.url.com") 283 referrer:MakeReferrer("http://www.referer.com")
294 referrer:MakeReferrer("http://www.referer.com") 284 transition:ui::PAGE_TRANSITION_TYPED
295 transition:ui::PAGE_TRANSITION_TYPED 285 rendererInitiated:NO];
296 rendererInitiated:NO]; 286 [session_controller_ commitPendingItem];
297 [session_controller_ commitPendingEntry];
298 287
299 [session_controller_ 288 [session_controller_ addPendingItem:GURL("http://www.another.url.com")
300 addPendingEntry:GURL("http://www.another.url.com") 289 referrer:MakeReferrer("http://www.referer.com")
301 referrer:MakeReferrer("http://www.referer.com") 290 transition:ui::PAGE_TRANSITION_TYPED
302 transition:ui::PAGE_TRANSITION_TYPED 291 rendererInitiated:NO];
303 rendererInitiated:NO]; 292 [session_controller_ discardNonCommittedItems];
304 [session_controller_ discardNonCommittedEntries];
305 293
306 EXPECT_EQ(1U, [[session_controller_ entries] count]); 294 EXPECT_EQ(1U, [[session_controller_ entries] count]);
307 EXPECT_EQ( 295 EXPECT_EQ(
308 GURL("http://www.url.com/"), 296 GURL("http://www.url.com/"),
309 [session_controller_ URLForSessionAtIndex:0U]); 297 [session_controller_ URLForSessionAtIndex:0U]);
310 EXPECT_EQ( 298 EXPECT_EQ(
311 [[session_controller_ entries] objectAtIndex:0U], 299 [[session_controller_ entries] objectAtIndex:0U],
312 [session_controller_ currentEntry]); 300 [session_controller_ currentEntry]);
313 } 301 }
314 302
315 TEST_F(CRWSessionControllerTest, 303 TEST_F(CRWSessionControllerTest,
316 CommitPendingEntryWithoutPendingOrCommittedEntry) { 304 commitPendingItemWithoutPendingOrCommittedEntry) {
317 [session_controller_ commitPendingEntry]; 305 [session_controller_ commitPendingItem];
318 306
319 EXPECT_EQ(0U, [[session_controller_ entries] count]); 307 EXPECT_EQ(0U, [[session_controller_ entries] count]);
320 EXPECT_EQ(nil, [session_controller_ currentEntry]); 308 EXPECT_EQ(nil, [session_controller_ currentEntry]);
321 } 309 }
322 310
323 TEST_F(CRWSessionControllerTest, 311 TEST_F(CRWSessionControllerTest,
324 CommitPendingEntryWithoutPendingEntryWithCommittedEntry) { 312 commitPendingItemWithoutPendingEntryWithCommittedEntry) {
325 // Setup committed entry 313 // Setup committed entry
326 [session_controller_ 314 [session_controller_ addPendingItem:GURL("http://www.url.com")
327 addPendingEntry:GURL("http://www.url.com") 315 referrer:MakeReferrer("http://www.referer.com")
328 referrer:MakeReferrer("http://www.referer.com") 316 transition:ui::PAGE_TRANSITION_TYPED
329 transition:ui::PAGE_TRANSITION_TYPED 317 rendererInitiated:NO];
330 rendererInitiated:NO]; 318 [session_controller_ commitPendingItem];
331 [session_controller_ commitPendingEntry];
332 319
333 // Commit pending entry when there is no such one 320 // Commit pending entry when there is no such one
334 [session_controller_ commitPendingEntry]; 321 [session_controller_ commitPendingItem];
335 322
336 EXPECT_EQ(1U, [[session_controller_ entries] count]); 323 EXPECT_EQ(1U, [[session_controller_ entries] count]);
337 EXPECT_EQ( 324 EXPECT_EQ(
338 [[session_controller_ entries] objectAtIndex:0U], 325 [[session_controller_ entries] objectAtIndex:0U],
339 [session_controller_ currentEntry]); 326 [session_controller_ currentEntry]);
340 } 327 }
341 328
342 // Tests that forward entries are discarded after navigation entry is committed. 329 // Tests that forward entries are discarded after navigation entry is committed.
343 TEST_F(CRWSessionControllerTest, CommitPendingEntryWithExistingForwardEntries) { 330 TEST_F(CRWSessionControllerTest, commitPendingItemWithExistingForwardEntries) {
344 // Make 3 entries. 331 // Make 3 entries.
345 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 332 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
346 referrer:MakeReferrer("http://www.example.com/a") 333 referrer:MakeReferrer("http://www.example.com/a")
347 transition:ui::PAGE_TRANSITION_LINK 334 transition:ui::PAGE_TRANSITION_LINK
348 rendererInitiated:YES]; 335 rendererInitiated:YES];
349 [session_controller_ commitPendingEntry]; 336 [session_controller_ commitPendingItem];
350 [session_controller_ addPendingEntry:GURL("http://www.example.com/1") 337 [session_controller_ addPendingItem:GURL("http://www.example.com/1")
351 referrer:MakeReferrer("http://www.example.com/b") 338 referrer:MakeReferrer("http://www.example.com/b")
352 transition:ui::PAGE_TRANSITION_LINK 339 transition:ui::PAGE_TRANSITION_LINK
353 rendererInitiated:YES]; 340 rendererInitiated:YES];
354 [session_controller_ commitPendingEntry]; 341 [session_controller_ commitPendingItem];
355 [session_controller_ addPendingEntry:GURL("http://www.example.com/2") 342 [session_controller_ addPendingItem:GURL("http://www.example.com/2")
356 referrer:MakeReferrer("http://www.example.com/c") 343 referrer:MakeReferrer("http://www.example.com/c")
357 transition:ui::PAGE_TRANSITION_LINK 344 transition:ui::PAGE_TRANSITION_LINK
358 rendererInitiated:YES]; 345 rendererInitiated:YES];
359 [session_controller_ commitPendingEntry]; 346 [session_controller_ commitPendingItem];
360 347
361 // Go back to the first entry. 348 // Go back to the first entry.
362 [session_controller_ goToEntryAtIndex:0]; 349 [session_controller_ goToItemAtIndex:0];
363 350
364 // Create and commit a new pending entry. 351 // Create and commit a new pending entry.
365 [session_controller_ addPendingEntry:GURL("http://www.example.com/2") 352 [session_controller_ addPendingItem:GURL("http://www.example.com/2")
366 referrer:MakeReferrer("http://www.example.com/c") 353 referrer:MakeReferrer("http://www.example.com/c")
367 transition:ui::PAGE_TRANSITION_LINK 354 transition:ui::PAGE_TRANSITION_LINK
368 rendererInitiated:YES]; 355 rendererInitiated:YES];
369 [session_controller_ commitPendingEntry]; 356 [session_controller_ commitPendingItem];
370 357
371 // All forward entries should go away. 358 // All forward entries should go away.
372 EXPECT_EQ(2U, [[session_controller_ entries] count]); 359 EXPECT_EQ(2U, [[session_controller_ entries] count]);
373 EXPECT_EQ(0U, [[session_controller_ forwardEntries] count]); 360 EXPECT_EQ(0U, [[session_controller_ forwardEntries] count]);
374 ASSERT_EQ(1, [session_controller_ currentNavigationIndex]); 361 ASSERT_EQ(1, [session_controller_ currentNavigationIndex]);
375 ASSERT_EQ(0, [session_controller_ previousNavigationIndex]); 362 ASSERT_EQ(0, [session_controller_ previousNavigationIndex]);
376 } 363 }
377 364
378 // Tests committing pending entry index from the middle. 365 // Tests committing pending entry index from the middle.
379 TEST_F(CRWSessionControllerTest, CommitPendingEntryIndex) { 366 TEST_F(CRWSessionControllerTest, commitPendingItemIndex) {
380 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 367 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
381 referrer:web::Referrer() 368 referrer:web::Referrer()
382 transition:ui::PAGE_TRANSITION_TYPED 369 transition:ui::PAGE_TRANSITION_TYPED
383 rendererInitiated:NO]; 370 rendererInitiated:NO];
384 [session_controller_ commitPendingEntry]; 371 [session_controller_ commitPendingItem];
385 [session_controller_ addPendingEntry:GURL("http://www.example.com/1") 372 [session_controller_ addPendingItem:GURL("http://www.example.com/1")
386 referrer:web::Referrer() 373 referrer:web::Referrer()
387 transition:ui::PAGE_TRANSITION_TYPED 374 transition:ui::PAGE_TRANSITION_TYPED
388 rendererInitiated:NO]; 375 rendererInitiated:NO];
389 [session_controller_ commitPendingEntry]; 376 [session_controller_ commitPendingItem];
390 [session_controller_ addPendingEntry:GURL("http://www.example.com/2") 377 [session_controller_ addPendingItem:GURL("http://www.example.com/2")
391 referrer:web::Referrer() 378 referrer:web::Referrer()
392 transition:ui::PAGE_TRANSITION_TYPED 379 transition:ui::PAGE_TRANSITION_TYPED
393 rendererInitiated:NO]; 380 rendererInitiated:NO];
394 [session_controller_ commitPendingEntry]; 381 [session_controller_ commitPendingItem];
395 ASSERT_EQ(3U, [[session_controller_ entries] count]); 382 ASSERT_EQ(3U, [[session_controller_ entries] count]);
396 383
397 // Go to the middle, and commit first pending entry index. 384 // Go to the middle, and commit first pending entry index.
398 [session_controller_ goToEntryAtIndex:1]; 385 [session_controller_ goToItemAtIndex:1];
399 [session_controller_ setPendingEntryIndex:0]; 386 [session_controller_ setPendingItemIndex:0];
400 ASSERT_EQ(0, [session_controller_ pendingEntryIndex]); 387 ASSERT_EQ(0, [session_controller_ pendingItemIndex]);
401 base::scoped_nsobject<CRWSessionEntry> pendingEntry( 388 base::scoped_nsobject<CRWSessionEntry> pendingEntry(
402 [[session_controller_ pendingEntry] retain]); 389 [[session_controller_ pendingEntry] retain]);
403 ASSERT_TRUE(pendingEntry); 390 ASSERT_TRUE(pendingEntry);
404 ASSERT_EQ(1, [session_controller_ currentNavigationIndex]); 391 ASSERT_EQ(1, [session_controller_ currentNavigationIndex]);
405 EXPECT_EQ(2, [session_controller_ previousNavigationIndex]); 392 EXPECT_EQ(2, [session_controller_ previousNavigationIndex]);
406 [session_controller_ commitPendingEntry]; 393 [session_controller_ commitPendingItem];
407 394
408 // Verify that pending entry has been committed and current and previous entry 395 // Verify that pending entry has been committed and current and previous entry
409 // indices updated. 396 // indices updated.
410 EXPECT_EQ(pendingEntry, [session_controller_ lastCommittedEntry]); 397 EXPECT_EQ(pendingEntry, [session_controller_ lastCommittedEntry]);
411 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 398 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
412 EXPECT_FALSE([session_controller_ pendingEntry]); 399 EXPECT_FALSE([session_controller_ pendingEntry]);
413 EXPECT_EQ(0, [session_controller_ currentNavigationIndex]); 400 EXPECT_EQ(0, [session_controller_ currentNavigationIndex]);
414 EXPECT_EQ(1, [session_controller_ previousNavigationIndex]); 401 EXPECT_EQ(1, [session_controller_ previousNavigationIndex]);
415 EXPECT_EQ(3U, [[session_controller_ entries] count]); 402 EXPECT_EQ(3U, [[session_controller_ entries] count]);
416 } 403 }
417 404
418 TEST_F(CRWSessionControllerTest, 405 TEST_F(CRWSessionControllerTest,
419 DiscardPendingEntryWithoutPendingOrCommittedEntry) { 406 DiscardPendingEntryWithoutPendingOrCommittedEntry) {
420 [session_controller_ discardNonCommittedEntries]; 407 [session_controller_ discardNonCommittedItems];
421 408
422 EXPECT_EQ(0U, [[session_controller_ entries] count]); 409 EXPECT_EQ(0U, [[session_controller_ entries] count]);
423 EXPECT_EQ(nil, [session_controller_ currentEntry]); 410 EXPECT_EQ(nil, [session_controller_ currentEntry]);
424 } 411 }
425 412
426 TEST_F(CRWSessionControllerTest, 413 TEST_F(CRWSessionControllerTest,
427 DiscardPendingEntryWithoutPendingEntryWithCommittedEntry) { 414 DiscardPendingEntryWithoutPendingEntryWithCommittedEntry) {
428 // Setup committed entry 415 // Setup committed entry
429 [session_controller_ 416 [session_controller_ addPendingItem:GURL("http://www.url.com")
430 addPendingEntry:GURL("http://www.url.com") 417 referrer:MakeReferrer("http://www.referer.com")
431 referrer:MakeReferrer("http://www.referer.com") 418 transition:ui::PAGE_TRANSITION_TYPED
432 transition:ui::PAGE_TRANSITION_TYPED 419 rendererInitiated:NO];
433 rendererInitiated:NO]; 420 [session_controller_ commitPendingItem];
434 [session_controller_ commitPendingEntry];
435 421
436 // Discard noncommitted entries when there is no such one 422 // Discard noncommitted entries when there is no such one
437 [session_controller_ discardNonCommittedEntries]; 423 [session_controller_ discardNonCommittedItems];
438 424
439 EXPECT_EQ(1U, [[session_controller_ entries] count]); 425 EXPECT_EQ(1U, [[session_controller_ entries] count]);
440 EXPECT_EQ( 426 EXPECT_EQ(
441 [[session_controller_ entries] objectAtIndex:0U], 427 [[session_controller_ entries] objectAtIndex:0U],
442 [session_controller_ currentEntry]); 428 [session_controller_ currentEntry]);
443 } 429 }
444 430
445 TEST_F(CRWSessionControllerTest, UpdatePendingEntryWithoutPendingEntry) { 431 TEST_F(CRWSessionControllerTest, updatePendingItemWithoutPendingEntry) {
446 [session_controller_ 432 [session_controller_ updatePendingItem:GURL("http://www.another.url.com")];
447 updatePendingEntry:GURL("http://www.another.url.com")]; 433 [session_controller_ commitPendingItem];
448 [session_controller_ commitPendingEntry];
449 434
450 EXPECT_EQ(0U, [[session_controller_ entries] count]); 435 EXPECT_EQ(0U, [[session_controller_ entries] count]);
451 EXPECT_EQ(nil, [session_controller_ currentEntry]); 436 EXPECT_EQ(nil, [session_controller_ currentEntry]);
452 } 437 }
453 438
454 TEST_F(CRWSessionControllerTest, UpdatePendingEntryWithPendingEntry) { 439 TEST_F(CRWSessionControllerTest, updatePendingItemWithPendingEntry) {
455 [session_controller_ 440 [session_controller_ addPendingItem:GURL("http://www.url.com")
456 addPendingEntry:GURL("http://www.url.com") 441 referrer:MakeReferrer("http://www.referer.com")
457 referrer:MakeReferrer("http://www.referer.com") 442 transition:ui::PAGE_TRANSITION_TYPED
458 transition:ui::PAGE_TRANSITION_TYPED 443 rendererInitiated:NO];
459 rendererInitiated:NO]; 444 [session_controller_ updatePendingItem:GURL("http://www.another.url.com")];
460 [session_controller_
461 updatePendingEntry:GURL("http://www.another.url.com")];
462 445
463 EXPECT_EQ( 446 EXPECT_EQ(
464 GURL("http://www.another.url.com/"), 447 GURL("http://www.another.url.com/"),
465 [session_controller_ currentURL]); 448 [session_controller_ currentURL]);
466 } 449 }
467 450
468 TEST_F(CRWSessionControllerTest, 451 TEST_F(CRWSessionControllerTest,
469 UpdatePendingEntryWithPendingEntryAlreadyCommited) { 452 updatePendingItemWithPendingEntryAlreadyCommited) {
470 [session_controller_ 453 [session_controller_ addPendingItem:GURL("http://www.url.com")
471 addPendingEntry:GURL("http://www.url.com") 454 referrer:MakeReferrer("http://www.referer.com")
472 referrer:MakeReferrer("http://www.referer.com") 455 transition:ui::PAGE_TRANSITION_TYPED
473 transition:ui::PAGE_TRANSITION_TYPED 456 rendererInitiated:NO];
474 rendererInitiated:NO]; 457 [session_controller_ commitPendingItem];
475 [session_controller_ commitPendingEntry]; 458 [session_controller_ updatePendingItem:GURL("http://www.another.url.com")];
476 [session_controller_ 459 [session_controller_ commitPendingItem];
477 updatePendingEntry:GURL("http://www.another.url.com")];
478 [session_controller_ commitPendingEntry];
479 460
480 EXPECT_EQ(1U, [[session_controller_ entries] count]); 461 EXPECT_EQ(1U, [[session_controller_ entries] count]);
481 EXPECT_EQ( 462 EXPECT_EQ(
482 GURL("http://www.url.com/"), 463 GURL("http://www.url.com/"),
483 [session_controller_ URLForSessionAtIndex:0U]); 464 [session_controller_ URLForSessionAtIndex:0U]);
484 EXPECT_EQ( 465 EXPECT_EQ(
485 [[session_controller_ entries] objectAtIndex:0U], 466 [[session_controller_ entries] objectAtIndex:0U],
486 [session_controller_ currentEntry]); 467 [session_controller_ currentEntry]);
487 } 468 }
488 469
489 // Tests inserting session controller state. 470 // Tests inserting session controller state.
490 TEST_F(CRWSessionControllerTest, InsertState) { 471 TEST_F(CRWSessionControllerTest, InsertState) {
491 // Add 1 committed and 1 pending entry to target controller. 472 // Add 1 committed and 1 pending entry to target controller.
492 [session_controller_ addPendingEntry:GURL("http://www.url.com/2") 473 [session_controller_ addPendingItem:GURL("http://www.url.com/2")
493 referrer:web::Referrer() 474 referrer:web::Referrer()
494 transition:ui::PAGE_TRANSITION_TYPED 475 transition:ui::PAGE_TRANSITION_TYPED
495 rendererInitiated:NO]; 476 rendererInitiated:NO];
496 [session_controller_ commitPendingEntry]; 477 [session_controller_ commitPendingItem];
497 [session_controller_ addPendingEntry:GURL("http://www.url.com/3") 478 [session_controller_ addPendingItem:GURL("http://www.url.com/3")
498 referrer:web::Referrer() 479 referrer:web::Referrer()
499 transition:ui::PAGE_TRANSITION_TYPED 480 transition:ui::PAGE_TRANSITION_TYPED
500 rendererInitiated:NO]; 481 rendererInitiated:NO];
501 482
502 // Create source session controller with 1 committed entry. 483 // Create source session controller with 1 committed entry.
503 base::scoped_nsobject<CRWSessionController> other_session_controller( 484 base::scoped_nsobject<CRWSessionController> other_session_controller(
504 [[CRWSessionController alloc] initWithWindowName:nil 485 [[CRWSessionController alloc] initWithWindowName:nil
505 openerId:nil 486 openerId:nil
506 openedByDOM:NO 487 openedByDOM:NO
507 openerNavigationIndex:0 488 openerNavigationIndex:0
508 browserState:&browser_state_]); 489 browserState:&browser_state_]);
509 [other_session_controller setWindowName:@"test-window"]; 490 [other_session_controller setWindowName:@"test-window"];
510 [other_session_controller addPendingEntry:GURL("http://www.url.com/0") 491 [other_session_controller addPendingItem:GURL("http://www.url.com/0")
511 referrer:web::Referrer() 492 referrer:web::Referrer()
512 transition:ui::PAGE_TRANSITION_TYPED 493 transition:ui::PAGE_TRANSITION_TYPED
513 rendererInitiated:NO]; 494 rendererInitiated:NO];
514 [other_session_controller commitPendingEntry]; 495 [other_session_controller commitPendingItem];
515 [other_session_controller addPendingEntry:GURL("http://www.url.com/1") 496 [other_session_controller addPendingItem:GURL("http://www.url.com/1")
516 referrer:web::Referrer() 497 referrer:web::Referrer()
517 transition:ui::PAGE_TRANSITION_TYPED 498 transition:ui::PAGE_TRANSITION_TYPED
518 rendererInitiated:NO]; 499 rendererInitiated:NO];
519 500
520 // Insert and verify the state of target session controller. 501 // Insert and verify the state of target session controller.
521 [session_controller_ 502 [session_controller_
522 insertStateFromSessionController:other_session_controller.get()]; 503 insertStateFromSessionController:other_session_controller.get()];
523 504
524 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]); 505 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]);
525 EXPECT_EQ(2U, [[session_controller_ entries] count]); 506 EXPECT_EQ(2U, [[session_controller_ entries] count]);
526 EXPECT_EQ(1, [session_controller_ currentNavigationIndex]); 507 EXPECT_EQ(1, [session_controller_ currentNavigationIndex]);
527 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]); 508 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]);
528 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 509 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
529 510
530 EXPECT_EQ(GURL("http://www.url.com/0"), 511 EXPECT_EQ(GURL("http://www.url.com/0"),
531 [session_controller_ URLForSessionAtIndex:0]); 512 [session_controller_ URLForSessionAtIndex:0]);
532 EXPECT_EQ(GURL("http://www.url.com/2"), 513 EXPECT_EQ(GURL("http://www.url.com/2"),
533 [session_controller_ URLForSessionAtIndex:1]); 514 [session_controller_ URLForSessionAtIndex:1]);
534 EXPECT_EQ(GURL("http://www.url.com/3"), 515 EXPECT_EQ(GURL("http://www.url.com/3"),
535 [[session_controller_ pendingEntry] navigationItem]->GetURL()); 516 [[session_controller_ pendingEntry] navigationItem]->GetURL());
536 } 517 }
537 518
538 // Tests inserting session controller state from empty session controller. 519 // Tests inserting session controller state from empty session controller.
539 TEST_F(CRWSessionControllerTest, InsertStateFromEmptySessionController) { 520 TEST_F(CRWSessionControllerTest, InsertStateFromEmptySessionController) {
540 // Add 2 committed entries to target controller. 521 // Add 2 committed entries to target controller.
541 [session_controller_ addPendingEntry:GURL("http://www.url.com/0") 522 [session_controller_ addPendingItem:GURL("http://www.url.com/0")
542 referrer:web::Referrer() 523 referrer:web::Referrer()
543 transition:ui::PAGE_TRANSITION_TYPED 524 transition:ui::PAGE_TRANSITION_TYPED
544 rendererInitiated:NO]; 525 rendererInitiated:NO];
545 [session_controller_ commitPendingEntry]; 526 [session_controller_ commitPendingItem];
546 [session_controller_ addPendingEntry:GURL("http://www.url.com/1") 527 [session_controller_ addPendingItem:GURL("http://www.url.com/1")
547 referrer:web::Referrer() 528 referrer:web::Referrer()
548 transition:ui::PAGE_TRANSITION_TYPED 529 transition:ui::PAGE_TRANSITION_TYPED
549 rendererInitiated:NO]; 530 rendererInitiated:NO];
550 [session_controller_ commitPendingEntry]; 531 [session_controller_ commitPendingItem];
551 532
552 // Create empty source session controller. 533 // Create empty source session controller.
553 base::scoped_nsobject<CRWSessionController> other_session_controller( 534 base::scoped_nsobject<CRWSessionController> other_session_controller(
554 [[CRWSessionController alloc] initWithWindowName:nil 535 [[CRWSessionController alloc] initWithWindowName:nil
555 openerId:nil 536 openerId:nil
556 openedByDOM:NO 537 openedByDOM:NO
557 openerNavigationIndex:0 538 openerNavigationIndex:0
558 browserState:&browser_state_]); 539 browserState:&browser_state_]);
559 [other_session_controller setWindowName:@"test-window"]; 540 [other_session_controller setWindowName:@"test-window"];
560 541
561 // Insert and verify the state of target session controller. 542 // Insert and verify the state of target session controller.
562 [session_controller_ 543 [session_controller_
563 insertStateFromSessionController:other_session_controller.get()]; 544 insertStateFromSessionController:other_session_controller.get()];
564 545
565 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]); 546 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]);
566 EXPECT_EQ(2U, [[session_controller_ entries] count]); 547 EXPECT_EQ(2U, [[session_controller_ entries] count]);
567 EXPECT_EQ(1, [session_controller_ currentNavigationIndex]); 548 EXPECT_EQ(1, [session_controller_ currentNavigationIndex]);
568 EXPECT_EQ(0, [session_controller_ previousNavigationIndex]); 549 EXPECT_EQ(0, [session_controller_ previousNavigationIndex]);
569 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 550 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
570 EXPECT_FALSE([session_controller_ pendingEntry]); 551 EXPECT_FALSE([session_controller_ pendingEntry]);
571 EXPECT_EQ(GURL("http://www.url.com/0"), 552 EXPECT_EQ(GURL("http://www.url.com/0"),
572 [session_controller_ URLForSessionAtIndex:0]); 553 [session_controller_ URLForSessionAtIndex:0]);
573 EXPECT_EQ(GURL("http://www.url.com/1"), 554 EXPECT_EQ(GURL("http://www.url.com/1"),
574 [session_controller_ URLForSessionAtIndex:1]); 555 [session_controller_ URLForSessionAtIndex:1]);
575 } 556 }
576 557
577 // Tests inserting session controller state to empty session controller. 558 // Tests inserting session controller state to empty session controller.
578 TEST_F(CRWSessionControllerTest, InsertStateToEmptySessionController) { 559 TEST_F(CRWSessionControllerTest, InsertStateToEmptySessionController) {
579 // Create source session controller with 2 committed entries and one 560 // Create source session controller with 2 committed entries and one
580 // pending entry. 561 // pending entry.
581 base::scoped_nsobject<CRWSessionController> other_session_controller( 562 base::scoped_nsobject<CRWSessionController> other_session_controller(
582 [[CRWSessionController alloc] initWithWindowName:nil 563 [[CRWSessionController alloc] initWithWindowName:nil
583 openerId:nil 564 openerId:nil
584 openedByDOM:NO 565 openedByDOM:NO
585 openerNavigationIndex:0 566 openerNavigationIndex:0
586 browserState:&browser_state_]); 567 browserState:&browser_state_]);
587 [other_session_controller setWindowName:@"test-window"]; 568 [other_session_controller setWindowName:@"test-window"];
588 [other_session_controller addPendingEntry:GURL("http://www.url.com/0") 569 [other_session_controller addPendingItem:GURL("http://www.url.com/0")
589 referrer:web::Referrer() 570 referrer:web::Referrer()
590 transition:ui::PAGE_TRANSITION_TYPED 571 transition:ui::PAGE_TRANSITION_TYPED
591 rendererInitiated:NO]; 572 rendererInitiated:NO];
592 [other_session_controller commitPendingEntry]; 573 [other_session_controller commitPendingItem];
593 [other_session_controller addPendingEntry:GURL("http://www.url.com/1") 574 [other_session_controller addPendingItem:GURL("http://www.url.com/1")
594 referrer:web::Referrer() 575 referrer:web::Referrer()
595 transition:ui::PAGE_TRANSITION_TYPED 576 transition:ui::PAGE_TRANSITION_TYPED
596 rendererInitiated:NO]; 577 rendererInitiated:NO];
597 [other_session_controller commitPendingEntry]; 578 [other_session_controller commitPendingItem];
598 [other_session_controller addPendingEntry:GURL("http://www.url.com/2") 579 [other_session_controller addPendingItem:GURL("http://www.url.com/2")
599 referrer:web::Referrer() 580 referrer:web::Referrer()
600 transition:ui::PAGE_TRANSITION_TYPED 581 transition:ui::PAGE_TRANSITION_TYPED
601 rendererInitiated:NO]; 582 rendererInitiated:NO];
602 583
603 // Insert and verify the state of target session controller. 584 // Insert and verify the state of target session controller.
604 [session_controller_ 585 [session_controller_
605 insertStateFromSessionController:other_session_controller.get()]; 586 insertStateFromSessionController:other_session_controller.get()];
606 587
607 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]); 588 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]);
608 EXPECT_EQ(2U, [[session_controller_ entries] count]); 589 EXPECT_EQ(2U, [[session_controller_ entries] count]);
609 EXPECT_EQ(1, [session_controller_ currentNavigationIndex]); 590 EXPECT_EQ(1, [session_controller_ currentNavigationIndex]);
610 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]); 591 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]);
611 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 592 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
612 EXPECT_FALSE([session_controller_ pendingEntry]); 593 EXPECT_FALSE([session_controller_ pendingEntry]);
613 EXPECT_EQ(GURL("http://www.url.com/0"), 594 EXPECT_EQ(GURL("http://www.url.com/0"),
614 [session_controller_ URLForSessionAtIndex:0]); 595 [session_controller_ URLForSessionAtIndex:0]);
615 EXPECT_EQ(GURL("http://www.url.com/1"), 596 EXPECT_EQ(GURL("http://www.url.com/1"),
616 [session_controller_ URLForSessionAtIndex:1]); 597 [session_controller_ URLForSessionAtIndex:1]);
617 } 598 }
618 599
619 // Tests inserting session controller state. Verifies that pending entry index 600 // Tests inserting session controller state. Verifies that pending entry index
620 // remains valid. 601 // remains valid.
621 TEST_F(CRWSessionControllerTest, 602 TEST_F(CRWSessionControllerTest,
622 InsertStateWithPendingEntryIndexInTargetController) { 603 InsertStateWithPendingEntryIndexInTargetController) {
623 // Add 2 committed entries and make the first entry pending. 604 // Add 2 committed entries and make the first entry pending.
624 [session_controller_ addPendingEntry:GURL("http://www.url.com/2") 605 [session_controller_ addPendingItem:GURL("http://www.url.com/2")
625 referrer:web::Referrer() 606 referrer:web::Referrer()
626 transition:ui::PAGE_TRANSITION_TYPED 607 transition:ui::PAGE_TRANSITION_TYPED
627 rendererInitiated:NO]; 608 rendererInitiated:NO];
628 [session_controller_ commitPendingEntry]; 609 [session_controller_ commitPendingItem];
629 [session_controller_ addPendingEntry:GURL("http://www.url.com/3") 610 [session_controller_ addPendingItem:GURL("http://www.url.com/3")
630 referrer:web::Referrer() 611 referrer:web::Referrer()
631 transition:ui::PAGE_TRANSITION_TYPED 612 transition:ui::PAGE_TRANSITION_TYPED
632 rendererInitiated:NO]; 613 rendererInitiated:NO];
633 [session_controller_ commitPendingEntry]; 614 [session_controller_ commitPendingItem];
634 [session_controller_ setPendingEntryIndex:0]; 615 [session_controller_ setPendingItemIndex:0];
635 616
636 // Create source session controller with 1 committed entry. 617 // Create source session controller with 1 committed entry.
637 base::scoped_nsobject<CRWSessionController> other_session_controller( 618 base::scoped_nsobject<CRWSessionController> other_session_controller(
638 [[CRWSessionController alloc] initWithWindowName:nil 619 [[CRWSessionController alloc] initWithWindowName:nil
639 openerId:nil 620 openerId:nil
640 openedByDOM:NO 621 openedByDOM:NO
641 openerNavigationIndex:0 622 openerNavigationIndex:0
642 browserState:&browser_state_]); 623 browserState:&browser_state_]);
643 [other_session_controller setWindowName:@"test-window"]; 624 [other_session_controller setWindowName:@"test-window"];
644 [other_session_controller addPendingEntry:GURL("http://www.url.com/0") 625 [other_session_controller addPendingItem:GURL("http://www.url.com/0")
645 referrer:web::Referrer() 626 referrer:web::Referrer()
646 transition:ui::PAGE_TRANSITION_TYPED 627 transition:ui::PAGE_TRANSITION_TYPED
647 rendererInitiated:NO]; 628 rendererInitiated:NO];
648 [other_session_controller commitPendingEntry]; 629 [other_session_controller commitPendingItem];
649 630
650 // Insert and verify the state of target session controller. 631 // Insert and verify the state of target session controller.
651 [session_controller_ 632 [session_controller_
652 insertStateFromSessionController:other_session_controller.get()]; 633 insertStateFromSessionController:other_session_controller.get()];
653 634
654 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]); 635 EXPECT_NSEQ(@"test-window", [session_controller_ windowName]);
655 EXPECT_EQ(3U, [[session_controller_ entries] count]); 636 EXPECT_EQ(3U, [[session_controller_ entries] count]);
656 EXPECT_EQ(2, [session_controller_ currentNavigationIndex]); 637 EXPECT_EQ(2, [session_controller_ currentNavigationIndex]);
657 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]); 638 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]);
658 EXPECT_EQ(1, [session_controller_ pendingEntryIndex]); 639 EXPECT_EQ(1, [session_controller_ pendingItemIndex]);
659 EXPECT_EQ(GURL("http://www.url.com/0"), 640 EXPECT_EQ(GURL("http://www.url.com/0"),
660 [session_controller_ URLForSessionAtIndex:0]); 641 [session_controller_ URLForSessionAtIndex:0]);
661 EXPECT_EQ(GURL("http://www.url.com/2"), 642 EXPECT_EQ(GURL("http://www.url.com/2"),
662 [session_controller_ URLForSessionAtIndex:1]); 643 [session_controller_ URLForSessionAtIndex:1]);
663 EXPECT_EQ(GURL("http://www.url.com/2"), 644 EXPECT_EQ(GURL("http://www.url.com/2"),
664 [[session_controller_ pendingEntry] navigationItem]->GetURL()); 645 [[session_controller_ pendingEntry] navigationItem]->GetURL());
665 } 646 }
666 647
667 // Tests state of an empty session controller. 648 // Tests state of an empty session controller.
668 TEST_F(CRWSessionControllerTest, EmptyController) { 649 TEST_F(CRWSessionControllerTest, EmptyController) {
669 EXPECT_EQ(0U, [[session_controller_ entries] count]); 650 EXPECT_EQ(0U, [[session_controller_ entries] count]);
670 EXPECT_EQ(-1, [session_controller_ currentNavigationIndex]); 651 EXPECT_EQ(-1, [session_controller_ currentNavigationIndex]);
671 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]); 652 EXPECT_EQ(-1, [session_controller_ previousNavigationIndex]);
672 EXPECT_FALSE([session_controller_ currentEntry]); 653 EXPECT_FALSE([session_controller_ currentEntry]);
673 EXPECT_FALSE([session_controller_ pendingEntry]); 654 EXPECT_FALSE([session_controller_ pendingEntry]);
674 EXPECT_EQ(-1, [session_controller_ pendingEntryIndex]); 655 EXPECT_EQ(-1, [session_controller_ pendingItemIndex]);
675 } 656 }
676 657
677 // Helper to create a NavigationItem. 658 // Helper to create a NavigationItem.
678 std::unique_ptr<web::NavigationItemImpl> CreateNavigationItem( 659 std::unique_ptr<web::NavigationItemImpl> CreateNavigationItem(
679 const std::string& url, 660 const std::string& url,
680 const std::string& referrer, 661 const std::string& referrer,
681 NSString* title) { 662 NSString* title) {
682 web::Referrer referrer_object(GURL(referrer), 663 web::Referrer referrer_object(GURL(referrer),
683 web::ReferrerPolicyDefault); 664 web::ReferrerPolicyDefault);
684 std::unique_ptr<web::NavigationItemImpl> navigation_item = 665 std::unique_ptr<web::NavigationItemImpl> navigation_item =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 // the entire object is created properly. 704 // the entire object is created properly.
724 CRWSessionEntry* current_entry = controller.get().currentEntry; 705 CRWSessionEntry* current_entry = controller.get().currentEntry;
725 EXPECT_EQ(current_entry.navigationItem->GetURL(), 706 EXPECT_EQ(current_entry.navigationItem->GetURL(),
726 GURL("http://www.yahoo.com")); 707 GURL("http://www.yahoo.com"));
727 EXPECT_EQ([[controller openerId] length], 0UL); 708 EXPECT_EQ([[controller openerId] length], 0UL);
728 } 709 }
729 710
730 // Tests index of previous navigation entry. 711 // Tests index of previous navigation entry.
731 TEST_F(CRWSessionControllerTest, PreviousNavigationEntry) { 712 TEST_F(CRWSessionControllerTest, PreviousNavigationEntry) {
732 EXPECT_EQ(session_controller_.get().previousNavigationIndex, -1); 713 EXPECT_EQ(session_controller_.get().previousNavigationIndex, -1);
733 [session_controller_ 714 [session_controller_ addPendingItem:GURL("http://www.url.com")
734 addPendingEntry:GURL("http://www.url.com") 715 referrer:MakeReferrer("http://www.referer.com")
735 referrer:MakeReferrer("http://www.referer.com") 716 transition:ui::PAGE_TRANSITION_TYPED
736 transition:ui::PAGE_TRANSITION_TYPED 717 rendererInitiated:NO];
737 rendererInitiated:NO]; 718 [session_controller_ commitPendingItem];
738 [session_controller_ commitPendingEntry];
739 EXPECT_EQ(session_controller_.get().previousNavigationIndex, -1); 719 EXPECT_EQ(session_controller_.get().previousNavigationIndex, -1);
740 [session_controller_ 720 [session_controller_ addPendingItem:GURL("http://www.url1.com")
741 addPendingEntry:GURL("http://www.url1.com") 721 referrer:MakeReferrer("http://www.referer.com")
742 referrer:MakeReferrer("http://www.referer.com") 722 transition:ui::PAGE_TRANSITION_TYPED
743 transition:ui::PAGE_TRANSITION_TYPED 723 rendererInitiated:NO];
744 rendererInitiated:NO]; 724 [session_controller_ commitPendingItem];
745 [session_controller_ commitPendingEntry];
746 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 0); 725 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 0);
747 [session_controller_ 726 [session_controller_ addPendingItem:GURL("http://www.url2.com")
748 addPendingEntry:GURL("http://www.url2.com") 727 referrer:MakeReferrer("http://www.referer.com")
749 referrer:MakeReferrer("http://www.referer.com") 728 transition:ui::PAGE_TRANSITION_TYPED
750 transition:ui::PAGE_TRANSITION_TYPED 729 rendererInitiated:NO];
751 rendererInitiated:NO]; 730 [session_controller_ commitPendingItem];
752 [session_controller_ commitPendingEntry];
753 731
754 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 1); 732 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 1);
755 733
756 [session_controller_ goToEntryAtIndex:1]; 734 [session_controller_ goToItemAtIndex:1];
757 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 2); 735 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 2);
758 736
759 [session_controller_ goToEntryAtIndex:0]; 737 [session_controller_ goToItemAtIndex:0];
760 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 1); 738 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 1);
761 739
762 [session_controller_ goToEntryAtIndex:1]; 740 [session_controller_ goToItemAtIndex:1];
763 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 0); 741 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 0);
764 742
765 [session_controller_ goToEntryAtIndex:2]; 743 [session_controller_ goToItemAtIndex:2];
766 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 1); 744 EXPECT_EQ(session_controller_.get().previousNavigationIndex, 1);
767 } 745 }
768 746
769 TEST_F(CRWSessionControllerTest, PushNewEntry) { 747 TEST_F(CRWSessionControllerTest, PushNewEntry) {
770 std::vector<std::unique_ptr<web::NavigationItem>> items; 748 std::vector<std::unique_ptr<web::NavigationItem>> items;
771 items.push_back(CreateNavigationItem("http://www.firstpage.com", 749 items.push_back(CreateNavigationItem("http://www.firstpage.com",
772 "http://www.starturl.com", @"First")); 750 "http://www.starturl.com", @"First"));
773 items.push_back(CreateNavigationItem("http://www.secondpage.com", 751 items.push_back(CreateNavigationItem("http://www.secondpage.com",
774 "http://www.firstpage.com", @"Second")); 752 "http://www.firstpage.com", @"Second"));
775 items.push_back(CreateNavigationItem("http://www.thirdpage.com", 753 items.push_back(CreateNavigationItem("http://www.thirdpage.com",
776 "http://www.secondpage.com", @"Third")); 754 "http://www.secondpage.com", @"Third"));
777 base::scoped_nsobject<CRWSessionController> controller( 755 base::scoped_nsobject<CRWSessionController> controller(
778 [[CRWSessionController alloc] initWithNavigationItems:std::move(items) 756 [[CRWSessionController alloc] initWithNavigationItems:std::move(items)
779 currentIndex:0 757 currentIndex:0
780 browserState:&browser_state_]); 758 browserState:&browser_state_]);
781 759
782 GURL pushPageGurl1("http://www.firstpage.com/#push1"); 760 GURL pushPageGurl1("http://www.firstpage.com/#push1");
783 NSString* stateObject1 = @"{'foo': 1}"; 761 NSString* stateObject1 = @"{'foo': 1}";
784 [controller pushNewEntryWithURL:pushPageGurl1 762 [controller pushNewItemWithURL:pushPageGurl1
785 stateObject:stateObject1 763 stateObject:stateObject1
786 transition:ui::PAGE_TRANSITION_LINK]; 764 transition:ui::PAGE_TRANSITION_LINK];
787 CRWSessionEntry* pushedEntry = [controller currentEntry]; 765 CRWSessionEntry* pushedEntry = [controller currentEntry];
788 web::NavigationItemImpl* pushedItem = pushedEntry.navigationItemImpl; 766 web::NavigationItemImpl* pushedItem = pushedEntry.navigationItemImpl;
789 NSUInteger expectedCount = 2; 767 NSUInteger expectedCount = 2;
790 EXPECT_EQ(expectedCount, controller.get().entries.count); 768 EXPECT_EQ(expectedCount, controller.get().entries.count);
791 EXPECT_EQ(pushPageGurl1, pushedEntry.navigationItem->GetURL()); 769 EXPECT_EQ(pushPageGurl1, pushedEntry.navigationItem->GetURL());
792 EXPECT_TRUE(pushedItem->IsCreatedFromPushState()); 770 EXPECT_TRUE(pushedItem->IsCreatedFromPushState());
793 EXPECT_NSEQ(stateObject1, pushedItem->GetSerializedStateObject()); 771 EXPECT_NSEQ(stateObject1, pushedItem->GetSerializedStateObject());
794 EXPECT_EQ(GURL("http://www.firstpage.com/"), 772 EXPECT_EQ(GURL("http://www.firstpage.com/"),
795 pushedEntry.navigationItem->GetReferrer().url); 773 pushedEntry.navigationItem->GetReferrer().url);
796 774
797 // Add another new entry and check size and fields again. 775 // Add another new entry and check size and fields again.
798 GURL pushPageGurl2("http://www.firstpage.com/push2"); 776 GURL pushPageGurl2("http://www.firstpage.com/push2");
799 [controller pushNewEntryWithURL:pushPageGurl2 777 [controller pushNewItemWithURL:pushPageGurl2
800 stateObject:nil 778 stateObject:nil
801 transition:ui::PAGE_TRANSITION_LINK]; 779 transition:ui::PAGE_TRANSITION_LINK];
802 pushedEntry = [controller currentEntry]; 780 pushedEntry = [controller currentEntry];
803 pushedItem = pushedEntry.navigationItemImpl; 781 pushedItem = pushedEntry.navigationItemImpl;
804 expectedCount = 3; 782 expectedCount = 3;
805 EXPECT_EQ(expectedCount, controller.get().entries.count); 783 EXPECT_EQ(expectedCount, controller.get().entries.count);
806 EXPECT_EQ(pushPageGurl2, pushedEntry.navigationItem->GetURL()); 784 EXPECT_EQ(pushPageGurl2, pushedEntry.navigationItem->GetURL());
807 EXPECT_TRUE(pushedItem->IsCreatedFromPushState()); 785 EXPECT_TRUE(pushedItem->IsCreatedFromPushState());
808 EXPECT_EQ(nil, pushedItem->GetSerializedStateObject()); 786 EXPECT_EQ(nil, pushedItem->GetSerializedStateObject());
809 EXPECT_EQ(pushPageGurl1, pushedEntry.navigationItem->GetReferrer().url); 787 EXPECT_EQ(pushPageGurl1, pushedEntry.navigationItem->GetReferrer().url);
810 } 788 }
811 789
(...skipping 11 matching lines...) Expand all
823 // Push state navigation. 801 // Push state navigation.
824 items.push_back( 802 items.push_back(
825 CreateNavigationItem("http://foo.com/bar", "http://foo.com", @"Fifth")); 803 CreateNavigationItem("http://foo.com/bar", "http://foo.com", @"Fifth"));
826 // Push state navigation. 804 // Push state navigation.
827 items.push_back(CreateNavigationItem("http://foo.com/bar#bar", 805 items.push_back(CreateNavigationItem("http://foo.com/bar#bar",
828 "http://foo.com/bar", @"Sixth")); 806 "http://foo.com/bar", @"Sixth"));
829 base::scoped_nsobject<CRWSessionController> controller( 807 base::scoped_nsobject<CRWSessionController> controller(
830 [[CRWSessionController alloc] initWithNavigationItems:std::move(items) 808 [[CRWSessionController alloc] initWithNavigationItems:std::move(items)
831 currentIndex:0 809 currentIndex:0
832 browserState:&browser_state_]); 810 browserState:&browser_state_]);
833 CRWSessionEntry* entry0 = [controller.get().entries objectAtIndex:0]; 811 web::NavigationItemImpl* item0 = [controller items][0].get();
834 CRWSessionEntry* entry1 = [controller.get().entries objectAtIndex:1]; 812 web::NavigationItemImpl* item1 = [controller items][1].get();
835 CRWSessionEntry* entry2 = [controller.get().entries objectAtIndex:2]; 813 web::NavigationItemImpl* item2 = [controller items][2].get();
836 CRWSessionEntry* entry3 = [controller.get().entries objectAtIndex:3]; 814 web::NavigationItemImpl* item3 = [controller items][3].get();
837 CRWSessionEntry* entry4 = [controller.get().entries objectAtIndex:4]; 815 web::NavigationItemImpl* item4 = [controller items][4].get();
838 CRWSessionEntry* entry5 = [controller.get().entries objectAtIndex:5]; 816 web::NavigationItemImpl* item5 = [controller items][5].get();
839 entry1.navigationItemImpl->SetIsCreatedFromPushState(true); 817 item1->SetIsCreatedFromPushState(true);
840 entry4.navigationItemImpl->SetIsCreatedFromHashChange(true); 818 item4->SetIsCreatedFromHashChange(true);
841 entry5.navigationItemImpl->SetIsCreatedFromPushState(true); 819 item5->SetIsCreatedFromPushState(true);
842 820
843 EXPECT_FALSE( 821 EXPECT_FALSE(
844 [controller isSameDocumentNavigationBetweenEntry:entry0 andEntry:entry0]); 822 [controller isSameDocumentNavigationBetweenItem:item0 andItem:item0]);
845 EXPECT_TRUE( 823 EXPECT_TRUE(
846 [controller isSameDocumentNavigationBetweenEntry:entry0 andEntry:entry1]); 824 [controller isSameDocumentNavigationBetweenItem:item0 andItem:item1]);
847 EXPECT_TRUE( 825 EXPECT_TRUE(
848 [controller isSameDocumentNavigationBetweenEntry:entry5 andEntry:entry3]); 826 [controller isSameDocumentNavigationBetweenItem:item5 andItem:item3]);
849 EXPECT_TRUE( 827 EXPECT_TRUE(
850 [controller isSameDocumentNavigationBetweenEntry:entry4 andEntry:entry3]); 828 [controller isSameDocumentNavigationBetweenItem:item4 andItem:item3]);
851 EXPECT_FALSE( 829 EXPECT_FALSE(
852 [controller isSameDocumentNavigationBetweenEntry:entry1 andEntry:entry2]); 830 [controller isSameDocumentNavigationBetweenItem:item1 andItem:item2]);
853 EXPECT_FALSE( 831 EXPECT_FALSE(
854 [controller isSameDocumentNavigationBetweenEntry:entry0 andEntry:entry5]); 832 [controller isSameDocumentNavigationBetweenItem:item0 andItem:item5]);
855 EXPECT_FALSE( 833 EXPECT_FALSE(
856 [controller isSameDocumentNavigationBetweenEntry:entry2 andEntry:entry4]); 834 [controller isSameDocumentNavigationBetweenItem:item2 andItem:item4]);
857 } 835 }
858 836
859 TEST_F(CRWSessionControllerTest, UpdateCurrentEntry) { 837 TEST_F(CRWSessionControllerTest, UpdateCurrentEntry) {
860 std::vector<std::unique_ptr<web::NavigationItem>> items; 838 std::vector<std::unique_ptr<web::NavigationItem>> items;
861 items.push_back(CreateNavigationItem("http://www.firstpage.com", 839 items.push_back(CreateNavigationItem("http://www.firstpage.com",
862 "http://www.starturl.com", @"First")); 840 "http://www.starturl.com", @"First"));
863 items.push_back(CreateNavigationItem("http://www.secondpage.com", 841 items.push_back(CreateNavigationItem("http://www.secondpage.com",
864 "http://www.firstpage.com", @"Second")); 842 "http://www.firstpage.com", @"Second"));
865 items.push_back(CreateNavigationItem("http://www.thirdpage.com", 843 items.push_back(CreateNavigationItem("http://www.thirdpage.com",
866 "http://www.secondpage.com", @"Third")); 844 "http://www.secondpage.com", @"Third"));
867 base::scoped_nsobject<CRWSessionController> controller( 845 base::scoped_nsobject<CRWSessionController> controller(
868 [[CRWSessionController alloc] initWithNavigationItems:std::move(items) 846 [[CRWSessionController alloc] initWithNavigationItems:std::move(items)
869 currentIndex:0 847 currentIndex:0
870 browserState:&browser_state_]); 848 browserState:&browser_state_]);
871 849
872 GURL replacePageGurl1("http://www.firstpage.com/#replace1"); 850 GURL replacePageGurl1("http://www.firstpage.com/#replace1");
873 NSString* stateObject1 = @"{'foo': 1}"; 851 NSString* stateObject1 = @"{'foo': 1}";
874 852
875 // Replace current entry and check the size of history and fields of the 853 // Replace current entry and check the size of history and fields of the
876 // modified entry. 854 // modified entry.
877 [controller updateCurrentEntryWithURL:replacePageGurl1 855 [controller updateCurrentItemWithURL:replacePageGurl1
878 stateObject:stateObject1]; 856 stateObject:stateObject1];
879 CRWSessionEntry* replacedEntry = [controller currentEntry]; 857 CRWSessionEntry* replacedEntry = [controller currentEntry];
880 web::NavigationItemImpl* replacedItem = replacedEntry.navigationItemImpl; 858 web::NavigationItemImpl* replacedItem = replacedEntry.navigationItemImpl;
881 NSUInteger expectedCount = 3; 859 NSUInteger expectedCount = 3;
882 EXPECT_EQ(expectedCount, controller.get().entries.count); 860 EXPECT_EQ(expectedCount, controller.get().entries.count);
883 EXPECT_EQ(replacePageGurl1, replacedEntry.navigationItem->GetURL()); 861 EXPECT_EQ(replacePageGurl1, replacedEntry.navigationItem->GetURL());
884 EXPECT_FALSE(replacedItem->IsCreatedFromPushState()); 862 EXPECT_FALSE(replacedItem->IsCreatedFromPushState());
885 EXPECT_NSEQ(stateObject1, replacedItem->GetSerializedStateObject()); 863 EXPECT_NSEQ(stateObject1, replacedItem->GetSerializedStateObject());
886 EXPECT_EQ(GURL("http://www.starturl.com/"), 864 EXPECT_EQ(GURL("http://www.starturl.com/"),
887 replacedEntry.navigationItem->GetReferrer().url); 865 replacedEntry.navigationItem->GetReferrer().url);
888 866
889 // Replace current entry and check size and fields again. 867 // Replace current entry and check size and fields again.
890 GURL replacePageGurl2("http://www.firstpage.com/#replace2"); 868 GURL replacePageGurl2("http://www.firstpage.com/#replace2");
891 [controller.get() updateCurrentEntryWithURL:replacePageGurl2 stateObject:nil]; 869 [controller.get() updateCurrentItemWithURL:replacePageGurl2 stateObject:nil];
892 replacedEntry = [controller currentEntry]; 870 replacedEntry = [controller currentEntry];
893 replacedItem = replacedEntry.navigationItemImpl; 871 replacedItem = replacedEntry.navigationItemImpl;
894 EXPECT_EQ(expectedCount, controller.get().entries.count); 872 EXPECT_EQ(expectedCount, controller.get().entries.count);
895 EXPECT_EQ(replacePageGurl2, replacedEntry.navigationItem->GetURL()); 873 EXPECT_EQ(replacePageGurl2, replacedEntry.navigationItem->GetURL());
896 EXPECT_FALSE(replacedItem->IsCreatedFromPushState()); 874 EXPECT_FALSE(replacedItem->IsCreatedFromPushState());
897 EXPECT_NSEQ(nil, replacedItem->GetSerializedStateObject()); 875 EXPECT_NSEQ(nil, replacedItem->GetSerializedStateObject());
898 EXPECT_EQ(GURL("http://www.starturl.com/"), 876 EXPECT_EQ(GURL("http://www.starturl.com/"),
899 replacedEntry.navigationItem->GetReferrer().url); 877 replacedEntry.navigationItem->GetReferrer().url);
900 } 878 }
901 879
902 TEST_F(CRWSessionControllerTest, TestBackwardForwardEntries) { 880 TEST_F(CRWSessionControllerTest, TestBackwardForwardEntries) {
903 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 881 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
904 referrer:MakeReferrer("http://www.example.com/a") 882 referrer:MakeReferrer("http://www.example.com/a")
905 transition:ui::PAGE_TRANSITION_LINK 883 transition:ui::PAGE_TRANSITION_LINK
906 rendererInitiated:NO]; 884 rendererInitiated:NO];
907 [session_controller_ commitPendingEntry]; 885 [session_controller_ commitPendingItem];
908 [session_controller_ addPendingEntry:GURL("http://www.example.com/1") 886 [session_controller_ addPendingItem:GURL("http://www.example.com/1")
909 referrer:MakeReferrer("http://www.example.com/b") 887 referrer:MakeReferrer("http://www.example.com/b")
910 transition:ui::PAGE_TRANSITION_LINK 888 transition:ui::PAGE_TRANSITION_LINK
911 rendererInitiated:NO]; 889 rendererInitiated:NO];
912 [session_controller_ commitPendingEntry]; 890 [session_controller_ commitPendingItem];
913 [session_controller_ addPendingEntry:GURL("http://www.example.com/redirect") 891 [session_controller_ addPendingItem:GURL("http://www.example.com/redirect")
914 referrer:MakeReferrer("http://www.example.com/r") 892 referrer:MakeReferrer("http://www.example.com/r")
915 transition:ui::PAGE_TRANSITION_IS_REDIRECT_MASK 893 transition:ui::PAGE_TRANSITION_IS_REDIRECT_MASK
916 rendererInitiated:NO]; 894 rendererInitiated:NO];
917 [session_controller_ commitPendingEntry]; 895 [session_controller_ commitPendingItem];
918 [session_controller_ addPendingEntry:GURL("http://www.example.com/2") 896 [session_controller_ addPendingItem:GURL("http://www.example.com/2")
919 referrer:MakeReferrer("http://www.example.com/c") 897 referrer:MakeReferrer("http://www.example.com/c")
920 transition:ui::PAGE_TRANSITION_LINK 898 transition:ui::PAGE_TRANSITION_LINK
921 rendererInitiated:NO]; 899 rendererInitiated:NO];
922 [session_controller_ commitPendingEntry]; 900 [session_controller_ commitPendingItem];
923 901
924 EXPECT_EQ(3, session_controller_.get().currentNavigationIndex); 902 EXPECT_EQ(3, session_controller_.get().currentNavigationIndex);
925 NSArray* backEntries = [session_controller_ backwardEntries]; 903 NSArray* backEntries = [session_controller_ backwardEntries];
926 EXPECT_EQ(2U, [backEntries count]); 904 EXPECT_EQ(2U, [backEntries count]);
927 EXPECT_EQ(0U, [[session_controller_ forwardEntries] count]); 905 EXPECT_EQ(0U, [[session_controller_ forwardEntries] count]);
928 EXPECT_EQ("http://www.example.com/redirect", 906 EXPECT_EQ("http://www.example.com/redirect",
929 [[backEntries objectAtIndex:0] navigationItem]->GetURL().spec()); 907 [[backEntries objectAtIndex:0] navigationItem]->GetURL().spec());
930 908
931 [session_controller_ goToEntryAtIndex:1]; 909 [session_controller_ goToItemAtIndex:1];
932 EXPECT_EQ(1U, [[session_controller_ backwardEntries] count]); 910 EXPECT_EQ(1U, [[session_controller_ backwardEntries] count]);
933 EXPECT_EQ(1U, [[session_controller_ forwardEntries] count]); 911 EXPECT_EQ(1U, [[session_controller_ forwardEntries] count]);
934 912
935 [session_controller_ goToEntryAtIndex:0]; 913 [session_controller_ goToItemAtIndex:0];
936 NSArray* forwardEntries = [session_controller_ forwardEntries]; 914 NSArray* forwardEntries = [session_controller_ forwardEntries];
937 EXPECT_EQ(0U, [[session_controller_ backwardEntries] count]); 915 EXPECT_EQ(0U, [[session_controller_ backwardEntries] count]);
938 EXPECT_EQ(2U, [forwardEntries count]); 916 EXPECT_EQ(2U, [forwardEntries count]);
939 EXPECT_EQ("http://www.example.com/2", 917 EXPECT_EQ("http://www.example.com/2",
940 [[forwardEntries objectAtIndex:1] navigationItem]->GetURL().spec()); 918 [[forwardEntries objectAtIndex:1] navigationItem]->GetURL().spec());
941 } 919 }
942 920
943 // Tests going to entries with existing and non-existing indices. 921 // Tests going to entries with existing and non-existing indices.
944 TEST_F(CRWSessionControllerTest, GoToEntryAtIndex) { 922 TEST_F(CRWSessionControllerTest, GoToEntryAtIndex) {
945 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 923 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
946 referrer:MakeReferrer("http://www.example.com/a") 924 referrer:MakeReferrer("http://www.example.com/a")
947 transition:ui::PAGE_TRANSITION_LINK 925 transition:ui::PAGE_TRANSITION_LINK
948 rendererInitiated:NO]; 926 rendererInitiated:NO];
949 [session_controller_ commitPendingEntry]; 927 [session_controller_ commitPendingItem];
950 [session_controller_ addPendingEntry:GURL("http://www.example.com/1") 928 [session_controller_ addPendingItem:GURL("http://www.example.com/1")
951 referrer:MakeReferrer("http://www.example.com/b") 929 referrer:MakeReferrer("http://www.example.com/b")
952 transition:ui::PAGE_TRANSITION_LINK 930 transition:ui::PAGE_TRANSITION_LINK
953 rendererInitiated:NO]; 931 rendererInitiated:NO];
954 [session_controller_ commitPendingEntry]; 932 [session_controller_ commitPendingItem];
955 [session_controller_ addPendingEntry:GURL("http://www.example.com/redirect") 933 [session_controller_ addPendingItem:GURL("http://www.example.com/redirect")
956 referrer:MakeReferrer("http://www.example.com/r") 934 referrer:MakeReferrer("http://www.example.com/r")
957 transition:ui::PAGE_TRANSITION_IS_REDIRECT_MASK 935 transition:ui::PAGE_TRANSITION_IS_REDIRECT_MASK
958 rendererInitiated:NO]; 936 rendererInitiated:NO];
959 [session_controller_ commitPendingEntry]; 937 [session_controller_ commitPendingItem];
960 [session_controller_ addPendingEntry:GURL("http://www.example.com/2") 938 [session_controller_ addPendingItem:GURL("http://www.example.com/2")
961 referrer:MakeReferrer("http://www.example.com/c") 939 referrer:MakeReferrer("http://www.example.com/c")
962 transition:ui::PAGE_TRANSITION_LINK 940 transition:ui::PAGE_TRANSITION_LINK
963 rendererInitiated:NO]; 941 rendererInitiated:NO];
964 [session_controller_ commitPendingEntry]; 942 [session_controller_ commitPendingItem];
965 [session_controller_ addPendingEntry:GURL("http://www.example.com/3") 943 [session_controller_ addPendingItem:GURL("http://www.example.com/3")
966 referrer:MakeReferrer("http://www.example.com/d") 944 referrer:MakeReferrer("http://www.example.com/d")
967 transition:ui::PAGE_TRANSITION_LINK 945 transition:ui::PAGE_TRANSITION_LINK
968 rendererInitiated:NO]; 946 rendererInitiated:NO];
969 [session_controller_ addTransientEntryWithURL:GURL("http://www.example.com")]; 947 [session_controller_ addTransientItemWithURL:GURL("http://www.example.com")];
970 EXPECT_EQ(3, session_controller_.get().currentNavigationIndex); 948 EXPECT_EQ(3, session_controller_.get().currentNavigationIndex);
971 EXPECT_EQ(2, session_controller_.get().previousNavigationIndex); 949 EXPECT_EQ(2, session_controller_.get().previousNavigationIndex);
972 EXPECT_TRUE(session_controller_.get().pendingEntry); 950 EXPECT_TRUE(session_controller_.get().pendingEntry);
973 EXPECT_TRUE(session_controller_.get().transientEntry); 951 EXPECT_TRUE(session_controller_.get().transientEntry);
974 952
975 // Going back should discard transient and pending entries. 953 // Going back should discard transient and pending entries.
976 [session_controller_ goToEntryAtIndex:1]; 954 [session_controller_ goToItemAtIndex:1];
977 EXPECT_EQ(1, session_controller_.get().currentNavigationIndex); 955 EXPECT_EQ(1, session_controller_.get().currentNavigationIndex);
978 EXPECT_EQ(3, session_controller_.get().previousNavigationIndex); 956 EXPECT_EQ(3, session_controller_.get().previousNavigationIndex);
979 EXPECT_FALSE(session_controller_.get().pendingEntry); 957 EXPECT_FALSE(session_controller_.get().pendingEntry);
980 EXPECT_FALSE(session_controller_.get().transientEntry); 958 EXPECT_FALSE(session_controller_.get().transientEntry);
981 959
982 // Going forward should discard transient entry. 960 // Going forward should discard transient entry.
983 [session_controller_ addTransientEntryWithURL:GURL("http://www.example.com")]; 961 [session_controller_ addTransientItemWithURL:GURL("http://www.example.com")];
984 EXPECT_TRUE(session_controller_.get().transientEntry); 962 EXPECT_TRUE(session_controller_.get().transientEntry);
985 [session_controller_ goToEntryAtIndex:2]; 963 [session_controller_ goToItemAtIndex:2];
986 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex); 964 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex);
987 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex); 965 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex);
988 EXPECT_FALSE(session_controller_.get().transientEntry); 966 EXPECT_FALSE(session_controller_.get().transientEntry);
989 967
990 // Out of bounds navigations should be no-op. 968 // Out of bounds navigations should be no-op.
991 [session_controller_ goToEntryAtIndex:-1]; 969 [session_controller_ goToItemAtIndex:-1];
992 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex); 970 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex);
993 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex); 971 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex);
994 [session_controller_ goToEntryAtIndex:NSIntegerMax]; 972 [session_controller_ goToItemAtIndex:NSIntegerMax];
995 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex); 973 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex);
996 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex); 974 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex);
997 975
998 // Going to current index should not change the previous index. 976 // Going to current index should not change the previous index.
999 [session_controller_ goToEntryAtIndex:2]; 977 [session_controller_ goToItemAtIndex:2];
1000 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex); 978 EXPECT_EQ(2, session_controller_.get().currentNavigationIndex);
1001 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex); 979 EXPECT_EQ(1, session_controller_.get().previousNavigationIndex);
1002 } 980 }
1003 981
1004 // Tests that visible URL is the same as transient URL if there are no committed 982 // Tests that visible URL is the same as transient URL if there are no committed
1005 // entries. 983 // entries.
1006 TEST_F(CRWSessionControllerTest, VisibleEntryWithSingleTransientEntry) { 984 TEST_F(CRWSessionControllerTest, VisibleEntryWithSingleTransientEntry) {
1007 [session_controller_ addTransientEntryWithURL:GURL("http://www.example.com")]; 985 [session_controller_ addTransientItemWithURL:GURL("http://www.example.com")];
1008 web::NavigationItem* visible_item = 986 web::NavigationItem* visible_item =
1009 [[session_controller_ visibleEntry] navigationItem]; 987 [[session_controller_ visibleEntry] navigationItem];
1010 ASSERT_TRUE(visible_item); 988 ASSERT_TRUE(visible_item);
1011 EXPECT_EQ("http://www.example.com/", visible_item->GetURL().spec()); 989 EXPECT_EQ("http://www.example.com/", visible_item->GetURL().spec());
1012 } 990 }
1013 991
1014 // Tests that visible URL is the same as transient URL if there is a committed 992 // Tests that visible URL is the same as transient URL if there is a committed
1015 // entry. 993 // entry.
1016 TEST_F(CRWSessionControllerTest, VisibleEntryWithCommittedAndTransientEntries) { 994 TEST_F(CRWSessionControllerTest, VisibleEntryWithCommittedAndTransientEntries) {
1017 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 995 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
1018 referrer:MakeReferrer("http://www.example.com/a") 996 referrer:MakeReferrer("http://www.example.com/a")
1019 transition:ui::PAGE_TRANSITION_LINK 997 transition:ui::PAGE_TRANSITION_LINK
1020 rendererInitiated:NO]; 998 rendererInitiated:NO];
1021 [session_controller_ commitPendingEntry]; 999 [session_controller_ commitPendingItem];
1022 [session_controller_ addTransientEntryWithURL:GURL("http://www.example.com")]; 1000 [session_controller_ addTransientItemWithURL:GURL("http://www.example.com")];
1023 web::NavigationItem* visible_item = 1001 web::NavigationItem* visible_item =
1024 [[session_controller_ visibleEntry] navigationItem]; 1002 [[session_controller_ visibleEntry] navigationItem];
1025 ASSERT_TRUE(visible_item); 1003 ASSERT_TRUE(visible_item);
1026 EXPECT_EQ("http://www.example.com/", visible_item->GetURL().spec()); 1004 EXPECT_EQ("http://www.example.com/", visible_item->GetURL().spec());
1027 } 1005 }
1028 1006
1029 // Tests that visible URL is the same as pending URL if it was user-initiated. 1007 // Tests that visible URL is the same as pending URL if it was user-initiated.
1030 TEST_F(CRWSessionControllerTest, 1008 TEST_F(CRWSessionControllerTest,
1031 VisibleEntryWithSingleUserInitiatedPendingEntry) { 1009 VisibleEntryWithSingleUserInitiatedPendingEntry) {
1032 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 1010 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
1033 referrer:MakeReferrer("http://www.example.com/a") 1011 referrer:MakeReferrer("http://www.example.com/a")
1034 transition:ui::PAGE_TRANSITION_LINK 1012 transition:ui::PAGE_TRANSITION_LINK
1035 rendererInitiated:NO]; 1013 rendererInitiated:NO];
1036 web::NavigationItem* visible_item = 1014 web::NavigationItem* visible_item =
1037 [[session_controller_ visibleEntry] navigationItem]; 1015 [[session_controller_ visibleEntry] navigationItem];
1038 ASSERT_TRUE(visible_item); 1016 ASSERT_TRUE(visible_item);
1039 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec()); 1017 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec());
1040 } 1018 }
1041 1019
1042 // Tests that visible URL is the same as pending URL if it was user-initiated 1020 // Tests that visible URL is the same as pending URL if it was user-initiated
1043 // and there is a committed entry. 1021 // and there is a committed entry.
1044 TEST_F(CRWSessionControllerTest, 1022 TEST_F(CRWSessionControllerTest,
1045 VisibleEntryWithCommittedAndUserInitiatedPendingEntry) { 1023 VisibleEntryWithCommittedAndUserInitiatedPendingEntry) {
1046 [session_controller_ addPendingEntry:GURL("http://www.example.com") 1024 [session_controller_ addPendingItem:GURL("http://www.example.com")
1047 referrer:MakeReferrer("http://www.example.com/a") 1025 referrer:MakeReferrer("http://www.example.com/a")
1048 transition:ui::PAGE_TRANSITION_LINK 1026 transition:ui::PAGE_TRANSITION_LINK
1049 rendererInitiated:NO]; 1027 rendererInitiated:NO];
1050 [session_controller_ commitPendingEntry]; 1028 [session_controller_ commitPendingItem];
1051 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 1029 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
1052 referrer:MakeReferrer("http://www.example.com/b") 1030 referrer:MakeReferrer("http://www.example.com/b")
1053 transition:ui::PAGE_TRANSITION_LINK 1031 transition:ui::PAGE_TRANSITION_LINK
1054 rendererInitiated:NO]; 1032 rendererInitiated:NO];
1055 web::NavigationItem* visible_item = 1033 web::NavigationItem* visible_item =
1056 [[session_controller_ visibleEntry] navigationItem]; 1034 [[session_controller_ visibleEntry] navigationItem];
1057 ASSERT_TRUE(visible_item); 1035 ASSERT_TRUE(visible_item);
1058 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec()); 1036 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec());
1059 } 1037 }
1060 1038
1061 // Tests that visible URL is not the same as pending URL if it was 1039 // Tests that visible URL is not the same as pending URL if it was
1062 // renderer-initiated. 1040 // renderer-initiated.
1063 TEST_F(CRWSessionControllerTest, 1041 TEST_F(CRWSessionControllerTest,
1064 VisibleEntryWithSingleRendererInitiatedPendingEntry) { 1042 VisibleEntryWithSingleRendererInitiatedPendingEntry) {
1065 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 1043 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
1066 referrer:MakeReferrer("http://www.example.com/a") 1044 referrer:MakeReferrer("http://www.example.com/a")
1067 transition:ui::PAGE_TRANSITION_LINK 1045 transition:ui::PAGE_TRANSITION_LINK
1068 rendererInitiated:YES]; 1046 rendererInitiated:YES];
1069 web::NavigationItem* visible_item = 1047 web::NavigationItem* visible_item =
1070 [[session_controller_ visibleEntry] navigationItem]; 1048 [[session_controller_ visibleEntry] navigationItem];
1071 ASSERT_FALSE(visible_item); 1049 ASSERT_FALSE(visible_item);
1072 } 1050 }
1073 1051
1074 // Tests that visible URL is not the same as pending URL if it was 1052 // Tests that visible URL is not the same as pending URL if it was
1075 // renderer-initiated and there is a committed entry. 1053 // renderer-initiated and there is a committed entry.
1076 TEST_F(CRWSessionControllerTest, 1054 TEST_F(CRWSessionControllerTest,
1077 VisibleEntryWithCommittedAndRendererInitiatedPendingEntry) { 1055 VisibleEntryWithCommittedAndRendererInitiatedPendingEntry) {
1078 [session_controller_ addPendingEntry:GURL("http://www.example.com") 1056 [session_controller_ addPendingItem:GURL("http://www.example.com")
1079 referrer:MakeReferrer("http://www.example.com/a") 1057 referrer:MakeReferrer("http://www.example.com/a")
1080 transition:ui::PAGE_TRANSITION_LINK 1058 transition:ui::PAGE_TRANSITION_LINK
1081 rendererInitiated:YES]; 1059 rendererInitiated:YES];
1082 [session_controller_ commitPendingEntry]; 1060 [session_controller_ commitPendingItem];
1083 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 1061 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
1084 referrer:MakeReferrer("http://www.example.com/b") 1062 referrer:MakeReferrer("http://www.example.com/b")
1085 transition:ui::PAGE_TRANSITION_LINK 1063 transition:ui::PAGE_TRANSITION_LINK
1086 rendererInitiated:YES]; 1064 rendererInitiated:YES];
1087 web::NavigationItem* visible_item = 1065 web::NavigationItem* visible_item =
1088 [[session_controller_ visibleEntry] navigationItem]; 1066 [[session_controller_ visibleEntry] navigationItem];
1089 ASSERT_TRUE(visible_item); 1067 ASSERT_TRUE(visible_item);
1090 EXPECT_EQ("http://www.example.com/", visible_item->GetURL().spec()); 1068 EXPECT_EQ("http://www.example.com/", visible_item->GetURL().spec());
1091 } 1069 }
1092 1070
1093 // Tests that visible URL is not the same as pending URL created via pending 1071 // Tests that visible URL is not the same as pending URL created via pending
1094 // navigation index. 1072 // navigation index.
1095 TEST_F(CRWSessionControllerTest, VisibleEntryWithPendingNavigationIndex) { 1073 TEST_F(CRWSessionControllerTest, VisibleEntryWithPendingNavigationIndex) {
1096 [session_controller_ addPendingEntry:GURL("http://www.example.com") 1074 [session_controller_ addPendingItem:GURL("http://www.example.com")
1097 referrer:MakeReferrer("http://www.example.com/a") 1075 referrer:MakeReferrer("http://www.example.com/a")
1098 transition:ui::PAGE_TRANSITION_LINK 1076 transition:ui::PAGE_TRANSITION_LINK
1099 rendererInitiated:NO]; 1077 rendererInitiated:NO];
1100 [session_controller_ commitPendingEntry]; 1078 [session_controller_ commitPendingItem];
1101 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 1079 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
1102 referrer:MakeReferrer("http://www.example.com/b") 1080 referrer:MakeReferrer("http://www.example.com/b")
1103 transition:ui::PAGE_TRANSITION_LINK 1081 transition:ui::PAGE_TRANSITION_LINK
1104 rendererInitiated:NO]; 1082 rendererInitiated:NO];
1105 [session_controller_ commitPendingEntry]; 1083 [session_controller_ commitPendingItem];
1106 1084
1107 [session_controller_ setPendingEntryIndex:0]; 1085 [session_controller_ setPendingItemIndex:0];
1108 1086
1109 web::NavigationItem* visible_item = 1087 web::NavigationItem* visible_item =
1110 [[session_controller_ visibleEntry] navigationItem]; 1088 [[session_controller_ visibleEntry] navigationItem];
1111 ASSERT_TRUE(visible_item); 1089 ASSERT_TRUE(visible_item);
1112 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec()); 1090 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec());
1113 } 1091 }
1114 1092
1115 // Tests that |-backwardEntries| is empty if all preceding entries are 1093 // Tests that |-backwardEntries| is empty if all preceding entries are
1116 // redirects. 1094 // redirects.
1117 TEST_F(CRWSessionControllerTest, BackwardEntriesForAllRedirects) { 1095 TEST_F(CRWSessionControllerTest, BackwardEntriesForAllRedirects) {
1118 [session_controller_ addPendingEntry:GURL("http://www.example.com") 1096 [session_controller_ addPendingItem:GURL("http://www.example.com")
1119 referrer:MakeReferrer("http://www.example.com/a") 1097 referrer:MakeReferrer("http://www.example.com/a")
1120 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT 1098 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT
1121 rendererInitiated:YES]; 1099 rendererInitiated:YES];
1122 [session_controller_ commitPendingEntry]; 1100 [session_controller_ commitPendingItem];
1123 [session_controller_ addPendingEntry:GURL("http://www.example.com/0") 1101 [session_controller_ addPendingItem:GURL("http://www.example.com/0")
1124 referrer:MakeReferrer("http://www.example.com/b") 1102 referrer:MakeReferrer("http://www.example.com/b")
1125 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT 1103 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT
1126 rendererInitiated:YES]; 1104 rendererInitiated:YES];
1127 [session_controller_ commitPendingEntry]; 1105 [session_controller_ commitPendingItem];
1128 EXPECT_EQ(0U, [session_controller_ backwardEntries].count); 1106 EXPECT_EQ(0U, [session_controller_ backwardEntries].count);
1129 } 1107 }
1130 1108
1131 } // anonymous namespace 1109 } // anonymous namespace
OLDNEW
« no previous file with comments | « ios/web/navigation/crw_session_controller+private_constructors.h ('k') | ios/web/navigation/crw_session_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698