OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/string_util.h" | |
6 #include "chrome/test/unit/chrome_test_suite.h" | |
7 | |
8 #if defined(OS_WIN) | |
9 #define DLLEXPORT __declspec(dllexport) | |
10 #else | |
11 #define DLLEXPORT | |
12 #define CDECL | |
13 #endif | |
14 | |
15 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | |
16 extern "C" { | |
17 DLLEXPORT int CDECL RunTests(int argc, char **argv) { | |
18 return ChromeTestSuite(argc, argv).Run(); | |
19 } | |
20 } | |
21 | |
22 #if defined(OS_WIN) | |
23 BOOL WINAPI DllMain(HINSTANCE dll_module, DWORD reason, LPVOID reserved) { | |
24 if (reason == DLL_PROCESS_DETACH) { | |
25 // The CRichEditCtrl (used by the omnibox) calls OleInitialize, but somehow | |
26 // does not always calls OleUninitialize, causing an unbalanced Ole | |
27 // initialization that triggers a DCHECK in ScopedOleInitializer the next | |
28 // time we run a test. | |
29 // This behavior has been seen on some Vista boxes, but not all of them. | |
30 // There is a flag to prevent Ole initialization in CRichEditCtrl (see | |
31 // http://support.microsoft.com/kb/238989), but it is set to 0 in recent | |
32 // Windows versions. | |
33 // This is a dirty hack to make sure the OleCount is back to 0 in all cases, | |
34 // so the next test will have Ole unitialized, as expected. | |
35 | |
36 if (OleInitialize(NULL) == S_FALSE) { | |
37 // We were already initialized, balance that extra-initialization. | |
38 OleUninitialize(); | |
39 } | |
40 // Balance the OleInitialize from the above test. | |
41 OleUninitialize(); | |
42 } | |
43 return TRUE; | |
44 } | |
45 | |
46 #endif | |
OLD | NEW |