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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_tab_helper_unittest.cc

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" 5 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/captive_portal/captive_portal_service.h" 9 #include "chrome/browser/captive_portal/captive_portal_service.h"
10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h" 10 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // Simulates a successful load of |url|. 85 // Simulates a successful load of |url|.
86 void SimulateSuccess(const GURL& url, 86 void SimulateSuccess(const GURL& url,
87 content::RenderViewHost* render_view_host) { 87 content::RenderViewHost* render_view_host) {
88 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 88 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
89 tab_helper().DidStartProvisionalLoadForFrame( 89 tab_helper().DidStartProvisionalLoadForFrame(
90 1, -1, true, url, false, false, render_view_host); 90 1, -1, true, url, false, false, render_view_host);
91 91
92 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 92 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
93 tab_helper().DidCommitProvisionalLoadForFrame( 93 tab_helper().DidCommitProvisionalLoadForFrame(
94 1, string16(), true, url, content::PAGE_TRANSITION_LINK, 94 1, base::string16(), true, url, content::PAGE_TRANSITION_LINK,
95 render_view_host); 95 render_view_host);
96 } 96 }
97 97
98 // Simulates a connection timeout while requesting |url|. 98 // Simulates a connection timeout while requesting |url|.
99 void SimulateTimeout(const GURL& url, 99 void SimulateTimeout(const GURL& url,
100 content::RenderViewHost* render_view_host) { 100 content::RenderViewHost* render_view_host) {
101 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 101 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
102 tab_helper().DidStartProvisionalLoadForFrame( 102 tab_helper().DidStartProvisionalLoadForFrame(
103 1, -1, true, url, false, false, render_view_host); 103 1, -1, true, url, false, false, render_view_host);
104 104
105 tab_helper().DidFailProvisionalLoad( 105 tab_helper().DidFailProvisionalLoad(
106 1, string16(), true, url, net::ERR_TIMED_OUT, string16(), 106 1, base::string16(), true, url, net::ERR_TIMED_OUT, base::string16(),
107 render_view_host); 107 render_view_host);
108 108
109 // Provisional load starts for the error page. 109 // Provisional load starts for the error page.
110 tab_helper().DidStartProvisionalLoadForFrame( 110 tab_helper().DidStartProvisionalLoadForFrame(
111 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host); 111 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host);
112 112
113 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); 113 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1);
114 tab_helper().DidCommitProvisionalLoadForFrame( 114 tab_helper().DidCommitProvisionalLoadForFrame(
115 1, string16(), true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 115 1, base::string16(), true, GURL(kErrorPageUrl),
116 render_view_host); 116 content::PAGE_TRANSITION_LINK, render_view_host);
117 } 117 }
118 118
119 // Simulates an abort while requesting |url|. 119 // Simulates an abort while requesting |url|.
120 void SimulateAbort(const GURL& url, 120 void SimulateAbort(const GURL& url,
121 content::RenderViewHost* render_view_host, 121 content::RenderViewHost* render_view_host,
122 NavigationType navigation_type) { 122 NavigationType navigation_type) {
123 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 123 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
124 tab_helper().DidStartProvisionalLoadForFrame( 124 tab_helper().DidStartProvisionalLoadForFrame(
125 1, -1, true, url, false, false, render_view_host); 125 1, -1, true, url, false, false, render_view_host);
126 126
127 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 127 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
128 if (navigation_type == kSameProcess) { 128 if (navigation_type == kSameProcess) {
129 tab_helper().DidFailProvisionalLoad( 129 tab_helper().DidFailProvisionalLoad(
130 1, string16(), true, url, net::ERR_ABORTED, string16(), 130 1, base::string16(), true, url, net::ERR_ABORTED, base::string16(),
131 render_view_host); 131 render_view_host);
132 } else { 132 } else {
133 // For interrupted provisional cross-process navigations, the 133 // For interrupted provisional cross-process navigations, the
134 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad 134 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad
135 // notification. 135 // notification.
136 tab_helper().RenderViewDeleted(render_view_host); 136 tab_helper().RenderViewDeleted(render_view_host);
137 } 137 }
138 138
139 // Make sure that above call resulted in abort, for tests that continue 139 // Make sure that above call resulted in abort, for tests that continue
140 // after the abort. 140 // after the abort.
141 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0); 141 EXPECT_CALL(mock_reloader(), OnAbort()).Times(0);
142 } 142 }
143 143
144 // Simulates an abort while loading an error page. 144 // Simulates an abort while loading an error page.
145 void SimulateAbortTimeout(const GURL& url, 145 void SimulateAbortTimeout(const GURL& url,
146 content::RenderViewHost* render_view_host, 146 content::RenderViewHost* render_view_host,
147 NavigationType navigation_type) { 147 NavigationType navigation_type) {
148 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 148 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
149 tab_helper().DidStartProvisionalLoadForFrame( 149 tab_helper().DidStartProvisionalLoadForFrame(
150 1, -1, true, url, false, false, render_view_host); 150 1, -1, true, url, false, false, render_view_host);
151 151
152 tab_helper().DidFailProvisionalLoad( 152 tab_helper().DidFailProvisionalLoad(
153 1, string16(), true, url, net::ERR_TIMED_OUT, string16(), 153 1, base::string16(), true, url, net::ERR_TIMED_OUT, base::string16(),
154 render_view_host); 154 render_view_host);
155 155
156 // Start event for the error page. 156 // Start event for the error page.
157 tab_helper().DidStartProvisionalLoadForFrame( 157 tab_helper().DidStartProvisionalLoadForFrame(
158 1, -1, true, url, true, false, render_view_host); 158 1, -1, true, url, true, false, render_view_host);
159 159
160 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 160 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
161 if (navigation_type == kSameProcess) { 161 if (navigation_type == kSameProcess) {
162 tab_helper().DidFailProvisionalLoad( 162 tab_helper().DidFailProvisionalLoad(
163 1, string16(), true, url, net::ERR_ABORTED, string16(), 163 1, base::string16(), true, url, net::ERR_ABORTED, base::string16(),
164 render_view_host); 164 render_view_host);
165 } else { 165 } else {
166 // For interrupted provisional cross-process navigations, the 166 // For interrupted provisional cross-process navigations, the
167 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad 167 // RenderViewHost is destroyed without sending a DidFailProvisionalLoad
168 // notification. 168 // notification.
169 tab_helper().RenderViewDeleted(render_view_host); 169 tab_helper().RenderViewDeleted(render_view_host);
170 } 170 }
171 171
172 // Make sure that above call resulted in abort, for tests that continue 172 // Make sure that above call resulted in abort, for tests that continue
173 // after the abort. 173 // after the abort.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) { 242 TEST_F(CaptivePortalTabHelperTest, HttpTimeoutLinkDoctor) {
243 SimulateTimeout(GURL(kHttpUrl), render_view_host1()); 243 SimulateTimeout(GURL(kHttpUrl), render_view_host1());
244 244
245 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 245 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
246 // Provisional load starts for the error page. 246 // Provisional load starts for the error page.
247 tab_helper().DidStartProvisionalLoadForFrame( 247 tab_helper().DidStartProvisionalLoadForFrame(
248 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host1()); 248 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host1());
249 249
250 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 250 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
251 tab_helper().DidCommitProvisionalLoadForFrame( 251 tab_helper().DidCommitProvisionalLoadForFrame(
252 1, string16(), true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 252 1, base::string16(), true, GURL(kErrorPageUrl),
253 render_view_host1()); 253 content::PAGE_TRANSITION_LINK, render_view_host1());
254 tab_helper().DidStopLoading(render_view_host1()); 254 tab_helper().DidStopLoading(render_view_host1());
255 } 255 }
256 256
257 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) { 257 TEST_F(CaptivePortalTabHelperTest, HttpsSuccess) {
258 SimulateSuccess(GURL(kHttpsUrl), render_view_host1()); 258 SimulateSuccess(GURL(kHttpsUrl), render_view_host1());
259 tab_helper().DidStopLoading(render_view_host1()); 259 tab_helper().DidStopLoading(render_view_host1());
260 EXPECT_FALSE(tab_helper().IsLoginTab()); 260 EXPECT_FALSE(tab_helper().IsLoginTab());
261 } 261 }
262 262
263 TEST_F(CaptivePortalTabHelperTest, HttpsTimeout) { 263 TEST_F(CaptivePortalTabHelperTest, HttpsTimeout) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // navigating before the old navigation cancels. We generate an abort message 325 // navigating before the old navigation cancels. We generate an abort message
326 // for the old navigation. 326 // for the old navigation.
327 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 327 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
328 EXPECT_CALL(mock_reloader(), 328 EXPECT_CALL(mock_reloader(),
329 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1); 329 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1);
330 tab_helper().DidStartProvisionalLoadForFrame( 330 tab_helper().DidStartProvisionalLoadForFrame(
331 1, -1, true, cross_process_url, false, false, render_view_host2()); 331 1, -1, true, cross_process_url, false, false, render_view_host2());
332 332
333 // The cross-process navigation fails. 333 // The cross-process navigation fails.
334 tab_helper().DidFailProvisionalLoad( 334 tab_helper().DidFailProvisionalLoad(
335 1, string16(), true, cross_process_url, net::ERR_FAILED, string16(), 335 1, base::string16(), true, cross_process_url, net::ERR_FAILED,
336 render_view_host2()); 336 base::string16(), render_view_host2());
337 337
338 // The same-site navigation finally is aborted. 338 // The same-site navigation finally is aborted.
339 tab_helper().DidFailProvisionalLoad( 339 tab_helper().DidFailProvisionalLoad(
340 1, string16(), true, same_site_url, net::ERR_ABORTED, string16(), 340 1, base::string16(), true, same_site_url, net::ERR_ABORTED,
341 render_view_host1()); 341 base::string16(), render_view_host1());
342 342
343 // The provisional load starts for the error page for the cross-process 343 // The provisional load starts for the error page for the cross-process
344 // navigation. 344 // navigation.
345 tab_helper().DidStartProvisionalLoadForFrame( 345 tab_helper().DidStartProvisionalLoadForFrame(
346 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host2()); 346 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host2());
347 347
348 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_FAILED)).Times(1); 348 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_FAILED)).Times(1);
349 tab_helper().DidCommitProvisionalLoadForFrame( 349 tab_helper().DidCommitProvisionalLoadForFrame(
350 1, string16(), true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_TYPED, 350 1, base::string16(), true, GURL(kErrorPageUrl),
351 render_view_host2()); 351 content::PAGE_TRANSITION_TYPED, render_view_host2());
352 } 352 }
353 353
354 // Similar to the above test, except the original RenderViewHost manages to 354 // Similar to the above test, except the original RenderViewHost manages to
355 // commit before its navigation is aborted. 355 // commit before its navigation is aborted.
356 TEST_F(CaptivePortalTabHelperTest, UnexpectedCommit) { 356 TEST_F(CaptivePortalTabHelperTest, UnexpectedCommit) {
357 GURL same_site_url = GURL(kHttpUrl); 357 GURL same_site_url = GURL(kHttpUrl);
358 GURL cross_process_url = GURL(kHttpsUrl2); 358 GURL cross_process_url = GURL(kHttpsUrl2);
359 359
360 // A same-site load for the original RenderViewHost starts. 360 // A same-site load for the original RenderViewHost starts.
361 EXPECT_CALL(mock_reloader(), 361 EXPECT_CALL(mock_reloader(),
362 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1); 362 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1);
363 tab_helper().DidStartProvisionalLoadForFrame( 363 tab_helper().DidStartProvisionalLoadForFrame(
364 1, -1, true, same_site_url, false, false, render_view_host1()); 364 1, -1, true, same_site_url, false, false, render_view_host1());
365 365
366 // It's unexpectedly interrupted by a cross-process navigation, which starts 366 // It's unexpectedly interrupted by a cross-process navigation, which starts
367 // navigating before the old navigation cancels. We generate an abort message 367 // navigating before the old navigation cancels. We generate an abort message
368 // for the old navigation. 368 // for the old navigation.
369 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 369 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
370 EXPECT_CALL(mock_reloader(), 370 EXPECT_CALL(mock_reloader(),
371 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1); 371 OnLoadStart(cross_process_url.SchemeIsSecure())).Times(1);
372 tab_helper().DidStartProvisionalLoadForFrame( 372 tab_helper().DidStartProvisionalLoadForFrame(
373 1, -1, true, cross_process_url, false, false, render_view_host2()); 373 1, -1, true, cross_process_url, false, false, render_view_host2());
374 374
375 // The cross-process navigation fails. 375 // The cross-process navigation fails.
376 tab_helper().DidFailProvisionalLoad( 376 tab_helper().DidFailProvisionalLoad(
377 1, string16(), true, cross_process_url, net::ERR_FAILED, string16(), 377 1, base::string16(), true, cross_process_url, net::ERR_FAILED,
378 base::string16(),
378 render_view_host2()); 379 render_view_host2());
379 380
380 // The same-site navigation succeeds. 381 // The same-site navigation succeeds.
381 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1); 382 EXPECT_CALL(mock_reloader(), OnAbort()).Times(1);
382 EXPECT_CALL(mock_reloader(), 383 EXPECT_CALL(mock_reloader(),
383 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1); 384 OnLoadStart(same_site_url.SchemeIsSecure())).Times(1);
384 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 385 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
385 tab_helper().DidCommitProvisionalLoadForFrame( 386 tab_helper().DidCommitProvisionalLoadForFrame(
386 1, string16(), true, same_site_url, content::PAGE_TRANSITION_LINK, 387 1, base::string16(), true, same_site_url, content::PAGE_TRANSITION_LINK,
387 render_view_host1()); 388 render_view_host1());
388 } 389 }
389 390
390 // Simulates navigations for a number of subframes, and makes sure no 391 // Simulates navigations for a number of subframes, and makes sure no
391 // CaptivePortalTabHelper function is called. 392 // CaptivePortalTabHelper function is called.
392 TEST_F(CaptivePortalTabHelperTest, HttpsSubframe) { 393 TEST_F(CaptivePortalTabHelperTest, HttpsSubframe) {
393 GURL url = GURL(kHttpsUrl); 394 GURL url = GURL(kHttpsUrl);
394 // Normal load. 395 // Normal load.
395 tab_helper().DidStartProvisionalLoadForFrame( 396 tab_helper().DidStartProvisionalLoadForFrame(
396 1, -1, false, url, false, false, render_view_host1()); 397 1, -1, false, url, false, false, render_view_host1());
397 tab_helper().DidCommitProvisionalLoadForFrame( 398 tab_helper().DidCommitProvisionalLoadForFrame(
398 1, string16(), false, url, content::PAGE_TRANSITION_LINK, 399 1, base::string16(), false, url, content::PAGE_TRANSITION_LINK,
399 render_view_host1()); 400 render_view_host1());
400 401
401 // Timeout. 402 // Timeout.
402 tab_helper().DidStartProvisionalLoadForFrame( 403 tab_helper().DidStartProvisionalLoadForFrame(
403 2, -1, false, url, false, false, render_view_host1()); 404 2, -1, false, url, false, false, render_view_host1());
404 tab_helper().DidFailProvisionalLoad( 405 tab_helper().DidFailProvisionalLoad(
405 2, string16(), false, url, net::ERR_TIMED_OUT, string16(), 406 2, base::string16(), false, url, net::ERR_TIMED_OUT, base::string16(),
406 render_view_host1()); 407 render_view_host1());
407 tab_helper().DidStartProvisionalLoadForFrame( 408 tab_helper().DidStartProvisionalLoadForFrame(
408 2, -1, false, url, true, false, render_view_host1()); 409 2, -1, false, url, true, false, render_view_host1());
409 tab_helper().DidFailProvisionalLoad( 410 tab_helper().DidFailProvisionalLoad(
410 2, string16(), false, url, net::ERR_ABORTED, string16(), 411 2, base::string16(), false, url, net::ERR_ABORTED, base::string16(),
411 render_view_host1()); 412 render_view_host1());
412 413
413 // Abort. 414 // Abort.
414 tab_helper().DidStartProvisionalLoadForFrame( 415 tab_helper().DidStartProvisionalLoadForFrame(
415 3, -1, false, url, false, false, render_view_host1()); 416 3, -1, false, url, false, false, render_view_host1());
416 tab_helper().DidFailProvisionalLoad( 417 tab_helper().DidFailProvisionalLoad(
417 3, string16(), false, url, net::ERR_ABORTED, string16(), 418 3, base::string16(), false, url, net::ERR_ABORTED, base::string16(),
418 render_view_host1()); 419 render_view_host1());
419 } 420 }
420 421
421 // Simulates a subframe erroring out at the same time as a provisional load, 422 // Simulates a subframe erroring out at the same time as a provisional load,
422 // but with a different error code. Make sure the TabHelper sees the correct 423 // but with a different error code. Make sure the TabHelper sees the correct
423 // error. 424 // error.
424 TEST_F(CaptivePortalTabHelperTest, HttpsSubframeParallelError) { 425 TEST_F(CaptivePortalTabHelperTest, HttpsSubframeParallelError) {
425 // URL used by both frames. 426 // URL used by both frames.
426 GURL url = GURL(kHttpsUrl); 427 GURL url = GURL(kHttpsUrl);
427 428
428 int frame_id = 2; 429 int frame_id = 2;
429 int subframe_id = 1; 430 int subframe_id = 1;
430 431
431 // Loads start. 432 // Loads start.
432 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1); 433 EXPECT_CALL(mock_reloader(), OnLoadStart(url.SchemeIsSecure())).Times(1);
433 tab_helper().DidStartProvisionalLoadForFrame( 434 tab_helper().DidStartProvisionalLoadForFrame(
434 frame_id, -1, true, url, false, false, render_view_host1()); 435 frame_id, -1, true, url, false, false, render_view_host1());
435 tab_helper().DidStartProvisionalLoadForFrame( 436 tab_helper().DidStartProvisionalLoadForFrame(
436 subframe_id, frame_id, false, url, false, false, render_view_host1()); 437 subframe_id, frame_id, false, url, false, false, render_view_host1());
437 438
438 // Loads return errors. 439 // Loads return errors.
439 tab_helper().DidFailProvisionalLoad( 440 tab_helper().DidFailProvisionalLoad(
440 frame_id, string16(), true, url, net::ERR_UNEXPECTED, string16(), 441 frame_id, base::string16(), true, url, net::ERR_UNEXPECTED,
441 render_view_host1()); 442 base::string16(), render_view_host1());
442 tab_helper().DidFailProvisionalLoad( 443 tab_helper().DidFailProvisionalLoad(
443 subframe_id, string16(), false, url, net::ERR_TIMED_OUT, string16(), 444 subframe_id, base::string16(), false, url, net::ERR_TIMED_OUT,
444 render_view_host1()); 445 base::string16(), render_view_host1());
445 446
446 // Provisional load starts for the error pages. 447 // Provisional load starts for the error pages.
447 tab_helper().DidStartProvisionalLoadForFrame( 448 tab_helper().DidStartProvisionalLoadForFrame(
448 frame_id, -1, true, url, true, false, render_view_host1()); 449 frame_id, -1, true, url, true, false, render_view_host1());
449 tab_helper().DidStartProvisionalLoadForFrame( 450 tab_helper().DidStartProvisionalLoadForFrame(
450 subframe_id, frame_id, false, url, true, false, render_view_host1()); 451 subframe_id, frame_id, false, url, true, false, render_view_host1());
451 452
452 // Error page load finishes. 453 // Error page load finishes.
453 tab_helper().DidCommitProvisionalLoadForFrame( 454 tab_helper().DidCommitProvisionalLoadForFrame(
454 subframe_id, string16(), false, url, 455 subframe_id, base::string16(), false, url,
455 content::PAGE_TRANSITION_AUTO_SUBFRAME, render_view_host1()); 456 content::PAGE_TRANSITION_AUTO_SUBFRAME, render_view_host1());
456 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1); 457 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_UNEXPECTED)).Times(1);
457 tab_helper().DidCommitProvisionalLoadForFrame( 458 tab_helper().DidCommitProvisionalLoadForFrame(
458 frame_id, string16(), true, url, content::PAGE_TRANSITION_LINK, 459 frame_id, base::string16(), true, url, content::PAGE_TRANSITION_LINK,
459 render_view_host1()); 460 render_view_host1());
460 } 461 }
461 462
462 // Simulates an HTTP to HTTPS redirect, which then times out. 463 // Simulates an HTTP to HTTPS redirect, which then times out.
463 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) { 464 TEST_F(CaptivePortalTabHelperTest, HttpToHttpsRedirectTimeout) {
464 GURL http_url(kHttpUrl); 465 GURL http_url(kHttpUrl);
465 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 466 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
466 tab_helper().DidStartProvisionalLoadForFrame( 467 tab_helper().DidStartProvisionalLoadForFrame(
467 1, -1, true, http_url, false, false, render_view_host1()); 468 1, -1, true, http_url, false, false, render_view_host1());
468 469
469 GURL https_url(kHttpsUrl); 470 GURL https_url(kHttpsUrl);
470 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1); 471 EXPECT_CALL(mock_reloader(), OnRedirect(true)).Times(1);
471 OnRedirect(ResourceType::MAIN_FRAME, https_url, 472 OnRedirect(ResourceType::MAIN_FRAME, https_url,
472 render_view_host1()->GetProcess()->GetID()); 473 render_view_host1()->GetProcess()->GetID());
473 474
474 tab_helper().DidFailProvisionalLoad( 475 tab_helper().DidFailProvisionalLoad(
475 1, string16(), true, https_url, net::ERR_TIMED_OUT, string16(), 476 1, base::string16(), true, https_url, net::ERR_TIMED_OUT,
476 render_view_host1()); 477 base::string16(), render_view_host1());
477 478
478 // Provisional load starts for the error page. 479 // Provisional load starts for the error page.
479 tab_helper().DidStartProvisionalLoadForFrame( 480 tab_helper().DidStartProvisionalLoadForFrame(
480 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host1()); 481 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host1());
481 482
482 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); 483 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1);
483 tab_helper().DidCommitProvisionalLoadForFrame( 484 tab_helper().DidCommitProvisionalLoadForFrame(
484 1, string16(), true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 485 1, base::string16(), true, GURL(kErrorPageUrl),
485 render_view_host1()); 486 content::PAGE_TRANSITION_LINK, render_view_host1());
486 } 487 }
487 488
488 // Simulates an HTTPS to HTTP redirect. 489 // Simulates an HTTPS to HTTP redirect.
489 TEST_F(CaptivePortalTabHelperTest, HttpsToHttpRedirect) { 490 TEST_F(CaptivePortalTabHelperTest, HttpsToHttpRedirect) {
490 GURL https_url(kHttpsUrl); 491 GURL https_url(kHttpsUrl);
491 EXPECT_CALL(mock_reloader(), 492 EXPECT_CALL(mock_reloader(),
492 OnLoadStart(https_url.SchemeIsSecure())).Times(1); 493 OnLoadStart(https_url.SchemeIsSecure())).Times(1);
493 tab_helper().DidStartProvisionalLoadForFrame(1, -1, true, https_url, false, 494 tab_helper().DidStartProvisionalLoadForFrame(1, -1, true, https_url, false,
494 false, render_view_host1()); 495 false, render_view_host1());
495 496
496 GURL http_url(kHttpUrl); 497 GURL http_url(kHttpUrl);
497 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); 498 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1);
498 OnRedirect(ResourceType::MAIN_FRAME, http_url, 499 OnRedirect(ResourceType::MAIN_FRAME, http_url,
499 render_view_host1()->GetProcess()->GetID()); 500 render_view_host1()->GetProcess()->GetID());
500 501
501 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 502 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
502 tab_helper().DidCommitProvisionalLoadForFrame( 503 tab_helper().DidCommitProvisionalLoadForFrame(
503 1, string16(), true, http_url, content::PAGE_TRANSITION_LINK, 504 1, base::string16(), true, http_url, content::PAGE_TRANSITION_LINK,
504 render_view_host1()); 505 render_view_host1());
505 } 506 }
506 507
507 // Simulates an HTTPS to HTTPS redirect. 508 // Simulates an HTTPS to HTTPS redirect.
508 TEST_F(CaptivePortalTabHelperTest, HttpToHttpRedirect) { 509 TEST_F(CaptivePortalTabHelperTest, HttpToHttpRedirect) {
509 GURL http_url(kHttpUrl); 510 GURL http_url(kHttpUrl);
510 EXPECT_CALL(mock_reloader(), 511 EXPECT_CALL(mock_reloader(),
511 OnLoadStart(http_url.SchemeIsSecure())).Times(1); 512 OnLoadStart(http_url.SchemeIsSecure())).Times(1);
512 tab_helper().DidStartProvisionalLoadForFrame( 513 tab_helper().DidStartProvisionalLoadForFrame(
513 1, -1, true, http_url, false, false, render_view_host1()); 514 1, -1, true, http_url, false, false, render_view_host1());
514 515
515 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1); 516 EXPECT_CALL(mock_reloader(), OnRedirect(http_url.SchemeIsSecure())).Times(1);
516 OnRedirect(ResourceType::MAIN_FRAME, http_url, 517 OnRedirect(ResourceType::MAIN_FRAME, http_url,
517 render_view_host1()->GetProcess()->GetID()); 518 render_view_host1()->GetProcess()->GetID());
518 519
519 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 520 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
520 tab_helper().DidCommitProvisionalLoadForFrame( 521 tab_helper().DidCommitProvisionalLoadForFrame(
521 1, string16(), true, http_url, content::PAGE_TRANSITION_LINK, 522 1, base::string16(), true, http_url, content::PAGE_TRANSITION_LINK,
522 render_view_host1()); 523 render_view_host1());
523 } 524 }
524 525
525 // Simulates redirect of a subframe. 526 // Simulates redirect of a subframe.
526 TEST_F(CaptivePortalTabHelperTest, SubframeRedirect) { 527 TEST_F(CaptivePortalTabHelperTest, SubframeRedirect) {
527 GURL http_url(kHttpUrl); 528 GURL http_url(kHttpUrl);
528 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 529 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
529 tab_helper().DidStartProvisionalLoadForFrame( 530 tab_helper().DidStartProvisionalLoadForFrame(
530 1, -1, true, http_url, false, false, render_view_host1()); 531 1, -1, true, http_url, false, false, render_view_host1());
531 532
532 GURL https_url(kHttpsUrl); 533 GURL https_url(kHttpsUrl);
533 OnRedirect(ResourceType::SUB_FRAME, https_url, 534 OnRedirect(ResourceType::SUB_FRAME, https_url,
534 render_view_host1()->GetProcess()->GetID()); 535 render_view_host1()->GetProcess()->GetID());
535 536
536 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1); 537 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::OK)).Times(1);
537 tab_helper().DidCommitProvisionalLoadForFrame( 538 tab_helper().DidCommitProvisionalLoadForFrame(
538 1, string16(), true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 539 1, base::string16(), true, GURL(kErrorPageUrl),
539 render_view_host1()); 540 content::PAGE_TRANSITION_LINK, render_view_host1());
540 } 541 }
541 542
542 // Simulates a redirect, for another RenderViewHost. 543 // Simulates a redirect, for another RenderViewHost.
543 TEST_F(CaptivePortalTabHelperTest, OtherRenderViewHostRedirect) { 544 TEST_F(CaptivePortalTabHelperTest, OtherRenderViewHostRedirect) {
544 GURL http_url(kHttpUrl); 545 GURL http_url(kHttpUrl);
545 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1); 546 EXPECT_CALL(mock_reloader(), OnLoadStart(false)).Times(1);
546 tab_helper().DidStartProvisionalLoadForFrame( 547 tab_helper().DidStartProvisionalLoadForFrame(
547 1, -1, true, http_url, false, false, render_view_host1()); 548 1, -1, true, http_url, false, false, render_view_host1());
548 549
549 // Another RenderViewHost sees a redirect. None of the reloader's functions 550 // Another RenderViewHost sees a redirect. None of the reloader's functions
550 // should be called. 551 // should be called.
551 GURL https_url(kHttpsUrl); 552 GURL https_url(kHttpsUrl);
552 OnRedirect(ResourceType::MAIN_FRAME, https_url, 553 OnRedirect(ResourceType::MAIN_FRAME, https_url,
553 render_view_host2()->GetProcess()->GetID()); 554 render_view_host2()->GetProcess()->GetID());
554 555
555 tab_helper().DidFailProvisionalLoad( 556 tab_helper().DidFailProvisionalLoad(
556 1, string16(), true, https_url, net::ERR_TIMED_OUT, string16(), 557 1, base::string16(), true, https_url, net::ERR_TIMED_OUT,
557 render_view_host1()); 558 base::string16(), render_view_host1());
558 559
559 // Provisional load starts for the error page. 560 // Provisional load starts for the error page.
560 tab_helper().DidStartProvisionalLoadForFrame( 561 tab_helper().DidStartProvisionalLoadForFrame(
561 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host1()); 562 1, -1, true, GURL(kErrorPageUrl), true, false, render_view_host1());
562 563
563 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1); 564 EXPECT_CALL(mock_reloader(), OnLoadCommitted(net::ERR_TIMED_OUT)).Times(1);
564 tab_helper().DidCommitProvisionalLoadForFrame( 565 tab_helper().DidCommitProvisionalLoadForFrame(
565 1, string16(), true, GURL(kErrorPageUrl), content::PAGE_TRANSITION_LINK, 566 1, base::string16(), true, GURL(kErrorPageUrl),
566 render_view_host1()); 567 content::PAGE_TRANSITION_LINK, render_view_host1());
567 } 568 }
568 569
569 TEST_F(CaptivePortalTabHelperTest, LoginTabLogin) { 570 TEST_F(CaptivePortalTabHelperTest, LoginTabLogin) {
570 EXPECT_FALSE(tab_helper().IsLoginTab()); 571 EXPECT_FALSE(tab_helper().IsLoginTab());
571 SetIsLoginTab(); 572 SetIsLoginTab();
572 EXPECT_TRUE(tab_helper().IsLoginTab()); 573 EXPECT_TRUE(tab_helper().IsLoginTab());
573 574
574 ObservePortalResult(RESULT_INTERNET_CONNECTED, RESULT_INTERNET_CONNECTED); 575 ObservePortalResult(RESULT_INTERNET_CONNECTED, RESULT_INTERNET_CONNECTED);
575 EXPECT_FALSE(tab_helper().IsLoginTab()); 576 EXPECT_FALSE(tab_helper().IsLoginTab());
576 } 577 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 EXPECT_FALSE(tab_helper().IsLoginTab()); 610 EXPECT_FALSE(tab_helper().IsLoginTab());
610 611
611 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE); 612 ObservePortalResult(RESULT_BEHIND_CAPTIVE_PORTAL, RESULT_NO_RESPONSE);
612 EXPECT_FALSE(tab_helper().IsLoginTab()); 613 EXPECT_FALSE(tab_helper().IsLoginTab());
613 614
614 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED); 615 ObservePortalResult(RESULT_NO_RESPONSE, RESULT_INTERNET_CONNECTED);
615 EXPECT_FALSE(tab_helper().IsLoginTab()); 616 EXPECT_FALSE(tab_helper().IsLoginTab());
616 } 617 }
617 618
618 } // namespace captive_portal 619 } // namespace captive_portal
OLDNEW
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_tab_helper.cc ('k') | chrome/browser/certificate_manager_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698