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/memory/ref_counted.h"
9 #include "ui/gfx/native_widget_types.h"
20 // A collections of functions designed for use with content_shell based browser
22 // Note: if a function here also works with browser_tests, it should be in
23 // content\public\test\browser_test_utils.h
27 class MessageLoopRunner
;
30 // Generate the file path for testing a particular test.
31 // The file for the tests is all located in
32 // content/test/data/dir/<file>
33 // The returned path is FilePath format.
34 base::FilePath
GetTestFilePath(const char* dir
, const char* file
);
36 // Generate the URL for testing a particular test.
37 // HTML for the tests is all located in
38 // test_root_directory/dir/<file>
39 // The returned path is GURL format.
40 GURL
GetTestUrl(const char* dir
, const char* file
);
42 // Navigates the selected tab of |window| to |url|, blocking until the
43 // navigation finishes.
44 void NavigateToURL(Shell
* window
, const GURL
& url
);
45 void LoadDataWithBaseURL(Shell
* window
,
47 const std::string data
,
48 const GURL
& base_url
);
50 // Navigates the selected tab of |window| to |url|, blocking until the given
51 // number of navigations finishes.
52 void NavigateToURLBlockUntilNavigationsComplete(Shell
* window
,
54 int number_of_navigations
);
56 // Wait until an application modal dialog is requested.
57 void WaitForAppModalDialog(Shell
* window
);
59 // Used to wait for a new Shell window to be created. Instantiate this object
60 // before the operation that will create the window.
61 class ShellAddedObserver
{
64 ~ShellAddedObserver();
66 // Will run a message loop to wait for the new window if it hasn't been
67 // created since the constructor.
71 void ShellCreated(Shell
* shell
);
74 scoped_refptr
<MessageLoopRunner
> runner_
;
76 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver
);
80 void SetWindowBounds(gfx::NativeWindow window
, const gfx::Rect
& bounds
);
83 } // namespace content
85 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_