OLD | NEW |
---|---|
(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_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ | |
6 #define CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "ui/base/page_transition_types.h" | |
11 | |
12 class GURL; | |
13 | |
14 namespace content { | |
15 | |
16 class RenderFrameHost; | |
17 struct Referrer; | |
18 | |
19 // An interface for simulating a navigation. Currently this only supports | |
20 // renderer-initiated navigations. | |
ncarter (slow)
2017/02/16 23:36:31
Should this comment, or the comment before CreateR
clamy
2017/02/17 17:34:52
Done.
| |
21 // TODO(clamy): support browser-initiated navigations. | |
22 class NavigationSimulator { | |
23 public: | |
24 // Creates a NavigationSimulator that will be used to simulate a | |
25 // renderer-initiated navigation to |original_url| received by | |
nasko
2017/02/16 18:47:59
It isn't immediately clear to me what "received by
clamy
2017/02/17 17:34:52
It's a renderer-initiated navigation, so it's the
| |
26 // |render_frame_host|. | |
27 static std::unique_ptr<NavigationSimulator> CreateRendererInitiated( | |
ncarter (slow)
2017/02/16 23:36:31
If we want a shorter name for this, it could be Fr
clamy
2017/02/17 17:34:52
I'm not sure it's clearer in that case, but I've u
| |
28 const GURL& original_url, | |
29 RenderFrameHost* render_frame_host); | |
30 | |
nasko
2017/02/16 18:47:59
Side node: It will be great to later on have stati
ncarter (slow)
2017/02/16 23:36:31
An alternative to consider would be to support cha
clamy
2017/02/17 17:34:52
I have updated the CL so that methods call any ear
| |
31 virtual ~NavigationSimulator(); | |
32 | |
33 // -------------------------------------------------------------------------- | |
34 | |
35 // The following functions should be used to simulate events happening during | |
36 // a navigation. | |
37 // | |
38 // Example of usage for a successful renderer-initiated navigation: | |
39 // unique_ptr<NavigationSimulator> simulator = | |
40 // NavigationSimulator::CreateRendererInitiated( | |
41 // original_url, render_frame_host); | |
42 // simulator.Start(); | |
ncarter (slow)
2017/02/16 23:36:32
These would be ->'s, not .'s, right?
clamy
2017/02/17 17:34:52
Done.
| |
43 // for (GURL redirect_url : redirects) | |
44 // simulator.Redirect(redirect_url); | |
45 // simulator.Commit(); | |
46 // | |
47 // Example of usage for a failed renderer-initiated navigation: | |
48 // unique_ptr<NavigationSimulator> simulator = | |
49 // NavigationSimulator::CreateRendererInitiated( | |
50 // original_url, render_frame_host); | |
51 // simulator.Start(); | |
52 // for (GURL redirect_url : redirects) | |
53 // simulator.Redirect(redirect_url); | |
54 // simulator.Fail(net_error); | |
ncarter (slow)
2017/02/16 23:36:31
It's not clear what the identifier |net_error| ind
clamy
2017/02/17 17:34:52
Done.
| |
55 // simulator.CommitErrorPage(); | |
56 // | |
57 // Example of usage for a same-page renderer-initiated navigation: | |
58 // unique_ptr<NavigationSimulator> simulator = | |
59 // NavigationSimulator::CreateRendererInitiated( | |
60 // original_url, render_frame_host); | |
61 // simulator.CommitSamePage(); | |
62 | |
63 // Simulates the start of the navigation. | |
64 virtual void Start() {} | |
ncarter (slow)
2017/02/16 23:36:32
I'm curious what makes requiring Start() to be an
clamy
2017/02/17 17:34:52
The goal is for people to create the NavigationSim
| |
65 | |
66 // Simulates a redirect to |new_url| for the navigation. | |
67 virtual void Redirect(const GURL& new_url) {} | |
68 | |
69 // Simulates the commit of the navigation in the RenderFrameHost. | |
70 virtual void Commit() {} | |
71 | |
72 // Simulates the navigation failing with the error code |error_code|. | |
73 virtual void Fail(int error_code) {} | |
74 | |
75 // Simulates the commit of an error page following a navigation failure. | |
76 virtual void CommitErrorPage() {} | |
77 | |
78 // Simulates the commit of a same-page navigation. | |
nasko
2017/02/16 18:47:59
It will be nice to list what navigations are same-
clamy
2017/02/17 17:34:52
Done.
| |
79 virtual void CommitSamePage() {} | |
80 | |
81 // -------------------------------------------------------------------------- | |
82 | |
83 // The following functions are used to specify the parameters of the | |
84 // navigation. Changes should be made before calling |Start|, unless they are | |
85 // meant to apply to a redirect. In that case, they should be made before | |
86 // calling |Redirect|. | |
87 | |
88 // The following parameters are constant during the navigation and may only be | |
89 // specified before calling |Start|. | |
90 virtual void SetTransition(ui::PageTransition transition) {} | |
91 | |
92 // The following parameters can change during redirects. They should be | |
93 // specified before calling |Start| if they need to apply to the navigation to | |
94 // the original url. Otherwise, they should be specified before calling | |
95 // |Redirect|. | |
96 virtual void SetReferrer(const Referrer& referrer) {} | |
97 }; | |
98 | |
99 } // namespace content | |
100 | |
101 #endif // CONTENT_PUBLIC_TEST_NAVIGATION_SIMULATOR_H_ | |
OLD | NEW |