| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/scoped_native_library.h" | 5 #include "base/scoped_native_library.h" |
| 6 #if defined(OS_WIN) | 6 #if defined(OS_WIN) |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #endif | 8 #endif |
| 9 | 9 |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // becomes zero, i.e. function pointer is still valid if the DLL used | 21 // becomes zero, i.e. function pointer is still valid if the DLL used |
| 22 // in this test is also used by another part of this executable. | 22 // in this test is also used by another part of this executable. |
| 23 // So, this test uses "ddraw.dll", which is not used by Chrome at all but | 23 // So, this test uses "ddraw.dll", which is not used by Chrome at all but |
| 24 // installed on all versions of Windows. | 24 // installed on all versions of Windows. |
| 25 const char kFunctionName[] = "DirectDrawCreate"; | 25 const char kFunctionName[] = "DirectDrawCreate"; |
| 26 NativeLibrary native_library; | 26 NativeLibrary native_library; |
| 27 { | 27 { |
| 28 FilePath path(GetNativeLibraryName(L"ddraw")); | 28 FilePath path(GetNativeLibraryName(L"ddraw")); |
| 29 native_library = LoadNativeLibrary(path, NULL); | 29 native_library = LoadNativeLibrary(path, NULL); |
| 30 ScopedNativeLibrary library(native_library); | 30 ScopedNativeLibrary library(native_library); |
| 31 EXPECT_TRUE(library.is_valid()); |
| 32 EXPECT_EQ(native_library, library.get()); |
| 31 FARPROC test_function = | 33 FARPROC test_function = |
| 32 reinterpret_cast<FARPROC>(library.GetFunctionPointer(kFunctionName)); | 34 reinterpret_cast<FARPROC>(library.GetFunctionPointer(kFunctionName)); |
| 33 EXPECT_EQ(0, IsBadCodePtr(test_function)); | 35 EXPECT_EQ(0, IsBadCodePtr(test_function)); |
| 34 EXPECT_EQ( | 36 EXPECT_EQ( |
| 35 GetFunctionPointerFromNativeLibrary(native_library, kFunctionName), | 37 GetFunctionPointerFromNativeLibrary(native_library, kFunctionName), |
| 36 test_function); | 38 test_function); |
| 37 } | 39 } |
| 38 EXPECT_EQ(NULL, | 40 EXPECT_EQ(NULL, |
| 39 GetFunctionPointerFromNativeLibrary(native_library, kFunctionName)); | 41 GetFunctionPointerFromNativeLibrary(native_library, kFunctionName)); |
| 40 #endif | 42 #endif |
| 41 } | 43 } |
| 42 | 44 |
| 43 } // namespace base | 45 } // namespace base |
| OLD | NEW |