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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DISALLOW_COPY_AND_ASSIGN(TestView); | 63 DISALLOW_COPY_AND_ASSIGN(TestView); |
64 }; | 64 }; |
65 | 65 |
66 // Delay in background thread before posting mouse move. | 66 // Delay in background thread before posting mouse move. |
67 const int kMouseMoveDelayMS = 200; | 67 const int kMouseMoveDelayMS = 200; |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 ViewEventTestBase::ViewEventTestBase() | 71 ViewEventTestBase::ViewEventTestBase() |
72 : window_(NULL), | 72 : window_(NULL), |
73 content_view_(NULL), | 73 content_view_(NULL) { |
74 ui_thread_(content::BrowserThread::UI, &message_loop_) { | |
75 } | 74 } |
76 | 75 |
77 void ViewEventTestBase::Done() { | 76 void ViewEventTestBase::Done() { |
78 base::MessageLoop::current()->Quit(); | 77 base::MessageLoop::current()->Quit(); |
79 | 78 |
80 #if defined(OS_WIN) && !defined(USE_AURA) | 79 #if defined(OS_WIN) && !defined(USE_AURA) |
81 // We need to post a message to tickle the Dispatcher getting called and | 80 // We need to post a message to tickle the Dispatcher getting called and |
82 // exiting out of the nested loop. Without this the quit never runs. | 81 // exiting out of the nested loop. Without this the quit never runs. |
83 if (window_) | 82 if (window_) |
84 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); | 83 PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); |
(...skipping 22 matching lines...) Expand all Loading... |
107 message_center::MessageCenter::Initialize(); | 106 message_center::MessageCenter::Initialize(); |
108 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
109 chromeos::CrasAudioHandler::InitializeForTesting(); | 108 chromeos::CrasAudioHandler::InitializeForTesting(); |
110 #endif | 109 #endif |
111 ash::Shell::CreateInstance(new ash::test::TestShellDelegate()); | 110 ash::Shell::CreateInstance(new ash::test::TestShellDelegate()); |
112 context = ash::Shell::GetPrimaryRootWindow(); | 111 context = ash::Shell::GetPrimaryRootWindow(); |
113 #endif | 112 #endif |
114 #elif defined(USE_AURA) | 113 #elif defined(USE_AURA) |
115 // Instead of using the ash shell, use an AuraTestHelper to create and manage | 114 // Instead of using the ash shell, use an AuraTestHelper to create and manage |
116 // the test screen. | 115 // the test screen. |
117 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 116 aura_test_helper_.reset( |
| 117 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
118 aura_test_helper_->SetUp(); | 118 aura_test_helper_->SetUp(); |
119 context = aura_test_helper_->root_window(); | 119 context = aura_test_helper_->root_window(); |
120 #endif | 120 #endif |
121 window_ = views::Widget::CreateWindowWithContext(this, context); | 121 window_ = views::Widget::CreateWindowWithContext(this, context); |
122 } | 122 } |
123 | 123 |
124 void ViewEventTestBase::TearDown() { | 124 void ViewEventTestBase::TearDown() { |
125 if (window_) { | 125 if (window_) { |
126 #if defined(OS_WIN) && !defined(USE_AURA) | 126 #if defined(OS_WIN) && !defined(USE_AURA) |
127 DestroyWindow(window_->GetNativeWindow()); | 127 DestroyWindow(window_->GetNativeWindow()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 dnd_thread_.reset(NULL); | 210 dnd_thread_.reset(NULL); |
211 } | 211 } |
212 | 212 |
213 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { | 213 void ViewEventTestBase::RunTestMethod(const base::Closure& task) { |
214 StopBackgroundThread(); | 214 StopBackgroundThread(); |
215 | 215 |
216 task.Run(); | 216 task.Run(); |
217 if (HasFatalFailure()) | 217 if (HasFatalFailure()) |
218 Done(); | 218 Done(); |
219 } | 219 } |
OLD | NEW |