Chromium Code Reviews| Index: content/test/navigation_simulator_impl.h |
| diff --git a/content/test/navigation_simulator_impl.h b/content/test/navigation_simulator_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..394d2233d7f62c97713f2889b87dd93aa9bd0b5b |
| --- /dev/null |
| +++ b/content/test/navigation_simulator_impl.h |
| @@ -0,0 +1,91 @@ |
| +// Copyright 2017 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. |
| + |
| +#ifndef CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_ |
| +#define CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_ |
| + |
| +#include <vector> |
| + |
| +#include "content/public/browser/web_contents_observer.h" |
| +#include "content/public/common/referrer.h" |
| +#include "content/public/test/navigation_simulator.h" |
| +#include "ui/base/page_transition_types.h" |
| + |
| +namespace content { |
| + |
| +class NavigationHandleImpl; |
| +class TestRenderFrameHost; |
| + |
| +// See NavigationSimulator for a description of what this class does. |
| +class NavigationSimulatorImpl : public NavigationSimulator, |
|
ncarter (slow)
2017/02/28 23:27:44
It looks like this ought to be preferred over Rend
clamy
2017/03/01 16:18:09
Done.
|
| + WebContentsObserver { |
|
ncarter (slow)
2017/02/28 23:27:44
should be public WebContentsObserver
clamy
2017/03/01 16:18:09
Done.
|
| + public: |
| + static void NavigateAndCommitFromDocument( |
| + const GURL& original_url, |
| + TestRenderFrameHost* render_frame_host); |
| + static void NavigateAndFailFromDocument( |
| + const GURL& original_url, |
| + int net_error_code, |
| + TestRenderFrameHost* render_frame_host); |
| + |
| + NavigationSimulatorImpl(const GURL& original_url, |
| + TestRenderFrameHost* render_frame_host); |
| + ~NavigationSimulatorImpl() override; |
| + |
| + // NavigationSimulator: |
| + void Start() override; |
| + void Redirect(const GURL& new_url) override; |
| + void Commit() override; |
| + void Fail(int error_code) override; |
| + void CommitErrorPage() override; |
| + void CommitSamePage() override; |
| + void SetTransition(ui::PageTransition transition) override; |
| + void SetReferrer(const Referrer& referrer) override; |
| + |
| + // WebContentsObserver: |
| + void DidStartNavigation(NavigationHandle* navigation_handle) override; |
| + void DidRedirectNavigation(NavigationHandle* navigation_handle) override; |
| + void ReadyToCommitNavigation(NavigationHandle* navigation_handle) override; |
| + void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
| + |
| + private: |
| + void OnWillStartRequest(); |
| + void OnWillRedirectRequest(); |
| + void OnWillProcessResponse(); |
| + |
| + enum State { |
| + INITIALIZATION, |
| + STARTED, |
| + FAILED, |
| + FINISHED, |
| + }; |
| + |
| + State state_ = INITIALIZATION; |
| + |
| + // The renderer associated with this navigation. |
| + TestRenderFrameHost* render_frame_host_; |
| + |
| + // The NavigationHandle associated with this navigation. |
| + NavigationHandleImpl* handle_; |
| + |
| + GURL navigation_url_; |
| + Referrer referrer_; |
| + ui::PageTransition transition_ = ui::PAGE_TRANSITION_LINK; |
| + |
| + // These are used to sanity check the content/public/ API calls emitted as |
| + // part of the navigation. |
| + int num_did_start_navigation_called_ = 0; |
| + int num_will_start_request_called_ = 0; |
| + int num_will_redirect_request_called_ = 0; |
| + int num_did_redirect_navigation_called_ = 0; |
| + int num_will_process_response_called_ = 0; |
| + int num_ready_to_commit_called_ = 0; |
| + int num_did_finish_navigation_called_ = 0; |
| + |
| + base::WeakPtrFactory<NavigationSimulatorImpl> weak_factory_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_ |