diff options
author | tmoniuszko@opera.com <tmoniuszko@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-31 20:28:47 +0000 |
---|---|---|
committer | tmoniuszko@opera.com <tmoniuszko@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-31 20:28:47 +0000 |
commit | cbd119a93f0674ec7f970be8799629a1b2c76eb0 (patch) | |
tree | fdada95ad49c9bb8c39341066757e694a83db9e9 /base | |
parent | ecc252866d86b2d3fb0fe12fb5791f0060e5df5c (diff) | |
download | chromium_src-cbd119a93f0674ec7f970be8799629a1b2c76eb0.zip chromium_src-cbd119a93f0674ec7f970be8799629a1b2c76eb0.tar.gz chromium_src-cbd119a93f0674ec7f970be8799629a1b2c76eb0.tar.bz2 |
ScopedNativeLibrary.Basic test fix
IsBadCodePtr() function was returning zero value randomly and the test was
raising false alarms sometimes. This fix changes the test to use
GetFunctionPointerFromNativeLibrary() instead.
BUG=
Review URL: https://codereview.chromium.org/32303002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/scoped_native_library_unittest.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/base/scoped_native_library_unittest.cc b/base/scoped_native_library_unittest.cc index c120555..035faa0 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"; + 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)); #endif } |