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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 // Flush any pending events to make sure we start with a clean slate. | 153 // Flush any pending events to make sure we start with a clean slate. |
154 ui_test_utils::RunAllPendingInMessageLoop(); | 154 ui_test_utils::RunAllPendingInMessageLoop(); |
155 | 155 |
156 // Schedule a task that starts the test. Need to do this as we're going to | 156 // Schedule a task that starts the test. Need to do this as we're going to |
157 // run the message loop. | 157 // run the message loop. |
158 MessageLoop::current()->PostTask( | 158 MessageLoop::current()->PostTask( |
159 FROM_HERE, | 159 FROM_HERE, |
160 base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this)); | 160 base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this)); |
161 | 161 |
162 ui_test_utils::RunMessageLoop(); | 162 content::RunMessageLoop(); |
163 } | 163 } |
164 | 164 |
165 gfx::Size ViewEventTestBase::GetPreferredSize() { | 165 gfx::Size ViewEventTestBase::GetPreferredSize() { |
166 return gfx::Size(); | 166 return gfx::Size(); |
167 } | 167 } |
168 | 168 |
169 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) { | 169 void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) { |
170 if (!dnd_thread_.get()) { | 170 if (!dnd_thread_.get()) { |
171 dnd_thread_.reset(new base::Thread("mouse-move-thread")); | 171 dnd_thread_.reset(new base::Thread("mouse-move-thread")); |
172 dnd_thread_->Start(); | 172 dnd_thread_->Start(); |
173 } | 173 } |
174 dnd_thread_->message_loop()->PostDelayedTask( | 174 dnd_thread_->message_loop()->PostDelayedTask( |
175 FROM_HERE, | 175 FROM_HERE, |
176 base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y), | 176 base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y), |
177 base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS)); | 177 base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS)); |
178 } | 178 } |
179 | 179 |
180 void ViewEventTestBase::StopBackgroundThread() { | 180 void ViewEventTestBase::StopBackgroundThread() { |
181 dnd_thread_.reset(NULL); | 181 dnd_thread_.reset(NULL); |
182 } | 182 } |
183 | 183 |
184 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 184 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
185 StopBackgroundThread(); | 185 StopBackgroundThread(); |
186 | 186 |
187 task.Run(); | 187 task.Run(); |
188 if (HasFatalFailure()) | 188 if (HasFatalFailure()) |
189 Done(); | 189 Done(); |
190 } | 190 } |
OLD | NEW |