Chromium Code Reviews| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <winternl.h> | 6 #include <winternl.h> |
| 7 | 7 |
| 8 #include <utility> | |
|
scottmg
2016/03/11 19:02:19
(is this actually used?)
Will Harris
2016/03/11 20:35:32
no. removed.
| |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/scoped_native_library.h" | |
| 8 #include "base/win/scoped_handle.h" | 12 #include "base/win/scoped_handle.h" |
| 9 | 13 #include "base/win/scoped_handle_test_dll.h" |
| 10 #include <utility> | |
| 11 | 14 |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 16 |
| 14 namespace base { | 17 namespace base { |
| 15 namespace win { | 18 namespace win { |
| 16 | 19 |
| 17 TEST(ScopedHandleTest, ScopedHandle) { | 20 TEST(ScopedHandleTest, ScopedHandle) { |
| 18 // Any illegal error code will do. We just need to test that it is preserved | 21 // Any illegal error code will do. We just need to test that it is preserved |
| 19 // by ScopedHandle to avoid bug 528394. | 22 // by ScopedHandle to avoid bug 528394. |
| 20 const DWORD magic_error = 0x12345678; | 23 const DWORD magic_error = 0x12345678; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 ASSERT_NE(HANDLE(nullptr), handle); | 86 ASSERT_NE(HANDLE(nullptr), handle); |
| 84 | 87 |
| 85 ASSERT_DEATH({ | 88 ASSERT_DEATH({ |
| 86 base::win::ScopedHandle handle_holder; | 89 base::win::ScopedHandle handle_holder; |
| 87 handle_holder.handle_ = handle; | 90 handle_holder.handle_ = handle; |
| 88 }, ""); | 91 }, ""); |
| 89 | 92 |
| 90 ASSERT_TRUE(::CloseHandle(handle)); | 93 ASSERT_TRUE(::CloseHandle(handle)); |
| 91 } | 94 } |
| 92 | 95 |
| 96 TEST(ScopedHandleTest, MultiModule) { | |
| 97 ScopedNativeLibrary module(FilePath(L"scoped_handle_test_dll.dll")); | |
| 98 | |
| 99 typedef decltype(base::win::testing::RunTest)* RunTestFunc; | |
| 100 | |
| 101 ASSERT_TRUE(module.is_valid()); | |
| 102 RunTestFunc func = | |
| 103 reinterpret_cast<RunTestFunc>(module.GetFunctionPointer("RunTest")); | |
| 104 ASSERT_NE(nullptr, func); | |
| 105 ASSERT_EQ(testing::Result::SUCCESS, func()); | |
| 106 } | |
| 107 | |
| 93 } // namespace win | 108 } // namespace win |
| 94 } // namespace base | 109 } // namespace base |
| OLD | NEW |