Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Unified Diff: win/scoped_handle_unittest.cc

Issue 2045223003: Update to Chromium //base at Chromium commit 82baa9afc6620c68cb2168f20bb65e77e3e57f0a. (Closed) Base URL: https://github.com/domokit/base.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « win/scoped_handle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: win/scoped_handle_unittest.cc
diff --git a/win/scoped_handle_unittest.cc b/win/scoped_handle_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..70431ace07d1b66777ee4814899029cb7a1d76d3
--- /dev/null
+++ b/win/scoped_handle_unittest.cc
@@ -0,0 +1,32 @@
+// 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/win/scoped_handle.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(ScopedHandleTest, ScopedHandle) {
+ // Any illegal error code will do. We just need to test that it is preserved
+ // by ScopedHandle to avoid bug 528394.
+ const DWORD magic_error = 0x12345678;
+
+ HANDLE handle = ::CreateMutex(nullptr, FALSE, nullptr);
+ // Call SetLastError after creating the handle.
+ ::SetLastError(magic_error);
+ base::win::ScopedHandle handle_holder(handle);
+ EXPECT_EQ(magic_error, ::GetLastError());
+
+ // Create a new handle and then set LastError again.
+ handle = ::CreateMutex(nullptr, FALSE, nullptr);
+ ::SetLastError(magic_error);
+ handle_holder.Set(handle);
+ EXPECT_EQ(magic_error, ::GetLastError());
+
+ // Create a new handle and then set LastError again.
+ handle = ::CreateMutex(nullptr, FALSE, nullptr);
+ base::win::ScopedHandle handle_source(handle);
+ ::SetLastError(magic_error);
+ handle_holder = std::move(handle_source);
+ EXPECT_EQ(magic_error, ::GetLastError());
+}
« no previous file with comments | « win/scoped_handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698