| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This file contains the definition for LayoutTestController. | 5 // This file contains the definition for LayoutTestController. |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "webkit/tools/test_shell/layout_test_controller.h" | 9 #include "webkit/tools/test_shell/layout_test_controller.h" |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/bind.h" |
| 13 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 14 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAnimationControlle
r.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAnimationControlle
r.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Most of these flags need to be cleared in Reset() so that they get turned | 63 // Most of these flags need to be cleared in Reset() so that they get turned |
| 63 // off between each test run. | 64 // off between each test run. |
| 64 bool LayoutTestController::accepts_editing_ = true; | 65 bool LayoutTestController::accepts_editing_ = true; |
| 65 bool LayoutTestController::wait_until_done_ = false; | 66 bool LayoutTestController::wait_until_done_ = false; |
| 66 bool LayoutTestController::can_open_windows_ = false; | 67 bool LayoutTestController::can_open_windows_ = false; |
| 67 bool LayoutTestController::close_remaining_windows_ = true; | 68 bool LayoutTestController::close_remaining_windows_ = true; |
| 68 bool LayoutTestController::stop_provisional_frame_loads_ = false; | 69 bool LayoutTestController::stop_provisional_frame_loads_ = false; |
| 69 LayoutTestController::WorkQueue LayoutTestController::work_queue_; | 70 LayoutTestController::WorkQueue LayoutTestController::work_queue_; |
| 70 | 71 |
| 71 LayoutTestController::LayoutTestController(TestShell* shell) : | 72 LayoutTestController::LayoutTestController(TestShell* shell) : |
| 72 ALLOW_THIS_IN_INITIALIZER_LIST(timeout_factory_(this)) { | 73 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 73 // Set static shell_ variable since we can't do it in an initializer list. | 74 // Set static shell_ variable since we can't do it in an initializer list. |
| 74 // We also need to be careful not to assign shell_ to new windows which are | 75 // We also need to be careful not to assign shell_ to new windows which are |
| 75 // temporary. | 76 // temporary. |
| 76 if (NULL == shell_) | 77 if (NULL == shell_) |
| 77 shell_ = shell; | 78 shell_ = shell; |
| 78 | 79 |
| 79 // Initialize the map that associates methods of this class with the names | 80 // Initialize the map that associates methods of this class with the names |
| 80 // they will use when called by JavaScript. The actual binding of those | 81 // they will use when called by JavaScript. The actual binding of those |
| 81 // names to their methods will be done by calling BindToJavaScript() (defined | 82 // names to their methods will be done by calling BindToJavaScript() (defined |
| 82 // by CppBoundClass, the parent to LayoutTestController). | 83 // by CppBoundClass, the parent to LayoutTestController). |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 const CppArgumentList& args, CppVariant* result) { | 145 const CppArgumentList& args, CppVariant* result) { |
| 145 bool is_debugger_present = false; | 146 bool is_debugger_present = false; |
| 146 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
| 147 // TODO(ojan): Make cross-platform. | 148 // TODO(ojan): Make cross-platform. |
| 148 is_debugger_present = ::IsDebuggerPresent(); | 149 is_debugger_present = ::IsDebuggerPresent(); |
| 149 #endif | 150 #endif |
| 150 | 151 |
| 151 if (!is_debugger_present) { | 152 if (!is_debugger_present) { |
| 152 // TODO(ojan): Use base::OneShotTimer. For some reason, using OneShotTimer | 153 // TODO(ojan): Use base::OneShotTimer. For some reason, using OneShotTimer |
| 153 // seems to cause layout test failures on the try bots. | 154 // seems to cause layout test failures on the try bots. |
| 154 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 155 MessageLoop::current()->PostDelayedTask( |
| 155 timeout_factory_.NewRunnableMethod( | 156 FROM_HERE, |
| 156 &LayoutTestController::notifyDoneTimedOut), | 157 base::Bind(&LayoutTestController::notifyDoneTimedOut, |
| 158 weak_factory_.GetWeakPtr()), |
| 157 shell_->GetLayoutTestTimeout()); | 159 shell_->GetLayoutTestTimeout()); |
| 158 } | 160 } |
| 159 | 161 |
| 160 wait_until_done_ = true; | 162 wait_until_done_ = true; |
| 161 result->SetNull(); | 163 result->SetNull(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 void LayoutTestController::notifyDone( | 166 void LayoutTestController::notifyDone( |
| 165 const CppArgumentList& args, CppVariant* result) { | 167 const CppArgumentList& args, CppVariant* result) { |
| 166 // Test didn't timeout. Kill the timeout timer. | 168 // Test didn't timeout. Kill the timeout timer. |
| 167 timeout_factory_.RevokeAll(); | 169 weak_factory_.InvalidateWeakPtrs(); |
| 168 | 170 |
| 169 completeNotifyDone(false); | 171 completeNotifyDone(false); |
| 170 result->SetNull(); | 172 result->SetNull(); |
| 171 } | 173 } |
| 172 | 174 |
| 173 void LayoutTestController::notifyDoneTimedOut() { | 175 void LayoutTestController::notifyDoneTimedOut() { |
| 174 completeNotifyDone(true); | 176 completeNotifyDone(true); |
| 175 } | 177 } |
| 176 | 178 |
| 177 void LayoutTestController::completeNotifyDone(bool is_timeout) { | 179 void LayoutTestController::completeNotifyDone(bool is_timeout) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 271 } |
| 270 result->SetNull(); | 272 result->SetNull(); |
| 271 } | 273 } |
| 272 | 274 |
| 273 void LayoutTestController::LogErrorToConsole(const std::string& text) { | 275 void LayoutTestController::LogErrorToConsole(const std::string& text) { |
| 274 shell_->delegate()->didAddMessageToConsole( | 276 shell_->delegate()->didAddMessageToConsole( |
| 275 WebConsoleMessage(WebConsoleMessage::LevelError, | 277 WebConsoleMessage(WebConsoleMessage::LevelError, |
| 276 WebString::fromUTF8(text)), | 278 WebString::fromUTF8(text)), |
| 277 WebString(), 0); | 279 WebString(), 0); |
| 278 } | 280 } |
| OLD | NEW |