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..062360fd73bbce1e8d140d13a8e591f5e280e5f1 |
| --- /dev/null |
| +++ b/content/test/navigation_simulator_impl.h |
| @@ -0,0 +1,83 @@ |
| +// 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, |
| + WebContentsObserver { |
| + public: |
| + 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; |
| + |
| + // WebContentsObservor: |
|
nasko
2017/02/16 18:47:59
Observer, not Observor.
clamy
2017/02/17 17:34:52
Done.
|
| + 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_; |
| + |
| + // The renderer associated to this navigation. |
|
nasko
2017/02/16 18:47:59
nit: "associated with"
clamy
2017/02/17 17:34:52
Done.
|
| + TestRenderFrameHost* render_frame_host_; |
| + |
| + // The NavigationHandle associated to this navigation. |
| + NavigationHandleImpl* handle_; |
| + |
| + GURL navigation_url_; |
| + Referrer referrer_; |
| + ui::PageTransition transition_; |
| + |
| + // These are used to sanity check the content/public/ API calls emitted as |
| + // part of the navigation. |
| + int num_did_start_navigation_called_; |
| + int num_will_start_request_called_; |
| + int num_will_redirect_request_called_; |
| + int num_did_redirect_navigation_called_; |
| + int num_will_process_response_called_; |
| + int num_ready_to_commit_called_; |
| + int num_did_finish_navigation_called_; |
| + |
| + base::WeakPtrFactory<NavigationSimulatorImpl> weak_factory_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_ |