| OLD | NEW |
| 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_PUBLIC_TEST_WEB_CONTENTS_TESTER_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_WEB_CONTENTS_TESTER_H_ |
| 6 #define CONTENT_PUBLIC_TEST_WEB_CONTENTS_TESTER_H_ | 6 #define CONTENT_PUBLIC_TEST_WEB_CONTENTS_TESTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" |
| 10 #include "ui/base/page_transition_types.h" | 11 #include "ui/base/page_transition_types.h" |
| 11 | 12 |
| 12 class GURL; | 13 class GURL; |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 class BrowserContext; | 17 class BrowserContext; |
| 17 class RenderFrameHost; | 18 class RenderFrameHost; |
| 18 class RenderViewHost; | 19 class RenderViewHost; |
| 19 class SiteInstance; | 20 class SiteInstance; |
| 21 class WebContentsImpl; |
| 20 class WebContents; | 22 class WebContents; |
| 21 struct Referrer; | 23 struct Referrer; |
| 22 | 24 |
| 23 // This interface allows embedders of content/ to write tests that depend on a | 25 // This interface allows embedders of content/ to write tests that depend on a |
| 24 // test version of WebContents. This interface can be retrieved from any | 26 // test version of WebContents. This interface can be retrieved from any |
| 25 // WebContents that was retrieved via a call to | 27 // WebContents that was retrieved via a call to |
| 26 // RenderViewHostTestHarness::GetWebContents() (directly or indirectly) or | 28 // RenderViewHostTestHarness::GetWebContents() (directly or indirectly) or |
| 27 // constructed explicitly via CreateTestWebContents. | 29 // constructed explicitly via CreateTestWebContents. |
| 28 // | 30 // |
| 29 // Tests within content/ can directly static_cast WebContents objects retrieved | 31 // Tests within content/ can directly static_cast WebContents objects retrieved |
| (...skipping 20 matching lines...) Expand all Loading... |
| 50 // As noted above you need to be sure the 'contents' object supports testing, | 52 // As noted above you need to be sure the 'contents' object supports testing, |
| 51 // i.e. is either created using one of the Create... functions below, or is | 53 // i.e. is either created using one of the Create... functions below, or is |
| 52 // retrieved via RenderViewHostTestHarness::GetWebContents(). | 54 // retrieved via RenderViewHostTestHarness::GetWebContents(). |
| 53 static WebContentsTester* For(WebContents* contents); | 55 static WebContentsTester* For(WebContents* contents); |
| 54 | 56 |
| 55 // Creates a WebContents enabled for testing. | 57 // Creates a WebContents enabled for testing. |
| 56 static WebContents* CreateTestWebContents( | 58 static WebContents* CreateTestWebContents( |
| 57 BrowserContext* browser_context, | 59 BrowserContext* browser_context, |
| 58 SiteInstance* instance); | 60 SiteInstance* instance); |
| 59 | 61 |
| 62 // Simulates the WebContentsView being shown to, or hidden from, the user. |
| 63 void WasShownForTest(); |
| 64 void WasHiddenForTest(); |
| 65 |
| 60 // Simulates the appropriate RenderView (pending if any, current otherwise) | 66 // Simulates the appropriate RenderView (pending if any, current otherwise) |
| 61 // sending a navigate notification for the NavigationController pending entry. | 67 // sending a navigate notification for the NavigationController pending entry. |
| 62 virtual void CommitPendingNavigation() = 0; | 68 virtual void CommitPendingNavigation() = 0; |
| 63 | 69 |
| 64 // Gets the pending RenderFrameHost, if any, for the main frame. For the | 70 // Gets the pending RenderFrameHost, if any, for the main frame. For the |
| 65 // current RenderFrameHost of the main frame, use WebContents::GetMainFrame(). | 71 // current RenderFrameHost of the main frame, use WebContents::GetMainFrame(). |
| 66 // PlzNavigate: When browser side navigation is enabled it returns the | 72 // PlzNavigate: When browser side navigation is enabled it returns the |
| 67 // speculative RenderFrameHost for the main frame if one exists. | 73 // speculative RenderFrameHost for the main frame if one exists. |
| 68 virtual RenderFrameHost* GetPendingMainFrame() const = 0; | 74 virtual RenderFrameHost* GetPendingMainFrame() const = 0; |
| 69 | 75 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 int page_id, | 119 int page_id, |
| 114 int nav_entry_id, | 120 int nav_entry_id, |
| 115 bool did_create_new_entry, | 121 bool did_create_new_entry, |
| 116 const GURL& url, | 122 const GURL& url, |
| 117 const Referrer& referrer, | 123 const Referrer& referrer, |
| 118 ui::PageTransition transition) = 0; | 124 ui::PageTransition transition) = 0; |
| 119 | 125 |
| 120 // Returns headers that were passed in the previous SaveFrameWithHeaders(...) | 126 // Returns headers that were passed in the previous SaveFrameWithHeaders(...) |
| 121 // call. | 127 // call. |
| 122 virtual const std::string& GetSaveFrameHeaders() = 0; | 128 virtual const std::string& GetSaveFrameHeaders() = 0; |
| 129 |
| 130 protected: |
| 131 WebContentsTester(); |
| 132 |
| 133 private: |
| 134 WebContentsImpl* web_contents(); |
| 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(WebContentsTester); |
| 123 }; | 137 }; |
| 124 | 138 |
| 125 } // namespace content | 139 } // namespace content |
| 126 | 140 |
| 127 #endif // CONTENT_PUBLIC_TEST_WEB_CONTENTS_TESTER_H_ | 141 #endif // CONTENT_PUBLIC_TEST_WEB_CONTENTS_TESTER_H_ |
| OLD | NEW |