linux_aura: Disable the plugin install infobar.
[chromium-blink-merge.git] / content / public / test / content_browser_test_utils.h
blobe0b0690b358cf7e99a8e002ff6279700b3457879
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.
5 #ifndef CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "ui/gfx/native_widget_types.h"
11 #include "url/gurl.h"
13 namespace base {
14 class FilePath;
17 namespace gfx {
18 class Rect;
21 // A collections of functions designed for use with content_shell based browser
22 // tests.
23 // Note: if a function here also works with browser_tests, it should be in
24 // content\public\test\browser_test_utils.h
26 namespace content {
28 class MessageLoopRunner;
29 class RenderViewCreatedObserver;
30 class Shell;
31 class WebContents;
33 // Generate the file path for testing a particular test.
34 // The file for the tests is all located in
35 // content/test/data/dir/<file>
36 // The returned path is FilePath format.
37 base::FilePath GetTestFilePath(const char* dir, const char* file);
39 // Generate the URL for testing a particular test.
40 // HTML for the tests is all located in
41 // test_root_directory/dir/<file>
42 // The returned path is GURL format.
43 GURL GetTestUrl(const char* dir, const char* file);
45 // Navigates the selected tab of |window| to |url|, blocking until the
46 // navigation finishes.
47 void NavigateToURL(Shell* window, const GURL& url);
48 void LoadDataWithBaseURL(Shell* window,
49 const GURL& url,
50 const std::string data,
51 const GURL& base_url);
53 // Navigates the selected tab of |window| to |url|, blocking until the given
54 // number of navigations finishes.
55 void NavigateToURLBlockUntilNavigationsComplete(Shell* window,
56 const GURL& url,
57 int number_of_navigations);
59 // Wait until an application modal dialog is requested.
60 void WaitForAppModalDialog(Shell* window);
62 // Used to wait for a new Shell window to be created. Instantiate this object
63 // before the operation that will create the window.
64 class ShellAddedObserver {
65 public:
66 ShellAddedObserver();
67 ~ShellAddedObserver();
69 // Will run a message loop to wait for the new window if it hasn't been
70 // created since the constructor.
71 Shell* GetShell();
73 private:
74 void ShellCreated(Shell* shell);
76 Shell* shell_;
77 scoped_refptr<MessageLoopRunner> runner_;
79 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver);
82 // Used to wait for a new WebContents to be created. Instantiate this object
83 // before the operation that will create the window.
84 class WebContentsAddedObserver {
85 public:
86 WebContentsAddedObserver();
87 ~WebContentsAddedObserver();
89 // Will run a message loop to wait for the new window if it hasn't been
90 // created since the constructor
91 WebContents* GetWebContents();
93 // Will tell whether RenderViewCreated Callback has invoked
94 bool RenderViewCreatedCalled();
96 base::Callback<void(WebContents*)> web_contents_created_callback_;
98 private:
99 void WebContentsCreated(WebContents* web_contents);
101 // Callback invoked on WebContents creation.
102 WebContents* web_contents_;
103 scoped_ptr<RenderViewCreatedObserver> child_observer_;
104 scoped_refptr<MessageLoopRunner> runner_;
106 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver);
109 #if defined OS_MACOSX
110 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds);
111 #endif
113 } // namespace content
115 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_