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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #endif | 94 #endif |
95 window_ = views::Widget::CreateWindow(this); | 95 window_ = views::Widget::CreateWindow(this); |
96 } | 96 } |
97 | 97 |
98 void ViewEventTestBase::TearDown() { | 98 void ViewEventTestBase::TearDown() { |
99 if (window_) { | 99 if (window_) { |
100 #if defined(OS_WIN) && !defined(USE_AURA) | 100 #if defined(OS_WIN) && !defined(USE_AURA) |
101 DestroyWindow(window_->GetNativeWindow()); | 101 DestroyWindow(window_->GetNativeWindow()); |
102 #else | 102 #else |
103 window_->Close(); | 103 window_->Close(); |
104 ui_test_utils::RunAllPendingInMessageLoop(); | 104 content::RunAllPendingInMessageLoop(); |
105 #endif | 105 #endif |
106 window_ = NULL; | 106 window_ = NULL; |
107 } | 107 } |
108 #if defined(USE_ASH) | 108 #if defined(USE_ASH) |
109 ash::Shell::DeleteInstance(); | 109 ash::Shell::DeleteInstance(); |
110 #endif | 110 #endif |
111 #if defined(USE_AURA) | 111 #if defined(USE_AURA) |
112 aura::Env::DeleteInstance(); | 112 aura::Env::DeleteInstance(); |
113 #endif | 113 #endif |
114 ui::CompositorTestSupport::Terminate(); | 114 ui::CompositorTestSupport::Terminate(); |
(...skipping 29 matching lines...) Expand all Loading... |
144 | 144 |
145 void ViewEventTestBase::StartMessageLoopAndRunTest() { | 145 void ViewEventTestBase::StartMessageLoopAndRunTest() { |
146 window_->Show(); | 146 window_->Show(); |
147 // Make sure the window is the foreground window, otherwise none of the | 147 // Make sure the window is the foreground window, otherwise none of the |
148 // mouse events are going to be targeted correctly. | 148 // mouse events are going to be targeted correctly. |
149 #if defined(OS_WIN) && !defined(USE_AURA) | 149 #if defined(OS_WIN) && !defined(USE_AURA) |
150 SetForegroundWindow(window_->GetNativeWindow()); | 150 SetForegroundWindow(window_->GetNativeWindow()); |
151 #endif | 151 #endif |
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 content::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 content::RunMessageLoop(); | 162 content::RunMessageLoop(); |
163 } | 163 } |
164 | 164 |
(...skipping 16 matching lines...) Expand all Loading... |
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 |