OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "base/win/scoped_handle.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace base { | |
10 namespace win { | |
rvargas (doing something else)
2015/09/10 22:42:02
nit: Could you remove these namespaces?
long reas
brucedawson
2015/09/10 23:21:46
We should probably do a code-cleanup pass at some
| |
11 | |
12 TEST(ScopedHandleTest, ScopedHandle) { | |
13 // Any illegal error code will do. We just need to test that it is preserved | |
14 // by ScopedHandle to avoid bug 528394. | |
15 const DWORD magic_error = 0x12345678; | |
16 | |
17 HANDLE handle = CreateMutex(nullptr, FALSE, nullptr); | |
rvargas (doing something else)
2015/09/10 22:42:02
nit: related to the previous one... use ::CreateMu
brucedawson
2015/09/10 23:21:46
Done, for CreateMutex(), SetLastError(), and GetLa
| |
18 // Call SetLastError after creating the handle. | |
19 SetLastError(magic_error); | |
20 ScopedHandle handle_holder(handle); | |
21 EXPECT_EQ(magic_error, GetLastError()); | |
22 | |
23 // Create a new handle and then set LastError again. | |
24 handle = CreateMutex(nullptr, FALSE, nullptr); | |
25 SetLastError(magic_error); | |
26 handle_holder.Set(handle); | |
27 EXPECT_EQ(magic_error, GetLastError()); | |
28 | |
29 // Create a new handle and then set LastError again. | |
30 handle = CreateMutex(nullptr, FALSE, nullptr); | |
31 ScopedHandle handle_source(handle); | |
32 SetLastError(magic_error); | |
33 handle_holder = std::move(handle_source); | |
34 EXPECT_EQ(magic_error, GetLastError()); | |
35 } | |
36 | |
37 } // namespace win | |
38 } // namespace base | |
OLD | NEW |