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 "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/scoped_native_library.h" | 11 #include "base/scoped_native_library.h" |
12 #include "base/test/multiprocess_test.h" | 12 #include "base/test/multiprocess_test.h" |
13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
14 #include "base/win/base_features.h" | |
14 #include "base/win/scoped_handle.h" | 15 #include "base/win/scoped_handle.h" |
15 | 16 |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "testing/multiprocess_func_list.h" | 18 #include "testing/multiprocess_func_list.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 namespace win { | 21 namespace win { |
21 | 22 |
22 namespace testing { | 23 namespace testing { |
23 extern "C" bool __declspec(dllexport) RunTest(); | 24 extern "C" bool __declspec(dllexport) RunTest(); |
(...skipping 17 matching lines...) Expand all Loading... | |
41 EXPECT_EQ(magic_error, ::GetLastError()); | 42 EXPECT_EQ(magic_error, ::GetLastError()); |
42 | 43 |
43 // Create a new handle and then set LastError again. | 44 // Create a new handle and then set LastError again. |
44 handle = ::CreateMutex(nullptr, false, nullptr); | 45 handle = ::CreateMutex(nullptr, false, nullptr); |
45 base::win::ScopedHandle handle_source(handle); | 46 base::win::ScopedHandle handle_source(handle); |
46 ::SetLastError(magic_error); | 47 ::SetLastError(magic_error); |
47 handle_holder = std::move(handle_source); | 48 handle_holder = std::move(handle_source); |
48 EXPECT_EQ(magic_error, ::GetLastError()); | 49 EXPECT_EQ(magic_error, ::GetLastError()); |
49 } | 50 } |
50 | 51 |
52 #if BUILDFLAG(SINGLE_MODULE_MODE_HANDLE_VERIFIER) | |
Will Harris
2016/06/01 16:46:40
why do these tests now depend on this, they didn't
Sébastien Marchand
2016/06/01 19:18:47
Hum, I thought that there was a #ifdef COMPONENT_B
| |
51 TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) { | 53 TEST(ScopedHandleTest, ActiveVerifierTrackedHasBeenClosed) { |
52 HANDLE handle = ::CreateMutex(nullptr, false, nullptr); | 54 HANDLE handle = ::CreateMutex(nullptr, false, nullptr); |
53 ASSERT_NE(HANDLE(nullptr), handle); | 55 ASSERT_NE(HANDLE(nullptr), handle); |
54 typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE); | 56 typedef NTSTATUS(WINAPI * NtCloseFunc)(HANDLE); |
55 NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>( | 57 NtCloseFunc ntclose = reinterpret_cast<NtCloseFunc>( |
56 GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose")); | 58 GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtClose")); |
57 ASSERT_NE(nullptr, ntclose); | 59 ASSERT_NE(nullptr, ntclose); |
58 | 60 |
59 ASSERT_DEATH({ | 61 ASSERT_DEATH({ |
60 base::win::ScopedHandle handle_holder(handle); | 62 base::win::ScopedHandle handle_holder(handle); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 return 1; | 124 return 1; |
123 auto run_test_function = reinterpret_cast<decltype(&testing::RunTest)>( | 125 auto run_test_function = reinterpret_cast<decltype(&testing::RunTest)>( |
124 module.GetFunctionPointer("RunTest")); | 126 module.GetFunctionPointer("RunTest")); |
125 if (!run_test_function) | 127 if (!run_test_function) |
126 return 1; | 128 return 1; |
127 if (!run_test_function()) | 129 if (!run_test_function()) |
128 return 1; | 130 return 1; |
129 | 131 |
130 return 0; | 132 return 0; |
131 } | 133 } |
134 #endif | |
132 | 135 |
133 } // namespace win | 136 } // namespace win |
134 } // namespace base | 137 } // namespace base |
OLD | NEW |