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

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

Issue 10831023: Move over a bunch of tests from browser_tests to content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « content/test/content_browser_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/test/content_browser_test_utils.h" 5 #include "content/test/content_browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/notification_source.h" 12 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/content_paths.h" 14 #include "content/public/common/content_paths.h"
15 #include "content/public/test/browser_test_utils.h"
15 #include "content/public/test/test_navigation_observer.h" 16 #include "content/public/test/test_navigation_observer.h"
16 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
17 #include "content/shell/shell.h" 18 #include "content/shell/shell.h"
18 #include "content/shell/shell_javascript_dialog_creator.h" 19 #include "content/shell/shell_javascript_dialog_creator.h"
19 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 FilePath GetTestFilePath(const char* dir, const char* file) { 24 FilePath GetTestFilePath(const char* dir, const char* file) {
24 FilePath path; 25 FilePath path;
25 PathService::Get(DIR_TEST_DATA, &path); 26 PathService::Get(DIR_TEST_DATA, &path);
26 return path.Append( 27 return path.Append(
27 FilePath().AppendASCII(dir).Append(FilePath().AppendASCII(file))); 28 FilePath().AppendASCII(dir).Append(FilePath().AppendASCII(file)));
28 } 29 }
29 30
30 GURL GetTestUrl(const char* dir, const char* file) { 31 GURL GetTestUrl(const char* dir, const char* file) {
31 return net::FilePathToFileURL(GetTestFilePath(dir, file)); 32 return net::FilePathToFileURL(GetTestFilePath(dir, file));
32 } 33 }
33 34
34 void NavigateToURL(Shell* window, const GURL& url) { 35 void NavigateToURLBlockUntilNavigationsComplete(Shell* window,
36 const GURL& url,
37 int number_of_navigations) {
38 WaitForLoadStop(window->web_contents());
35 NavigationController* controller = &window->web_contents()->GetController(); 39 NavigationController* controller = &window->web_contents()->GetController();
36 TestNavigationObserver same_tab_observer( 40 TestNavigationObserver same_tab_observer(
37 Source<NavigationController>(controller), 41 Source<NavigationController>(controller),
38 NULL, 42 NULL,
39 1); 43 number_of_navigations);
40 44
41 window->LoadURL(url); 45 window->LoadURL(url);
42 46
43 base::RunLoop run_loop; 47 base::RunLoop run_loop;
44 same_tab_observer.WaitForObservation( 48 same_tab_observer.WaitForObservation(
45 base::Bind(&RunThisRunLoop, base::Unretained(&run_loop)), 49 base::Bind(&RunThisRunLoop, base::Unretained(&run_loop)),
46 GetQuitTaskForRunLoop(&run_loop)); 50 GetQuitTaskForRunLoop(&run_loop));
47 } 51 }
48 52
53 void NavigateToURL(Shell* window, const GURL& url) {
54 NavigateToURLBlockUntilNavigationsComplete(window, url, 1);
55 }
56
49 void WaitForAppModalDialog(Shell* window) { 57 void WaitForAppModalDialog(Shell* window) {
50 ShellJavaScriptDialogCreator* dialog_creator = 58 ShellJavaScriptDialogCreator* dialog_creator =
51 static_cast<ShellJavaScriptDialogCreator*>( 59 static_cast<ShellJavaScriptDialogCreator*>(
52 window->GetJavaScriptDialogCreator()); 60 window->GetJavaScriptDialogCreator());
53 61
54 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); 62 scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner();
55 dialog_creator->set_dialog_request_callback(runner->QuitClosure()); 63 dialog_creator->set_dialog_request_callback(runner->QuitClosure());
56 runner->Run(); 64 runner->Run();
57 } 65 }
58 66
59 } // namespace content 67 } // namespace content
OLDNEW
« no previous file with comments | « content/test/content_browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698