| 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 52f48f18fd7330fcf6c6a9f155c2288064e05d9c..7ffd2a3204cc4ffa1a2b6012ff9643b8ccd1b93f 100644
|
| --- a/content/public/test/browser_test_utils.h
|
| +++ b/content/public/test/browser_test_utils.h
|
| @@ -61,6 +61,7 @@ namespace content {
|
|
|
| class BrowserContext;
|
| class MessageLoopRunner;
|
| +class NavigationHandle;
|
| class RenderViewHost;
|
| class RenderWidgetHost;
|
| class WebContents;
|
| @@ -574,6 +575,61 @@ class BrowserTestClipboardScope {
|
| DISALLOW_COPY_AND_ASSIGN(BrowserTestClipboardScope);
|
| };
|
|
|
| +// This class can be used to pause and resume navigations, based on a URL
|
| +// match. Note that it only keeps track of one navigation at a time.
|
| +// Navigations are paused automatically before hitting the network, and are
|
| +// resumed automatically if a Wait method is called for a future event.
|
| +// Note: This class is one time use only! After it successfully tracks a
|
| +// navigation it will ignore all subsequent navigations. Explicitly create
|
| +// mutliple of these managers if you want to pause multiple navigations.
|
| +class TestNavigationManager : public WebContentsObserver {
|
| + public:
|
| + // Monitors notifications within the given frame tree node. Use the other
|
| + // constructor if the manager should monitor all frames, which is equivalent
|
| + // to passing kFrameTreeNodeInvalidId for |frame_tree_node_id|.
|
| + TestNavigationManager(int frame_tree_node_id,
|
| + WebContents* web_contents,
|
| + const GURL& url);
|
| +
|
| + // Monitors any frame in WebContents.
|
| + TestNavigationManager(WebContents* web_contents, const GURL& url);
|
| +
|
| + ~TestNavigationManager() override;
|
| +
|
| + // 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();
|
| +
|
| + // Waits until the navigation has been finished. Will automatically resume
|
| + // navigations paused before this point.
|
| + void WaitForNavigationFinished();
|
| +
|
| + private:
|
| + // WebContentsObserver:
|
| + void DidStartNavigation(NavigationHandle* handle) override;
|
| + void DidFinishNavigation(NavigationHandle* handle) override;
|
| +
|
| + // Called when the NavigationThrottle pauses the navigation in
|
| + // WillStartRequest.
|
| + void OnWillStartRequest();
|
| +
|
| + // Resumes the navigation.
|
| + void ResumeNavigation();
|
| +
|
| + // If this member is not |kFrameTreeNodeInvalidId|, notifications are filtered
|
| + // so only this frame is monitored.
|
| + int filtering_frame_tree_node_id_;
|
| +
|
| + const GURL url_;
|
| + bool navigation_paused_;
|
| + NavigationHandle* handle_;
|
| + bool handled_navigation_;
|
| + scoped_refptr<MessageLoopRunner> will_start_loop_runner_;
|
| + scoped_refptr<MessageLoopRunner> did_finish_loop_runner_;
|
| +
|
| + base::WeakPtrFactory<TestNavigationManager> weak_factory_;
|
| +};
|
| +
|
| } // namespace content
|
|
|
| #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
|
|
|