| 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 "chrome/test/base/view_event_test_base.h" | 5 #include "chrome/test/base/view_event_test_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 content_view_(NULL), | 61 content_view_(NULL), |
| 62 ui_thread_(content::BrowserThread::UI, &message_loop_) { | 62 ui_thread_(content::BrowserThread::UI, &message_loop_) { |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ViewEventTestBase::Done() { | 65 void ViewEventTestBase::Done() { |
| 66 MessageLoop::current()->Quit(); | 66 MessageLoop::current()->Quit(); |
| 67 | 67 |
| 68 #if defined(OS_WIN) && !defined(USE_AURA) | 68 #if defined(OS_WIN) && !defined(USE_AURA) |
| 69 // We need to post a message to tickle the Dispatcher getting called and | 69 // We need to post a message to tickle the Dispatcher getting called and |
| 70 // exiting out of the nested loop. Without this the quit never runs. | 70 // exiting out of the nested loop. Without this the quit never runs. |
| 71 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); | 71 if (window_) |
| 72 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); |
| 72 #endif | 73 #endif |
| 73 | 74 |
| 74 // If we're in a nested message loop, as is the case with menus, we | 75 // If we're in a nested message loop, as is the case with menus, we |
| 75 // need to quit twice. The second quit does that for us. Finish all | 76 // need to quit twice. The second quit does that for us. Finish all |
| 76 // pending UI events before posting closure because events it may be | 77 // pending UI events before posting closure because events it may be |
| 77 // executed before UI events are executed. | 78 // executed before UI events are executed. |
| 78 ui_controls::RunClosureAfterAllPendingUIEvents(MessageLoop::QuitClosure()); | 79 ui_controls::RunClosureAfterAllPendingUIEvents(MessageLoop::QuitClosure()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void ViewEventTestBase::SetUp() { | 82 void ViewEventTestBase::SetUp() { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 dnd_thread_.reset(NULL); | 174 dnd_thread_.reset(NULL); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 177 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
| 177 StopBackgroundThread(); | 178 StopBackgroundThread(); |
| 178 | 179 |
| 179 task.Run(); | 180 task.Run(); |
| 180 if (HasFatalFailure()) | 181 if (HasFatalFailure()) |
| 181 Done(); | 182 Done(); |
| 182 } | 183 } |
| OLD | NEW |