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

Side by Side Diff: base/win/scoped_handle_unittest.cc

Issue 90963002: Revert of Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/win/scoped_handle.h ('k') | base/win/scoped_process_information.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #include "testing/gtest/include/gtest/gtest.h"
7
8 void CreateHandle(int value, HANDLE* result) {
9 *result = reinterpret_cast<HANDLE>(value);
10 }
11
12 TEST(ScopedHandleTest, Receive) {
13 base::win::ScopedHandle handle;
14 int value = 51;
15
16 {
17 // This is not really the expected use case, but it is a very explicit test.
18 base::win::ScopedHandle::Receiver a = handle.Receive();
19 HANDLE* pointer = a;
20 *pointer = reinterpret_cast<HANDLE>(value);
21 }
22
23 EXPECT_EQ(handle.Get(), reinterpret_cast<HANDLE>(value));
24 HANDLE to_discard = handle.Take();
25
26 // The standard use case:
27 value = 183;
28 CreateHandle(value, handle.Receive());
29 EXPECT_EQ(handle.Get(), reinterpret_cast<HANDLE>(value));
30 to_discard = handle.Take();
31 }
OLDNEW
« no previous file with comments | « base/win/scoped_handle.h ('k') | base/win/scoped_process_information.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698