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

Unified Diff: content/public/test/browser_test_utils.h

Issue 2396493002: Improve the TestNavigationManager (Closed)
Patch Set: Addressed Nasko's nit Created 4 years, 2 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/public/test/browser_test_utils.h
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h
index 4d02c44c9e6dae39b4f98780befcbc0443ea7688..0429a1be430f86903eb73c8cd12bae07b78f878f 100644
--- a/content/public/test/browser_test_utils.h
+++ b/content/public/test/browser_test_utils.h
@@ -612,11 +612,11 @@ class TestNavigationManager : public WebContentsObserver {
// Waits until the navigation request is ready to be sent to the network
// stack. Returns false if the request was aborted before starting.
- WARN_UNUSED_RESULT bool WaitForWillStartRequest();
+ WARN_UNUSED_RESULT bool WaitForRequestStart();
// Waits until the navigation response has been sent received. Returns false
// if the request was aborted before getting a response.
- WARN_UNUSED_RESULT bool WaitForWillProcessResponse();
+ WARN_UNUSED_RESULT bool WaitForResponse();
// Waits until the navigation has been finished. Will automatically resume
// navigations paused before this point.
@@ -628,6 +628,13 @@ class TestNavigationManager : public WebContentsObserver {
virtual bool ShouldMonitorNavigation(NavigationHandle* handle);
private:
+ enum class NavigationState {
+ INITIAL = 0,
+ STARTED = 1,
+ RESPONSE = 2,
+ FINISHED = 3,
+ };
+
// WebContentsObserver:
void DidStartNavigation(NavigationHandle* handle) override;
void DidFinishNavigation(NavigationHandle* handle) override;
@@ -640,17 +647,21 @@ class TestNavigationManager : public WebContentsObserver {
// WillProcessResponse.
void OnWillProcessResponse();
- // Resumes the navigation.
- void ResumeNavigation();
+ // Waits for the desired state. Returns false if the desired state cannot be
+ // reached (eg the navigation finishes before reaching this state).
+ bool WaitForDesiredState();
+
+ // Called when the state of the navigation has changed. This will either stop
+ // the message loop if the state specified by the user has been reached, or
+ // resume the navigation if it hasn't been reached yet.
+ void OnNavigationStateChanged();
const GURL url_;
- bool navigation_paused_in_will_start_;
- bool navigation_paused_in_will_process_response_;
NavigationHandle* handle_;
- bool handled_navigation_;
- scoped_refptr<MessageLoopRunner> will_start_loop_runner_;
- scoped_refptr<MessageLoopRunner> will_process_response_loop_runner_;
- scoped_refptr<MessageLoopRunner> did_finish_loop_runner_;
+ bool navigation_paused_;
+ NavigationState current_state_;
+ NavigationState desired_state_;
+ scoped_refptr<MessageLoopRunner> loop_runner_;
base::WeakPtrFactory<TestNavigationManager> weak_factory_;
« no previous file with comments | « content/browser/web_contents/web_contents_impl_browsertest.cc ('k') | content/public/test/browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698