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

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

Powered by Google App Engine
This is Rietveld 408576698