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

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

Issue 10483003: Move the rest of the content\test headers that are used by embedders to content\public\test. This w… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_WEB_CONTENTS_TESTER_H_
6 #define CONTENT_TEST_WEB_CONTENTS_TESTER_H_
7 #pragma once
8
9 #include "content/public/common/page_transition_types.h"
10
11 class GURL;
12
13 namespace webkit_glue {
14 struct WebPreferences;
15 }
16
17 namespace content {
18
19 class BrowserContext;
20 struct Referrer;
21 class RenderViewHost;
22 class SiteInstance;
23 class WebContents;
24
25 // This interface allows embedders of content/ to write tests that
26 // depend on a test version of WebContents. This interface can be
27 // retrieved from any content::WebContents that was retrieved via a
28 // call to RenderViewHostTestHarness::GetWebContents() (directly or
29 // indirectly) or constructed explicitly via one of the
30 // WebContentsTester::Create... methods.
31 //
32 // Tests within content/ can directly static_cast WebContents objects
33 // retrieved or created as described above to
34 // content::TestWebContents.
35 //
36 // Design note: We considered two alternatives to this separate test
37 // interface approach:
38 //
39 // a) Define a TestWebContents interface that inherits fromn
40 // WebContents, and have the concrete TestWebContents inherit from it
41 // as well as from content::WebContentsImpl. This approach was
42 // discarded as it introduces a diamond inheritance pattern, which
43 // means we wouldn't be e.g. able to downcast from WebContents to
44 // WebContentsImpl using static_cast.
45 //
46 // b) Define a TestWebContents interface that inherits from
47 // WebContents, and have the concrete TestWebContents implement it,
48 // using composition of a content::WebContentsImpl to implement most
49 // methods. This approach was discarded as there is a fundamental
50 // assumption in content/ that a WebContents* can be downcast to a
51 // WebContentsImpl*, and this wouldn't be true for TestWebContents
52 // objects.
53 class WebContentsTester {
54 public:
55 // Retrieves a WebContentsTester to drive tests of the specified
56 // WebContents. As noted above you need to be sure the 'contents'
57 // object supports testing, i.e. is either created using one of the
58 // Create... functions below, or is retrieved via
59 // RenderViewHostTestHarness::GetWebContents().
60 static WebContentsTester* For(WebContents* contents);
61
62 // Creates a WebContents enabled for testing.
63 static WebContents* CreateTestWebContents(
64 BrowserContext* browser_context,
65 SiteInstance* instance);
66
67 // Deprecated. Creates a WebContents enabled for testing, that
68 // counts the number of times SetFocusToLocationBar is called.
69 static WebContents*
70 CreateTestWebContentsCountSetFocusToLocationBar(
71 BrowserContext* browser_context,
72 SiteInstance* instance);
73
74 // Deprecated. Creates a WebContents enabled for testing, that
75 // counts the number of times Focus is called.
76 static WebContents* CreateTestWebContentsCountFocus(
77 BrowserContext* browser_context,
78 SiteInstance* instance);
79
80 // Simulates the appropriate RenderView (pending if any, current otherwise)
81 // sending a navigate notification for the NavigationController pending entry.
82 virtual void CommitPendingNavigation() = 0;
83
84 // Only implementations retrieved via the deprecated
85 // CreateTestWebContentsFor... methods above will implement this
86 // method. It retrieves the number of times the focus-related calls
87 // in question have been made.
88 virtual int GetNumberOfFocusCalls() = 0;
89
90 virtual content::RenderViewHost* GetPendingRenderViewHost() const = 0;
91
92 // Creates a pending navigation to the given URL with the default parameters
93 // and then commits the load with a page ID one larger than any seen. This
94 // emulates what happens on a new navigation.
95 virtual void NavigateAndCommit(const GURL& url) = 0;
96
97 // Sets the loading state to the given value.
98 virtual void TestSetIsLoading(bool value) = 0;
99
100 // Simulates the current RVH notifying that it has unloaded so that the
101 // pending RVH navigation can proceed.
102 // Does nothing if no cross-navigation is pending.
103 virtual void ProceedWithCrossSiteNavigation() = 0;
104
105 virtual void TestDidNavigate(content::RenderViewHost* render_view_host,
106 int page_id,
107 const GURL& url,
108 content::PageTransition transition) = 0;
109
110 virtual void TestDidNavigateWithReferrer(
111 content::RenderViewHost* render_view_host,
112 int page_id,
113 const GURL& url,
114 const content::Referrer& referrer,
115 content::PageTransition transition) = 0;
116
117 // Promote GetWebkitPrefs to public.
118 virtual webkit_glue::WebPreferences TestGetWebkitPrefs() = 0;
119 };
120
121 } // namespace content
122
123 #endif // CONTENT_TEST_WEB_CONTENTS_TESTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698