Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Class WinApiInterface provides a way to mock windows API calls in | |
| 6 // unit tests. Functions can call members of class WinApiInterface | |
| 7 // instead of Windows API functions, and subclasses of WinApiInterface | |
| 8 // can be used by tests. Members of this class should do nothing except | |
| 9 // calling the real API call they are named after. | |
| 10 // | |
| 11 // Tests should be written with the assumption that new calls will be | |
| 12 // added over time. For example, if you use gmock to create a strict mock | |
| 13 // of WinApiInterface, do not make any other windows API calls in the code | |
| 14 // under test. | |
| 15 | |
| 16 #ifndef BASE_WIN_WIN_API_INTERFACE_H_ | |
| 17 #define BASE_WIN_WIN_API_INTERFACE_H_ | |
| 18 | |
| 19 #include <windows.h> | |
| 20 | |
| 21 namespace base { | |
| 22 namespace win { | |
| 23 | |
| 24 class WinApiInterface { | |
| 25 public: | |
| 26 virtual DWORD QueryDosDevice(LPCTSTR lpDeviceName, | |
| 27 LPTSTR lpTargetPath, | |
| 28 DWORD ucchMax) { | |
| 29 return ::QueryDosDevice(lpDeviceName, lpTargetPath, ucchMax); | |
| 30 } | |
| 31 | |
| 32 virtual DWORD GetLogicalDriveStrings(DWORD nBufferLength, | |
| 33 LPTSTR lpBuffer) { | |
| 34 return ::GetLogicalDriveStrings(nBufferLength, lpBuffer); | |
| 35 } | |
| 36 | |
| 37 static WinApiInterface* GetInstance(); | |
|
rvargas (doing something else)
2012/01/11 22:26:26
This has to be exported.
| |
| 38 }; | |
| 39 | |
| 40 } // namespace win | |
| 41 } // namespace base | |
| 42 | |
| 43 #endif // BASE_WIN_WIN_API_INTERFACE_H_ | |
| OLD | NEW |