Revert "Removing the avatar menu for the new multi profile style and show the avatar...
[chromium-blink-merge.git] / base / scoped_native_library_unittest.cc
blobc120555ec69a1ae0f216a53dc5f8f53035b61f6e
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
3 // found in the LICENSE file.
5 #include "base/scoped_native_library.h"
6 #if defined(OS_WIN)
7 #include "base/files/file_path.h"
8 #endif
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace base {
14 // Tests whether or not a function pointer retrieved via ScopedNativeLibrary
15 // is available only in a scope.
16 TEST(ScopedNativeLibrary, Basic) {
17 #if defined(OS_WIN)
18 // Get the pointer to DirectDrawCreate() from "ddraw.dll" and verify it
19 // is valid only in this scope.
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
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
24 // installed on all versions of Windows.
25 FARPROC test_function;
27 FilePath path(GetNativeLibraryName(L"ddraw"));
28 ScopedNativeLibrary library(path);
29 test_function = reinterpret_cast<FARPROC>(
30 library.GetFunctionPointer("DirectDrawCreate"));
31 EXPECT_EQ(0, IsBadCodePtr(test_function));
33 EXPECT_NE(0, IsBadCodePtr(test_function));
34 #endif
37 } // namespace base