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 | |
33 namespace gfx { | 27 namespace gfx { |
34 class Size; | 28 class Size; |
35 } | 29 } |
36 | 30 |
37 namespace wm { | 31 namespace wm { |
38 class WMState; | 32 class WMState; |
| 33 class WMTestHelper; |
39 } | 34 } |
40 | 35 |
41 // Base class for Views based tests that dispatch events. | 36 // Base class for Views based tests that dispatch events. |
42 // | 37 // |
43 // As views based event test involves waiting for events to be processed, | 38 // As views based event test involves waiting for events to be processed, |
44 // writing a views based test is slightly different than that of writing | 39 // writing a views based test is slightly different than that of writing |
45 // other unit tests. In particular when the test fails or is done you need | 40 // other unit tests. In particular when the test fails or is done you need |
46 // to stop the message loop. This can be done by way of invoking the Done | 41 // to stop the message loop. This can be done by way of invoking the Done |
47 // method. | 42 // method. |
48 // | 43 // |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Thread for posting background MouseMoves. | 143 // Thread for posting background MouseMoves. |
149 scoped_ptr<base::Thread> dnd_thread_; | 144 scoped_ptr<base::Thread> dnd_thread_; |
150 | 145 |
151 content::TestBrowserThreadBundle thread_bundle_; | 146 content::TestBrowserThreadBundle thread_bundle_; |
152 | 147 |
153 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
154 ui::ScopedOleInitializer ole_initializer_; | 149 ui::ScopedOleInitializer ole_initializer_; |
155 #endif | 150 #endif |
156 | 151 |
157 #if defined(USE_AURA) | 152 #if defined(USE_AURA) |
158 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 153 scoped_ptr<wm::WMTestHelper> wm_test_helper_; |
159 scoped_ptr<wm::WMState> wm_state_; | 154 scoped_ptr<wm::WMState> wm_state_; |
160 #endif | 155 #endif |
161 | 156 |
162 ChromeViewsDelegate views_delegate_; | 157 ChromeViewsDelegate views_delegate_; |
163 | 158 |
164 DISALLOW_COPY_AND_ASSIGN(ViewEventTestBase); | 159 DISALLOW_COPY_AND_ASSIGN(ViewEventTestBase); |
165 }; | 160 }; |
166 | 161 |
167 // Convenience macro for defining a ViewEventTestBase. See class description | 162 // Convenience macro for defining a ViewEventTestBase. See class description |
168 // of ViewEventTestBase for details. | 163 // of ViewEventTestBase for details. |
169 #define VIEW_TEST(test_class, name) \ | 164 #define VIEW_TEST(test_class, name) \ |
170 TEST_F(test_class, name) {\ | 165 TEST_F(test_class, name) {\ |
171 StartMessageLoopAndRunTest();\ | 166 StartMessageLoopAndRunTest();\ |
172 } | 167 } |
173 | 168 |
174 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) | 169 #endif // defined(HAS_OUT_OF_PROC_TEST_RUNNER) |
175 | 170 |
176 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ | 171 #endif // CHROME_TEST_BASE_VIEW_EVENT_TEST_BASE_H_ |
OLD | NEW |