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

Side by Side 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: const char* kFunctionName changed to const char kFunctionName[] Created 7 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 namespace base { 12 namespace base {
13 13
14 // Tests whether or not a function pointer retrieved via ScopedNativeLibrary 14 // Tests whether or not a function pointer retrieved via ScopedNativeLibrary
15 // is available only in a scope. 15 // is available only in a scope.
16 TEST(ScopedNativeLibrary, Basic) { 16 TEST(ScopedNativeLibrary, Basic) {
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 // Get the pointer to DirectDrawCreate() from "ddraw.dll" and verify it 18 // Get the pointer to DirectDrawCreate() from "ddraw.dll" and verify it
19 // is valid only in this scope. 19 // is valid only in this scope.
20 // FreeLibrary() doesn't actually unload a DLL until its reference count 20 // FreeLibrary() doesn't actually unload a DLL until its reference count
21 // becomes zero, i.e. this 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 FARPROC test_function; 25 const char kFunctionName[] = "DirectDrawCreate";
26 NativeLibrary native_library;
26 { 27 {
cpu_(ooo_6.6-7.5) 2013/10/30 20:08:45 the code here is different, the scope blocks of 26
Tomasz Moniuszko 2013/10/31 09:13:37 Why do you think we are testing different cases? I
27 FilePath path(GetNativeLibraryName(L"ddraw")); 28 FilePath path(GetNativeLibraryName(L"ddraw"));
28 ScopedNativeLibrary library(path); 29 native_library = LoadNativeLibrary(path, NULL);
29 test_function = reinterpret_cast<FARPROC>( 30 ScopedNativeLibrary library(native_library);
30 library.GetFunctionPointer("DirectDrawCreate")); 31 FARPROC test_function =
32 reinterpret_cast<FARPROC>(library.GetFunctionPointer(kFunctionName));
31 EXPECT_EQ(0, IsBadCodePtr(test_function)); 33 EXPECT_EQ(0, IsBadCodePtr(test_function));
34 EXPECT_EQ(
35 GetFunctionPointerFromNativeLibrary(native_library, kFunctionName),
36 test_function);
32 } 37 }
33 EXPECT_NE(0, IsBadCodePtr(test_function)); 38 EXPECT_EQ(NULL,
39 GetFunctionPointerFromNativeLibrary(native_library, kFunctionName));
34 #endif 40 #endif
35 } 41 }
36 42
37 } // namespace base 43 } // namespace base
OLDNEW
« 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