| OLD | NEW |
| 1 // Copyright (c) 2011 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <ole2.h> | 8 #include <ole2.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/compiler_specific.h" | |
| 14 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 15 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 16 #include "chrome/browser/automation/ui_controls.h" | 15 #include "chrome/browser/automation/ui_controls.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 19 #include "ui/gfx/compositor/test/compositor_test_support.h" | 18 #include "ui/gfx/compositor/test/compositor_test_support.h" |
| 20 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 21 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 22 | 21 |
| 23 #if defined(USE_AURA) | 22 #if defined(USE_AURA) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 // Delay in background thread before posting mouse move. | 56 // Delay in background thread before posting mouse move. |
| 58 const int kMouseMoveDelayMS = 200; | 57 const int kMouseMoveDelayMS = 200; |
| 59 | 58 |
| 60 } // namespace | 59 } // namespace |
| 61 | 60 |
| 62 ViewEventTestBase::ViewEventTestBase() | 61 ViewEventTestBase::ViewEventTestBase() |
| 63 : window_(NULL), | 62 : window_(NULL), |
| 64 content_view_(NULL), | 63 content_view_(NULL), |
| 65 ui_thread_(content::BrowserThread::UI, &message_loop_), | 64 ui_thread_(content::BrowserThread::UI, &message_loop_) { |
| 66 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | |
| 67 } | 65 } |
| 68 | 66 |
| 69 void ViewEventTestBase::Done() { | 67 void ViewEventTestBase::Done() { |
| 70 // Cancel the pending time-out. | |
| 71 method_factory_.RevokeAll(); | |
| 72 | |
| 73 MessageLoop::current()->Quit(); | 68 MessageLoop::current()->Quit(); |
| 74 | 69 |
| 75 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
| 76 // We need to post a message to tickle the Dispatcher getting called and | 71 // We need to post a message to tickle the Dispatcher getting called and |
| 77 // exiting out of the nested loop. Without this the quit never runs. | 72 // exiting out of the nested loop. Without this the quit never runs. |
| 78 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); | 73 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); |
| 79 #endif | 74 #endif |
| 80 | 75 |
| 81 // If we're in a nested message loop, as is the case with menus, we | 76 // If we're in a nested message loop, as is the case with menus, we |
| 82 // need to quit twice. The second quit does that for us. Finish all | 77 // need to quit twice. The second quit does that for us. Finish all |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 dnd_thread_.reset(NULL); | 178 dnd_thread_.reset(NULL); |
| 184 } | 179 } |
| 185 | 180 |
| 186 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 181 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
| 187 StopBackgroundThread(); | 182 StopBackgroundThread(); |
| 188 | 183 |
| 189 task.Run(); | 184 task.Run(); |
| 190 if (HasFatalFailure()) | 185 if (HasFatalFailure()) |
| 191 Done(); | 186 Done(); |
| 192 } | 187 } |
| OLD | NEW |