Enable password generation only if sync for passwords is enabled.
[chromium-blink-merge.git] / base / scoped_native_library_unittest.cc
blob7efffdd989f566ed334f5583396717baf68a197d
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/file_path.h"
8 #endif
10 #include "testing/gtest/include/gtest/gtest.h"
12 // Tests whether or not a function pointer retrieved via ScopedNativeLibrary
13 // is available only in a scope.
14 TEST(ScopedNativeLibrary, Basic) {
15 #if defined(OS_WIN)
16 // Get the pointer to DirectDrawCreate() from "ddraw.dll" and verify it
17 // is valid only in this scope.
18 // FreeLibrary() doesn't actually unload a DLL until its reference count
19 // becomes zero, i.e. this function pointer is still valid if the DLL used
20 // in this test is also used by another part of this executable.
21 // So, this test uses "ddraw.dll", which is not used by Chrome at all but
22 // installed on all versions of Windows.
23 FARPROC test_function;
25 FilePath path(base::GetNativeLibraryName(L"ddraw"));
26 base::ScopedNativeLibrary library(path);
27 test_function = reinterpret_cast<FARPROC>(
28 library.GetFunctionPointer("DirectDrawCreate"));
29 EXPECT_EQ(0, IsBadCodePtr(test_function));
31 EXPECT_NE(0, IsBadCodePtr(test_function));
32 #endif