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

Side by Side Diff: ipc/attachment_broker_unprivileged_win_unittest.cc

Issue 1493413004: ipc: Allow attachment brokering for shared memory handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp1
Patch Set: Fix more tests. Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « ipc/attachment_broker_privileged_win_unittest.cc ('k') | ipc/handle_attachment_win.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 2015 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 "build/build_config.h"
6
7 #include <windows.h>
8
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/process/process.h"
12 #include "ipc/attachment_broker_messages.h"
13 #include "ipc/attachment_broker_unprivileged_win.h"
14 #include "ipc/handle_attachment_win.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace IPC {
18
19 TEST(AttachmentBrokerUnprivilegedWinTest, ReceiveValidMessage) {
20 HANDLE handle = LongToHandle(8);
21 base::ProcessId destination = base::Process::Current().Pid();
22 scoped_refptr<internal::HandleAttachmentWin> attachment(
23 new internal::HandleAttachmentWin(handle, HandleWin::DUPLICATE));
24 AttachmentBrokerMsg_WinHandleHasBeenDuplicated msg(
25 attachment->GetWireFormat(destination));
26 AttachmentBrokerUnprivilegedWin attachment_broker;
27 EXPECT_TRUE(attachment_broker.OnMessageReceived(msg));
28 EXPECT_EQ(1u, attachment_broker.attachments_.size());
29
30 scoped_refptr<BrokerableAttachment> received_attachment =
31 attachment_broker.attachments_.front();
32 EXPECT_EQ(BrokerableAttachment::WIN_HANDLE,
33 received_attachment->GetBrokerableType());
34 internal::HandleAttachmentWin* received_handle_attachment =
35 static_cast<internal::HandleAttachmentWin*>(received_attachment.get());
36 EXPECT_EQ(handle, received_handle_attachment->get_handle());
37 }
38
39 TEST(AttachmentBrokerUnprivilegedWinTest, ReceiveInvalidMessage) {
40 HANDLE handle = LongToHandle(8);
41 base::ProcessId destination = base::Process::Current().Pid() + 1;
42 scoped_refptr<internal::HandleAttachmentWin> attachment(
43 new internal::HandleAttachmentWin(handle, HandleWin::DUPLICATE));
44 AttachmentBrokerMsg_WinHandleHasBeenDuplicated msg(
45 attachment->GetWireFormat(destination));
46 AttachmentBrokerUnprivilegedWin attachment_broker;
47 EXPECT_TRUE(attachment_broker.OnMessageReceived(msg));
48 EXPECT_EQ(0u, attachment_broker.attachments_.size());
49 }
50
51 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/attachment_broker_privileged_win_unittest.cc ('k') | ipc/handle_attachment_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698