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

Side by Side Diff: content/browser/frame_host/load_progress_tracker_browsertest.cc

Issue 263973003: Move LoadProgressTracker to the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/frame_host/load_progress_tracker.h"
6
7 #include "content/browser/frame_host/frame_tree.h"
8 #include "content/browser/frame_host/frame_tree_node.h"
9 #include "content/browser/frame_host/navigator_delegate.h"
10 #include "content/browser/frame_host/navigator_impl.h"
11 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/shell/browser/shell.h"
16
17 namespace content {
18
19 class LoadProgressTrackerBrowserTest : public ContentBrowserTest {
20 public:
21 LoadProgressTrackerBrowserTest() {}
22
23 LoadProgressTracker* load_progress_tracker() {
24 WebContentsImpl* wc =
25 static_cast<WebContentsImpl*>(shell()->web_contents());
26 FrameTreeNode* root = wc->GetFrameTree()->root();
27 NavigatorImpl* navigator = static_cast<NavigatorImpl*>(root->navigator());
28 return navigator->load_progress_tracker_for_testing();
29 }
30
31 private:
32 DISALLOW_COPY_AND_ASSIGN(LoadProgressTrackerBrowserTest);
33 };
34
35 struct TestNavigatorDelegate : public NavigatorDelegate {
36 virtual void DidChangeLoadProgress(double progress) OVERRIDE {
37 progresses.push_back(progress);
38 }
39
40 std::vector<double> progresses;
41 };
42
43 IN_PROC_BROWSER_TEST_F(LoadProgressTrackerBrowserTest, BasicProgress) {
44 ASSERT_TRUE(test_server()->Start());
45
46 LoadProgressTracker* tracker = load_progress_tracker();
47
48 NavigatorDelegate* old_delegate;
49 TestNavigatorDelegate delegate;
50 old_delegate = tracker->delegate_;
51 tracker->delegate_ = &delegate;
52
53 NavigateToURL(shell(),
54 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
55 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.
56
57 // All updates should be in order ...
58 EXPECT_EQ(delegate.progresses.end(),
59 std::adjacent_find(delegate.progresses.begin(),
60 delegate.progresses.end(),
61 std::greater<double>()));
62
63 // ... and the last one should be 1.0, meaning complete.
64 EXPECT_EQ(1.0, *delegate.progresses.rbegin());
65
66 tracker->delegate_ = old_delegate;
67 }
68
69 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698