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

Unified Diff: content/browser/web_contents/web_contents_impl_browsertest.cc

Issue 263973003: Move LoadProgressTracker to the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl_browsertest.cc
diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc
index 2a09fe216f1f134087def75d6edf02e279f0a5e6..64c209321285a4da50f0a869fc6102033eeec6b3 100644
--- a/content/browser/web_contents/web_contents_impl_browsertest.cc
+++ b/content/browser/web_contents/web_contents_impl_browsertest.cc
@@ -158,7 +158,7 @@ class LoadingStateChangedDelegate : public WebContentsDelegate {
, loadingStateToDifferentDocumentCount_(0) {
}
- // WebContentsDelgate:
+ // WebContentsDelegate:
virtual void LoadingStateChanged(WebContents* contents,
bool to_different_document) OVERRIDE {
loadingStateChangedCount_++;
@@ -456,5 +456,64 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
EXPECT_TRUE(new_web_contents_observer.RenderViewCreatedCalled());
}
+struct LoadProgressDelegateAndObserver : public WebContentsDelegate,
+ public WebContentsObserver {
+ LoadProgressDelegateAndObserver(Shell* shell)
+ : WebContentsObserver(shell->web_contents()),
+ did_start_loading(false),
+ did_stop_loading(false) {
+ web_contents()->SetDelegate(this);
+ }
+
+ // WebContentsDelegate:
+ virtual void LoadProgressChanged(WebContents* source,
+ double progress) OVERRIDE {
+ EXPECT_TRUE(did_start_loading);
+ EXPECT_FALSE(did_stop_loading);
+ progresses.push_back(progress);
+ }
+
+ // WebContentsObserver:
+ virtual void DidStartLoading(RenderViewHost* render_view_host) OVERRIDE {
+ EXPECT_FALSE(did_start_loading);
+ EXPECT_EQ(0U, progresses.size());
+ EXPECT_FALSE(did_stop_loading);
+ did_start_loading = true;
+ }
+
+ virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE {
+ EXPECT_TRUE(did_start_loading);
+ EXPECT_GE(progresses.size(), 1U);
+ EXPECT_FALSE(did_stop_loading);
+ did_stop_loading = true;
+ }
+
+ bool did_start_loading;
+ std::vector<double> progresses;
+ bool did_stop_loading;
+};
+
+IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgress) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ scoped_ptr<LoadProgressDelegateAndObserver> delegate(
+ new LoadProgressDelegateAndObserver(shell()));
+
+ NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
+
+ const std::vector<double>& progresses = delegate->progresses;
+ // All updates should be in order ...
+ if (std::adjacent_find(progresses.begin(),
+ progresses.end(),
+ std::greater<double>()) != progresses.end()) {
+ ADD_FAILURE() << "Progress values should be in order: "
+ << ::testing::PrintToString(progresses);
+ }
+
+ // ... and the last one should be 1.0, meaning complete.
+ ASSERT_GE(progresses.size(), 1U)
+ << "There should be at least one progress update";
+ EXPECT_EQ(1.0, *progresses.rbegin());
+}
+
} // namespace content
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698