Index: base/scoped_native_library_unittest.cc |
diff --git a/base/scoped_native_library_unittest.cc b/base/scoped_native_library_unittest.cc |
index c120555ec69a1ae0f216a53dc5f8f53035b61f6e..e7984d9dce62e5ebf43135e7bba6ab0707cdd744 100644 |
--- a/base/scoped_native_library_unittest.cc |
+++ b/base/scoped_native_library_unittest.cc |
@@ -18,19 +18,25 @@ TEST(ScopedNativeLibrary, Basic) { |
// Get the pointer to DirectDrawCreate() from "ddraw.dll" and verify it |
// is valid only in this scope. |
// FreeLibrary() doesn't actually unload a DLL until its reference count |
- // becomes zero, i.e. this function pointer is still valid if the DLL used |
+ // becomes zero, i.e. function pointer is still valid if the DLL used |
// in this test is also used by another part of this executable. |
// So, this test uses "ddraw.dll", which is not used by Chrome at all but |
// installed on all versions of Windows. |
- FARPROC test_function; |
+ const char* kFunctionName = "DirectDrawCreate"; |
Mark Mentovai
2013/10/25 20:13:26
Use const char kFunctionName[] instead.
Tomasz Moniuszko
2013/10/28 10:34:57
Done.
|
+ NativeLibrary native_library; |
{ |
FilePath path(GetNativeLibraryName(L"ddraw")); |
- ScopedNativeLibrary library(path); |
- test_function = reinterpret_cast<FARPROC>( |
- library.GetFunctionPointer("DirectDrawCreate")); |
+ native_library = LoadNativeLibrary(path, NULL); |
+ ScopedNativeLibrary library(native_library); |
+ FARPROC test_function = |
+ reinterpret_cast<FARPROC>(library.GetFunctionPointer(kFunctionName)); |
EXPECT_EQ(0, IsBadCodePtr(test_function)); |
+ EXPECT_EQ( |
+ GetFunctionPointerFromNativeLibrary(native_library, kFunctionName), |
+ test_function); |
} |
- EXPECT_NE(0, IsBadCodePtr(test_function)); |
+ EXPECT_EQ(NULL, |
+ GetFunctionPointerFromNativeLibrary(native_library, kFunctionName)); |
Mark Mentovai
2013/10/25 20:13:26
Is this safe? You’re expecting native_library to h
Tomasz Moniuszko
2013/10/28 10:24:22
GetProcAddress() returns NULL when invalid handle
|
#endif |
} |