OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ |
6 #define CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ | 6 #define CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // simulator->Start(); | 80 // simulator->Start(); |
81 // for (GURL redirect_url : redirects) | 81 // for (GURL redirect_url : redirects) |
82 // simulator->Redirect(redirect_url); | 82 // simulator->Redirect(redirect_url); |
83 // simulator->Fail(net::ERR_TIMED_OUT); | 83 // simulator->Fail(net::ERR_TIMED_OUT); |
84 // simulator->CommitErrorPage(); | 84 // simulator->CommitErrorPage(); |
85 // | 85 // |
86 // Example of usage for a same-page renderer-initiated navigation: | 86 // Example of usage for a same-page renderer-initiated navigation: |
87 // unique_ptr<NavigationSimulator> simulator = | 87 // unique_ptr<NavigationSimulator> simulator = |
88 // NavigationSimulator::CreateRendererInitiated( | 88 // NavigationSimulator::CreateRendererInitiated( |
89 // original_url, render_frame_host); | 89 // original_url, render_frame_host); |
90 // simulator->CommitSamePage(); | 90 // simulator->CommitSameDocument(); |
91 // | 91 // |
92 // Example of usage for a renderer-initiated navigation which is cancelled by | 92 // Example of usage for a renderer-initiated navigation which is cancelled by |
93 // a throttle upon redirecting. Note that registering the throttle is done | 93 // a throttle upon redirecting. Note that registering the throttle is done |
94 // elsewhere: | 94 // elsewhere: |
95 // unique_ptr<NavigationSimulator> simulator = | 95 // unique_ptr<NavigationSimulator> simulator = |
96 // NavigationSimulator::CreateRendererInitiated( | 96 // NavigationSimulator::CreateRendererInitiated( |
97 // original_url, render_frame_host); | 97 // original_url, render_frame_host); |
98 // simulator->SetTransition(ui::PAGE_TRANSITION_LINK); | 98 // simulator->SetTransition(ui::PAGE_TRANSITION_LINK); |
99 // simulator->Start(); | 99 // simulator->Start(); |
100 // simulator->Redirect(redirect_url); | 100 // simulator->Redirect(redirect_url); |
101 // EXPECT_EQ(NavigationThrottle::CANCEL, | 101 // EXPECT_EQ(NavigationThrottle::CANCEL, |
102 // simulator->GetLastThrottleCheckResult()); | 102 // simulator->GetLastThrottleCheckResult()); |
103 | 103 |
104 // Simulates the start of the navigation. | 104 // Simulates the start of the navigation. |
105 virtual void Start(); | 105 virtual void Start(); |
106 | 106 |
107 // Simulates a redirect to |new_url| for the navigation. | 107 // Simulates a redirect to |new_url| for the navigation. |
108 virtual void Redirect(const GURL& new_url); | 108 virtual void Redirect(const GURL& new_url); |
109 | 109 |
110 // Simulates the commit of the navigation in the RenderFrameHost. | 110 // Simulates the commit of the navigation in the RenderFrameHost. |
111 virtual void Commit(); | 111 virtual void Commit(); |
112 | 112 |
113 // Simulates the navigation failing with the error code |error_code|. | 113 // Simulates the navigation failing with the error code |error_code|. |
114 virtual void Fail(int error_code); | 114 virtual void Fail(int error_code); |
115 | 115 |
116 // Simulates the commit of an error page following a navigation failure. | 116 // Simulates the commit of an error page following a navigation failure. |
117 virtual void CommitErrorPage(); | 117 virtual void CommitErrorPage(); |
118 | 118 |
119 // Simulates the commit of a same-page navigation, ie fragment navigations or | 119 // Simulates the commit of a same-document navigation, ie fragment navigations |
120 // pushState/popState navigations. | 120 // or pushState/popState navigations. |
121 virtual void CommitSamePage(); | 121 virtual void CommitSameDocument(); |
122 | 122 |
123 // -------------------------------------------------------------------------- | 123 // -------------------------------------------------------------------------- |
124 | 124 |
125 // The following functions are used to specify the parameters of the | 125 // The following functions are used to specify the parameters of the |
126 // navigation. Changes should be made before calling |Start|, unless they are | 126 // navigation. Changes should be made before calling |Start|, unless they are |
127 // meant to apply to a redirect. In that case, they should be made before | 127 // meant to apply to a redirect. In that case, they should be made before |
128 // calling |Redirect|. | 128 // calling |Redirect|. |
129 | 129 |
130 // The following parameters are constant during the navigation and may only be | 130 // The following parameters are constant during the navigation and may only be |
131 // specified before calling |Start|. | 131 // specified before calling |Start|. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 // Closure that is set when WaitForThrottleChecksComplete is called. | 201 // Closure that is set when WaitForThrottleChecksComplete is called. |
202 base::Closure throttle_checks_wait_closure_; | 202 base::Closure throttle_checks_wait_closure_; |
203 | 203 |
204 base::WeakPtrFactory<NavigationSimulator> weak_factory_; | 204 base::WeakPtrFactory<NavigationSimulator> weak_factory_; |
205 }; | 205 }; |
206 | 206 |
207 } // namespace content | 207 } // namespace content |
208 | 208 |
209 #endif // CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ | 209 #endif // CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ |
OLD | NEW |