diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-19 23:34:17 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-19 23:34:17 +0000 |
commit | e078590661444968a2c49a3e5464413714471dca (patch) | |
tree | 13a4dbe4dedccc8057361bd86c89e065390247fc /base/scoped_native_library_unittest.cc | |
parent | d9f76627b14170b95639619089139b6f0493ae8c (diff) | |
download | chromium_src-e078590661444968a2c49a3e5464413714471dca.zip chromium_src-e078590661444968a2c49a3e5464413714471dca.tar.gz chromium_src-e078590661444968a2c49a3e5464413714471dca.tar.bz2 |
Move scoped_temp_dir and scoped_native_library back from base/memory to base.
It looks like they got moved accidentally in http://codereview.chromium.org/6714032
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7048007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/scoped_native_library_unittest.cc')
-rw-r--r-- | base/scoped_native_library_unittest.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/base/scoped_native_library_unittest.cc b/base/scoped_native_library_unittest.cc new file mode 100644 index 0000000..7efffdd --- /dev/null +++ b/base/scoped_native_library_unittest.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/scoped_native_library.h" +#if defined(OS_WIN) +#include "base/file_path.h" +#endif + +#include "testing/gtest/include/gtest/gtest.h" + +// Tests whether or not a function pointer retrieved via ScopedNativeLibrary +// is available only in a scope. +TEST(ScopedNativeLibrary, Basic) { +#if defined(OS_WIN) + // 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 + // 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; + { + FilePath path(base::GetNativeLibraryName(L"ddraw")); + base::ScopedNativeLibrary library(path); + test_function = reinterpret_cast<FARPROC>( + library.GetFunctionPointer("DirectDrawCreate")); + EXPECT_EQ(0, IsBadCodePtr(test_function)); + } + EXPECT_NE(0, IsBadCodePtr(test_function)); +#endif +} |