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 #ifndef CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ | 5 #ifndef CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ |
6 #define CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ | 6 #define CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ |
7 | 7 |
8 // We only want to use ViewEventTestBase in test targets which properly | 8 // We only want to use ViewEventTestBase in test targets which properly |
9 // isolate each test case by running each test in a separate process. | 9 // isolate each test case by running each test in a separate process. |
10 // This way if a test hangs the test launcher can reliably terminate it. | 10 // This way if a test hangs the test launcher can reliably terminate it. |
11 #if defined(HAS_OUT_OF_PROC_TEST_RUNNER) | 11 #if defined(HAS_OUT_OF_PROC_TEST_RUNNER) |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "chrome/browser/ui/views/chrome_views_delegate.h" | 18 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
19 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/views/widget/widget_delegate.h" | 21 #include "ui/views/widget/widget_delegate.h" |
22 | 22 |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
24 #include "ui/base/win/scoped_ole_initializer.h" | 24 #include "ui/base/win/scoped_ole_initializer.h" |
25 #endif | 25 #endif |
26 | 26 |
| 27 namespace aura { |
| 28 namespace test { |
| 29 class AuraTestHelper; |
| 30 } |
| 31 } |
| 32 |
27 namespace gfx { | 33 namespace gfx { |
28 class Size; | 34 class Size; |
29 } | 35 } |
30 | 36 |
31 namespace wm { | 37 namespace wm { |
32 class WMState; | 38 class WMState; |
33 class WMTestHelper; | |
34 } | 39 } |
35 | 40 |
36 // Base class for Views based tests that dispatch events. | 41 // Base class for Views based tests that dispatch events. |
37 // | 42 // |
38 // As views based event test involves waiting for events to be processed, | 43 // As views based event test involves waiting for events to be processed, |
39 // writing a views based test is slightly different than that of writing | 44 // writing a views based test is slightly different than that of writing |
40 // other unit tests. In particular when the test fails or is done you need | 45 // other unit tests. In particular when the test fails or is done you need |
41 // to stop the message loop. This can be done by way of invoking the Done | 46 // to stop the message loop. This can be done by way of invoking the Done |
42 // method. | 47 // method. |
43 // | 48 // |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Thread for posting background MouseMoves. | 148 // Thread for posting background MouseMoves. |
144 scoped_ptr<base::Thread> dnd_thread_; | 149 scoped_ptr<base::Thread> dnd_thread_; |
145 | 150 |
146 content::TestBrowserThreadBundle thread_bundle_; | 151 content::TestBrowserThreadBundle thread_bundle_; |
147 | 152 |
148 #if defined(OS_WIN) | 153 #if defined(OS_WIN) |
149 ui::ScopedOleInitializer ole_initializer_; | 154 ui::ScopedOleInitializer ole_initializer_; |
150 #endif | 155 #endif |
151 | 156 |
152 #if defined(USE_AURA) | 157 #if defined(USE_AURA) |
153 scoped_ptr<wm::WMTestHelper> wm_test_helper_; | 158 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
154 scoped_ptr<wm::WMState> wm_state_; | 159 scoped_ptr<wm::WMState> wm_state_; |
155 #endif | 160 #endif |
156 | 161 |
157 ChromeViewsDelegate views_delegate_; | 162 ChromeViewsDelegate views_delegate_; |
158 | 163 |
159 DISALLOW_COPY_AND_ASSIGN(ViewEventTestBase); | 164 DISALLOW_COPY_AND_ASSIGN(ViewEventTestBase); |
160 }; | 165 }; |
161 | 166 |
162 // Convenience macro for defining a ViewEventTestBase. See class description | 167 // Convenience macro for defining a ViewEventTestBase. See class description |
163 // of ViewEventTestBase for details. | 168 // of ViewEventTestBase for details. |
164 #define VIEW_TEST(test_class, name) \ | 169 #define VIEW_TEST(test_class, name) \ |
165 TEST_F(test_class, name) {\ | 170 TEST_F(test_class, name) {\ |
166 StartMessageLoopAndRunTest();\ | 171 StartMessageLoopAndRunTest();\ |
167 } | 172 } |
168 | 173 |
169 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) | 174 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) |
170 | 175 |
171 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ | 176 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ |
OLD | NEW |