Index: content/browser/frame_host/load_progress_tracker_browsertest.cc |
diff --git a/content/browser/frame_host/load_progress_tracker_browsertest.cc b/content/browser/frame_host/load_progress_tracker_browsertest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9b57e01908e177f68ed5afb8f8fa41df37fe39a7 |
--- /dev/null |
+++ b/content/browser/frame_host/load_progress_tracker_browsertest.cc |
@@ -0,0 +1,69 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/frame_host/load_progress_tracker.h" |
+ |
+#include "content/browser/frame_host/frame_tree.h" |
+#include "content/browser/frame_host/frame_tree_node.h" |
+#include "content/browser/frame_host/navigator_delegate.h" |
+#include "content/browser/frame_host/navigator_impl.h" |
+#include "content/browser/web_contents/web_contents_impl.h" |
+#include "content/public/test/browser_test_utils.h" |
+#include "content/public/test/content_browser_test.h" |
+#include "content/public/test/content_browser_test_utils.h" |
+#include "content/shell/browser/shell.h" |
+ |
+namespace content { |
+ |
+class LoadProgressTrackerBrowserTest : public ContentBrowserTest { |
+ public: |
+ LoadProgressTrackerBrowserTest() {} |
+ |
+ LoadProgressTracker* load_progress_tracker() { |
+ WebContentsImpl* wc = |
+ static_cast<WebContentsImpl*>(shell()->web_contents()); |
+ FrameTreeNode* root = wc->GetFrameTree()->root(); |
+ NavigatorImpl* navigator = static_cast<NavigatorImpl*>(root->navigator()); |
+ return navigator->load_progress_tracker_for_testing(); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(LoadProgressTrackerBrowserTest); |
+}; |
+ |
+struct TestNavigatorDelegate : public NavigatorDelegate { |
+ virtual void DidChangeLoadProgress(double progress) OVERRIDE { |
+ progresses.push_back(progress); |
+ } |
+ |
+ std::vector<double> progresses; |
+}; |
+ |
+IN_PROC_BROWSER_TEST_F(LoadProgressTrackerBrowserTest, BasicProgress) { |
+ ASSERT_TRUE(test_server()->Start()); |
+ |
+ LoadProgressTracker* tracker = load_progress_tracker(); |
+ |
+ NavigatorDelegate* old_delegate; |
+ TestNavigatorDelegate delegate; |
+ old_delegate = tracker->delegate_; |
+ tracker->delegate_ = &delegate; |
+ |
+ NavigateToURL(shell(), |
+ test_server()->GetURL("files/site_isolation/blank.html")); |
nasko
2014/05/02 22:48:23
It will be nice if this test actually does real cr
Avi (use Gerrit)
2014/05/05 15:15:02
I'm looking at that test and I'm not convinced tha
nasko
2014/05/05 15:30:56
Long term I think we will have such setup, Nick's
|
+ WaitForLoadStop(shell()->web_contents()); |
nasko
2014/05/02 22:48:23
This wait seems redundant, as NavigateToURL will w
Avi (use Gerrit)
2014/05/05 15:15:02
Good point.
|
+ |
+ // All updates should be in order ... |
+ EXPECT_EQ(delegate.progresses.end(), |
+ std::adjacent_find(delegate.progresses.begin(), |
+ delegate.progresses.end(), |
+ std::greater<double>())); |
+ |
+ // ... and the last one should be 1.0, meaning complete. |
+ EXPECT_EQ(1.0, *delegate.progresses.rbegin()); |
+ |
+ tracker->delegate_ = old_delegate; |
+} |
+ |
+} // namespace content |