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 |