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