Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: content/test/content_browser_test_utils.cc

Issue 214823006: Move ContentBrowserTest class to content/public, since it's used by components_browsertests for bro… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: remove other files Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "content/test/content_browser_test_utils.h"
6
7 #include "base/bind.h"
8 #include "base/files/file_path.h"
9 #include "base/path_service.h"
10 #include "base/run_loop.h"
11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/content_paths.h"
15 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/test_navigation_observer.h"
17 #include "content/public/test/test_utils.h"
18 #include "content/shell/browser/shell.h"
19 #include "content/shell/browser/shell_javascript_dialog_manager.h"
20 #include "net/base/net_util.h"
21
22 namespace content {
23
24 base::FilePath GetTestFilePath(const char* dir, const char* file) {
25 base::FilePath path;
26 PathService::Get(DIR_TEST_DATA, &path);
27 return path.Append(base::FilePath().AppendASCII(dir).Append(
28 base::FilePath().AppendASCII(file)));
29 }
30
31 GURL GetTestUrl(const char* dir, const char* file) {
32 return net::FilePathToFileURL(GetTestFilePath(dir, file));
33 }
34
35 void NavigateToURLBlockUntilNavigationsComplete(Shell* window,
36 const GURL& url,
37 int number_of_navigations) {
38 WaitForLoadStop(window->web_contents());
39 TestNavigationObserver same_tab_observer(window->web_contents(),
40 number_of_navigations);
41
42 window->LoadURL(url);
43 same_tab_observer.Wait();
44 }
45
46 void NavigateToURL(Shell* window, const GURL& url) {
47 NavigateToURLBlockUntilNavigationsComplete(window, url, 1);
48 }
49
50 void WaitForAppModalDialog(Shell* window) {
51 ShellJavaScriptDialogManager* dialog_manager=
52 static_cast<ShellJavaScriptDialogManager*>(
53 window->GetJavaScriptDialogManager());
54
55 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner();
56 dialog_manager->set_dialog_request_callback(runner->QuitClosure());
57 runner->Run();
58 }
59
60 ShellAddedObserver::ShellAddedObserver()
61 : shell_(NULL) {
62 Shell::SetShellCreatedCallback(
63 base::Bind(&ShellAddedObserver::ShellCreated, base::Unretained(this)));
64 }
65
66 ShellAddedObserver::~ShellAddedObserver() {
67 }
68
69 Shell* ShellAddedObserver::GetShell() {
70 if (shell_)
71 return shell_;
72
73 runner_ = new MessageLoopRunner();
74 runner_->Run();
75 return shell_;
76 }
77
78 void ShellAddedObserver::ShellCreated(Shell* shell) {
79 DCHECK(!shell_);
80 shell_ = shell;
81 if (runner_.get())
82 runner_->QuitClosure().Run();
83 }
84
85 } // namespace content
OLDNEW
« no previous file with comments | « content/test/content_browser_test_utils.h ('k') | content/test/content_browser_test_utils_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698