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_TEST_CONTENT_BROWSER_TEST_UTILS_H_
6 #define CONTENT_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_browsertests.
21 // Note: if a function here also works with browser_tests, it should be in
22 // content\public\test\browser_test_utils.h
26 class MessageLoopRunner
;
29 // Generate the file path for testing a particular test.
30 // The file for the tests is all located in
31 // content/test/data/dir/<file>
32 // The returned path is FilePath format.
33 base::FilePath
GetTestFilePath(const char* dir
, const char* file
);
35 // Generate the URL for testing a particular test.
36 // HTML for the tests is all located in
37 // test_root_directory/dir/<file>
38 // The returned path is GURL format.
39 GURL
GetTestUrl(const char* dir
, const char* file
);
41 // Navigates the selected tab of |window| to |url|, blocking until the
42 // navigation finishes.
43 void NavigateToURL(Shell
* window
, const GURL
& url
);
45 // Navigates the selected tab of |window| to |url|, blocking until the given
46 // number of navigations finishes.
47 void NavigateToURLBlockUntilNavigationsComplete(Shell
* window
,
49 int number_of_navigations
);
51 // Wait until an application modal dialog is requested.
52 void WaitForAppModalDialog(Shell
* window
);
54 // Used to wait for a new Shell window to be created. Instantiate this object
55 // before the operation that will create the window.
56 class ShellAddedObserver
{
59 ~ShellAddedObserver();
61 // Will run a message loop to wait for the new window if it hasn't been
62 // created since the constructor.
66 void ShellCreated(Shell
* shell
);
69 scoped_refptr
<MessageLoopRunner
> runner_
;
71 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver
);
75 void SetWindowBounds(gfx::NativeWindow window
, const gfx::Rect
& bounds
);
78 } // namespace content
80 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_