OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/mac/xpc_message_server.h" | 5 #include "sandbox/mac/xpc_message_server.h" |
6 | 6 |
7 #include <Block.h> | 7 #include <Block.h> |
8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
9 #include <servers/bootstrap.h> | 9 #include <servers/bootstrap.h> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/mac/mac_util.h" | 13 #include "base/mac/mac_util.h" |
14 #include "base/mac/scoped_mach_port.h" | 14 #include "base/mac/scoped_mach_port.h" |
15 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
16 #include "base/test/multiprocess_test.h" | 16 #include "base/test/multiprocess_test.h" |
17 #include "sandbox/mac/xpc.h" | 17 #include "sandbox/mac/xpc.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "testing/multiprocess_func_list.h" | 19 #include "testing/multiprocess_func_list.h" |
20 | 20 |
21 namespace sandbox { | 21 namespace sandbox { |
22 | 22 |
23 class XPCMessageServerTest : public testing::Test { | 23 class XPCMessageServerTest : public testing::Test { |
24 public: | 24 public: |
25 virtual void SetUp() OVERRIDE { | 25 virtual void SetUp() override { |
26 if (!RunXPCTest()) | 26 if (!RunXPCTest()) |
27 return; | 27 return; |
28 ASSERT_TRUE(InitializeXPC()); | 28 ASSERT_TRUE(InitializeXPC()); |
29 } | 29 } |
30 | 30 |
31 bool RunXPCTest() { | 31 bool RunXPCTest() { |
32 return base::mac::IsOSMountainLionOrLater(); | 32 return base::mac::IsOSMountainLionOrLater(); |
33 } | 33 } |
34 }; | 34 }; |
35 | 35 |
(...skipping 25 matching lines...) Expand all Loading... |
61 return false; | 61 return false; |
62 } | 62 } |
63 scoped_send_right_.reset(server_.GetServerPort()); | 63 scoped_send_right_.reset(server_.GetServerPort()); |
64 | 64 |
65 demux_block_ = Block_copy(demux_block); | 65 demux_block_ = Block_copy(demux_block); |
66 pipe_ = xpc_pipe_create_from_port(server_.GetServerPort(), 0); | 66 pipe_ = xpc_pipe_create_from_port(server_.GetServerPort(), 0); |
67 | 67 |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 virtual void DemuxMessage(IPCMessage request) OVERRIDE { | 71 virtual void DemuxMessage(IPCMessage request) override { |
72 demux_block_(request); | 72 demux_block_(request); |
73 } | 73 } |
74 | 74 |
75 xpc_pipe_t pipe() { return pipe_; } | 75 xpc_pipe_t pipe() { return pipe_; } |
76 | 76 |
77 XPCMessageServer* server() { return &server_; } | 77 XPCMessageServer* server() { return &server_; } |
78 | 78 |
79 private: | 79 private: |
80 void (^demux_block_)(IPCMessage request); | 80 void (^demux_block_)(IPCMessage request); |
81 | 81 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ASSERT_EQ(0, xpc_pipe_routine(first.pipe(), request, &reply)); | 210 ASSERT_EQ(0, xpc_pipe_routine(first.pipe(), request, &reply)); |
211 | 211 |
212 EXPECT_EQ(1, xpc_dictionary_get_int64(reply, "seen_by_first")); | 212 EXPECT_EQ(1, xpc_dictionary_get_int64(reply, "seen_by_first")); |
213 EXPECT_EQ(2, xpc_dictionary_get_int64(reply, "seen_by_second")); | 213 EXPECT_EQ(2, xpc_dictionary_get_int64(reply, "seen_by_second")); |
214 | 214 |
215 xpc_release(request); | 215 xpc_release(request); |
216 xpc_release(reply); | 216 xpc_release(reply); |
217 } | 217 } |
218 | 218 |
219 } // namespace sandbox | 219 } // namespace sandbox |
OLD | NEW |