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

Side by Side Diff: content/public/test/test_navigation_observer.h

Issue 884683002: Revert of PlzNavigate: Add a browser test for basic navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/test/test_navigation_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ 5 #ifndef CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_
6 #define CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ 6 #define CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 #include "ui/base/page_transition_types.h"
15 #include "url/gurl.h"
16 14
17 namespace content { 15 namespace content {
18 class RenderFrameHost;
19 class WebContents; 16 class WebContents;
20 struct LoadCommittedDetails; 17 struct LoadCommittedDetails;
21 18
22 // For browser_tests, which run on the UI thread, run a second 19 // For browser_tests, which run on the UI thread, run a second
23 // MessageLoop and quit when the navigation completes loading. 20 // MessageLoop and quit when the navigation completes loading.
24 class TestNavigationObserver { 21 class TestNavigationObserver {
25 public: 22 public:
26 // Create and register a new TestNavigationObserver against the 23 // Create and register a new TestNavigationObserver against the
27 // |web_contents|. 24 // |web_contents|.
28 TestNavigationObserver(WebContents* web_contents, 25 TestNavigationObserver(WebContents* web_contents,
29 int number_of_navigations); 26 int number_of_navigations);
30 // Like above but waits for one navigation. 27 // Like above but waits for one navigation.
31 explicit TestNavigationObserver(WebContents* web_contents); 28 explicit TestNavigationObserver(WebContents* web_contents);
32 29
33 virtual ~TestNavigationObserver(); 30 virtual ~TestNavigationObserver();
34 31
35 // Runs a nested message loop and blocks until the expected number of 32 // Runs a nested message loop and blocks until the expected number of
36 // navigations are complete. 33 // navigations are complete.
37 void Wait(); 34 void Wait();
38 35
39 // Start/stop watching newly created WebContents. 36 // Start/stop watching newly created WebContents.
40 void StartWatchingNewWebContents(); 37 void StartWatchingNewWebContents();
41 void StopWatchingNewWebContents(); 38 void StopWatchingNewWebContents();
42 39
43 const GURL& last_navigation_url() const { return last_navigation_url_; }
44
45 int last_navigation_succeeded() const { return last_navigation_succeeded_; }
46
47 protected: 40 protected:
48 // Register this TestNavigationObserver as an observer of the |web_contents|. 41 // Register this TestNavigationObserver as an observer of the |web_contents|.
49 void RegisterAsObserver(WebContents* web_contents); 42 void RegisterAsObserver(WebContents* web_contents);
50 43
51 private: 44 private:
52 class TestWebContentsObserver; 45 class TestWebContentsObserver;
53 46
54 // Callbacks for WebContents-related events. 47 // Callbacks for WebContents-related events.
55 void OnWebContentsCreated(WebContents* web_contents); 48 void OnWebContentsCreated(WebContents* web_contents);
56 void OnWebContentsDestroyed(TestWebContentsObserver* observer, 49 void OnWebContentsDestroyed(TestWebContentsObserver* observer,
57 WebContents* web_contents); 50 WebContents* web_contents);
58 void OnNavigationEntryCommitted( 51 void OnNavigationEntryCommitted(
59 TestWebContentsObserver* observer, 52 TestWebContentsObserver* observer,
60 WebContents* web_contents, 53 WebContents* web_contents,
61 const LoadCommittedDetails& load_details); 54 const LoadCommittedDetails& load_details);
62 void OnDidAttachInterstitialPage(WebContents* web_contents); 55 void OnDidAttachInterstitialPage(WebContents* web_contents);
63 void OnDidStartLoading(WebContents* web_contents); 56 void OnDidStartLoading(WebContents* web_contents);
64 void OnDidStopLoading(WebContents* web_contents); 57 void OnDidStopLoading(WebContents* web_contents);
65 void OnDidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
66 const GURL& validated_url,
67 bool is_error_page,
68 bool is_iframe_srcdoc);
69 void OnDidFailProvisionalLoad(RenderFrameHost* render_frame_host,
70 const GURL& validated_url,
71 int error_code,
72 const base::string16& error_description);
73 void OnDidCommitProvisionalLoadForFrame(RenderFrameHost* render_frame_host,
74 const GURL& url,
75 ui::PageTransition transition_type);
76 58
77 // If true the navigation has started. 59 // If true the navigation has started.
78 bool navigation_started_; 60 bool navigation_started_;
79 61
80 // The number of navigations that have been completed. 62 // The number of navigations that have been completed.
81 int navigations_completed_; 63 int navigations_completed_;
82 64
83 // The number of navigations to wait for. 65 // The number of navigations to wait for.
84 int number_of_navigations_; 66 int number_of_navigations_;
85 67
86 // The url of the navigation that last committed.
87 GURL last_navigation_url_;
88
89 // True if the last navigation succeeded.
90 bool last_navigation_succeeded_;
91
92 // The MessageLoopRunner used to spin the message loop. 68 // The MessageLoopRunner used to spin the message loop.
93 scoped_refptr<MessageLoopRunner> message_loop_runner_; 69 scoped_refptr<MessageLoopRunner> message_loop_runner_;
94 70
95 // Callback invoked on WebContents creation. 71 // Callback invoked on WebContents creation.
96 base::Callback<void(WebContents*)> web_contents_created_callback_; 72 base::Callback<void(WebContents*)> web_contents_created_callback_;
97 73
98 // Living TestWebContentsObservers created by this observer. 74 // Living TestWebContentsObservers created by this observer.
99 std::set<TestWebContentsObserver*> web_contents_observers_; 75 std::set<TestWebContentsObserver*> web_contents_observers_;
100 76
101 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); 77 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver);
102 }; 78 };
103 79
104 } // namespace content 80 } // namespace content
105 81
106 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_ 82 #endif // CONTENT_PUBLIC_TEST_TEST_NAVIGATION_OBSERVER_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/test/test_navigation_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698