| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ | 5 #ifndef CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ |
| 6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ | 6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ |
| 7 | 7 |
| 8 // A collection of functions designed for use with content_shell based browser | 8 // A collection of functions designed for use with content_shell based browser |
| 9 // tests internal to the content/ module. | 9 // tests internal to the content/ module. |
| 10 // Note: If a function here also works with browser_tests, it should be in | 10 // Note: If a function here also works with browser_tests, it should be in |
| 11 // the content public API. | 11 // the content public API. |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "cc/surfaces/surface_id.h" | 21 #include "cc/surfaces/surface_id.h" |
| 22 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 22 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 23 #include "content/public/browser/web_contents_delegate.h" | 23 #include "content/public/browser/web_contents_delegate.h" |
| 24 #include "content/public/common/file_chooser_params.h" | 24 #include "content/public/common/file_chooser_params.h" |
| 25 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 namespace cc { | |
| 29 class SurfaceManager; | |
| 30 } | |
| 31 | |
| 32 namespace content { | 28 namespace content { |
| 33 | 29 |
| 34 class FrameTreeNode; | 30 class FrameTreeNode; |
| 35 class RenderFrameHost; | 31 class RenderFrameHost; |
| 36 class RenderWidgetHostViewChildFrame; | |
| 37 class Shell; | 32 class Shell; |
| 38 class SiteInstance; | 33 class SiteInstance; |
| 39 class ToRenderFrameHost; | 34 class ToRenderFrameHost; |
| 40 | 35 |
| 41 // Navigates the frame represented by |node| to |url|, blocking until the | 36 // Navigates the frame represented by |node| to |url|, blocking until the |
| 42 // navigation finishes. | 37 // navigation finishes. |
| 43 void NavigateFrameToURL(FrameTreeNode* node, const GURL& url); | 38 void NavigateFrameToURL(FrameTreeNode* node, const GURL& url); |
| 44 | 39 |
| 45 // Sets the DialogManager to proceed by default or not when showing a | 40 // Sets the DialogManager to proceed by default or not when showing a |
| 46 // BeforeUnload dialog. | 41 // BeforeUnload dialog. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void RequestBeginning(net::URLRequest* request, | 106 void RequestBeginning(net::URLRequest* request, |
| 112 content::ResourceContext* resource_context, | 107 content::ResourceContext* resource_context, |
| 113 content::AppCacheService* appcache_service, | 108 content::AppCacheService* appcache_service, |
| 114 ResourceType resource_type, | 109 ResourceType resource_type, |
| 115 std::vector<std::unique_ptr<content::ResourceThrottle>>* | 110 std::vector<std::unique_ptr<content::ResourceThrottle>>* |
| 116 throttles) override; | 111 throttles) override; |
| 117 | 112 |
| 118 GURL url_; | 113 GURL url_; |
| 119 }; | 114 }; |
| 120 | 115 |
| 121 // Helper class to assist with hit testing surfaces in multiple processes. | |
| 122 // WaitForSurfaceReady() will only return after a Surface from |target_view| | |
| 123 // has been composited in the top-level frame's Surface. At that point, | |
| 124 // browser process hit testing to target_view's Surface can succeed. | |
| 125 class SurfaceHitTestReadyNotifier { | |
| 126 public: | |
| 127 SurfaceHitTestReadyNotifier(RenderWidgetHostViewChildFrame* target_view); | |
| 128 ~SurfaceHitTestReadyNotifier() {} | |
| 129 | |
| 130 void WaitForSurfaceReady(); | |
| 131 | |
| 132 private: | |
| 133 bool ContainsSurfaceId(const cc::SurfaceId& container_surface_id); | |
| 134 | |
| 135 cc::SurfaceManager* surface_manager_; | |
| 136 cc::SurfaceId root_surface_id_; | |
| 137 RenderWidgetHostViewChildFrame* target_view_; | |
| 138 | |
| 139 DISALLOW_COPY_AND_ASSIGN(SurfaceHitTestReadyNotifier); | |
| 140 }; | |
| 141 | |
| 142 // Helper for mocking choosing a file via a file dialog. | 116 // Helper for mocking choosing a file via a file dialog. |
| 143 class FileChooserDelegate : public WebContentsDelegate { | 117 class FileChooserDelegate : public WebContentsDelegate { |
| 144 public: | 118 public: |
| 145 // Constructs a WebContentsDelegate that mocks a file dialog. | 119 // Constructs a WebContentsDelegate that mocks a file dialog. |
| 146 // The mocked file dialog will always reply that the user selected |file|. | 120 // The mocked file dialog will always reply that the user selected |file|. |
| 147 FileChooserDelegate(const base::FilePath& file); | 121 FileChooserDelegate(const base::FilePath& file); |
| 148 | 122 |
| 149 // Implementation of WebContentsDelegate::RunFileChooser. | 123 // Implementation of WebContentsDelegate::RunFileChooser. |
| 150 void RunFileChooser(RenderFrameHost* render_frame_host, | 124 void RunFileChooser(RenderFrameHost* render_frame_host, |
| 151 const FileChooserParams& params) override; | 125 const FileChooserParams& params) override; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 175 |
| 202 // The RunLoop used to spin the message loop. | 176 // The RunLoop used to spin the message loop. |
| 203 base::RunLoop run_loop_; | 177 base::RunLoop run_loop_; |
| 204 | 178 |
| 205 DISALLOW_COPY_AND_ASSIGN(UrlCommitObserver); | 179 DISALLOW_COPY_AND_ASSIGN(UrlCommitObserver); |
| 206 }; | 180 }; |
| 207 | 181 |
| 208 } // namespace content | 182 } // namespace content |
| 209 | 183 |
| 210 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ | 184 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ |
| OLD | NEW |