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

Side by Side Diff: content/test/navigation_simulator_impl.h

Issue 2682313002: Introduce NavigationSimulator to use in unit tests (Closed)
Patch Set: Added same-page navigation simulation 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_
6 #define CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_
7
8 #include <vector>
9
10 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/common/referrer.h"
12 #include "content/public/test/navigation_simulator.h"
13 #include "ui/base/page_transition_types.h"
14
15 namespace content {
16
17 class NavigationHandleImpl;
18 class TestRenderFrameHost;
19
20 // See NavigationSimulator for a description of what this class does.
21 class NavigationSimulatorImpl : public NavigationSimulator,
22 WebContentsObserver {
23 public:
24 NavigationSimulatorImpl(const GURL& original_url,
25 TestRenderFrameHost* render_frame_host);
26 ~NavigationSimulatorImpl() override;
27
28 // NavigationSimulator:
29 void Start() override;
30 void Redirect(const GURL& new_url) override;
31 void Commit() override;
32 void Fail(int error_code) override;
33 void CommitErrorPage() override;
34 void CommitSamePage() override;
35 void SetTransition(ui::PageTransition transition) override;
36 void SetReferrer(const Referrer& referrer) override;
37
38 // WebContentsObservor:
nasko 2017/02/16 18:47:59 Observer, not Observor.
clamy 2017/02/17 17:34:52 Done.
39 void DidStartNavigation(NavigationHandle* navigation_handle) override;
40 void DidRedirectNavigation(NavigationHandle* navigation_handle) override;
41 void ReadyToCommitNavigation(NavigationHandle* navigation_handle) override;
42 void DidFinishNavigation(NavigationHandle* navigation_handle) override;
43
44 private:
45 void OnWillStartRequest();
46 void OnWillRedirectRequest();
47 void OnWillProcessResponse();
48
49 enum State {
50 INITIALIZATION,
51 STARTED,
52 FAILED,
53 FINISHED,
54 };
55
56 State state_;
57
58 // The renderer associated to this navigation.
nasko 2017/02/16 18:47:59 nit: "associated with"
clamy 2017/02/17 17:34:52 Done.
59 TestRenderFrameHost* render_frame_host_;
60
61 // The NavigationHandle associated to this navigation.
62 NavigationHandleImpl* handle_;
63
64 GURL navigation_url_;
65 Referrer referrer_;
66 ui::PageTransition transition_;
67
68 // These are used to sanity check the content/public/ API calls emitted as
69 // part of the navigation.
70 int num_did_start_navigation_called_;
71 int num_will_start_request_called_;
72 int num_will_redirect_request_called_;
73 int num_did_redirect_navigation_called_;
74 int num_will_process_response_called_;
75 int num_ready_to_commit_called_;
76 int num_did_finish_navigation_called_;
77
78 base::WeakPtrFactory<NavigationSimulatorImpl> weak_factory_;
79 };
80
81 } // namespace content
82
83 #endif // CONTENT_TEST_NAVIGATION_SIMULATOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698