Remove couple of Ime related NOTREACHED() in RWHVChildFrame.
[chromium-blink-merge.git] / ipc / attachment_broker_unprivileged_win_unittest.cc
blobe67c54a61c7390d4ad16ac6c6c83be3d5913c709
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.
5 #include "build/build_config.h"
7 #include <windows.h>
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"
17 namespace IPC {
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());
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());
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());
51 } // namespace IPC