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

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: yep 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
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 a8ada8f80d114ad0a02f25457001671b70f61cb4..12682d5a9264b9c4758f99c7a21e8861ffdcfb5f 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_++;
@@ -176,6 +176,16 @@ class LoadingStateChangedDelegate : public WebContentsDelegate {
int loadingStateToDifferentDocumentCount_;
};
+struct LoadProgressDelegate : public WebContentsDelegate {
+ // WebContentsDelegate:
+ virtual void LoadProgressChanged(WebContents* source,
+ double progress) OVERRIDE {
+ progresses.push_back(progress);
+ }
+
+ std::vector<double> progresses;
+};
+
// See: http://crbug.com/298193
#if defined(OS_WIN)
#define MAYBE_DidStopLoadingDetails DISABLED_DidStopLoadingDetails
@@ -437,5 +447,27 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
EXPECT_EQ(3, delegate->loadingStateToDifferentDocumentCount());
}
+IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgress) {
Charlie Reis 2014/05/07 23:51:00 This doesn't seem to test that DidStartLoading and
Avi (use Gerrit) 2014/05/13 21:08:08 Done.
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ scoped_ptr<LoadProgressDelegate> delegate(new LoadProgressDelegate());
+ shell()->web_contents()->SetDelegate(delegate.get());
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698