Index: content/test/content_browser_test_utils_internal.h |
diff --git a/content/test/content_browser_test_utils_internal.h b/content/test/content_browser_test_utils_internal.h |
index 75965383bdc9ca68935c73ac83b9e872be92753a..64b18e4517c23e3aa1a3b14649a9801f731317a7 100644 |
--- a/content/test/content_browser_test_utils_internal.h |
+++ b/content/test/content_browser_test_utils_internal.h |
@@ -13,11 +13,13 @@ |
#include <string> |
#include <vector> |
+#include "base/files/file_path.h" |
#include "base/macros.h" |
#include "base/memory/weak_ptr.h" |
#include "cc/surfaces/surface_id.h" |
#include "content/public/browser/navigation_handle.h" |
#include "content/public/browser/resource_dispatcher_host_delegate.h" |
+#include "content/public/browser/web_contents_delegate.h" |
#include "content/public/browser/web_contents_observer.h" |
#include "url/gurl.h" |
@@ -29,6 +31,7 @@ namespace content { |
class FrameTreeNode; |
class MessageLoopRunner; |
+class RenderFrameHost; |
class RenderWidgetHostViewChildFrame; |
class Shell; |
class SiteInstance; |
@@ -175,6 +178,25 @@ class SurfaceHitTestReadyNotifier { |
DISALLOW_COPY_AND_ASSIGN(SurfaceHitTestReadyNotifier); |
}; |
+// Helper for mocking choosing a file via a file dialog. |
+class FileChooserDelegate : public WebContentsDelegate { |
+ public: |
+ // Constructs a WebContentsDelegate that mocks a file dialog. |
+ // The mocked file dialog will always reply that the user selected |file|. |
+ FileChooserDelegate(const base::FilePath& file); |
+ |
+ // Implementation of WebContentsDelegate::RunFileChooser. |
+ void RunFileChooser(RenderFrameHost* render_frame_host, |
+ const FileChooserParams& params) override; |
+ |
+ // Whether the file dialog was shown. |
+ bool file_chosen() { return file_chosen_; } |
+ |
+ private: |
+ base::FilePath file_; |
+ bool file_chosen_; |
+}; |
+ |
} // namespace content |
#endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_ |