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