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

Side by Side Diff: content/browser/web_contents/web_contents_impl_browsertest.cc

Issue 1080143003: Move DidStartLoading, DidStopLoading, DidChangeLoadProgress to RFHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Add delegate accessor from Navigator + Re-add scoped trackers Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/browser/web_contents/web_contents_view.h" 9 #include "content/browser/web_contents/web_contents_view.h"
10 #include "content/common/frame_messages.h" 10 #include "content/common/frame_messages.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 public WebContentsObserver { 484 public WebContentsObserver {
485 LoadProgressDelegateAndObserver(Shell* shell) 485 LoadProgressDelegateAndObserver(Shell* shell)
486 : WebContentsObserver(shell->web_contents()), 486 : WebContentsObserver(shell->web_contents()),
487 did_start_loading(false), 487 did_start_loading(false),
488 did_stop_loading(false) { 488 did_stop_loading(false) {
489 web_contents()->SetDelegate(this); 489 web_contents()->SetDelegate(this);
490 } 490 }
491 491
492 // WebContentsDelegate: 492 // WebContentsDelegate:
493 void LoadProgressChanged(WebContents* source, double progress) override { 493 void LoadProgressChanged(WebContents* source, double progress) override {
494 EXPECT_TRUE(did_start_loading); 494 EXPECT_TRUE(did_start_loading);
Fabrice (no longer in Chrome) 2015/04/16 13:55:26 This implies DidStartLoading was called before the
495 EXPECT_FALSE(did_stop_loading); 495 EXPECT_FALSE(did_stop_loading);
496 progresses.push_back(progress); 496 progresses.push_back(progress);
497 } 497 }
498 498
499 // WebContentsObserver: 499 // WebContentsObserver:
500 void DidStartLoading() override { 500 void DidStartLoading() override {
501 EXPECT_FALSE(did_start_loading); 501 EXPECT_FALSE(did_start_loading);
502 EXPECT_EQ(0U, progresses.size()); 502 EXPECT_EQ(0U, progresses.size());
Fabrice (no longer in Chrome) 2015/04/16 13:55:26 This implies there has been no loading progress up
503 EXPECT_FALSE(did_stop_loading); 503 EXPECT_FALSE(did_stop_loading);
504 did_start_loading = true; 504 did_start_loading = true;
505 } 505 }
506 506
507 void DidStopLoading() override { 507 void DidStopLoading() override {
508 EXPECT_TRUE(did_start_loading); 508 EXPECT_TRUE(did_start_loading);
509 EXPECT_GE(progresses.size(), 1U); 509 EXPECT_GE(progresses.size(), 1U);
Fabrice (no longer in Chrome) 2015/04/16 13:55:26 This implies there has been at least one load prog
510 EXPECT_FALSE(did_stop_loading); 510 EXPECT_FALSE(did_stop_loading);
511 did_stop_loading = true; 511 did_stop_loading = true;
512 } 512 }
513 513
514 bool did_start_loading; 514 bool did_start_loading;
515 std::vector<double> progresses; 515 std::vector<double> progresses;
516 bool did_stop_loading; 516 bool did_stop_loading;
517 }; 517 };
518 518
519 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgress) { 519 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgress) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 569 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
570 570
571 // Start at a real page. 571 // Start at a real page.
572 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 572 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
573 573
574 // Simulate a navigation that has not completed. 574 // Simulate a navigation that has not completed.
575 scoped_ptr<LoadProgressDelegateAndObserver> delegate( 575 scoped_ptr<LoadProgressDelegateAndObserver> delegate(
576 new LoadProgressDelegateAndObserver(shell())); 576 new LoadProgressDelegateAndObserver(shell()));
577 RenderFrameHost* main_frame = shell()->web_contents()->GetMainFrame(); 577 RenderFrameHost* main_frame = shell()->web_contents()->GetMainFrame();
578 FrameHostMsg_DidStartLoading start_msg(main_frame->GetRoutingID(), true); 578 FrameHostMsg_DidStartLoading start_msg(main_frame->GetRoutingID(), true);
579 static_cast<WebContentsImpl*>(shell()->web_contents())->OnMessageReceived( 579 static_cast<RenderFrameHostImpl*>(main_frame)->OnMessageReceived(start_msg);
580 main_frame, start_msg);
581 EXPECT_TRUE(delegate->did_start_loading); 580 EXPECT_TRUE(delegate->did_start_loading);
582 EXPECT_FALSE(delegate->did_stop_loading); 581 EXPECT_FALSE(delegate->did_stop_loading);
583 582
584 // Also simulate a DidChangeLoadProgress, but not a DidStopLoading. 583 // Also simulate a DidChangeLoadProgress, but not a DidStopLoading.
585 FrameHostMsg_DidChangeLoadProgress progress_msg(main_frame->GetRoutingID(), 584 FrameHostMsg_DidChangeLoadProgress progress_msg(main_frame->GetRoutingID(),
586 1.0); 585 1.0);
587 static_cast<WebContentsImpl*>(shell()->web_contents())->OnMessageReceived( 586 static_cast<RenderFrameHostImpl*>(main_frame)->OnMessageReceived(
588 main_frame, progress_msg); 587 progress_msg);
589 EXPECT_TRUE(delegate->did_start_loading); 588 EXPECT_TRUE(delegate->did_start_loading);
590 EXPECT_FALSE(delegate->did_stop_loading); 589 EXPECT_FALSE(delegate->did_stop_loading);
591 590
592 // Now interrupt with a new cross-process navigation. 591 // Now interrupt with a new cross-process navigation.
593 TestNavigationObserver tab_observer(shell()->web_contents(), 1); 592 TestNavigationObserver tab_observer(shell()->web_contents(), 1);
594 GURL url(embedded_test_server()->GetURL("foo.com", "/title2.html")); 593 GURL url(embedded_test_server()->GetURL("foo.com", "/title2.html"));
595 shell()->LoadURL(url); 594 shell()->LoadURL(url);
596 tab_observer.Wait(); 595 tab_observer.Wait();
597 EXPECT_EQ(url, shell()->web_contents()->GetLastCommittedURL()); 596 EXPECT_EQ(url, shell()->web_contents()->GetLastCommittedURL());
598 597
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 scoped_ptr<FirstVisuallyNonEmptyPaintObserver> observer( 634 scoped_ptr<FirstVisuallyNonEmptyPaintObserver> observer(
636 new FirstVisuallyNonEmptyPaintObserver(shell())); 635 new FirstVisuallyNonEmptyPaintObserver(shell()));
637 636
638 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 637 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
639 638
640 observer->WaitForDidFirstVisuallyNonEmptyPaint(); 639 observer->WaitForDidFirstVisuallyNonEmptyPaint();
641 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_); 640 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_);
642 } 641 }
643 642
644 } // namespace content 643 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698