OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ | 5 #ifndef CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ |
6 #define CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ | 6 #define CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include <atlbase.h> | 10 #include <atlbase.h> |
11 #include <atlwin.h> | 11 #include <atlwin.h> |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
19 #include "base/process_util.h" | 19 #include "base/process_util.h" |
20 #include "base/scoped_comptr_win.h" | |
21 #include "base/win/registry.h" | 20 #include "base/win/registry.h" |
| 21 #include "base/win/scoped_comptr.h" |
22 | 22 |
| 23 #include "chrome_frame/test/simulate_input.h" |
23 #include "chrome_frame/test_utils.h" | 24 #include "chrome_frame/test_utils.h" |
24 #include "chrome_frame/test/simulate_input.h" | |
25 #include "chrome_frame/utils.h" | 25 #include "chrome_frame/utils.h" |
26 | 26 |
27 // Include without path to make GYP build see it. | 27 // Include without path to make GYP build see it. |
28 #include "chrome_tab.h" // NOLINT | 28 #include "chrome_tab.h" // NOLINT |
29 | 29 |
30 #include "gtest/gtest.h" | 30 #include "gtest/gtest.h" |
31 | 31 |
32 // Needed for CreateFunctor. | 32 // Needed for CreateFunctor. |
33 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | 33 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING |
34 #include "testing/gmock_mutant.h" | 34 #include "testing/gmock_mutant.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 HRESULT hr = ref_instance->Initialize(timeout_seconds); | 111 HRESULT hr = ref_instance->Initialize(timeout_seconds); |
112 if (FAILED(hr)) { | 112 if (FAILED(hr)) { |
113 LOG(ERROR) << "Failed to Initialize Hung COM call detector. Error:" | 113 LOG(ERROR) << "Failed to Initialize Hung COM call detector. Error:" |
114 << hr; | 114 << hr; |
115 return NULL; | 115 return NULL; |
116 } | 116 } |
117 return this_instance; | 117 return this_instance; |
118 } | 118 } |
119 | 119 |
120 void TearDown() { | 120 void TearDown() { |
121 ScopedComPtr<IMessageFilter> prev_filter; | 121 base::win::ScopedComPtr<IMessageFilter> prev_filter; |
122 CoRegisterMessageFilter(prev_filter_.get(), prev_filter.Receive()); | 122 CoRegisterMessageFilter(prev_filter_.get(), prev_filter.Receive()); |
123 DestroyWindow(); | 123 DestroyWindow(); |
124 m_hWnd = NULL; | 124 m_hWnd = NULL; |
125 } | 125 } |
126 | 126 |
127 STDMETHOD_(DWORD, HandleInComingCall)(DWORD call_type, | 127 STDMETHOD_(DWORD, HandleInComingCall)(DWORD call_type, |
128 HTASK caller, | 128 HTASK caller, |
129 DWORD tick_count, | 129 DWORD tick_count, |
130 LPINTERFACEINFO interface_info) { | 130 LPINTERFACEINFO interface_info) { |
131 return SERVERCALL_ISHANDLED; | 131 return SERVERCALL_ISHANDLED; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return hr; | 175 return hr; |
176 } | 176 } |
177 | 177 |
178 static const int kHungDetectTimerId = 0x0000baba; | 178 static const int kHungDetectTimerId = 0x0000baba; |
179 SetTimer(kHungDetectTimerId, 1000 * (timeout_seconds + 40), NULL); | 179 SetTimer(kHungDetectTimerId, 1000 * (timeout_seconds + 40), NULL); |
180 return S_OK; | 180 return S_OK; |
181 } | 181 } |
182 | 182 |
183 // used to detect if outgoing COM calls hung. | 183 // used to detect if outgoing COM calls hung. |
184 bool is_hung_; | 184 bool is_hung_; |
185 ScopedComPtr<IMessageFilter> prev_filter_; | 185 base::win::ScopedComPtr<IMessageFilter> prev_filter_; |
186 }; | 186 }; |
187 | 187 |
188 // MessageLoopForUI wrapper that runs only for a limited time. | 188 // MessageLoopForUI wrapper that runs only for a limited time. |
189 // We need a UI message loop in the main thread. | 189 // We need a UI message loop in the main thread. |
190 class TimedMsgLoop { | 190 class TimedMsgLoop { |
191 public: | 191 public: |
192 TimedMsgLoop() : quit_loop_invoked_(false) { | 192 TimedMsgLoop() : quit_loop_invoked_(false) { |
193 } | 193 } |
194 | 194 |
195 void RunFor(int seconds) { | 195 void RunFor(int seconds) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } // namespace chrome_frame_test | 335 } // namespace chrome_frame_test |
336 | 336 |
337 // TODO(tommi): This is a temporary workaround while we're getting our | 337 // TODO(tommi): This is a temporary workaround while we're getting our |
338 // Singleton story straight. Ideally each test should clear up any singletons | 338 // Singleton story straight. Ideally each test should clear up any singletons |
339 // it might have created, but test cases do not implicitly have their own | 339 // it might have created, but test cases do not implicitly have their own |
340 // AtExitManager, so we have this workaround method for tests that depend on | 340 // AtExitManager, so we have this workaround method for tests that depend on |
341 // "fresh" singletons. The implementation is in chrome_frame_unittest_main.cc. | 341 // "fresh" singletons. The implementation is in chrome_frame_unittest_main.cc. |
342 void DeleteAllSingletons(); | 342 void DeleteAllSingletons(); |
343 | 343 |
344 #endif // CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ | 344 #endif // CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ |
OLD | NEW |