OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 method_factory_.RevokeAll(); | 63 method_factory_.RevokeAll(); |
64 | 64 |
65 MessageLoop::current()->Quit(); | 65 MessageLoop::current()->Quit(); |
66 | 66 |
67 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
68 // We need to post a message to tickle the Dispatcher getting called and | 68 // We need to post a message to tickle the Dispatcher getting called and |
69 // exiting out of the nested loop. Without this the quit never runs. | 69 // exiting out of the nested loop. Without this the quit never runs. |
70 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); | 70 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); |
71 #endif | 71 #endif |
72 | 72 |
73 // If we're in a nested message loop, as is the case with menus, we | 73 // If we're in a nested message loop, as is the case with menus, we need |
74 // need to quit twice. The second quit does that for us. Finish all | 74 // to quit twice. The second quit does that for us. |
75 // pending UI events before posting closure because events it may be | 75 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
76 // executed before UI events are executed. | |
77 ui_controls::RunClosureAfterAllPendingUIEvents(MessageLoop::QuitClosure()); | |
78 } | 76 } |
79 | 77 |
80 void ViewEventTestBase::SetUp() { | 78 void ViewEventTestBase::SetUp() { |
81 #if defined(OS_WIN) | 79 #if defined(OS_WIN) |
82 OleInitialize(NULL); | 80 OleInitialize(NULL); |
83 #endif | 81 #endif |
84 window_ = views::Widget::CreateWindow(this); | 82 window_ = views::Widget::CreateWindow(this); |
85 } | 83 } |
86 | 84 |
87 void ViewEventTestBase::TearDown() { | 85 void ViewEventTestBase::TearDown() { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 dnd_thread_.reset(NULL); | 163 dnd_thread_.reset(NULL); |
166 } | 164 } |
167 | 165 |
168 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 166 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
169 StopBackgroundThread(); | 167 StopBackgroundThread(); |
170 | 168 |
171 task.Run(); | 169 task.Run(); |
172 if (HasFatalFailure()) | 170 if (HasFatalFailure()) |
173 Done(); | 171 Done(); |
174 } | 172 } |
OLD | NEW |