OLD | NEW |
(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/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/shell/shell.h" |
| 18 #include "net/base/net_util.h" |
| 19 |
| 20 namespace content { |
| 21 |
| 22 FilePath GetTestFilePath(const char* dir, const char* file) { |
| 23 FilePath path; |
| 24 PathService::Get(DIR_TEST_DATA, &path); |
| 25 return path.Append( |
| 26 FilePath().AppendASCII(dir).Append(FilePath().AppendASCII(file))); |
| 27 } |
| 28 |
| 29 GURL GetTestUrl(const char* dir, const char* file) { |
| 30 return net::FilePathToFileURL(GetTestFilePath(dir, file)); |
| 31 } |
| 32 |
| 33 void NavigateToURL(Shell* window, const GURL& url) { |
| 34 NavigationController* controller = &window->web_contents()->GetController(); |
| 35 TestNavigationObserver same_tab_observer( |
| 36 Source<NavigationController>(controller), |
| 37 NULL, |
| 38 1); |
| 39 |
| 40 window->LoadURL(url); |
| 41 |
| 42 base::RunLoop run_loop; |
| 43 same_tab_observer.WaitForObservation( |
| 44 base::Bind(&RunThisRunLoop, base::Unretained(&run_loop)), |
| 45 GetQuitTaskForRunLoop(&run_loop)); |
| 46 } |
| 47 |
| 48 } // namespace content |
OLD | NEW |