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

Unified Diff: content/test/navigation_simulator_impl.h

Issue 2682313002: Introduce NavigationSimulator to use in unit tests (Closed)
Patch Set: Fixed issue with OOPIF Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/BUILD.gn ('k') | content/test/navigation_simulator_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « content/test/BUILD.gn ('k') | content/test/navigation_simulator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698