| OLD | NEW |
| 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/public/test/content_browser_test_utils.h" | 5 #include "content/public/test/content_browser_test_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/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 "base/strings/pattern.h" | 11 #include "base/strings/pattern.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/thread_restrictions.h" |
| 13 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
| 14 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/common/content_paths.h" | 17 #include "content/public/common/content_paths.h" |
| 17 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
| 18 #include "content/public/test/test_navigation_observer.h" | 19 #include "content/public/test/test_navigation_observer.h" |
| 19 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
| 20 #include "content/shell/browser/shell.h" | 21 #include "content/shell/browser/shell.h" |
| 21 #include "content/shell/browser/shell_javascript_dialog_manager.h" | 22 #include "content/shell/browser/shell_javascript_dialog_manager.h" |
| 22 #include "net/base/filename_util.h" | 23 #include "net/base/filename_util.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 base::FilePath GetTestFilePath(const char* dir, const char* file) { | 27 base::FilePath GetTestFilePath(const char* dir, const char* file) { |
| 27 base::FilePath path; | 28 base::FilePath path; |
| 29 base::ThreadRestrictions::ScopedAllowIO allow_io_for_path_service; |
| 28 PathService::Get(DIR_TEST_DATA, &path); | 30 PathService::Get(DIR_TEST_DATA, &path); |
| 29 return path.Append(base::FilePath().AppendASCII(dir).Append( | 31 if (dir) |
| 30 base::FilePath().AppendASCII(file))); | 32 path = path.AppendASCII(dir); |
| 33 return path.AppendASCII(file); |
| 31 } | 34 } |
| 32 | 35 |
| 33 GURL GetTestUrl(const char* dir, const char* file) { | 36 GURL GetTestUrl(const char* dir, const char* file) { |
| 34 return net::FilePathToFileURL(GetTestFilePath(dir, file)); | 37 return net::FilePathToFileURL(GetTestFilePath(dir, file)); |
| 35 } | 38 } |
| 36 | 39 |
| 37 void NavigateToURLBlockUntilNavigationsComplete(Shell* window, | 40 void NavigateToURLBlockUntilNavigationsComplete(Shell* window, |
| 38 const GURL& url, | 41 const GURL& url, |
| 39 int number_of_navigations) { | 42 int number_of_navigations) { |
| 40 WaitForLoadStop(window->web_contents()); | 43 WaitForLoadStop(window->web_contents()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 158 |
| 156 std::string ascii_message = base::UTF16ToASCII(message); | 159 std::string ascii_message = base::UTF16ToASCII(message); |
| 157 if (base::MatchPattern(ascii_message, filter_)) { | 160 if (base::MatchPattern(ascii_message, filter_)) { |
| 158 message_ = ascii_message; | 161 message_ = ascii_message; |
| 159 message_loop_runner_->Quit(); | 162 message_loop_runner_->Quit(); |
| 160 } | 163 } |
| 161 return false; | 164 return false; |
| 162 } | 165 } |
| 163 | 166 |
| 164 } // namespace content | 167 } // namespace content |
| OLD | NEW |