Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1573)

Unified Diff: base/win/win_api_interface.h

Issue 9167004: Match whole path components in DevicePathToDriveLetterPath(). Add tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rev Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/win/win_api_interface.h
diff --git a/base/win/win_api_interface.h b/base/win/win_api_interface.h
new file mode 100644
index 0000000000000000000000000000000000000000..2447b71e7f70f7f102101062b8e344a03e0005e7
--- /dev/null
+++ b/base/win/win_api_interface.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Class WinApiInterface provides a way to mock windows API calls in
+// unit tests. Functions can call members of class WinApiInterface
+// instead of Windows API functions, and subclasses of WinApiInterface
+// can be used by tests. Members of this class should do nothing except
+// calling the real API call they are named after.
+//
+// Tests should be written with the assumption that new calls will be
+// added over time. For example, if you use gmock to create a strict mock
+// of WinApiInterface, do not make any other windows API calls in the code
+// under test.
+
+#ifndef BASE_WIN_WIN_API_INTERFACE_H_
+#define BASE_WIN_WIN_API_INTERFACE_H_
+
+#include <windows.h>
+
+namespace base {
+namespace win {
+
+class WinApiInterface {
+ public:
+ virtual DWORD QueryDosDevice(LPCTSTR lpDeviceName,
+ LPTSTR lpTargetPath,
+ DWORD ucchMax) {
+ return ::QueryDosDevice(lpDeviceName, lpTargetPath, ucchMax);
+ }
+
+ virtual DWORD GetLogicalDriveStrings(DWORD nBufferLength,
+ LPTSTR lpBuffer) {
+ return ::GetLogicalDriveStrings(nBufferLength, lpBuffer);
+ }
+
+ static WinApiInterface* GetInstance();
rvargas (doing something else) 2012/01/11 22:26:26 This has to be exported.
+};
+
+} // namespace win
+} // namespace base
+
+#endif // BASE_WIN_WIN_API_INTERFACE_H_

Powered by Google App Engine
This is Rietveld 408576698