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

Unified Diff: base/scoped_native_library_unittest.cc

Issue 32303002: ScopedNativeLibrary.Basic test fix (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698